This repository was archived by the owner on Mar 20, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdroneci-test-xiaomi.sh
More file actions
851 lines (716 loc) · 23.8 KB
/
droneci-test-xiaomi.sh
File metadata and controls
851 lines (716 loc) · 23.8 KB
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
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
#! /bin/bash
# Script For Building Android arm64 Kernel
#
# Copyright (c) 2018-2020 Panchajanya1999 <rsk52959@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Kernel building script
# Function to show an informational message
msg() {
echo -e "\e[1;32m$*\e[0m"
}
err() {
echo -e "\e[1;41m$*\e[0m"
exit 1
}
##------------------------------------------------------##
##----------Basic Informations, COMPULSORY--------------##
# The defult directory where the kernel should be placed
KERNEL_DIR=$PWD
# The name of the Kernel, to name the ZIP
KERNEL="STRIX"
# Kernel zip name type
TYPE="nightly"
# The name of the device for which the kernel is built
MODEL="Redmi Note 6 Pro"
MODEL1="Redmi Note 5 Pro"
MODEL2="MI 6X/A2"
# The codename of the device
DEVICE="tulip"
DEVICE1="whyred"
DEVICE2="wayne"
# Retrieves branch information
CI_BRANCH=$(git rev-parse --abbrev-ref HEAD)
export CI_BRANCH
# Kernel revision
KERNELTYPE=EAS
KERNELTYPE1=HMP
# The defconfig which should be used. Get it from config.gz from
# your device or check source
DEFCONFIG=tulip_defconfig
DEFCONFIG1=whyred_defconfig
DEFCONFIG2=wayne_defconfig
# Show manufacturer info
MANUFACTURERINFO="XiaoMI, Inc."
# Specify compiler.
# 'clang' or 'gcc'
if [[ "$CI_BRANCH" == "sdm660-hmp-rebase" ]]; then
COMPILER=gcc
elif [[ "$CI_BRANCH" == "lto-gcc-clang" ]]; then
COMPILER=clang
else
COMPILER=gcc
fi
if [ $COMPILER = "clang" ]
then
# install few necessary packages
apt-get update -y && apt-get -y install llvm lld
else
apt-get -y install libfl-dev
fi
# Clean source prior building. 1 is NO(default) | 0 is YES
INCREMENTAL=1
# Push ZIP to Telegram. 1 is YES | 0 is NO(default)
PTTG=1
if [ $PTTG = 1 ]
then
# Set Telegram Chat ID
CHATID="-1001353688353"
fi
# Generate a full DEFCONFIG prior building. 1 is YES | 0 is NO(default)
DEF_REG=0
# Build dtbo.img (select this only if your source has support to building dtbo.img)
# 1 is YES | 0 is NO(default)
BUILD_DTBO=0
# Sign the zipfile
# 1 is YES | 0 is NO
SIGN=0
# Debug purpose. Send logs on every successfull builds
# 1 is YES | 0 is NO(default)
LOG_DEBUG=0
##------------------------------------------------------##
##---------Do Not Touch Anything Beyond This------------##
# Check if we are using a dedicated CI ( Continuous Integration ), and
# set KBUILD_BUILD_VERSION and KBUILD_BUILD_HOST and CI_BRANCH
## Set defaults first
DISTRO=$(cat /etc/issue)
export token="1750976833:AAHwfDO3UUqesCPNITIP88GbgEATKHRHlGk"
## Check for CI
if [ -n "$CI" ]
then
if [ -n "$CIRCLECI" ]
then
export KBUILD_BUILD_VERSION=$CIRCLE_BUILD_NUM
export KBUILD_BUILD_HOST="CircleCI"
export CI_BRANCH=$CIRCLE_BRANCH
fi
if [ -n "$DRONE" ]
then
export KBUILD_BUILD_VERSION="1"
export KBUILD_BUILD_HOST="DroneCI"
export CI_BRANCH=$DRONE_BRANCH
else
echo "Not presetting Build Version"
fi
fi
#Check Kernel Version
KERVER=$(make kernelversion)
# Set a commit head
COMMIT_HEAD=$(git log --oneline -1)
# Set Date
DATE=$(TZ=Asia/Jakarta date +"%Y%m%d-%T")
#Now Its time for other stuffs like cloning, exporting, etc
clone() {
echo " "
if [ $COMPILER = "clang" ]
then
if [[ "$CI_BRANCH" == "lto-gcc-clang" ]]; then
msg "|| Cloning Proton clang ||"
git clone --depth=1 https://github.com/kdrag0n/proton-clang.git clang
else
msg "|| Cloning STRIX clang ||"
git clone --depth=1 https://github.com/STRIX-Project/STRIX-clang.git clang
fi
# Toolchain Directory defaults to clang-llvm
TC_DIR=$KERNEL_DIR/clang
elif [ $COMPILER = "gcc" ]
then
if [[ "$CI_BRANCH" == "sdm660-hmp-rebase" ]]; then
msg "|| Cloning GCC 8 & 5 ||"
git clone https://github.com/najahiiii/aarch64-linux-gnu.git -b gcc8-201903-A --depth=1 gcc64
git clone https://github.com/arter97/arm-eabi-5.1.git -b master --depth=1 gcc32
GCC64_DIR=$KERNEL_DIR/gcc64
GCC32_DIR=$KERNEL_DIR/gcc32
else
msg "|| Cloning GCC 10.3.1 ||"
git clone https://github.com/fiqri19102002/aarch64-gcc.git -b elf-gcc-11-tarballs --depth=1 gcc64
git clone https://github.com/fiqri19102002/arm-gcc.git -b elf-gcc-11-tarballs --depth=1 gcc32
GCC64_DIR=$KERNEL_DIR/gcc64
GCC32_DIR=$KERNEL_DIR/gcc32
fi
fi
msg "|| Cloning Anykernel ||"
git clone --depth 1 https://github.com/STRIX-Project/AnyKernel3.git -b tulip-test
if [ $BUILD_DTBO = 1 ]
then
msg "|| Cloning libufdt ||"
git clone https://android.googlesource.com/platform/system/libufdt "$KERNEL_DIR"/scripts/ufdt/libufdt
fi
}
##------------------------------------------------------##
exports() {
export KBUILD_BUILD_USER="FiqriArdyansyah"
export ARCH=arm64
export SUBARCH=arm64
if [ $COMPILER = "clang" ]
then
KBUILD_COMPILER_STRING=$("$TC_DIR"/bin/clang --version | head -n 1 | perl -pe 's/\(http.*?\)//gs' | sed -e 's/ */ /g' -e 's/[[:space:]]*$//')
PATH=$TC_DIR/bin/:$PATH
elif [ $COMPILER = "gcc" ]
then
if [[ "$CI_BRANCH" == "sdm660-hmp-rebase" ]]; then
KBUILD_COMPILER_STRING="gcc version 8.3.0(GNU Toolchain for the A-profile Architecture 8.3-2019.03(arm-rel-8.36))"
PATH=$GCC64_DIR/bin/:$GCC32_DIR/bin/:/usr/bin:$PATH
else
KBUILD_COMPILER_STRING=$("$GCC64_DIR"/bin/aarch64-elf-gcc --version | head -n 1)
PATH=$GCC64_DIR/bin/:$GCC32_DIR/bin/:/usr/bin:$PATH
fi
fi
export PATH KBUILD_COMPILER_STRING
export BOT_MSG_URL="https://api.telegram.org/bot$token/sendMessage"
export BOT_BUILD_URL="https://api.telegram.org/bot$token/sendDocument"
PROCS=$(nproc --all)
export PROCS
}
##---------------------------------------------------------##
tg_post_msg() {
curl -s -X POST "$BOT_MSG_URL" -d chat_id="$2" \
-d "disable_web_page_preview=true" \
-d "parse_mode=html" \
-d text="$1"
}
##----------------------------------------------------------------##
tg_post_build() {
#Post MD5Checksum alongwith for easeness
MD5CHECK=$(md5sum "$1" | cut -d' ' -f1)
#Show the Checksum alongwith caption
curl --progress-bar -F document=@"$1" "$BOT_BUILD_URL" \
-F chat_id="$2" \
-F "disable_web_page_preview=true" \
-F "parse_mode=html" \
-F caption="$3 | <b>MD5 Checksum : </b><code>$MD5CHECK</code>"
}
##----------------------------------------------------------##
# Set naming to old cam for zip file
setversioning() {
if [[ "$CI_BRANCH" == "sdm660-oc-test" ]]; then
KERNELNAME="$KERNEL-$DEVICE-$KERNELTYPE-OC-$TYPE-oldcam-$DATE"
export KERNELTYPE KERNELNAME
export ZIPNAME="$KERNELNAME.zip"
elif [[ "$CI_BRANCH" == "sdm660-eas-test" ]]; then
KERNELNAME="$KERNEL-$DEVICE-$KERNELTYPE-$TYPE-oldcam-$DATE"
export KERNELTYPE KERNELNAME
export ZIPNAME="$KERNELNAME.zip"
elif [[ "$CI_BRANCH" == "sdm660-hmp-rebase" ]]; then
KERNELNAME="$KERNEL-$DEVICE-$KERNELTYPE1-$TYPE-oldcam-$DATE"
export KERNELTYPE KERNELNAME
export ZIPNAME="$KERNELNAME.zip"
else
KERNELNAME="$KERNEL-$DEVICE-$KERNELTYPE-$TYPE-oldcam-$DATE"
export KERNELTYPE KERNELNAME
export ZIPNAME="$KERNELNAME.zip"
fi
}
##--------------------------------------------------------------##
build_kernel() {
if [ $INCREMENTAL = 0 ]
then
msg "|| Cleaning Sources ||"
make clean && make mrproper && rm -rf out
fi
if [ "$PTTG" = 1 ]
then
tg_post_msg "<b>Docker OS: </b><code>$DISTRO</code>%0A<b>Kernel Version : </b><code>$KERVER</code>%0A<b>Date : </b><code>$(TZ=Asia/Jakarta date)</code>%0A<b>Device : </b><code>$MODEL [$DEVICE]</code>%0A<b>Manufacturer : </b><code>$MANUFACTURERINFO</code>%0A<b>Pipeline Host : </b><code>$KBUILD_BUILD_HOST</code>%0A<b>Host Core Count : </b><code>$PROCS</code>%0A<b>Compiler Used : </b><code>$KBUILD_COMPILER_STRING</code>%0a<b>Branch : </b><code>$CI_BRANCH</code>%0A<b>Top Commit : </b><code>$COMMIT_HEAD</code>%0A<b>Status : </b>#Nightly" "$CHATID"
fi
msg "|| Started Compilation ||"
make O=out $DEFCONFIG
if [ $DEF_REG = 1 ]
then
cp .config arch/arm64/configs/$DEFCONFIG
git add arch/arm64/configs/$DEFCONFIG
git commit -m "$DEFCONFIG: Regenerate
This is an auto-generated commit"
fi
BUILD_START=$(date +"%s")
if [ $COMPILER = "clang" ]
then
make -j"$PROCS" O=out \
CROSS_COMPILE=aarch64-linux-gnu- \
CROSS_COMPILE_ARM32=arm-linux-gnueabi- \
CC=clang \
AR=llvm-ar \
NM=llvm-nm \
LD=ld.lld \
OBJDUMP=llvm-objdump \
STRIP=llvm-strip
fi
if [ $COMPILER = "gcc" ]
then
if [[ "$CI_BRANCH" == "sdm660-hmp-rebase" ]]; then
export CROSS_COMPILE_ARM32=$GCC32_DIR/bin/arm-eabi-
make -j"$PROCS" O=out CROSS_COMPILE=aarch64-linux-gnu-
else
export CROSS_COMPILE_ARM32=$GCC32_DIR/bin/arm-eabi-
make -j"$PROCS" O=out CROSS_COMPILE=aarch64-elf-
fi
fi
BUILD_END=$(date +"%s")
DIFF=$((BUILD_END - BUILD_START))
if [ -f "$KERNEL_DIR"/out/arch/arm64/boot/Image.gz-dtb ]
then
msg "|| Kernel successfully compiled ||"
elif ! [ -f $KERNEL_DIR/out/arch/arm64/boot/Image.gz-dtb ]
then
echo -e "Kernel compilation failed, See buildlog to fix errors"
tg_post_msg "<b>Build failed to compile after $((DIFF / 60)) minute(s) and $((DIFF % 60)) seconds</b>" "$CHATID"
exit 1
fi
if [ $BUILD_DTBO = 1 ]
then
msg "|| Building DTBO ||"
tg_post_msg "<code>Building DTBO..</code>" "$CHATID"
python2 "$KERNEL_DIR/scripts/ufdt/libufdt/utils/src/mkdtboimg.py" \
create "$KERNEL_DIR/out/arch/arm64/boot/dtbo.img" --page_size=4096 "$KERNEL_DIR/out/arch/arm64/boot/dts/qcom/sm6150-idp-overlay.dtbo"
fi
}
##--------------------------------------------------------------##
gen_zip() {
msg "|| Zipping into a flashable zip ||"
mv "$KERNEL_DIR"/out/arch/arm64/boot/Image.gz-dtb AnyKernel3/Image.gz-dtb
if [ $BUILD_DTBO = 1 ]
then
mv "$KERNEL_DIR"/out/arch/arm64/boot/dtbo.img AnyKernel3/dtbo.img
fi
cd AnyKernel3 || exit
zip -r9 "$ZIPNAME" * -x .git README.md
## Prepare a final zip variable
ZIP_FINAL="$ZIPNAME"
if [ "$PTTG" = 1 ]
then
tg_post_build "$ZIP_FINAL" "$CHATID" "Build took : $((DIFF / 60)) minute(s) and $((DIFF % 60)) second(s)"
fi
cd ..
}
##--------------------------------------------------------------##
# Now Its time for other stuffs like cloning
cloneak() {
rm -rf "$KERNEL_DIR/AnyKernel3"
msg "|| Cloning Anykernel for tulip ||"
git clone --depth 1 https://github.com/STRIX-Project/AnyKernel3.git -b tulip
}
# Ship China firmware builds
setnewcam() {
# Switch to new cam blob from defconfig
sed -i 's/CONFIG_MACH_XIAOMI_NEW_CAMERA=n/CONFIG_MACH_XIAOMI_NEW_CAMERA=y/g' arch/arm64/configs/$DEFCONFIG
msg "|| Newcam for tulip ready ||"
}
# Set naming to new cam for zip file
setversioning1() {
if [[ "$CI_BRANCH" == "sdm660-oc-test" ]]; then
KERNELNAME1="$KERNEL-$DEVICE-$KERNELTYPE-OC-$TYPE-newcam-$DATE"
export KERNELTYPE KERNELNAME1
export ZIPNAME1="$KERNELNAME1.zip"
elif [[ "$CI_BRANCH" == "sdm660-eas-test" ]]; then
KERNELNAME1="$KERNEL-$DEVICE-$KERNELTYPE-$TYPE-newcam-$DATE"
export KERNELTYPE KERNELNAME1
export ZIPNAME1="$KERNELNAME1.zip"
elif [[ "$CI_BRANCH" == "sdm660-hmp-rebase" ]]; then
KERNELNAME1="$KERNEL-$DEVICE-$KERNELTYPE1-$TYPE-newcam-$DATE"
export KERNELTYPE KERNELNAME1
export ZIPNAME1="$KERNELNAME1.zip"
else
KERNELNAME1="$KERNEL-$DEVICE-$KERNELTYPE-$TYPE-newcam-$DATE"
export KERNELTYPE KERNELNAME1
export ZIPNAME1="$KERNELNAME1.zip"
fi
}
gen_zip1() {
msg "|| Zipping into a flashable zip ||"
mv "$KERNEL_DIR"/out/arch/arm64/boot/Image.gz-dtb AnyKernel3/Image.gz-dtb
if [ $BUILD_DTBO = 1 ]
then
mv "$KERNEL_DIR"/out/arch/arm64/boot/dtbo.img AnyKernel3/dtbo.img
fi
cd AnyKernel3 || exit
zip -r9 "$ZIPNAME1" * -x .git README.md
## Prepare a final zip variable
ZIP_FINAL="$ZIPNAME1"
if [ "$PTTG" = 1 ]
then
tg_post_build "$ZIP_FINAL" "$CHATID" "Build took : $((DIFF / 60)) minute(s) and $((DIFF % 60)) second(s)"
fi
cd ..
}
if [[ "$CI_BRANCH" == "sdm660-hmp-rebase" ]]; then
setversioning
clone
exports
build_kernel
gen_zip
else
setversioning
clone
exports
build_kernel
gen_zip
setversioning1
setnewcam
cloneak
build_kernel
gen_zip1
fi
if [ $LOG_DEBUG = "1" ]
then
tg_post_build "error.log" "$CHATID" "Debug Mode Logs"
fi
##------------------------------------------------------------------##
msg "|| compile for whyred device ||"
rm -r "$KERNEL_DIR/out"
mkdir "$KERNEL_DIR/out"
##----------------------------------------------------------##
# Now Its time for other stuffs like cloning
cloneak1() {
rm -rf "$KERNEL_DIR/AnyKernel3"
msg "|| Cloning Anykernel for whyred ||"
git clone --depth 1 https://github.com/STRIX-Project/AnyKernel3.git -b whyred-test
}
##------------------------------------------------------------------##
build_kernel1() {
if [ $INCREMENTAL = 0 ]
then
msg "|| Cleaning Sources ||"
make clean && make mrproper && rm -rf out
fi
if [ "$PTTG" = 1 ]
then
tg_post_msg "<b>Docker OS: </b><code>$DISTRO</code>%0A<b>Kernel Version : </b><code>$KERVER</code>%0A<b>Date : </b><code>$(TZ=Asia/Jakarta date)</code>%0A<b>Device : </b><code>$MODEL1 [$DEVICE1]</code>%0A<b>Manufacturer : </b><code>$MANUFACTURERINFO</code>%0A<b>Pipeline Host : </b><code>$KBUILD_BUILD_HOST</code>%0A<b>Host Core Count : </b><code>$PROCS</code>%0A<b>Compiler Used : </b><code>$KBUILD_COMPILER_STRING</code>%0a<b>Branch : </b><code>$CI_BRANCH</code>%0A<b>Last Commit : </b><code>$COMMIT_HEAD</code>%0A<b>Status : </b>#Nightly" "$CHATID"
fi
msg "|| Started Compilation ||"
make O=out $DEFCONFIG1
if [ $DEF_REG = 1 ]
then
cp .config arch/arm64/configs/$DEFCONFIG1
git add arch/arm64/configs/$DEFCONFIG1
git commit -m "$DEFCONFIG1: Regenerate
This is an auto-generated commit"
fi
BUILD_START=$(date +"%s")
if [ $COMPILER = "clang" ]
then
make -j"$PROCS" O=out \
CROSS_COMPILE=aarch64-linux-gnu- \
CROSS_COMPILE_ARM32=arm-linux-gnueabi- \
CC=clang \
AR=llvm-ar \
OBJDUMP=llvm-objdump \
STRIP=llvm-strip
fi
if [ $COMPILER = "gcc" ]
then
if [[ "$CI_BRANCH" == "sdm660-hmp-rebase" ]]; then
export CROSS_COMPILE_ARM32=$GCC32_DIR/bin/arm-eabi-
make -j"$PROCS" O=out CROSS_COMPILE=aarch64-linux-gnu-
else
export CROSS_COMPILE_ARM32=$GCC32_DIR/bin/arm-eabi-
make -j"$PROCS" O=out CROSS_COMPILE=aarch64-elf-
fi
fi
BUILD_END=$(date +"%s")
DIFF=$((BUILD_END - BUILD_START))
if [ -f "$KERNEL_DIR"/out/arch/arm64/boot/Image.gz-dtb ]
then
msg "|| Kernel successfully compiled ||"
elif ! [ -f $KERNEL_DIR/out/arch/arm64/boot/Image.gz-dtb ]
then
echo -e "Kernel compilation failed, See buildlog to fix errors"
tg_post_msg "<b>Build failed to compile after $((DIFF / 60)) minute(s) and $((DIFF % 60)) seconds</b>" "$CHATID"
exit 1
fi
if [ $BUILD_DTBO = 1 ]
then
msg "|| Building DTBO ||"
tg_post_msg "<code>Building DTBO..</code>" "$CHATID"
python2 "$KERNEL_DIR/scripts/ufdt/libufdt/utils/src/mkdtboimg.py" \
create "$KERNEL_DIR/out/arch/arm64/boot/dtbo.img" --page_size=4096 "$KERNEL_DIR/out/arch/arm64/boot/dts/qcom/sm6150-idp-overlay.dtbo"
fi
}
##--------------------------------------------------------------##
# Set naming to old cam for zip file
setversioning2() {
if [[ "$CI_BRANCH" == "sdm660-oc-test" ]]; then
KERNELNAME2="$KERNEL-$DEVICE1-$KERNELTYPE-OC-$TYPE-oldcam-$DATE"
export KERNELTYPE KERNELNAME2
export ZIPNAME2="$KERNELNAME2.zip"
elif [[ "$CI_BRANCH" == "sdm660-eas-test" ]]; then
KERNELNAME2="$KERNEL-$DEVICE1-$KERNELTYPE-$TYPE-oldcam-$DATE"
export KERNELTYPE KERNELNAME2
export ZIPNAME2="$KERNELNAME2.zip"
elif [[ "$CI_BRANCH" == "sdm660-hmp-rebase" ]]; then
KERNELNAME2="$KERNEL-$DEVICE1-$KERNELTYPE1-$TYPE-oldcam-$DATE"
export KERNELTYPE KERNELNAME2
export ZIPNAME2="$KERNELNAME2.zip"
else
KERNELNAME2="$KERNEL-$DEVICE1-$KERNELTYPE-$TYPE-oldcam-$DATE"
export KERNELTYPE KERNELNAME2
export ZIPNAME2="$KERNELNAME2.zip"
fi
}
##--------------------------------------------------------------##
gen_zip2() {
msg "|| Zipping into a flashable zip ||"
mv "$KERNEL_DIR"/out/arch/arm64/boot/Image.gz-dtb AnyKernel3/Image.gz-dtb
if [ $BUILD_DTBO = 1 ]
then
mv "$KERNEL_DIR"/out/arch/arm64/boot/dtbo.img AnyKernel3/dtbo.img
fi
cd AnyKernel3 || exit
zip -r9 "$ZIPNAME2" * -x .git README.md
# Prepare a final zip variable
ZIP_FINAL="$ZIPNAME2"
if [ "$PTTG" = 1 ]
then
tg_post_build "$ZIP_FINAL" "$CHATID" "Build took : $((DIFF / 60)) minute(s) and $((DIFF % 60)) second(s)"
fi
cd ..
}
##--------------------------------------------------------------##
# Ship China firmware builds
setnewcam1() {
# Switch to new cam from defconfig
sed -i 's/CONFIG_MACH_XIAOMI_NEW_CAMERA=n/CONFIG_MACH_XIAOMI_NEW_CAMERA=y/g' arch/arm64/configs/$DEFCONFIG1
msg "|| Newcam for whyred ready ||"
}
# Set naming to new cam for zip file
setversioning3() {
if [[ "$CI_BRANCH" == "sdm660-oc-test" ]]; then
KERNELNAME3="$KERNEL-$DEVICE1-$KERNELTYPE-OC-$TYPE-newcam-$DATE"
export KERNELTYPE KERNELNAME3
export ZIPNAME3="$KERNELNAME3.zip"
elif [[ "$CI_BRANCH" == "sdm660-eas-test" ]]; then
KERNELNAME3="$KERNEL-$DEVICE1-$KERNELTYPE-$TYPE-newcam-$DATE"
export KERNELTYPE KERNELNAME3
export ZIPNAME3="$KERNELNAME3.zip"
elif [[ "$CI_BRANCH" == "sdm660-hmp-rebase" ]]; then
KERNELNAME3="$KERNEL-$DEVICE1-$KERNELTYPE1-$TYPE-newcam-$DATE"
export KERNELTYPE KERNELNAME3
export ZIPNAME3="$KERNELNAME3.zip"
else
KERNELNAME3="$KERNEL-$DEVICE1-$KERNELTYPE-$TYPE-newcam-$DATE"
export KERNELTYPE KERNELNAME3
export ZIPNAME3="$KERNELNAME3.zip"
fi
}
gen_zip3() {
msg "|| Zipping into a flashable zip ||"
mv "$KERNEL_DIR"/out/arch/arm64/boot/Image.gz-dtb AnyKernel3/Image.gz-dtb
if [ $BUILD_DTBO = 1 ]
then
mv "$KERNEL_DIR"/out/arch/arm64/boot/dtbo.img AnyKernel3/dtbo.img
fi
cd AnyKernel3 || exit
zip -r9 "$ZIPNAME3" * -x .git README.md
## Prepare a final zip variable
ZIP_FINAL="$ZIPNAME3"
if [ "$PTTG" = 1 ]
then
tg_post_build "$ZIP_FINAL" "$CHATID" "Build took : $((DIFF / 60)) minute(s) and $((DIFF % 60)) second(s)"
fi
cd ..
}
if [[ "$CI_BRANCH" == "sdm660-hmp-rebase" ]]; then
setversioning2
cloneak1
exports
build_kernel1
gen_zip2
else
setversioning2
cloneak1
exports
build_kernel1
gen_zip2
setversioning3
setnewcam1
cloneak1
build_kernel1
gen_zip3
fi
if [ $LOG_DEBUG = "1" ]
then
tg_post_build "error.log" "$CHATID" "Debug Mode Logs"
fi
##----------------------------------------------------------##
msg "|| compile for wayne/jasmine device ||"
rm -r "$KERNEL_DIR/out"
mkdir "$KERNEL_DIR/out"
##----------------------------------------------------------##
# Now Its time for other stuffs like cloning
cloneak2() {
rm -rf "$KERNEL_DIR/AnyKernel3"
msg "|| Cloning Anykernel for wayne/jasmine ||"
git clone --depth 1 https://github.com/STRIX-Project/AnyKernel3.git -b wayne/jasmine-test
}
##------------------------------------------------------------------##
build_kernel2() {
if [ $INCREMENTAL = 0 ]
then
msg "|| Cleaning Sources ||"
make clean && make mrproper && rm -rf out
fi
if [ "$PTTG" = 1 ]
then
tg_post_msg "<b>Docker OS: </b><code>$DISTRO</code>%0A<b>Kernel Version : </b><code>$KERVER</code>%0A<b>Date : </b><code>$(TZ=Asia/Jakarta date)</code>%0A<b>Device : </b><code>$MODEL2 [$DEVICE2]</code>%0A<b>Manufacturer : </b><code>$MANUFACTURERINFO</code>%0A<b>Pipeline Host : </b><code>$KBUILD_BUILD_HOST</code>%0A<b>Host Core Count : </b><code>$PROCS</code>%0A<b>Compiler Used : </b><code>$KBUILD_COMPILER_STRING</code>%0a<b>Branch : </b><code>$CI_BRANCH</code>%0A<b>Last Commit : </b><code>$COMMIT_HEAD</code>%0A<b>Status : </b>#Nightly" "$CHATID"
fi
msg "|| Started Compilation ||"
make O=out $DEFCONFIG2
if [ $DEF_REG = 1 ]
then
cp .config arch/arm64/configs/$DEFCONFIG2
git add arch/arm64/configs/$DEFCONFIG2
git commit -m "$DEFCONFIG2: Regenerate
This is an auto-generated commit"
fi
BUILD_START=$(date +"%s")
if [ $COMPILER = "clang" ]
then
make -j"$PROCS" O=out \
CROSS_COMPILE=aarch64-linux-gnu- \
CROSS_COMPILE_ARM32=arm-linux-gnueabi- \
CC=clang \
AR=llvm-ar \
OBJDUMP=llvm-objdump \
STRIP=llvm-strip
fi
if [ $COMPILER = "gcc" ]
then
if [[ "$CI_BRANCH" == "sdm660-hmp-rebase" ]]; then
export CROSS_COMPILE_ARM32=$GCC32_DIR/bin/arm-eabi-
make -j"$PROCS" O=out CROSS_COMPILE=aarch64-linux-gnu-
else
export CROSS_COMPILE_ARM32=$GCC32_DIR/bin/arm-eabi-
make -j"$PROCS" O=out CROSS_COMPILE=aarch64-elf-
fi
fi
BUILD_END=$(date +"%s")
DIFF=$((BUILD_END - BUILD_START))
if [ -f "$KERNEL_DIR"/out/arch/arm64/boot/Image.gz-dtb ]
then
msg "|| Kernel successfully compiled ||"
elif ! [ -f $KERNEL_DIR/out/arch/arm64/boot/Image.gz-dtb ]
then
echo -e "Kernel compilation failed, See buildlog to fix errors"
tg_post_msg "<b>Build failed to compile after $((DIFF / 60)) minute(s) and $((DIFF % 60)) seconds</b>" "$CHATID"
exit 1
fi
if [ $BUILD_DTBO = 1 ]
then
msg "|| Building DTBO ||"
tg_post_msg "<code>Building DTBO..</code>" "$CHATID"
python2 "$KERNEL_DIR/scripts/ufdt/libufdt/utils/src/mkdtboimg.py" \
create "$KERNEL_DIR/out/arch/arm64/boot/dtbo.img" --page_size=4096 "$KERNEL_DIR/out/arch/arm64/boot/dts/qcom/sm6150-idp-overlay.dtbo"
fi
}
##--------------------------------------------------------------##
# Set naming to new cam for zip file
setversioning4() {
if [[ "$CI_BRANCH" == "sdm660-eas-test" ]]; then
KERNELNAME4="$KERNEL-$DEVICE2-$KERNELTYPE-$TYPE-newcam-$DATE"
export KERNELTYPE KERNELNAME4
export ZIPNAME4="$KERNELNAME4.zip"
elif [[ "$CI_BRANCH" == "sdm660-hmp-rebase" ]]; then
KERNELNAME4="$KERNEL-$DEVICE2-$KERNELTYPE1-$TYPE-newcam-$DATE"
export KERNELTYPE KERNELNAME4
export ZIPNAME4="$KERNELNAME4.zip"
else
KERNELNAME4="$KERNEL-$DEVICE2-$KERNELTYPE-$TYPE-newcam-$DATE"
export KERNELTYPE KERNELNAME4
export ZIPNAME4="$KERNELNAME4.zip"
fi
}
##--------------------------------------------------------------##
gen_zip4() {
msg "|| Zipping into a flashable zip ||"
mv "$KERNEL_DIR"/out/arch/arm64/boot/Image.gz-dtb AnyKernel3/Image.gz-dtb
if [ $BUILD_DTBO = 1 ]
then
mv "$KERNEL_DIR"/out/arch/arm64/boot/dtbo.img AnyKernel3/dtbo.img
fi
cd AnyKernel3 || exit
zip -r9 "$ZIPNAME4" * -x .git README.md
# Prepare a final zip variable
ZIP_FINAL="$ZIPNAME4"
if [ "$PTTG" = 1 ]
then
tg_post_build "$ZIP_FINAL" "$CHATID" "Build took : $((DIFF / 60)) minute(s) and $((DIFF % 60)) second(s)"
fi
cd ..
}
##--------------------------------------------------------------##
# Ship China firmware builds
setoldcam() {
# Switch to old cam from defconfig
sed -i 's/CONFIG_MACH_XIAOMI_NEW_CAMERA=y/CONFIG_MACH_XIAOMI_NEW_CAMERA=n/g' arch/arm64/configs/$DEFCONFIG2
msg "|| Oldcam for MI 6X/A2 ready ||"
}
# Set naming to old cam for zip file
setversioning5() {
if [[ "$CI_BRANCH" == "sdm660-eas-test" ]]; then
KERNELNAME5="$KERNEL-$DEVICE2-$KERNELTYPE-$TYPE-oldcam-$DATE"
export KERNELTYPE KERNELNAME5
export ZIPNAME5="$KERNELNAME5.zip"
elif [[ "$CI_BRANCH" == "sdm660-hmp-rebase" ]]; then
KERNELNAME5="$KERNEL-$DEVICE2-$KERNELTYPE1-$TYPE-oldcam-$DATE"
export KERNELTYPE KERNELNAME5
export ZIPNAME5="$KERNELNAME5.zip"
else
KERNELNAME5="$KERNEL-$DEVICE2-$KERNELTYPE-$TYPE-oldcam-$DATE"
export KERNELTYPE KERNELNAME5
export ZIPNAME5="$KERNELNAME5.zip"
fi
}
gen_zip5() {
msg "|| Zipping into a flashable zip ||"
mv "$KERNEL_DIR"/out/arch/arm64/boot/Image.gz-dtb AnyKernel3/Image.gz-dtb
if [ $BUILD_DTBO = 1 ]
then
mv "$KERNEL_DIR"/out/arch/arm64/boot/dtbo.img AnyKernel3/dtbo.img
fi
cd AnyKernel3 || exit
zip -r9 "$ZIPNAME5" * -x .git README.md
## Prepare a final zip variable
ZIP_FINAL="$ZIPNAME5"
if [ "$PTTG" = 1 ]
then
tg_post_build "$ZIP_FINAL" "$CHATID" "Build took : $((DIFF / 60)) minute(s) and $((DIFF % 60)) second(s)"
fi
cd ..
}
##--------------------------------------------------------------##
if [[ "$CI_BRANCH" == "sdm660-eas-test" ]]; then
setversioning4
cloneak2
exports
build_kernel2
gen_zip4
setversioning5
setoldcam
cloneak2
build_kernel2
gen_zip5
fi
if [ $LOG_DEBUG = "1" ]
then
tg_post_build "error.log" "$CHATID" "Debug Mode Logs"
fi
##------------------------------------------------------------------##