-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
163 lines (145 loc) · 4.51 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/bin/bash
# Custom Kernel build script
# Constants
green='\033[01;32m'
red='\033[01;31m'
blink_red='\033[05;31m'
cyan='\033[0;36m'
yellow='\033[0;33m'
blue='\033[0;34m'
default='\033[0m'
# Resources
KERNEL_DIR=$PWD
IMAGE=$KERNEL_DIR/arch/arm64/boot/Image
#IMAGE=$KERNEL_DIR/arch/arm/boot/zImage for 32 bit architecture
DTBTOOL=$KERNEL_DIR/scripts/dtbToolCM
TOOLCHAIN=/home/techie/dnd/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin
#Paths
OUT_DIR=$KERNEL_DIR/out
OUT_ZIP=$KERNEL_DIR/Releases
MODULE_DIR=$OUT_DIR/modules
NEW_OUT=$OUT_DIR
# Kernel Version Info
BASE="Nucleon™-Kernel-"
CUR_VER="V1"
NUCLEON_VER="$BASE$CUR_VER"
CUR_TIME="$(date "+%y.%m.%d-%H.%M.%S")"
# Variables
DEFCONFIG="kenzo_defconfig"
export CROSS_COMPILE=$TOOLCHAIN/aarch64-linux-android-
export ARCH=arm64
export SUBARCH=arm64
export KBUILD_BUILD_USER="AKabhishek"
export KBUILD_BUILD_HOST="Flashing-machine"
function make_nucleon {
echo -e "$green*******************************************************"
echo " Compiling $NUCLEON_VER "
echo -e "*****************************************************"
echo
mkdir Releases
make $DEFCONFIG
make -j4
rm -rf $NEWOUT/Image
cp -vr $IMAGE $NEW_OUT/zImage
make_dtb
make_modules
make_zip
housekeeping
echo -e "$green*******************************************************"
echo " Compilation Completed!! "
echo -e "*****************************************************$default"
}
function make_onlyclean {
echo -e "$green***********************************************"
echo " Cleaning up object files and other stuff "
echo -e "***********************************************$default"
make clean
make mrproper
}
function make_clean {
echo -e "$green***********************************************"
echo " Cleaning up object files and other stuff "
echo -e "***********************************************$default"
make clean
make mrproper
make_nucleon
}
function make_recompile {
echo -e "$cyan*******************************************************"
echo " Recompiling $NUCLEON_VER "
echo -e "*****************************************************"
make -j4
rm -rf $NEWOUT/Image
cp -vr $IMAGE $NEW_OUT
make_dtb
make_modules
make_zip
housekeeping
}
function make_dtb {
echo -e "$blue*******************************************************"
echo " Creating dt.img.... "
echo -e "*****************************************************"
rm -rf $NEWOUT/dtb
$DTBTOOL -v -s 2048 -o $NEW_OUT/dtb -p scripts/dtc/ arch/arm/boot/dts/
}
function make_modules {
rm -rf $MODULE_DIR/*
echo -e "$cyan*******************************************************"
echo " Finding modules.... "
echo -e "*****************************************************"
find . -path ./build -prune -o -name '*.ko' -print | xargs cp -t $MODULE_DIR/
cd $KERNEL_DIR
}
function make_zip {
echo -e "$yellow*******************************************************"
echo " Zipping up.... "
echo -e "*****************************************************"
cd $OUT_DIR
rm -f '*.zip'
zip -r9 Nucleon-Kenzo-`echo $CUR_VER``echo $CUR_TIME`.zip *
mv Nucleon-Kenzo-`echo $CUR_VER``echo $CUR_TIME`.zip $OUT_ZIP
echo "Find your zip in Release directory"
echo -e "$default"
cd $KERNEL_DIR
}
function housekeeping {
echo -e "$green*******************************************************"
echo " Cleaning up the mess created... "
echo -e "*****************************************************$default"
rm -rf $NEW_OUT/Image
rm -rf $NEW_OUT/dtb
}
BUILD_START=$(date +"%s")
while read -p " 'A' to Compile Again , 'D' to Compile Dirty , 'C' to do a clean compilation , 'E' to do clean only , 'N' to exit " choice
do
case "$choice" in
a|A)
make_nucleon
break
;;
d|D )
make_recompile
break
;;
c|C )
make_clean
break;
;;
e|E )
make_onlyclean
break;
;;
n|N )
break
;;
* )
echo
echo "Failed !"
echo
;;
esac
done
BUILD_END=$(date +"%s")
DIFF=$(($BUILD_END - $BUILD_START))
echo -e "$green Nucleon Build completed in $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) seconds.$default"