forked from 187MoD/Ares-Kernel-Pie
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_Ares.sh
441 lines (408 loc) · 17.5 KB
/
build_Ares.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
#!/bin/bash
#
# Ares-Kernel Build Script
#
# Author: sunilpaulmathew <[email protected]>
#
#
# This script 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.
#
#
# ***** ***** ***** ..How to use this script… ***** ***** ***** #
#
# For those who want to build this kernel using this script…
#
# 1. Properly locate Stock, UBER & Linaro toolchains (Line# 40, 42 & 44)
# 2. Select the preferred toolchain for building (Line# 46)
# 3. Set the 'KERNEL_VARIANT' (Line# 52)
# 4. To build all the supported variants, set 'KERNEL_VARIANT' to "all"
# 5. Open Terminal, ‘cd’ to the Kernel ‘root’ folder and run ‘. build_variant-Ares.sh’
# 6. The output (anykernel zip) file will be generated in the ‘release_Ares’ folder
# 7. Enjoy your new Kernel
#
# ***** ***** *Variables to be configured manually* ***** ***** #
# Toolchains
GOOGLE="/home/skater187/toolchains/android-ndk-r15c/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-"
UBERTC="/home/skater187/toolchains/venom-toolchain_9.2/bin/arm-none-eabi-"
LINARO="/home/skater187/toolchains/arm-linux-androideabi-7.3-linaro/bin/arm-eabi-"
TOOLCHAIN="ubertc" # Leave empty for using Google’s stock toolchain
ARCHITECTURE="arm"
KERNEL_NAME="Ares-Kernel"
KERNEL_VARIANT="kltedv" # options: klte, kltekor, kltedv, klteduos, kltekdi & all (build all the variants)
KERNEL_VERSION="beta-v1.7.0" # leave as such, if no specific version tag
KERNEL_DEFCONFIG="Ares_@$KERNEL_VARIANT@_defconfig"
KERNEL_DATE="$(date +"%Y%m%d")"
BUILD_DIR="output_$KERNEL_VARIANT"
KERNEL_IMAGE="$BUILD_DIR/arch/arm/boot/zImage"
COMPILE_DTB="y"
DTB="$BUILD_DIR/arch/arm/boot/dt.img"
ANYKERNEL_DIR="anykernel_Ares"
RELEASE_DIR="release_Ares"
PREPARE_RELEASE=""
NUM_CPUS="" # number of cpu cores used for build (leave empty for auto detection)
# ***** ***** ***** ***** ***THE END*** ***** ***** ***** ***** #
COLOR_RED="\033[0;31m"
COLOR_GREEN="\033[1;32m"
COLOR_NEUTRAL="\033[0m"
export ARCH=$ARCHITECTURE
if [ -z "$TOOLCHAIN" ]; then
echo -e $COLOR_GREEN"\n Initializing Google's stock toolchain...n"$COLOR_NEUTRAL
export CROSS_COMPILE="${CCACHE} $GOOGLE"
elif [ "ubertc" == "$TOOLCHAIN" ]; then
echo -e $COLOR_GREEN"\n Initializing Bleeding-Edge-Toolchainn-9.x...\n"$COLOR_NEUTRAL
export CROSS_COMPILE="${CCACHE} $UBERTC"
elif [ "linaro" == "$TOOLCHAIN" ]; then
echo -e $COLOR_GREEN"\n Initializing Linaro-7.x toolchain...\n"$COLOR_NEUTRAL
export CROSS_COMPILE="${CCACHE} $LINARO"
fi
export KBUILD_BUILD_USER=187-Mod-[The~Skater~187
export KBUILD_BUILD_HOST=xda-developers.com]
if [ -z "$NUM_CPUS" ]; then
NUM_CPUS=`grep -c ^processor /proc/cpuinfo`
fi
# Initialize building...
if [ -z "$KERNEL_VARIANT" ]; then
echo -e $COLOR_GREEN"\n Please select the variant to build... 'KERNEL_VARIANT' should not be empty...\n"$COLOR_NEUTRAL
elif [ -e arch/arm/configs/$KERNEL_DEFCONFIG ]; then
if [ -e $BUILD_DIR ]; then
if [ -e $BUILD_DIR/.config ]; then
rm -f $BUILD_DIR/.config
if [ -e $KERNEL_IMAGE ]; then
rm -f $KERNEL_IMAGE
fi
fi
else
mkdir $BUILD_DIR
fi
echo -e $COLOR_GREEN"\n building $KERNEL_NAME $KERNEL_VERSION for $KERNEL_VARIANT\n"$COLOR_NEUTRAL
make -C $(pwd) O=$BUILD_DIR $KERNEL_DEFCONFIG
# updating kernel version
sed -i "s;lineageos;$KERNEL_VERSION;" $BUILD_DIR/.config;
make -j$NUM_CPUS -C $(pwd) O=$BUILD_DIR
if [ -e $KERNEL_IMAGE ]; then
echo -e $COLOR_GREEN"\n copying zImage to anykernel directory\n"$COLOR_NEUTRAL
cp $KERNEL_IMAGE $ANYKERNEL_DIR
# compile dtb if required
if [ "y" == "$COMPILE_DTB" ]; then
echo -e $COLOR_GREEN"\n compiling device tree blob (dtb)\n"$COLOR_NEUTRAL
if [ -f $DTB ]; then
rm -f $DTB
fi
chmod 777 tools/dtbToolCM
tools/dtbToolCM -2 -o $DTB -s 2048 -p output_$KERNEL_VARIANT/scripts/dtc/ output_$KERNEL_VARIANT/arch/arm/boot/
# removing old dtb (if any)
if [ -f $ANYKERNEL_DIR/dtb ]; then
rm -f $ANYKERNEL_DIR/dtb
fi
# copying generated dtb to anykernel directory
if [ -e $DTB ]; then
mv -f $DTB $ANYKERNEL_DIR/dtb
fi
fi
# adding version tag to ramdisk in order to access from the Kernel Manager
echo $KERNEL_VERSION > $ANYKERNEL_DIR/ramdisk/version
echo -e $COLOR_GREEN"\n generating recovery flashable zip file\n"$COLOR_NEUTRAL
cd $ANYKERNEL_DIR && zip -r9 $KERNEL_NAME-$KERNEL_VARIANT-$KERNEL_VERSION-$KERNEL_DATE.zip * -x README.md $KERNEL_NAME-$KERNEL_VARIANT-$KERNEL_VERSION-$KERNEL_DATE.zip && cd ..
echo -e $COLOR_GREEN"\n cleaning...\n"$COLOR_NEUTRAL
# check and create release folder.
if [ ! -d "$RELEASE_DIR" ]; then
mkdir $RELEASE_DIR
fi
rm $ANYKERNEL_DIR/zImage && mv $ANYKERNEL_DIR/$KERNEL_NAME* $RELEASE_DIR
if [ -f $ANYKERNEL_DIR/dtb ]; then
rm -f $ANYKERNEL_DIR/dtb
fi
if [ "y" == "$PREPARE_RELEASE" ]; then
echo -e $COLOR_GREEN"\n Preparing for kernel release\n"$COLOR_NEUTRAL
cp $RELEASE_DIR/$KERNEL_NAME-$KERNEL_VARIANT-$KERNEL_VERSION-$KERNEL_DATE.zip kernel-release/$KERNEL_NAME-$KERNEL_VARIANT.zip
fi
echo -e $COLOR_GREEN"\n Building for $KERNEL_VARIANT finished... please visit '$RELEASE_DIR'...\n"$COLOR_NEUTRAL
else
if [ -f $ANYKERNEL_DIR/dtb ]; then
rm -f $ANYKERNEL_DIR/dtb
fi
echo -e $COLOR_RED"\n Building for $KERNEL_VARIANT failed. Please fix the issues and try again...\n"$COLOR_NEUTRAL
fi
elif [ "all" == "$KERNEL_VARIANT" ]; then
echo -e $COLOR_GREEN"\n building $KERNEL_NAME $KERNEL_VERSION for all the supported variants...\n"$COLOR_NEUTRAL
# kltekor
if [ -e output_kltekor/ ]; then
if [ -e output_kltekor/.config ]; then
rm -f output_kltekor/.config
if [ -e output_kltekor/arch/arm/boot/zImage ]; then
rm -f output_kltekor/arch/arm/boot/zImage
fi
fi
else
mkdir output_kltekor
fi
echo -e $COLOR_GREEN"\n building $KERNEL_NAME for kltekor\n"$COLOR_NEUTRAL
make -C $(pwd) O=output_kltekor Ares_@kltekor@_defconfig
# updating kernel version
sed -i "s;lineageos;$KERNEL_VERSION;" output_kltekor/.config;
make -j$NUM_CPUS -C $(pwd) O=output_kltekor
if [ -e output_kltekor/arch/arm/boot/zImage ]; then
echo -e $COLOR_GREEN"\n copying zImage to anykernel directory\n"$COLOR_NEUTRAL
cp output_kltekor/arch/arm/boot/zImage $ANYKERNEL_DIR
# compile dtb if required
if [ "y" == "$COMPILE_DTB" ]; then
echo -e $COLOR_GREEN"\n compiling device tree blob (dtb)\n"$COLOR_NEUTRAL
if [ -f output_kltekor/arch/arm/boot/dt.img ]; then
rm -f output_kltekor/arch/arm/boot/dt.img
fi
chmod 777 tools/dtbToolCM
tools/dtbToolCM -2 -o output_kltekor/arch/arm/boot/dt.img -s 2048 -p output_kltekor/scripts/dtc/ output_kltekor/arch/arm/boot/
# removing old dtb (if any)
if [ -f $ANYKERNEL_DIR/dtb ]; then
rm -f $ANYKERNEL_DIR/dtb
fi
# copying generated dtb to anykernel directory
if [ -e output_kltekor/arch/arm/boot/dt.img ]; then
mv -f output_kltekor/arch/arm/boot/dt.img $ANYKERNEL_DIR/dtb
fi
fi
# adding version tag to ramdisk in order to access from the Kernel Manager
echo $KERNEL_VERSION > $ANYKERNEL_DIR/ramdisk/version
echo -e $COLOR_GREEN"\n generating recovery flashable zip file\n"$COLOR_NEUTRAL
cd $ANYKERNEL_DIR && zip -r9 $KERNEL_NAME-kltekor-$KERNEL_VERSION-$KERNEL_DATE.zip * -x README.md $KERNEL_NAME-kltekor-$KERNEL_VERSION-$KERNEL_DATE.zip && cd ..
echo -e $COLOR_GREEN"\n cleaning...\n"$COLOR_NEUTRAL
# check and create release folder...
if [ ! -d "$RELEASE_DIR" ]; then
mkdir $RELEASE_DIR
fi
rm $ANYKERNEL_DIR/zImage && mv $ANYKERNEL_DIR/$KERNEL_NAME* $RELEASE_DIR
if [ -f $ANYKERNEL_DIR/dtb ]; then
rm -f $ANYKERNEL_DIR/dtb
fi
echo -e $COLOR_GREEN"\n Preparing for kernel release\n"$COLOR_NEUTRAL
cp $RELEASE_DIR/$KERNEL_NAME-kltekor-$KERNEL_VERSION-$KERNEL_DATE.zip kernel-release/$KERNEL_NAME-kltekor.zip
else
if [ -f $ANYKERNEL_DIR/dtb ]; then
rm -f $ANYKERNEL_DIR/dtb
fi
echo -e $COLOR_RED"\n Building for kltekor failed. Please fix the issues and try again...\n"$COLOR_NEUTRAL
fi
# klte
if [ -e output_klte/ ]; then
if [ -e output_klte/.config ]; then
rm -f output_klte/.config
if [ -e output_klte/arch/arm/boot/zImage ]; then
rm -f output_klte/arch/arm/boot/zImage
fi
fi
else
mkdir output_klte
fi
echo -e $COLOR_GREEN"\n building $KERNEL_NAME for klte\n"$COLOR_NEUTRAL
make -C $(pwd) O=output_klte Ares_@klte@_defconfig
# updating kernel version
sed -i "s;lineageos;$KERNEL_VERSION;" output_klte/.config;
make -j$NUM_CPUS -C $(pwd) O=output_klte
if [ -e output_klte/arch/arm/boot/zImage ]; then
echo -e $COLOR_GREEN"\n copying zImage to anykernel directory\n"$COLOR_NEUTRAL
cp output_klte/arch/arm/boot/zImage $ANYKERNEL_DIR/
# compile dtb if required
if [ "y" == "$COMPILE_DTB" ]; then
echo -e $COLOR_GREEN"\n compiling device tree blob (dtb)\n"$COLOR_NEUTRAL
if [ -f output_klte/arch/arm/boot/dt.img ]; then
rm -f output_klte/arch/arm/boot/dt.img
fi
chmod 777 tools/dtbToolCM
tools/dtbToolCM -2 -o output_klte/arch/arm/boot/dt.img -s 2048 -p output_klte/scripts/dtc/ output_klte/arch/arm/boot/
# removing old dtb (if any)
if [ -f $ANYKERNEL_DIR/dtb ]; then
rm -f $ANYKERNEL_DIR/dtb
fi
# copying generated dtb to anykernel directory
if [ -e output_klte/arch/arm/boot/dt.img ]; then
mv -f output_klte/arch/arm/boot/dt.img $ANYKERNEL_DIR/dtb
fi
fi
# adding version tag to ramdisk in order to access from the Kernel Manager
echo $KERNEL_VERSION > $ANYKERNEL_DIR/ramdisk/version
echo -e $COLOR_GREEN"\n generating recovery flashable zip file\n"$COLOR_NEUTRAL
cd $ANYKERNEL_DIR && zip -r9 $KERNEL_NAME-klte-$KERNEL_VERSION-$KERNEL_DATE.zip * -x README.md $KERNEL_NAME-klte-$KERNEL_VERSION-$KERNEL_DATE.zip && cd ..
echo -e $COLOR_GREEN"\n cleaning...\n"$COLOR_NEUTRAL
rm $ANYKERNEL_DIR/zImage && mv $ANYKERNEL_DIR/$KERNEL_NAME* $RELEASE_DIR
if [ -f $ANYKERNEL_DIR/dtb ]; then
rm -f $ANYKERNEL_DIR/dtb
fi
echo -e $COLOR_GREEN"\n Preparing for kernel release\n"$COLOR_NEUTRAL
cp $RELEASE_DIR/$KERNEL_NAME-klte-$KERNEL_VERSION-$KERNEL_DATE.zip kernel-release/$KERNEL_NAME-klte.zip
else
if [ -f $ANYKERNEL_DIR/dtb ]; then
rm -f $ANYKERNEL_DIR/dtb
fi
echo -e $COLOR_RED"\n Building for klte failed. Please fix the issues and try again...\n"$COLOR_NEUTRAL
fi
# kltedv
if [ -e output_kltedv/ ]; then
if [ -e output_kltedv/.config ]; then
rm -f output_kltedv/.config
if [ -e output_kltedv/arch/arm/boot/zImage ]; then
rm -f output_kltedv/arch/arm/boot/zImage
fi
fi
else
mkdir output_kltedv
fi
echo -e $COLOR_GREEN"\n building $KERNEL_NAME for kltedv\n"$COLOR_NEUTRAL
make -C $(pwd) O=output_kltedv Ares_@kltedv@_defconfig
# updating kernel version
sed -i "s;lineageos;$KERNEL_VERSION;" output_kltedv/.config;
make -j$NUM_CPUS -C $(pwd) O=output_kltedv
if [ -e output_kltedv/arch/arm/boot/zImage ]; then
echo -e $COLOR_GREEN"\n copying zImage to anykernel directory\n"$COLOR_NEUTRAL
cp output_kltedv/arch/arm/boot/zImage $ANYKERNEL_DIR/
# compile dtb if required
if [ "y" == "$COMPILE_DTB" ]; then
echo -e $COLOR_GREEN"\n compiling device tree blob (dtb)\n"$COLOR_NEUTRAL
if [ -f output_kltedv/arch/arm/boot/dt.img ]; then
rm -f output_kltedv/arch/arm/boot/dt.img
fi
chmod 777 tools/dtbToolCM
tools/dtbToolCM -2 -o output_kltedv/arch/arm/boot/dt.img -s 2048 -p output_kltedv/scripts/dtc/ output_kltedv/arch/arm/boot/
# removing old dtb (if any)
if [ -f $ANYKERNEL_DIR/dtb ]; then
rm -f $ANYKERNEL_DIR/dtb
fi
# copying generated dtb to anykernel directory
if [ -e output_kltedv/arch/arm/boot/dt.img ]; then
mv -f output_kltedv/arch/arm/boot/dt.img $ANYKERNEL_DIR/dtb
fi
fi
# adding version tag to ramdisk in order to access from the Kernel Manager
echo $KERNEL_VERSION > $ANYKERNEL_DIR/ramdisk/version
echo -e $COLOR_GREEN"\n generating recovery flashable zip file\n"$COLOR_NEUTRAL
cd $ANYKERNEL_DIR && zip -r9 $KERNEL_NAME-kltedv-$KERNEL_VERSION-$KERNEL_DATE.zip * -x README.md $KERNEL_NAME-kltedv-$KERNEL_VERSION-$KERNEL_DATE.zip && cd ..
echo -e $COLOR_GREEN"\n cleaning...\n"$COLOR_NEUTRAL
rm $ANYKERNEL_DIR/zImage && mv $ANYKERNEL_DIR/$KERNEL_NAME* $RELEASE_DIR
if [ -f $ANYKERNEL_DIR/dtb ]; then
rm -f $ANYKERNEL_DIR/dtb
fi
echo -e $COLOR_GREEN"\n Preparing for kernel release\n"$COLOR_NEUTRAL
cp $RELEASE_DIR/$KERNEL_NAME-kltedv-$KERNEL_VERSION-$KERNEL_DATE.zip kernel-release/$KERNEL_NAME-kltedv.zip
else
if [ -f $ANYKERNEL_DIR/dtb ]; then
rm -f $ANYKERNEL_DIR/dtb
fi
echo -e $COLOR_RED"\n Building for kltedv failed. Please fix the issues and try again...\n"$COLOR_NEUTRAL
fi
# klteduos
if [ -e output_klteduos/ ]; then
if [ -e output_klteduos/.config ]; then
rm -f output_klteduos/.config
if [ -e output_klteduos/arch/arm/boot/zImage ]; then
rm -f output_klteduos/arch/arm/boot/zImage
fi
fi
else
mkdir output_klteduos
fi
echo -e $COLOR_GREEN"\n building $KERNEL_NAME for klteduos\n"$COLOR_NEUTRAL
make -C $(pwd) O=output_klteduos Ares_@klteduos@_defconfig
# updating kernel version
sed -i "s;lineageos;$KERNEL_VERSION;" output_klteduos/.config;
make -j$NUM_CPUS -C $(pwd) O=output_klteduos
if [ -e output_klteduos/arch/arm/boot/zImage ]; then
echo -e $COLOR_GREEN"\n copying zImage to anykernel directory\n"$COLOR_NEUTRAL
cp output_klteduos/arch/arm/boot/zImage $ANYKERNEL_DIR/
# compile dtb if required
if [ "y" == "$COMPILE_DTB" ]; then
echo -e $COLOR_GREEN"\n compiling device tree blob (dtb)\n"$COLOR_NEUTRAL
if [ -f output_klteduos/arch/arm/boot/dt.img ]; then
rm -f output_klteduos/arch/arm/boot/dt.img
fi
chmod 777 tools/dtbToolCM
tools/dtbToolCM -2 -o output_klteduos/arch/arm/boot/dt.img -s 2048 -p output_klteduos/scripts/dtc/ output_klteduos/arch/arm/boot/
# removing old dtb (if any)
if [ -f $ANYKERNEL_DIR/dtb ]; then
rm -f $ANYKERNEL_DIR/dtb
fi
# copying generated dtb to anykernel directory
if [ -e output_klteduos/arch/arm/boot/dt.img ]; then
mv -f output_klteduos/arch/arm/boot/dt.img $ANYKERNEL_DIR/dtb
fi
fi
# adding version tag to ramdisk in order to access from the Kernel Manager
echo $KERNEL_VERSION > $ANYKERNEL_DIR/ramdisk/version
echo -e $COLOR_GREEN"\n generating recovery flashable zip file\n"$COLOR_NEUTRAL
cd $ANYKERNEL_DIR && zip -r9 $KERNEL_NAME-klteduos-$KERNEL_VERSION-$KERNEL_DATE.zip * -x README.md $KERNEL_NAME-klteduos-$KERNEL_VERSION-$KERNEL_DATE.zip && cd ..
echo -e $COLOR_GREEN"\n cleaning...\n"$COLOR_NEUTRAL
rm $ANYKERNEL_DIR/zImage && mv $ANYKERNEL_DIR/$KERNEL_NAME* $RELEASE_DIR
if [ -f $ANYKERNEL_DIR/dtb ]; then
rm -f $ANYKERNEL_DIR/dtb
fi
echo -e $COLOR_GREEN"\n Preparing for kernel release\n"$COLOR_NEUTRAL
cp $RELEASE_DIR/$KERNEL_NAME-klteduos-$KERNEL_VERSION-$KERNEL_DATE.zip kernel-release/$KERNEL_NAME-klteduos.zip
else
if [ -f $ANYKERNEL_DIR/dtb ]; then
rm -f $ANYKERNEL_DIR/dtb
fi
echo -e $COLOR_RED"\n Building for klteduos failed. Please fix the issues and try again...\n"$COLOR_NEUTRAL
fi
# kltekdi
if [ -e output_kltekdi/ ]; then
if [ -e output_kltekdi/.config ]; then
rm -f output_kltekdi/.config
if [ -e output_kltekdi/arch/arm/boot/zImage ]; then
rm -f output_kltekdi/arch/arm/boot/zImage
fi
fi
else
mkdir output_kltekdi
fi
echo -e $COLOR_GREEN"\n building $KERNEL_NAME for kltekdi\n"$COLOR_NEUTRAL
make -C $(pwd) O=output_kltekdi Ares_@kltekdi@_defconfig
# updating kernel version
sed -i "s;lineageos;$KERNEL_VERSION;" output_kltekdi/.config;
make -j$NUM_CPUS -C $(pwd) O=output_kltekdi
if [ -e output_kltekdi/arch/arm/boot/zImage ]; then
echo -e $COLOR_GREEN"\n copying zImage to anykernel directory\n"$COLOR_NEUTRAL
cp output_kltekdi/arch/arm/boot/zImage $ANYKERNEL_DIR/
# compile dtb if required
if [ "y" == "$COMPILE_DTB" ]; then
echo -e $COLOR_GREEN"\n compiling device tree blob (dtb)\n"$COLOR_NEUTRAL
if [ -f output_kltekdi/arch/arm/boot/dt.img ]; then
rm -f output_kltekdi/arch/arm/boot/dt.img
fi
chmod 777 tools/dtbToolCM
tools/dtbToolCM -2 -o output_kltekdi/arch/arm/boot/dt.img -s 2048 -p output_kltekdi/scripts/dtc/ output_kltekdi/arch/arm/boot/
# removing old dtb (if any)
if [ -f $ANYKERNEL_DIR/dtb ]; then
rm -f $ANYKERNEL_DIR/dtb
fi
# copying generated dtb to anykernel directory
if [ -e output_kltekdi/arch/arm/boot/dt.img ]; then
mv -f output_kltekdi/arch/arm/boot/dt.img $ANYKERNEL_DIR/dtb
fi
fi
# adding version tag to ramdisk in order to access from the Kernel Manager
echo $KERNEL_VERSION > $ANYKERNEL_DIR/ramdisk/version
echo -e $COLOR_GREEN"\n generating recovery flashable zip file\n"$COLOR_NEUTRAL
cd $ANYKERNEL_DIR && zip -r9 $KERNEL_NAME-kltekdi-$KERNEL_VERSION-$KERNEL_DATE.zip * -x README.md $KERNEL_NAME-kltekdi-$KERNEL_VERSION-$KERNEL_DATE.zip && cd ..
echo -e $COLOR_GREEN"\n cleaning...\n"$COLOR_NEUTRAL
rm $ANYKERNEL_DIR/zImage && mv $ANYKERNEL_DIR/$KERNEL_NAME* $RELEASE_DIR
if [ -f $ANYKERNEL_DIR/dtb ]; then
rm -f $ANYKERNEL_DIR/dtb
fi
echo -e $COLOR_GREEN"\n Preparing for kernel release\n"$COLOR_NEUTRAL
cp $RELEASE_DIR/$KERNEL_NAME-kltekdi-$KERNEL_VERSION-$KERNEL_DATE.zip kernel-release/$KERNEL_NAME-kltekdi.zip
echo -e $COLOR_GREEN"\n everything done... please visit '$RELEASE_DIR'...\n"$COLOR_NEUTRAL
else
if [ -f $ANYKERNEL_DIR/dtb ]; then
rm -f $ANYKERNEL_DIR/dtb
fi
echo -e $COLOR_RED"\n Building for kltekdi failed. Please fix the issues and try again...\n"$COLOR_NEUTRAL
fi
else
echo -e $COLOR_GREEN"\n '$KERNEL_VARIANT' is not a supported variant... please check...\n"$COLOR_NEUTRAL
fi