-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathbuild.sh
executable file
·56 lines (46 loc) · 1.84 KB
/
build.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
#!/bin/bash
#Stop script if something is broken
set -e
#Export CROSS_COMPILE to point toolchain
export CROSS_COMPILE="ccache ../toolchain/arm-eabi-4.8/bin/arm-eabi-"
#Export target product
export TARGET_KERNEL_PRODUCT=`cat DEVICE_TREE`
#Echo actual vars
echo "We are actually building for $TARGET_KERNEL_PRODUCT with $CROSS_COMPILE"
#Workaround for + appended on kernelrelease
export LOCALVERSION=
#Create vars for OUT, SCRIPTS and RAMDISK directories
OUT_DIRECTORY=../out/$TARGET_KERNEL_PRODUCT
RAMDISK_DIRECTORY=../ramdisk/$TARGET_KERNEL_PRODUCT
SCRIPTS_DIRECTORY=../scripts/$TARGET_KERNEL_PRODUCT
CERTIFICATES_DIRECTORY=../.certificates
#Create and clean out directory for your device
mkdir -p $OUT_DIRECTORY
if [ "$(ls -A $OUT_DIRECTORY)" ]; then
rm $OUT_DIRECTORY/* -R
fi
#Kernel part
make -j all
cp arch/arm/boot/zImage $OUT_DIRECTORY/zImage
#Modules part
make INSTALL_MOD_STRIP=--strip-unneeded INSTALL_MOD_PATH=$OUT_DIRECTORY/system INSTALL_MOD_DIR=$OUT_DIRECTORY/system android_modules_install
#Repack part
if [ -d "$RAMDISK_DIRECTORY" ]; then
../mtk-tools/repack-MT65xx.pl -boot $OUT_DIRECTORY/zImage $RAMDISK_DIRECTORY $OUT_DIRECTORY/boot.img
rm $OUT_DIRECTORY/zImage
#Flashable zip build
if [ -d "$SCRIPTS_DIRECTORY" ]; then
cp $SCRIPTS_DIRECTORY/* $OUT_DIRECTORY -R
FLASHABLE_ZIP="$OUT_DIRECTORY/`cat DEVICE_NAME`-`make kernelversion`-`git rev-parse --short HEAD`"
FLASHABLE_ZIP_2="`cat DEVICE_NAME`-`make kernelversion`-`git rev-parse --short HEAD`"
echo "Creating flashable at '$FLASHABLE_ZIP'.zip"
pushd $OUT_DIRECTORY
zip -r -0 "$FLASHABLE_ZIP_2".zip .
popd
if [ ! -d "$CERTIFICATES_DIRECTORY" ]; then
echo "Warning ! We can't sign flashable.zip, you need to run ./certificates.sh"
else
java -jar $SCRIPTS_DIRECTORY/../signapk.jar $CERTIFICATES_DIRECTORY/certificate.pem $CERTIFICATES_DIRECTORY/key.pk8 "$FLASHABLE_ZIP".zip "$FLASHABLE_ZIP"-signed.zip
fi
fi
fi