-
Notifications
You must be signed in to change notification settings - Fork 0
/
cwmCompile.sh
executable file
·140 lines (113 loc) · 3.92 KB
/
cwmCompile.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/bash
RECOVERY_URL=git://github.com/CyanogenMod/android_bootable_recovery.git
#LEO_URL=git://github.com/CyanogenMod/android_device_htc_leo.git
#RECOVERY_DIR=/data/android/git/android_bootable_recovery
#LEO_DIR=/data/android/git/android_device_htc_leo
CM_DIR=/data/android/git/CM-ics
WORKDIR=/data/android/recovery
OUTPUT=$WORKDIR/out
SOURCE=$WORKDIR/source
mkdir -p $OUTPUT
mkdir -p $SOURCE
rm -rf $OUTPUT/*
cd $WORKDIR
NIGHTLY=0
[[ "$1" == "NIGHTLY" ]] && NIGHTLY=1
syncDirs()
{
echo -n "Synchronising directories ... "
cp -alf $CM_DIR/* $SOURCE/.
# echo -n "Recovery ... "
# pushd $SOURCE/bootable/recovery > /dev/null 2>&1
# rm -rf *
# rsync -az $RECOVERY_DIR/* .
# popd > /dev/null 2>&1
echo -n "leo ... "
# pushd $SOURCE/device/htc/leo > /dev/null 2>&1
# rm -rf *
# rsync -az $LEO_DIR/* .
# popd > /dev/null 2>&1
echo "DONE"
}
clean()
{
echo -n "Cleaning up ... "
pushd $SOURCE > /dev/null 2>&1
rm -rf $OUTPUT/*
make -j2 clean dataclean installclean > /dev/null 2>&1
rm -rf * > /dev/null 2>&1
popd > /dev/null 2>&1
echo "DONE"
}
compile()
{
manufacturer=$1
device=$2
bootloader=$3
clean
syncDirs
echo -n "Compiling image ... "
pushd $SOURCE > /dev/null 2>&1
VERSION1=`grep RECOVERY_VERSION bootable/recovery/Android.mk | head -n 1 | awk '{ print $NF }' | sed s/v//`
VERSION2=$VERSION1
#if [[ $NIGHTLY -eq 1 ]] ; then
VERSION2=$VERSION1-`date +%Y%m%d`
#fi
#cp ./vendor/cyanogen/products/cyanogen_${device}.mk buildspec.mk
echo -n "setting up environment ... "
. build/envsetup.sh > /dev/null 2>&1
echo -n "running lunch ... "
lunch cm_${device}-eng > /dev/null 2>&1
echo -n "compiling recovery ... "
if [[ $manufacturer == "samsung" ]] ; then
make -j 5 bootimage
else
make -j 5 recoveryimage 2>&1 | tail -n 10
fi
echo "DONE"
popd > /dev/null 2>&1
if [[ "${device}" == "leo" ]] ; then
cp $SOURCE/out/target/product/${device}/recovery.img $OUTPUT/recovery_${VERSION2}_${device}.img
cp $SOURCE/out/target/product/${device}/recovery.img $WORKDIR/CWR/recovery_${device}.img
cat > $WORKDIR/CWR/sdcard/clockworkmod/.settings << EOF
{"paypal_transaction_id":"","is_clockworkmod":true,"current_recovery_version":"${VERSION1}","flash_recovery":"","detected_device":"leo","readonly_recovery":false,"recovery_timestamp":"`date +%s`","reboot_recovery":""}
EOF
pushd $WORKDIR/CWR > /dev/null 2>&1
zip -9Dr $OUTPUT/recovery_${VERSION2}_${device}_CWR.zip *
popd > /dev/null 2>&1
zip -9Dr $OUTPUT/recovery_${VERSION2}_${device}.img.zip $OUTPUT/recovery_${VERSION2}_${device}.img
pushd $OUTPUT > /dev/null 2>&1
mkdir -p ${VERSION2}_${device}_sd
cp $SOURCE/out/target/product/${device}/ramdisk-recovery.img ${VERSION2}_${device}_sd/initrd.gz
cp $SOURCE/out/target/product/${device}/kernel ${VERSION2}_${device}_sd/zImage
zip -9Dr recovery_${VERSION2}_${device}_sd.zip ${VERSION2}_${device}_sd
rm -rf ${VERSION2}_${device}_sd
popd > /dev/null 2>&1
else
cp $SOURCE/out/target/product/${device}/recovery.img $OUTPUT/recovery_${VERSION2}_${device}.img
zip -9Dr $OUTPUT/recovery_${VERSION2}_${device}.img.zip $OUTPUT/recovery_${VERSION2}_${device}.img
fi
mkdir -p /data/dropbox/Dropbox/${device}/android/recovery/${VERSION1}
if [[ $NIGHTLY -eq 1 ]] ; then
cp $OUTPUT/*.img /data/dropbox/Dropbox/${device}/android/recovery/${VERSION1}/.
else
cp $OUTPUT/* /data/dropbox/Dropbox/${device}/android/recovery/${VERSION1}/.
fi
chown -R dropbox:dropbox /data/dropbox/Dropbox/${device}/android/recovery/*
}
echo -n "Syncing latest repos ... "
echo -n "Recovery ... "
pushd ${RECOVERY_DIR} > /dev/null 2>&1
git pull > /dev/null 2>&1
git pull ${RECOVERY_URL} ics > /dev/null 2>&1
popd > /dev/null 2>&1
echo -n "leo ... "
pushd ${LEO_DIR} > /dev/null 2>&1
git pull > /dev/null 2>&1
git pull ${LEO_URL} ics > /dev/null 2>&1
popd > /dev/null 2>&1
echo "DONE"
clean
compile htc leo
compile htc click
#compile samsung galaxys2