-
Notifications
You must be signed in to change notification settings - Fork 4
/
build-ssh.sh
executable file
·131 lines (110 loc) · 3.42 KB
/
build-ssh.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
#!/bin/bash -e
msg() {
echo
echo ==== $* ====
echo
}
grep 'VERSION = ' "Makefile" >>build-config
grep 'PATCHLEVEL = ' "Makefile" >>build-config
grep 'SUBLEVEL = ' "Makefile" >>build-config
sed -i 's/VERSION = /MAIN=/g' build-config >> build-config
sed -i 's/PATCHLEVEL = /PATCHLEVEL=/g' build-config >> build-config
sed -i 's/SUBLEVEL = /SUBLEVEL=/g' build-config >> build-config
sed -i '/CKMAIN=/ d' build-config
sed -i '/KERNELMAIN=/ d' build-config
# -----------------------
. build-config
TOOLS_DIR=/home/giro/m8/tools
MAKE=$TOOLS_DIR/make.sh
# -----------------------
UPSTREAM="$MAIN.$PATCHLEVEL.$SUBLEVEL"
ZIP=$TARGET_DIR/$VERSION.zip
SHA1=$TOOLS_DIR/sha1.sh
FTP=$LOCAL_BUILD_DIR/ftp.sh
UPDATE_ROOT=$LOCAL_BUILD_DIR/update
KEYS=$LOCAL_BUILD_DIR/keys
CERT=$KEYS/certificate.pem
KEY=$KEYS/key.pk8
ANYKERNEL=$LOCAL_BUILD_DIR/kernel
ZIMAGE=arch/arm/boot/zImage
msg Building: $VERSION
echo " Defconfig: $DEFCONFIG"
echo " Local build dir: $LOCAL_BUILD_DIR"
echo " Target dir: $TARGET_DIR"
echo " Tools dir: $TOOLS_DIR"
echo
echo " Target system partition: $SYSTEM_PARTITION"
echo
if [ -e $CERT -a -e $KEY ]
then
msg Reusing existing $CERT and $KEY
else
msg Regenerating keys, pleae enter the required information.
(
mkdir -p $KEYS
cd $KEYS
openssl genrsa -out key.pem 1024 && \
openssl req -new -key key.pem -out request.pem && \
openssl x509 -req -days 9999 -in request.pem -signkey key.pem -out certificate.pem && \
openssl pkcs8 -topk8 -outform DER -in key.pem -inform PEM -out key.pk8 -nocrypt
)
fi
if [ -e $UPDATE_ROOT ]
then
rm -rf $UPDATE_ROOT
fi
if [ -e $LOCAL_BUILD_DIR/update.zip ]
then
rm -f $LOCAL_BUILD_DIR/update.zip
fi
$MAKE $DEFCONFIG
perl -pi -e 's/(CONFIG_LOCALVERSION="[^"]*)/\1-'"$VERSION"'"/' .config
$MAKE -j$N_CORES
msg Kernel built successfully, building $ZIP
mkdir -p $UPDATE_ROOT/system/lib/modules
find . -name '*.ko' -exec cp {} $UPDATE_ROOT/system/lib/modules/ \;
mkdir -p $UPDATE_ROOT/META-INF/com/google/android
cp $TOOLS_DIR/update-binary $UPDATE_ROOT/META-INF/com/google/android
$SHA1
SUM=`sha1sum $ZIMAGE | cut --delimiter=' ' -f 1`
(
cat <<EOF
$BANNER
EOF
sed -e "s|@@SYSTEM_PARTITION@@|$SYSTEM_PARTITION|" \
-e "s|@@FLASH_BOOT@@|$FLASH_BOOT|" \
-e "s|@@SUM@@|$SUM|" \
-e "s|@@UPSTREAM@@|$UPSTREAM|" \
-e "s|@@VERSION@@|$VERSION|" \
< $TOOLS_DIR/updater-script
) > $UPDATE_ROOT/META-INF/com/google/android/updater-script
mkdir -p $UPDATE_ROOT/kernel
cp $ZIMAGE $ANYKERNEL
cp $ANYKERNEL/* $UPDATE_ROOT/kernel
(
cd $UPDATE_ROOT
zip -r ../update.zip .
)
java -jar $TOOLS_DIR/signapk.jar $CERT $KEY $LOCAL_BUILD_DIR/update.zip $ZIP
make mrproper
sed -i '/MAIN=/ d' build-config
sed -i '/PATCHLEVEL=/ d' build-config
sed -i '/SUBLEVEL=/ d' build-config
cp build-config $LOCAL_BUILD_DIR/build-config
cat banner >temp2
echo "<p>Latest version: <font color="#0000FF">$VERSION</p></font>" >>temp2
echo "<p><a style="'"color: #0ACF66"'" href=http://vp-zp.com/snuzzo$FTPTARGETDIR/$DATE/$VERSION.zip>Quick-Click Download</a></p>" >>temp2
cat temp2 > ChangeLog.html
git log >> temp
sed -i -e 's/^/<p>/' temp
sed -i '/<p>commit/ d' temp
sed -i '/<p>Author/ d' temp
sed -i -e 's/Date:/<font color="#CF0A45">Date:/' temp
perl -ne 'chomp; printf "%s</p></font>\n", $_' < temp >> temp2
head -n 250 temp2 > ChangeLog.html
echo "</div></body></html>" >> ChangeLog.html
rm temp2
rm temp
mv ChangeLog.html $TARGET_DIR/ChangeLog.html
$FTP
msg COMPLETE