-
Notifications
You must be signed in to change notification settings - Fork 8
/
build_kernel.sh
executable file
·694 lines (658 loc) · 22.9 KB
/
build_kernel.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
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
#! /bin/bash
set -e
# Export build variables
export KBUILD_BUILD_USER="localhost"
export KBUILD_BUILD_HOST="localhost"
export PLATFORM_VERSION=11
export ANDROID_MAJOR_VERSION=r
SRCTREE=$(pwd)
USER=$(whoami)
# Lets make the Terminal a bit more Colorful
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
NC='\033[0m'
# Define Kernel Version
VER="v3.5"
# Compiler
TOOLCHAIN="$SRCTREE/toolchain/bin"
LLVM_DIS_ARGS="llvm-dis AR=llvm-ar AS=llvm-as NM=llvm-nm LD=ld.lld OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump STRIP=llvm-strip"
TRIPLE="aarch64-linux-gnu-"
CROSS="$SRCTREE/toolchain/bin/aarch64-linux-gnu-"
CROSS_ARM32="$SRCTREE/toolchain/bin/arm-linux-gnueabi-"
LD="$SRCTREE/toolchain/lib"
# OS
DISTRO=$(lsb_release -d | awk -F"\t" '{print $2}')
GLIBC_VERSION=$(ldd --version | grep 'ldd (' | awk '{print $NF}')
# Simplify Pathes
PERMISSIVE="$SRCTREE/kernel_zip/aroma/kernel/permissive"
ENFORCING="$SRCTREE/kernel_zip/aroma/kernel/enforce"
ANYKERNEL="$SRCTREE/kernel_zip/anykernel"
# Telegram (Please Configure it or Type on End: No."
CHAT_ID=""
BOT_TOKEN=""
TELEGRAM_API="https://api.telegram.org/bot${BOT_TOKEN}"
# Initialize
init() {
if [ -z "$CHAT_ID" ] || [ -z "$BOT_TOKEN" ]; then
clear
echo -e "${YELLOW}Warning: Your BOT Token or Chat ID is Empty!${NC}\n"
sleep 2
fi
if [ -d $SRCTREE/kernel_zip/aroma/kernel/enforce ] || [ -d $SRCTREE/kernel_zip/aroma/kernel/permissive ]; then
sleep 1
else
mkdir $SRCTREE/kernel_zip/aroma/kernel/enforce
mkdir $SRCTREE/kernel_zip/aroma/kernel/permissive
sleep 1
fi
git restore $SRCTREE/kernel_zip/aroma/META-INF/com/google/android/aroma-config
clear
find "$ANYKERNEL" -type f -name "*.zip" -exec rm {} +
echo -e "${YELLOW}Do you want to make a Clean Build? [yes|no]${NC}\n"
echo -e "${GREEN}Hint: Type Yes or No in this Field below.${NC}\n"
printf "${USER}:~${SRCTREE}$ "
read -r ans
ans=$(echo "${ans}" | tr '[:lower:]' '[:upper:]')
while [ "$ans" != "YES" ] && [ "$ans" != "NO" ]; do
printf "Please answer 'yes' or 'no':'\\n"
printf "${USER}:~${SRCTREE}$ "
read -r ans
ans=$(echo "${ans}" | tr '[:lower:]' '[:upper:]')
done
if [ "$ans" = "YES" ]; then
clear
echo -e "${YELLOW}Cleaning up ...${NC}\n"
rm -rf out out2 && make clean && make mrproper
toolchain
elif [ "$ans" = "NO" ]; then
toolchain
fi
}
glibc_patch() {
# Patch GLIBC
WORK_DIR=$HOME/toolchains/neutron-clang
echo -e "${YELLOW}Downloading patchelf binary from NixOS repos...${NC}\n"
mkdir -p "${HOME}"/.neutron-tc/patchelf-temp
if [ -f "patchelf-0.18.0-x86_64.tar.gz" ]; then
echo -e "${YELLOW}File exists ... Skip!${NC}\n"
else
wget -qO- https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0-x86_64.tar.gz | bsdtar -C "${HOME}"/.neutron-tc/patchelf-temp -xf -
fi
mv "${HOME}"/.neutron-tc/patchelf-temp/bin/patchelf "${HOME}"/.neutron-tc/
rm -rf "${HOME}"/.neutron-tc/patchelf-temp
mkdir "${HOME}"/.neutron-tc/glibc &>/dev/null || (rm -rf "${HOME}"/.neutron-tc/glibc && mkdir "${HOME}"/.neutron-tc/glibc)
echo -e "${YELLOW}Downloading latest libs from ArchLinux repos...${NC}\n"
wget -qO- https://archlinux.org/packages/core/x86_64/glibc/download | bsdtar -C "${HOME}"/.neutron-tc/glibc -xf -
wget -qO- https://archlinux.org/packages/core/x86_64/lib32-glibc/download | bsdtar -C "${HOME}"/.neutron-tc/glibc -xf -
wget -qO- https://archlinux.org/packages/core/x86_64/gcc-libs/download | bsdtar -C "${HOME}"/.neutron-tc/glibc -xf -
wget -qO- https://archlinux.org/packages/core/x86_64/lib32-gcc-libs/download | bsdtar -C "${HOME}"/.neutron-tc/glibc -xf -
ln -svf "${HOME}"/.neutron-tc/glibc/usr/lib "${HOME}"/.neutron-tc/glibc/usr/lib64
echo -e "${BLUE}Patching libs...${NC}\n"
for bin in $(find "${HOME}"/.neutron-tc/glibc -type f -exec file {} \; | grep 'ELF .* interpreter' | awk '{print $1}'); do
bin="${bin::-1}"
echo "Patching: ${bin}"
"${HOME}"/.neutron-tc/patchelf --set-rpath "${HOME}"/.neutron-tc/glibc/usr/lib --force-rpath --set-interpreter "${HOME}"/.neutron-tc/glibc/usr/lib/ld-linux-x86-64.so.2 "${bin}"
done
echo -e "${BLUE}Patching Toolchain...${NC}\n"
for bin in $(find "${WORK_DIR}" -type f -exec file {} \; | grep 'ELF .* interpreter' | awk '{print $1}'); do
bin="${bin::-1}"
echo "Patching: ${bin}"
"${HOME}"/.neutron-tc/patchelf --add-rpath "${HOME}"/.neutron-tc/glibc/usr/lib --force-rpath --set-interpreter "${HOME}"/.neutron-tc/glibc/usr/lib/ld-linux-x86-64.so.2 "${bin}"
done
echo -e "${YELLOW}Cleaning...${NC}\n"
rm -rf "${HOME}"/.neutron-tc/patchelf
echo -e "${GREEN}Done${NC}\n"
}
# Let's do a Toolchain check
toolchain() {
clear
if [ -d "$TOOLCHAIN" ]; then
clear
echo -e "${GREEN}Toolchain found. Skip!${NC}\n"
sleep 2
clear
select_device
else
echo -e "${RED}No Toolchain found!${NC}\n"
echo -e "${YELLOW}Warning: Toolchains need different Operating Systems!${NC}\n"
echo -e "${RED}Warning for Neutron Toolchain! Before type 'yes', make sure that u have 'libarchive-tools' installed else it will fail to patch your GLIBC!${NC}\n"
echo -e "${YELLOW}Check below if your System are compatible before u Continue.${NC}\n"
echo -e "${GREEN}Your current OS is: $DISTRO - GLIBC: $GLIBC_VERSION${NC}\n"
if [[ "$DISTRO" == "Ubuntu 24.04 LTS" || "$DISTRO" == "Ubuntu 23.10" || "$DISTRO" == "Ubuntu 22.04.4 LTS" ]]; then
echo -e "${YELLOW}➜ Neutron needs ${GREEN}Ubuntu 24.04 LTS | Ubuntu 23.10 | Ubuntu 22.04.4 LTS [GLIBC2.38]${NC}"
echo -e "${YELLOW}Vortex needs ${RED}Ubuntu 21.10 [GLIBC2.34]${NC}"
echo -e "${YELLOW}Proton needs ${RED}Ubuntu 20.04 [GLIBC2.31]${NC}"
elif [[ "$DISTRO" == "Ubuntu 21.10" ]]; then
echo -e "${YELLOW}Neutron needs ${RED}Ubuntu 23.10 [GLIBC2.38]${NC}"
echo -e "${YELLOW}➜ Vortex needs ${GREEN}Ubuntu 21.10 [GLIBC2.34]${NC}"
echo -e "${YELLOW}Proton needs ${RED}Ubuntu 20.04 [GLIBC2.31]${NC}"
elif [[ "$DISTRO" == "Ubuntu 20.04.6 LTS" ]]; then
echo -e "${YELLOW}Neutron needs ${RED}Ubuntu 23.10 [GLIBC2.38]${NC}"
echo -e "${YELLOW}Vortex needs ${RED}Ubuntu 21.10 [GLIBC2.34]${NC}"
echo -e "${YELLOW}➜ Proton needs ${GREEN}Ubuntu 20.04.6 LTS [GLIBC2.31]${NC}"
fi
echo ""
echo -e "${GREEN}Proceed to Download the Toolchain?${NC}\n"
echo -e "${GREEN}Hint: Type Yes or No in this Field below.${NC}\n"
printf "${USER}:~${SRCTREE}$ "
read -r ans
ans=$(echo "${ans}" | tr '[:lower:]' '[:upper:]')
while [ "$ans" != "YES" ] && [ "$ans" != "NO" ]; do
printf "Please answer 'yes' or 'no':'\\n"
printf "${USER}:~${SRCTREE}$ "
read -r ans
ans=$(echo "${ans}" | tr '[:lower:]' '[:upper:]')
done
if [ "$ans" = "YES" ]; then
case "$DISTRO" in
"Ubuntu 24.04 LTS" | "Ubuntu 23.10" | "Ubuntu 23.04" | "Ubuntu 22.04.4 LTS")
clear
mkdir -p "$HOME/toolchains/neutron-clang"
cd "$HOME/toolchains/neutron-clang" || exit
echo -e "${RED}Downloading Neutron-Clang 18 ...${NC}\n"
if [ -f "neutron-clang-05012024.tar.zst" ]; then
echo -e "${YELLOW}Skipping Downloading Toolchain ... already exists!${NC}\n"
else
wget https://github.com/Neutron-Toolchains/clang-build-catalogue/releases/download/05012024/neutron-clang-05012024.tar.zst -q --show-progress
fi
echo -e "${RED}Extracting tar...${NC}\n"
tar -I zstd -xf "neutron-clang-05012024.tar.zst"
glibc_patch
cd "$SRCTREE" || exit
cp -r "$HOME/toolchains/neutron-clang" toolchain
clear
select_device
;;
"Ubuntu 21.10")
echo -e "${YELLOW}Downloading Vortex-Clang Toolchain ...${NC}\n"
git clone --depth=1 https://github.com/vijaymalav564/vortex-clang toolchain
clear
select_device
;;
"Ubuntu 20.04.6 LTS")
echo -e "${YELLOW}Downloading Proton-Clang Toolchain ...${NC}\n"
git clone --depth=1 https://github.com/kdrag0n/proton-clang toolchain
clear
select_device
;;
*)
echo "Unsupported DISTRO: $DISTRO"
;;
esac
elif [[ "$ans" == "NO" ]]; then
clear
case "$DISTRO" in
"Ubuntu 24.04 LTS" | "Ubuntu 23.10" | "Ubuntu 23.04" | "Ubuntu 22.04.4 LTS" | "Ubuntu 21.10" | "Ubuntu 20.04.6 LTS")
echo -e "${YELLOW}Skipping Toolchain download ...${NC}\n"
;;
*)
echo "Unsupported DISTRO: $DISTRO"
;;
esac
else
echo "Invalid answer: $ans"
fi
fi
}
select_device() {
echo -e "${GREEN}Please select your Device${NC}\n"
select devices in "Galaxy A40 (a40)" "Galaxy A30s (a30s)" "Galaxy A30 (a30)" "Galaxy A8 2018 (jackpotlte)" "Exit"; do
case "$devices" in
"Galaxy A40 (a40)")
clear
echo -e "${GREEN}Please Select your Compilation Type (OS).${NC}\n"
select os in "Build for ALL OS" "Build only for AOSP" "Build only for OneUI" "Exit"; do
case "$os" in
"Build for ALL OS")
codename="a40"
echo -e "${BLUE}"
build_all
echo -e "${NC}"
break
;;
"Build only for AOSP")
codename="a40"
echo -e "${BLUE}"
set_selinux_permissive
builder_aosp
copy_aosp
pack_aosp
echo -e "${NC}"
break
;;
"Build only for OneUI")
codename="a40"
echo -e "${BLUE}"
set_selinux_permissive
builder_oneui
copy_oneui
pack_oneui
echo -e "${NC}"
break
;;
"Exit")
clear
echo -e "${RED}Exiting ...${NC}\n"
exit
;;
*)
echo -e "${RED}Invalid option. Please select again.${NC}\n"
;;
esac
done
;;
"Galaxy A30s (a30s)")
clear
echo -e "${GREEN}Please Select your Compilation Type (OS).${NC}\n"
select os in "Build for ALL OS" "Build only for AOSP" "Build only for OneUI" "Exit"; do
case "$os" in
"Build for ALL OS")
codename="a30s"
echo -e "${BLUE}"
build_all
echo -e "${NC}"
break
;;
"Build only for AOSP")
codename="a30s"
echo -e "${BLUE}"
set_selinux_permissive
builder_aosp
copy_aosp
pack_aosp
echo -e "${NC}"
break
;;
"Build only for OneUI")
codename="a30s"
echo -e "${BLUE}"
set_selinux_permissive
builder_oneui
copy_oneui
pack_oneui
echo -e "${NC}"
break
;;
"Exit")
clear
echo -e "${RED}Exiting ...${NC}\n"
exit
;;
*)
echo -e "${RED}Invalid option. Please select again.${NC}\n"
;;
esac
done
;;
"Galaxy A30 (a30)")
clear
echo -e "${GREEN}Please Select your Compilation Type (OS).${NC}\n"
select os in "Build for ALL OS" "Build only for AOSP" "Build only for OneUI" "Exit"; do
case "$os" in
"Build for ALL OS")
codename="a30"
echo -e "${BLUE}"
build_all
echo -e "${NC}"
break
;;
"Build only for AOSP")
codename="a30"
echo -e "${BLUE}"
set_selinux_permissive
builder_aosp
copy_aosp
pack_aosp
echo -e "${NC}"
break
;;
"Build only for OneUI")
codename="a30"
echo -e "${BLUE}"
set_selinux_permissive
builder_oneui
copy_oneui
pack_oneui
echo -e "${NC}"
break
;;
"Exit")
clear
echo -e "${RED}Exiting ...${NC}\n"
exit
;;
*)
echo -e "${RED}Invalid option. Please select again.${NC}\n"
;;
esac
done
;;
"Galaxy A8 2018 (jackpotlte)")
clear
echo -e "${RED}Please Select your Compilation Type (OS).${NC}\n"
select os in "Build for ALL OS" "Build only for AOSP" "Build only for OneUI" "Exit"; do
case "$os" in
"Build for ALL OS")
codename="jackpotlte"
echo -e "${BLUE}"
build_all
echo -e "${NC}"
break
;;
"Build only for AOSP")
codename="jackpotlte"
echo -e "${BLUE}"
set_selinux_permissive
builder_aosp
copy_aosp
pack_aosp
echo -e "${NC}"
break
;;
"Build only for OneUI")
codename="jackpotlte"
echo -e "${BLUE}"
set_selinux_permissive
builder_oneui
copy_oneui
pack_oneui
echo -e "${NC}"
break
;;
"Exit")
clear
echo -e "${RED}Exiting ...${NC}\n"
exit
;;
*)
echo -e "${RED}Invalid option. Please select again.${NC}\n"
;;
esac
done
;;
"Exit")
clear
echo -e "${RED}Exiting ...${NC}\n"
exit
;;
*)
echo -e "${RED}Invalid option. Please select again.${NC}\n"
;;
esac
done
}
compile_text() {
echo -e "${YELLOW}Note that u see only a blinking / freezed Cursor but the script is running.\n"
echo -e "Troubleshoot: if u feel that the script takes to long, press CTRL-C and check on Top the RED line for the log file in ${SRCTREE}\n"
echo -n -e "Compile Kernel, please wait ... "
echo -n -e "\033[?25h"
}
build_text() {
echo -e "${RED}Debug (Permissive|Enforcing)${GREEN} ZIP created: $ZIP_FILENAME and saved in $SRCTREE/kernel_zip/${NC}\n"
echo -e "${GREEN}***************************************************"
echo " Kernel: $VERSION.$PATCHLEVEL.$SUBLEVEL"
echo " Build Date: $(date +'%Y-%m-%d %H:%M %Z')"
echo -e "***************************************************${NC}\n"
}
build_info() {
if ! grep -q "# Auto-Generated by" "version"; then
sed -i '1i# Auto-Generated by '"$0"'!' "version"
fi
# Auto Generate Debug/Single ZIP Build date/Version
sed -i "s/Kernel: .*$/Kernel: $VERSION.$PATCHLEVEL.$SUBLEVEL/g" "version"
sed -i "s/Build Date: .*/Build Date: $(date +'%Y-%m-%d %H:%M %Z')/g" "version"
}
makefile_info() {
# Extract version information from Makefile
VERSION=$(awk '/^VERSION/ {print $3}' Makefile)
PATCHLEVEL=$(awk '/^PATCHLEVEL/ {print $3}' Makefile)
SUBLEVEL=$(awk '/^SUBLEVEL/ {print $3}' Makefile)
}
set_selinux_permissive() {
sed -i 's/# CONFIG_SECURITY_SELINUX_SETENFORCE_OVERRIDE is not set/CONFIG_SECURITY_SELINUX_SETENFORCE_OVERRIDE=y/g' arch/arm64/configs/exynos7885-${codename}_defconfig
}
set_selinux_enforcing() {
sed -i 's/CONFIG_SECURITY_SELINUX_SETENFORCE_OVERRIDE=y/# CONFIG_SECURITY_SELINUX_SETENFORCE_OVERRIDE is not set/g' arch/arm64/configs/exynos7885-${codename}_defconfig
}
make_common() {
trap "echo -e \"${RED}Build Error!${NC}\n\"" EXIT
PATH=$TOOLCHAIN:$PATH \
make O=out$1 -j$(nproc --all) \
ARCH=arm64 \
LLVM_DIS="$LLVM_DIS_ARGS" \
LLVM=1 \
LLVM_IAS=1 \
CC=clang \
LD_LIBRARY_PATH="$LD:$LD_LIBRARY_PATH" \
CLANG_TRIPLE=$TRIPLE \
CROSS_COMPILE="$CROSS" \
CROSS_COMPILE_ARM32="$CROSS_ARM32" &>compile$1.log
trap "" EXIT
}
make_out() {
make_common
}
make_out2() {
make_common 2
}
builder_aosp() {
make O=out ARCH=arm64 exynos7885-${codename}_defconfig aosp.config
clear
echo -e "${RED}Build started for Permissive AOSP Kernel > compile.log ...${NC}\n"
compile_text
make_out
set_selinux_enforcing
make O=out2 ARCH=arm64 exynos7885-${codename}_defconfig aosp.config
clear
echo -e "${RED}Build started for Enforcing AOSP Kernel > compile2.log ...${NC}\n"
compile_text
make_out2
echo -e "${NC}"
clear
echo -e "${YELLOW}Creating ZIP for $codename ...${NC}\n"
}
builder_oneui() {
make O=out ARCH=arm64 exynos7885-${codename}_defconfig
clear
echo -e "${RED}Build started for Permissive OneUI Kernel > compile.log ...${NC}\n"
compile_text
make_out
set_selinux_enforcing
make O=out2 ARCH=arm64 exynos7885-${codename}_defconfig
clear
echo -e "${RED}Build started for Enforcing OneUI Kernel > compile2.log ...${NC}\n"
compile_text
make_out2
echo -e "${NC}"
clear
echo -e "${YELLOW}Creating ZIP for $codename ...${NC}\n"
}
copy_oneui() {
cp out/arch/arm64/boot/Image "$ANYKERNEL/oneui/permissive/"
cp out2/arch/arm64/boot/Image "$ANYKERNEL/oneui/enforce/"
if [[ "$codename" = "a40" || "$codename" == "a30s" ]]; then
cp $ANYKERNEL/prebuilt/${codename}/dtbo.img "$ANYKERNEL/oneui/enforce/"
cp $ANYKERNEL/prebuilt/${codename}/dtbo.img "$ANYKERNEL/oneui/permissive/"
cp $ANYKERNEL/prebuilt/${codename}/dtb.img "$ANYKERNEL/oneui/enforce/dtb.img"
cp $ANYKERNEL/prebuilt/${codename}/dtb.img "$ANYKERNEL/oneui/permissive/dtb.img"
elif [ "$codename" = "a30" ]; then
cp $ANYKERNEL/prebuilt/a30/dtbo.img "$ANYKERNEL/oneui/enforce/"
cp $ANYKERNEL/prebuilt/a30/dtbo.img "$ANYKERNEL/oneui/permissive/"
cp $ANYKERNEL/prebuilt/a30/dtb_enf.img "$ANYKERNEL/oneui/enforce/dtb.img"
cp $ANYKERNEL/prebuilt/a30/dtb_perm.img "$ANYKERNEL/oneui/permissive/dtb.img"
elif [ "$codename" = "jackpotlte" ]; then
cp out2/arch/arm64/boot/dtb.img "$ANYKERNEL/oneui/enforce/"
cp out/arch/arm64/boot/dtb.img "$ANYKERNEL/oneui/permissive/"
fi
}
copy_aosp() {
cp out/arch/arm64/boot/Image "$ANYKERNEL/aosp/permissive/"
cp out2/arch/arm64/boot/Image "$ANYKERNEL/aosp/enforce/"
if [[ "$codename" = "a40" || "$codename" == "a30s" ]]; then
cp $ANYKERNEL/prebuilt/${codename}/dtbo.img "$ANYKERNEL/aosp/enforce/"
cp $ANYKERNEL/prebuilt/${codename}/dtbo.img "$ANYKERNEL/aosp/permissive/"
cp $ANYKERNEL/prebuilt/${codename}/dtb.img "$ANYKERNEL/aosp/enforce/dtb.img"
cp $ANYKERNEL/prebuilt/${codename}/dtb.img "$ANYKERNEL/aosp/permissive/dtb.img"
elif [ "$codename" = "a30" ]; then
cp $ANYKERNEL/prebuilt/a30/dtbo.img "$ANYKERNEL/aosp/enforce/"
cp $ANYKERNEL/prebuilt/a30/dtbo.img "$ANYKERNEL/aosp/permissive/"
cp $ANYKERNEL/prebuilt/a30/dtb_enf.img "$ANYKERNEL/aosp/enforce/dtb.img"
cp $ANYKERNEL/prebuilt/a30/dtb_perm.img "$ANYKERNEL/aosp/permissive/dtb.img"
elif [ "$codename" = "jackpotlte" ]; then
cp out2/arch/arm64/boot/dtb.img "$ANYKERNEL/aosp/enforce/"
cp out/arch/arm64/boot/dtb.img "$ANYKERNEL/aosp/permissive/"
fi
}
build_all() {
if [[ "$codename" == "a40" || "$codename" == "a30s" || "$codename" == "a30" ]]; then
set_selinux_permissive
builder_oneui
copy_oneui
create_zip_permissive_oneui META-INF tools anykernel.sh Image dtb.img dtbo.img version
create_zip_enforcing_oneui META-INF tools anykernel.sh Image dtb.img dtbo.img version
cd "$SRCTREE" || exit
set_selinux_permissive
builder_aosp
copy_aosp
create_zip_permissive_aosp META-INF tools anykernel.sh Image dtb.img dtbo.img version
create_zip_enforcing_aosp META-INF tools anykernel.sh Image dtb.img dtbo.img version
aroma
elif [ "$codename" = "jackpotlte" ]; then
set_selinux_permissive
builder_oneui
copy_oneui
create_zip_permissive_oneui META-INF tools anykernel.sh Image dtb.img version
create_zip_enforcing_oneui META-INF tools anykernel.sh Image dtb.img version
cd "$SRCTREE" || exit
set_selinux_permissive
builder_aosp
copy_aosp
create_zip_permissive_aosp META-INF tools anykernel.sh Image dtb.img version
create_zip_enforcing_aosp META-INF tools anykernel.sh Image dtb.img version
aroma
fi
}
create_zip_permissive_aosp() {
cd "$SRCTREE" || exit
makefile_info
cd "$ANYKERNEL/aosp/permissive" || exit
build_info
ZIP_FILENAME="Nameless_${codename}_${VER}-debug-permissive-aosp.zip"
zip -r9 "$ZIP_FILENAME" "$@"
}
create_zip_enforcing_aosp() {
cd "$SRCTREE" || exit
makefile_info
cd "$ANYKERNEL/aosp/enforce" || exit
build_info
ZIP_FILENAME="Nameless_${codename}_${VER}-debug-enforcing-aosp.zip"
zip -r9 "$ZIP_FILENAME" "$@"
}
create_zip_permissive_oneui() {
cd "$SRCTREE" || exit
makefile_info
cd "$ANYKERNEL/oneui/permissive" || exit
build_info
ZIP_FILENAME="Nameless_${codename}_${VER}-debug-permissive-oneui.zip"
zip -r9 "$ZIP_FILENAME" "$@"
}
create_zip_enforcing_oneui() {
cd "$SRCTREE" || exit
makefile_info
cd "$ANYKERNEL/oneui/enforce" || exit
build_info
ZIP_FILENAME="Nameless_${codename}_${VER}-debug-enforcing-oneui.zip"
zip -r9 "$ZIP_FILENAME" "$@"
}
create_aroma() {
cd "$SRCTREE/kernel_zip/aroma" || exit
cp "$ANYKERNEL/oneui/permissive/Nameless_${codename}_${VER}-debug-permissive-oneui.zip" "$PERMISSIVE/oneui.zip"
cp "$ANYKERNEL/oneui/enforce/Nameless_${codename}_${VER}-debug-enforcing-oneui.zip" "$ENFORCING/oneui.zip"
cp "$ANYKERNEL/aosp/permissive/Nameless_${codename}_${VER}-debug-permissive-aosp.zip" "$PERMISSIVE/aosp.zip"
cp "$ANYKERNEL/aosp/enforce/Nameless_${codename}_${VER}-debug-enforcing-aosp.zip" "$ENFORCING/aosp.zip"
AROMA_FILENAME="Nameless_${codename}_${VER}-AROMA.zip"
zip -r9 "$AROMA_FILENAME" "$@"
}
aroma() {
# create and pack AROMA
cd "$ANYKERNEL" || exit
if [[ "$codename" == "a40" || "$codename" == "a30s" || "$codename" == "a30" ]]; then
sed -i "s/sysprop/${codename}/g" "$SRCTREE/kernel_zip/aroma/META-INF/com/google/android/aroma-config"
create_aroma META-INF tools kernel
elif [ "$codename" = "jackpotlte" ]; then
sed -i 's/sysprop/A8 2018/g' "$SRCTREE/kernel_zip/aroma/META-INF/com/google/android/aroma-config"
create_aroma META-INF tools kernel
fi
cp "$SRCTREE/kernel_zip/aroma/$AROMA_FILENAME" "$SRCTREE/kernel_zip/"
cd "$SRCTREE" || exit
clear
echo -e "${GREEN}AROMA Installer created: $AROMA_FILENAME and saved in $SRCTREE/kernel_zip/${NC}\n"
build_text
tg_upload
}
pack_aosp() {
# create and pack ZIP
cd "$ANYKERNEL" || exit
if [[ "$codename" == "a40" || "$codename" == "a30s" || "$codename" == "a30" ]]; then
create_zip_enforcing_aosp META-INF tools anykernel.sh Image dtb.img dtbo.img version
create_zip_permissive_aosp META-INF tools anykernel.sh Image dtb.img dtbo.img version
elif [ "$codename" = "jackpotlte" ]; then
create_zip_enforcing_aosp META-INF tools anykernel.sh Image dtb.img version
create_zip_permissive_aosp META-INF tools anykernel.sh Image dtb.img version
fi
while [ ! -f "$ANYKERNEL/aosp/permissive/Nameless_${codename}_${VER}-debug-permissive-aosp.zip" ] || [ ! -f "$ANYKERNEL/aosp/enforce/Nameless_${codename}_${VER}-debug-enforcing-aosp.zip" ]; do
sleep 1
done
find "$ANYKERNEL/aosp" -type f -name "*.zip" -exec cp -t "$SRCTREE/kernel_zip" {} +
cd "$SRCTREE" || exit
clear
build_text
tg_upload
}
pack_oneui() {
# create and pack ZIP
cd "$ANYKERNEL" || exit
if [[ "$codename" == "a40" || "$codename" == "a30s" || "$codename" == "a30" ]]; then
create_zip_enforcing_oneui META-INF tools anykernel.sh Image dtb.img dtbo.img version
create_zip_permissive_oneui META-INF tools anykernel.sh Image dtb.img dtbo.img version
elif [ "$codename" = "jackpotlte" ]; then
create_zip_enforcing_oneui META-INF tools anykernel.sh Image dtb.img version
create_zip_permissive_oneui META-INF tools anykernel.sh Image dtb.img version
fi
while [ ! -f "$ANYKERNEL/oneui/permissive/Nameless_${codename}_${VER}-debug-permissive-oneui.zip" ] || [ ! -f "$ANYKERNEL/oneui/enforce/Nameless_${codename}_${VER}-debug-enforcing-oneui.zip" ]; do
sleep 1
done
find "$ANYKERNEL/oneui" -type f -name "*.zip" -exec cp -t "$SRCTREE/kernel_zip" {} +
cd "$SRCTREE" || exit
clear
build_text
tg_upload
}
tg_upload() {
echo -e "${GREEN}Upload to Telegram?${NC}\n"
echo -e "${GREEN}Hint: Type Yes or No in this Field below.${NC}\n"
printf "${USER}:~${SRCTREE}$ "
read -r ans
ans=$(echo "${ans}" | tr '[:lower:]' '[:upper:]')
while [ "$ans" != "YES" ] && [ "$ans" != "NO" ]; do
printf "Please answer 'yes' or 'no':'\\n"
printf "${USER}:~${SRCTREE}$ "
read -r ans
ans=$(echo "${ans}" | tr '[:lower:]' '[:upper:]')
done
if [ "$ans" = "YES" ]; then
echo -e "${GREEN}Uploading $SRCTREE/kernel_zip/$ZIP_FILENAME to Telegram ...${NC}"
file_size_mb=$(stat -c "%s" "$SRCTREE/kernel_zip/${ZIP_FILENAME}" | awk '{printf "%.2f", $1 / (1024 * 1024)}')
curl -s -X POST "${TELEGRAM_API}/sendMessage" -d "chat_id=${CHAT_ID}" -d "text=Uploading: ${ZIP_FILENAME}%0ASize: ${file_size_mb}MB%0ABuild Date: $(date +'%Y-%m-%d %H:%M:%S')"
curl -s -F chat_id="${CHAT_ID}" -F document=@"$SRCTREE/kernel_zip/${ZIP_FILENAME}" "${TELEGRAM_API}/sendDocument"
clear
elif [ "$ans" = "NO" ]; then
clear
echo -e "${RED}Telegram Upload skipped. Exiting ...${NC}\n"
echo -e "${GREEN}ZIP Output: $SRCTREE/kernel_zip/${ZIP_FILENAME}${NC}\n"
exit
fi
}
init