-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·123 lines (113 loc) · 3.39 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
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
#
# Copyright © 2016, Varun Chitre "varun.chitre15" <[email protected]>
# Copyright © 2017, Ritesh Saxena <[email protected]>
# Copyright © 2018, Mohd Faraz <[email protected]>
#
# Custom build script
#
# This software is licensed under the terms of the GNU General Public
# License version 2, as published by the Free Software Foundation, and
# may be copied, distributed, and modified under those terms.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# Please maintain this if you use this script or any part of it
#
KERNEL_DIR=$PWD
KERN_IMG=$KERNEL_DIR/out/arch/arm64/boot/Image.gz-dtb
BUILD_START=$(date +"%s")
blue='\033[0;34m'
cyan='\033[0;36m'
green='\e[0;32m'
yellow='\033[0;33m'
red='\033[0;31m'
nocol='\033[0m'
purple='\e[0;35m'
white='\e[0;37m'
DEVICE="LS-5015"
J="-j$(grep -c ^processor /proc/cpuinfo)"
rm -rf $KERNEL_DIR/out
mkdir $KERNEL_DIR/out
# Get Toolchain
UBER=$KERNEL_DIR/../uber
function TC() {
if [[ -d ${UBER} ]]; then
if [[ -d ${UBER}/.git ]]; then
cd ${UBER}
git fetch origin
git reset --hard origin/master
git clean -fxd > /dev/null 2>&1
cd ${KERNEL_DIR}
else
rm -rf ${UBER}
fi
else
git clone https://bitbucket.org/UBERTC/aarch64-linux-android-4.9-kernel.git $UBER
fi
}
# Modify the following variable if you want to build
export CROSS_COMPILE=$UBER/bin/aarch64-linux-android-
export ARCH=arm64
export SUBARCH=arm64
export KBUILD_BUILD_USER="Faraz"
export KBUILD_BUILD_HOST="TimeMachine"
export USE_CCACHE=1
BUILD_DIR=$KERNEL_DIR/build
VERSION="X4"
DATE=$(date -u +%Y%m%d-%H%M)
ZIP_NAME=Nichrome-$DEVICE-$VERSION-$DATE
compile_kernel ()
{
echo -e "$cyan****************************************************"
echo " Compiling Nichrome kernel "
echo -e "****************************************************"
echo -e "$nocol"
rm -f $KERN_IMG
make O=out LS5015_defconfig
make O=out $J
if ! [ -a $KERN_IMG ];
then
echo -e "$red Kernel Compilation failed! Fix the errors! $nocol"
exit 1
fi
make_zip
}
make_zip ()
{
if [[ $( ls ${KERNEL_DIR}/out/arch/arm64/boot/Image.gz-dtb 2>/dev/null | wc -l ) != "0" ]]; then
BUILD_RESULT_STRING="BUILD SUCCESSFUL"
echo "Making Zip"
rm $BUILD_DIR/*.zip
rm $BUILD_DIR/zImage
cp $KERNEL_DIR/out/arch/arm64/boot/Image.gz-dtb $BUILD_DIR/zImage
cd $BUILD_DIR
zip -r ${ZIP_NAME}.zip *
cd $KERNEL_DIR
rm -rf $KERNEL_DIR/out
rm $BUILD_DIR/zImage
else
BUILD_RESULT_STRING="BUILD FAILED"
fi
}
case $1 in
clean)
make ARCH=arm64 O=out-j8 clean mrproper
;;
*)
TC
compile_kernel
;;
esac
BUILD_END=$(date +"%s")
DIFF=$(($BUILD_END - $BUILD_START))
if [[ "${BUILD_RESULT_STRING}" = "BUILD SUCCESSFUL" ]]; then
echo -e "$cyan****************************************************************************************$nocol"
echo -e "$cyan*$nocol${red} ${BUILD_RESULT_STRING}$nocol"
echo -e "$cyan*$nocol$yellow Build completed in $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) seconds.$nocol"
echo -e "$cyan*$nocol${green} ZIP LOCATION: ${BUILD_DIR}/${ZIP_NAME}.zip$nocol"
echo -e "$cyan*$nocol${green} SIZE: $( du -h ${BUILD_DIR}/${ZIP_NAME}.zip | awk '{print $1}' )$nocol"
echo -e "$cyan****************************************************************************************$nocol"
fi