This repository has been archived by the owner on Nov 18, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
build_boeffla.sh
616 lines (587 loc) · 25.6 KB
/
build_boeffla.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
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
#!/bin/bash
#
# Boeffla-Kernel (unofficial) Build Script
#
# Author: sunilpaulmathew <sunil.kde@gmail.com>
#
#
# 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 toolchain (Line# 44)
# 2. Set 'KERNEL_VARIANT' (Line# 40).
# 3. To build all the supported variants, set 'KERNEL_VARIANT' to "all"
# 4. Open Terminal, ‘cd’ to the Kernel ‘root’ folder and run ‘. build_boeffla.sh’
# 5. The output (anykernel zip) file will be generated in the ‘release_boeffla’ folder
# 6. Enjoy your new Kernel
#
# ***** ***** *Variables to be configured manually* ***** ***** #
#
KERNEL_NAME="Boeffla-Kernel"
KERNEL_VARIANT="kltekor" # options: klte, kltekor, kltedv, klteduos, kltekdi & all (build all the variants)
KERNEL_VERSION="stable-v19"
TOOLCHAIN="/home/sunil/UBERTC-arm-eabi-8.2.1/bin/arm-linux-gnueabi-"
ARCHITECTURE="arm"
NUM_CPUS="" # number of cpu cores used for build (leave empty for auto detection)
KERNEL_DEFCONFIG="Boeffla_@$KERNEL_VARIANT@_defconfig"
COMPILE_DTB="y"
PREPARE_MODULES=""
PREPARE_RELEASE=""
KERNEL_DATE="$(date +"%Y%m%d")"
BUILD_DIR="output_$KERNEL_VARIANT"
ANYKERNEL_DIR="anykernel_boeffla"
MODULES_DIR="$ANYKERNEL_DIR/modules"
RELEASE_DIR="release_boeffla"
KERNEL_IMAGE="$BUILD_DIR/arch/arm/boot/zImage"
DTB="$BUILD_DIR/arch/arm/boot/dt.img"
COMPILER_FLAGS_KERNEL="-Wno-maybe-uninitialized -Wno-array-bounds"
COMPILER_FLAGS_MODULE="-Wno-maybe-uninitialized -Wno-array-bounds"
# ***** ***** ***** ***** ***THE END*** ***** ***** ***** ***** #
COLOR_RED="\033[0;31m"
COLOR_GREEN="\033[1;32m"
COLOR_NEUTRAL="\033[0m"
export ARCH=$ARCHITECTURE
export CROSS_COMPILE="${CCACHE} $TOOLCHAIN"
if [ -z "$NUM_CPUS" ]; then
NUM_CPUS=`grep -c ^processor /proc/cpuinfo`
fi
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_DIRT/.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 CFLAGS_KERNEL="$COMPILER_FLAGS_KERNEL" CFLAGS_MODULE="$COMPILER_FLAGS_MODULE" $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) for $KERNEL_VARIANT\n"$COLOR_NEUTRAL
if [ -f $DTB ]; then
rm -f $DTB
fi
chmod 777 tools_boeffla/dtbToolCM
tools_boeffla/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
# prepare modules if required
if [ "y" == "$PREPARE_MODULES" ]; then
# check and create 'modules' folder.
if [ ! -d "$MODULES_DIR" ]; then
mkdir $MODULES_DIR
mkdir $MODULES_DIR/system/
mkdir $MODULES_DIR/system/vendor/
mkdir $MODULES_DIR/system/vendor/lib/
mkdir $MODULES_DIR/system/vendor/lib/modules/
elif [ ! -d "$MODULES_DIR/system/" ]; then
mkdir $MODULES_DIR/system/
mkdir $MODULES_DIR/system/vendor/
mkdir $MODULES_DIR/system/vendor/lib/
mkdir $MODULES_DIR/system/vendor/lib/modules/
elif [ ! -d "$MODULES_DIR/system/vendor/" ]; then
mkdir $MODULES_DIR/system/vendor/
mkdir $MODULES_DIR/system/vendor/lib/
mkdir $MODULES_DIR/system/vendor/lib/modules/
elif [ ! -d "$MODULES_DIR/system/vendor/lib/" ]; then
mkdir $MODULES_DIR/system/vendor/lib/
mkdir $MODULES_DIR/system/vendor/lib/modules/
elif [ ! -d "$MODULES_DIR/system/vendor/lib/modules/" ]; then
mkdir $MODULES_DIR/system/vendor/lib/modules/
fi
if [ -z "$(ls -A $MODULES_DIR/system/vendor/lib/modules/)" ]; then
echo -e $COLOR_GREEN"\n “Preparing "modules" folder...\n"$COLOR_NEUTRAL
else
rm -r $MODULES_DIR/system/vendor/lib/modules/*
fi
echo -e $COLOR_GREEN"\n copying generated 'modules'\n"$COLOR_NEUTRAL
find $BUILD_DIR -name '*.ko' -exec cp -av {} $MODULES_DIR/system/vendor/lib/modules \;
# set module permissions
chmod 644 $MODULES_DIR/system/vendor/lib/modules/*
# strip 'modules'
${TOOLCHAIN}strip --strip-unneeded $MODULES_DIR/system/vendor/lib/modules/*
fi
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
echo -e $COLOR_GREEN"\n cleaning...\n"$COLOR_NEUTRAL
cd ..
# check and create release folder
if [ ! -d "$RELEASE_DIR" ]; then
mkdir $RELEASE_DIR
fi
rm $ANYKERNEL_DIR/zImage && rm $ANYKERNEL_DIR/dtb && mv $ANYKERNEL_DIR/$KERNEL_NAME-* $RELEASE_DIR
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
echo -e $COLOR_GREEN"\n Building for $KERNEL_VARIANT is 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 $KERNEL_VERSION for kltekor\n"$COLOR_NEUTRAL
make -C $(pwd) O=output_kltekor CFLAGS_KERNEL="$COMPILER_FLAGS_KERNEL" CFLAGS_MODULE="$COMPILER_FLAGS_MODULE" Boeffla_@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) for kltekor\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_boeffla/dtbToolCM
tools_boeffla/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
# prepare modules if required
if [ "y" == "$PREPARE_MODULES" ]; then
# check and create 'modules' folder.
if [ ! -d "$MODULES_DIR" ]; then
mkdir $MODULES_DIR
mkdir $MODULES_DIR/system/
mkdir $MODULES_DIR/system/vendor/
mkdir $MODULES_DIR/system/vendor/lib/
mkdir $MODULES_DIR/system/vendor/lib/modules/
elif [ ! -d "$MODULES_DIR/system/" ]; then
mkdir $MODULES_DIR/system/
mkdir $MODULES_DIR/system/vendor/
mkdir $MODULES_DIR/system/vendor/lib/
mkdir $MODULES_DIR/system/vendor/lib/modules/
elif [ ! -d "$MODULES_DIR/system/vendor/" ]; then
mkdir $MODULES_DIR/system/vendor/
mkdir $MODULES_DIR/system/vendor/lib/
mkdir $MODULES_DIR/system/vendor/lib/modules/
elif [ ! -d "$MODULES_DIR/system/vendor/lib/" ]; then
mkdir $MODULES_DIR/system/vendor/lib/
mkdir $MODULES_DIR/system/vendor/lib/modules/
elif [ ! -d "$MODULES_DIR/system/vendor/lib/modules/" ]; then
mkdir $MODULES_DIR/system/vendor/lib/modules/
fi
if [ -z "$(ls -A $MODULES_DIR/system/vendor/lib/modules/)" ]; then
echo -e $COLOR_GREEN"\n “Preparing "modules" folder...\n"$COLOR_NEUTRAL
else
rm -r $MODULES_DIR/system/vendor/lib/modules/*
fi
echo -e $COLOR_GREEN"\n copying generated 'modules'\n"$COLOR_NEUTRAL
find output_kltekor -name '*.ko' -exec cp -av {} $MODULES_DIR/system/vendor/lib/modules \;
# set module permissions
chmod 644 $MODULES_DIR/system/vendor/lib/modules/*
# strip 'modules'
${TOOLCHAIN}strip --strip-unneeded $MODULES_DIR/system/vendor/lib/modules/*
fi
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
echo -e $COLOR_GREEN"\n cleaning...\n"$COLOR_NEUTRAL
cd ..
# check and create release folder
if [ ! -d "$RELEASE_DIR" ]; then
mkdir $RELEASE_DIR
fi
rm $ANYKERNEL_DIR/zImage && rm $ANYKERNEL_DIR/dtb && mv $ANYKERNEL_DIR/$KERNEL_NAME-* $RELEASE_DIR
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
echo -e $COLOR_RED"\n Building for kltekor is 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 $KERNEL_VERSION for klte\n"$COLOR_NEUTRAL
make -C $(pwd) O=output_klte CFLAGS_KERNEL="$COMPILER_FLAGS_KERNEL" CFLAGS_MODULE="$COMPILER_FLAGS_MODULE" Boeffla_@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) for klte\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_boeffla/dtbToolCM
tools_boeffla/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
# prepare modules if required
if [ "y" == "$PREPARE_MODULES" ]; then
# check and create 'modules' folder.
if [ ! -d "$MODULES_DIR" ]; then
mkdir $MODULES_DIR
mkdir $MODULES_DIR/system/
mkdir $MODULES_DIR/system/vendor/
mkdir $MODULES_DIR/system/vendor/lib/
mkdir $MODULES_DIR/system/vendor/lib/modules/
elif [ ! -d "$MODULES_DIR/system/" ]; then
mkdir $MODULES_DIR/system/
mkdir $MODULES_DIR/system/vendor/
mkdir $MODULES_DIR/system/vendor/lib/
mkdir $MODULES_DIR/system/vendor/lib/modules/
elif [ ! -d "$MODULES_DIR/system/vendor/" ]; then
mkdir $MODULES_DIR/system/vendor/
mkdir $MODULES_DIR/system/vendor/lib/
mkdir $MODULES_DIR/system/vendor/lib/modules/
elif [ ! -d "$MODULES_DIR/system/vendor/lib/" ]; then
mkdir $MODULES_DIR/system/vendor/lib/
mkdir $MODULES_DIR/system/vendor/lib/modules/
elif [ ! -d "$MODULES_DIR/system/vendor/lib/modules/" ]; then
mkdir $MODULES_DIR/system/vendor/lib/modules/
fi
if [ -z "$(ls -A $MODULES_DIR/system/vendor/lib/modules/)" ]; then
echo -e $COLOR_GREEN"\n “Preparing "modules" folder...\n"$COLOR_NEUTRAL
else
rm -r $MODULES_DIR/system/vendor/lib/modules/*
fi
echo -e $COLOR_GREEN"\n copying generated 'modules'\n"$COLOR_NEUTRAL
find output_klte -name '*.ko' -exec cp -av {} $MODULES_DIR/system/vendor/lib/modules \;
# set module permissions
chmod 644 $MODULES_DIR/system/vendor/lib/modules/*
# strip 'modules'
${TOOLCHAIN}strip --strip-unneeded $MODULES_DIR/system/vendor/lib/modules/*
fi
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
echo -e $COLOR_GREEN"\n cleaning...\n"$COLOR_NEUTRAL
cd ..
# check and create release folder
if [ ! -d "$RELEASE_DIR" ]; then
mkdir $RELEASE_DIR
fi
rm $ANYKERNEL_DIR/zImage && rm $ANYKERNEL_DIR/dtb && mv $ANYKERNEL_DIR/$KERNEL_NAME-* $RELEASE_DIR
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
echo -e $COLOR_RED"\n Building for klte is 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 $KERNEL_VERSION for kltedv\n"$COLOR_NEUTRAL
make -C $(pwd) O=output_kltedv CFLAGS_KERNEL="$COMPILER_FLAGS_KERNEL" CFLAGS_MODULE="$COMPILER_FLAGS_MODULE" Boeffla_@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) for kltedv\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_boeffla/dtbToolCM
tools_boeffla/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
# prepare modules if required
if [ "y" == "$PREPARE_MODULES" ]; then
# check and create 'modules' folder.
if [ ! -d "$MODULES_DIR" ]; then
mkdir $MODULES_DIR
mkdir $MODULES_DIR/system/
mkdir $MODULES_DIR/system/vendor/
mkdir $MODULES_DIR/system/vendor/lib/
mkdir $MODULES_DIR/system/vendor/lib/modules/
elif [ ! -d "$MODULES_DIR/system/" ]; then
mkdir $MODULES_DIR/system/
mkdir $MODULES_DIR/system/vendor/
mkdir $MODULES_DIR/system/vendor/lib/
mkdir $MODULES_DIR/system/vendor/lib/modules/
elif [ ! -d "$MODULES_DIR/system/vendor/" ]; then
mkdir $MODULES_DIR/system/vendor/
mkdir $MODULES_DIR/system/vendor/lib/
mkdir $MODULES_DIR/system/vendor/lib/modules/
elif [ ! -d "$MODULES_DIR/system/vendor/lib/" ]; then
mkdir $MODULES_DIR/system/vendor/lib/
mkdir $MODULES_DIR/system/vendor/lib/modules/
elif [ ! -d "$MODULES_DIR/system/vendor/lib/modules/" ]; then
mkdir $MODULES_DIR/system/vendor/lib/modules/
fi
if [ -z "$(ls -A $MODULES_DIR/system/vendor/lib/modules/)" ]; then
echo -e $COLOR_GREEN"\n “Preparing "modules" folder...\n"$COLOR_NEUTRAL
else
rm -r $MODULES_DIR/system/vendor/lib/modules/*
fi
echo -e $COLOR_GREEN"\n copying generated 'modules'\n"$COLOR_NEUTRAL
find output_kltedv -name '*.ko' -exec cp -av {} $MODULES_DIR/system/vendor/lib/modules \;
# set module permissions
chmod 644 $MODULES_DIR/system/vendor/lib/modules/*
# strip 'modules'
${TOOLCHAIN}strip --strip-unneeded $MODULES_DIR/system/vendor/lib/modules/*
fi
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
echo -e $COLOR_GREEN"\n cleaning...\n"$COLOR_NEUTRAL
cd ..
# check and create release folder
if [ ! -d "$RELEASE_DIR" ]; then
mkdir $RELEASE_DIR
fi
rm $ANYKERNEL_DIR/zImage && rm $ANYKERNEL_DIR/dtb && mv $ANYKERNEL_DIR/$KERNEL_NAME-* $RELEASE_DIR
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
echo -e $COLOR_RED"\n Building for kltedv is 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 $KERNEL_VERSION for klteduos\n"$COLOR_NEUTRAL
make -C $(pwd) O=output_klteduos CFLAGS_KERNEL="$COMPILER_FLAGS_KERNEL" CFLAGS_MODULE="$COMPILER_FLAGS_MODULE" Boeffla_@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) for klteduos\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_boeffla/dtbToolCM
tools_boeffla/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
# prepare modules if required
if [ "y" == "$PREPARE_MODULES" ]; then
# check and create 'modules' folder.
if [ ! -d "$MODULES_DIR" ]; then
mkdir $MODULES_DIR
mkdir $MODULES_DIR/system/
mkdir $MODULES_DIR/system/vendor/
mkdir $MODULES_DIR/system/vendor/lib/
mkdir $MODULES_DIR/system/vendor/lib/modules/
elif [ ! -d "$MODULES_DIR/system/" ]; then
mkdir $MODULES_DIR/system/
mkdir $MODULES_DIR/system/vendor/
mkdir $MODULES_DIR/system/vendor/lib/
mkdir $MODULES_DIR/system/vendor/lib/modules/
elif [ ! -d "$MODULES_DIR/system/vendor/" ]; then
mkdir $MODULES_DIR/system/vendor/
mkdir $MODULES_DIR/system/vendor/lib/
mkdir $MODULES_DIR/system/vendor/lib/modules/
elif [ ! -d "$MODULES_DIR/system/vendor/lib/" ]; then
mkdir $MODULES_DIR/system/vendor/lib/
mkdir $MODULES_DIR/system/vendor/lib/modules/
elif [ ! -d "$MODULES_DIR/system/vendor/lib/modules/" ]; then
mkdir $MODULES_DIR/system/vendor/lib/modules/
fi
if [ -z "$(ls -A $MODULES_DIR/system/vendor/lib/modules/)" ]; then
echo -e $COLOR_GREEN"\n “Preparing "modules" folder...\n"$COLOR_NEUTRAL
else
rm -r $MODULES_DIR/system/vendor/lib/modules/*
fi
echo -e $COLOR_GREEN"\n copying generated 'modules'\n"$COLOR_NEUTRAL
find output_klteduos -name '*.ko' -exec cp -av {} $MODULES_DIR/system/vendor/lib/modules \;
# set module permissions
chmod 644 $MODULES_DIR/system/vendor/lib/modules/*
# strip 'modules'
${TOOLCHAIN}strip --strip-unneeded $MODULES_DIR/system/vendor/lib/modules/*
fi
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
echo -e $COLOR_GREEN"\n cleaning...\n"$COLOR_NEUTRAL
cd ..
# check and create release folder
if [ ! -d "$RELEASE_DIR" ]; then
mkdir $RELEASE_DIR
fi
rm $ANYKERNEL_DIR/zImage && rm $ANYKERNEL_DIR/dtb && mv $ANYKERNEL_DIR/$KERNEL_NAME-* $RELEASE_DIR
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
echo -e $COLOR_GREEN"\n everything done... please visit '$RELEASE_DIR'...\n"$COLOR_NEUTRAL
else
echo -e $COLOR_RED"\n Building for klteduos is 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 $KERNEL_VERSION for kltekdi\n"$COLOR_NEUTRAL
make -C $(pwd) O=output_kltekdi CFLAGS_KERNEL="$COMPILER_FLAGS_KERNEL" CFLAGS_MODULE="$COMPILER_FLAGS_MODULE" Boeffla_@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) for kltekdi\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_boeffla/dtbToolCM
tools_boeffla/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
# prepare modules if required
if [ "y" == "$PREPARE_MODULES" ]; then
# check and create 'modules' folder.
if [ ! -d "$MODULES_DIR" ]; then
mkdir $MODULES_DIR
mkdir $MODULES_DIR/system/
mkdir $MODULES_DIR/system/vendor/
mkdir $MODULES_DIR/system/vendor/lib/
mkdir $MODULES_DIR/system/vendor/lib/modules/
elif [ ! -d "$MODULES_DIR/system/" ]; then
mkdir $MODULES_DIR/system/
mkdir $MODULES_DIR/system/vendor/
mkdir $MODULES_DIR/system/vendor/lib/
mkdir $MODULES_DIR/system/vendor/lib/modules/
elif [ ! -d "$MODULES_DIR/system/vendor/" ]; then
mkdir $MODULES_DIR/system/vendor/
mkdir $MODULES_DIR/system/vendor/lib/
mkdir $MODULES_DIR/system/vendor/lib/modules/
elif [ ! -d "$MODULES_DIR/system/vendor/lib/" ]; then
mkdir $MODULES_DIR/system/vendor/lib/
mkdir $MODULES_DIR/system/vendor/lib/modules/
elif [ ! -d "$MODULES_DIR/system/vendor/lib/modules/" ]; then
mkdir $MODULES_DIR/system/vendor/lib/modules/
fi
if [ -z "$(ls -A $MODULES_DIR/system/vendor/lib/modules/)" ]; then
echo -e $COLOR_GREEN"\n “Preparing "modules" folder...\n"$COLOR_NEUTRAL
else
rm -r $MODULES_DIR/system/vendor/lib/modules/*
fi
echo -e $COLOR_GREEN"\n copying generated 'modules'\n"$COLOR_NEUTRAL
find output_kltekdi -name '*.ko' -exec cp -av {} $MODULES_DIR/system/vendor/lib/modules \;
# set module permissions
chmod 644 $MODULES_DIR/system/vendor/lib/modules/*
# strip 'modules'
${TOOLCHAIN}strip --strip-unneeded $MODULES_DIR/system/vendor/lib/modules/*
fi
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
echo -e $COLOR_GREEN"\n cleaning...\n"$COLOR_NEUTRAL
cd ..
# check and create release folder
if [ ! -d "$RELEASE_DIR" ]; then
mkdir $RELEASE_DIR
fi
rm $ANYKERNEL_DIR/zImage && rm $ANYKERNEL_DIR/dtb && mv $ANYKERNEL_DIR/$KERNEL_NAME-* $RELEASE_DIR
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
echo -e $COLOR_RED"\n Building for kltekdi is 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