-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
Β·591 lines (503 loc) Β· 21.6 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
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
#!/usr/bin/env bash
# Android Kernel Build Script
# Setup colour for the script
blue='\033[0;34m'
yellow='\033[0;33m'
white='\033[0m'
red='\033[0;31m'
green='\e[0;32m'
magenta='\033[1;35m'
lgreen='\e[92m'
cyan='\033[0;36m'
purple='\033[0;35m'
pink='\033[38;5;206m'
orange_yellow='\033[38;5;214m'
greenish_yellow='\033[38;5;190m'
blink_red='\033[05;31m'
blink_green='\033[1;32;5m'
blink_yellow='\033[1;33;5m'
reset='\e[0m'
##------------------------------------------------------##
# Function to show an informational message
msg() {
echo -e "\e[1;32m$*\e[0m"
}
err() {
echo -e "\e[1;41m$*\e[0m"
exit 1
}
##------------------------------------------------------##
# Timeout
function countdown() {
for ((i = $1; i > 0; i--)); do
echo "Countdown: $i"
sleep 1
done
}
##------------------------------------------------------##
# Get Linux distro and version
if [ -f /etc/os-release ]; then
. /etc/os-release
OS=$NAME
VER=$VERSION_ID
else
OS=$(uname -s)
VER=$(uname -r)
fi
echo $OS $VER
##------------------------------------------------------##
# Check if is Legendary!
if [[ "$OS" == *"Tumbleweed"* ]]; then
echo -e "${magenta} << You are LEGENDARY! >> ${white}"
else
echo -e "${lgreen} << May the force be with you! >> ${reset}"
fi
##------------------------------------------------------##
# Check if a good linux is being used
if [[ "$OS" == *"SUSE"* ]] || [[ "$OS" == *"Regata"* ]] || [[ "$OS" == *"Fedora"* ]] || [[ "$OS" == *"Nobara"* ]] || [[ "$OS" == *"Ultramarine"* ]] || [[ "$OS" == *"Rocky"* ]] || [[ "$OS" == *"Arch"* ]]; then
echo -e "${cyan} << Congratulations! You are using a decent Linux >> ${white}"
else
echo -e "${red} << Danger detected! You are using MEME linux. Get out of this garbage as soon as possible >> ${white}"
fi
##------------------------------------------------------##
# Setup the build environment if OS is openSUSE
AKHILNARANG="environment"
msg $green "|| Clone & Build environment ||" $white
if [[ "$OS" == *"SUSE"* ]] || [[ "$OS" == *"Regata"* ]]; then
echo -e "${blue} << Environment to openSUSE >> ${white}"
# Check if $DIR exists or not
if [[ ! -d "$AKHILNARANG" ]]; then
echo -e "$yellow $AKHILNARANG not found, downloading... $white"
git clone --depth=1 https://github.com/TogoFire/scripts -b akh ${AKHILNARANG}
cd "${AKHILNARANG}" && bash setup/opensuse.sh
cd ..
else
echo -e "$yellow $AKHILNARANG found, skipping step $white"
fi
fi
# Setup the build environment if OS is Fedora
if [[ "$OS" == *"Fedora"* ]] || [[ "$OS" == *"Nobara"* ]] || [[ "$OS" == *"Ultramarine"* ]] || [[ "$OS" == *"Rocky"* ]]; then
echo -e "${blue} << Environment to Fedora >> ${white}"
# Check if $DIR exists or not
if [[ ! -d "$AKHILNARANG" ]]; then
echo -e "$yellow $AKHILNARANG not found, downloading... $white"
git clone --depth=1 https://github.com/TogoFire/scripts -b akh ${AKHILNARANG}
cd "${AKHILNARANG}" && bash setup/fedora.sh
cd ..
else
echo -e "$yellow $AKHILNARANG found, skipping step $white"
fi
fi
# Setup the build environment if OS is Arch
if [[ "$OS" == *"Arch"* ]] || [[ "$OS" == *"Manjaro"* ]] || [[ "$OS" == *"Endeavour"* ]] || [[ "$OS" == *"Garuda"* ]]; then
echo -e "${blue} << Environment to Arch >> ${white}"
# Check if $DIR exists or not
if [[ ! -d "$AKHILNARANG" ]]; then
echo -e "$yellow $AKHILNARANG not found, downloading... $white"
git clone --depth=1 https://github.com/akhilnarang/scripts ${AKHILNARANG}
cd "${AKHILNARANG}" && bash setup/arch-manjaro.sh
cd ..
else
echo -e "$yellow $AKHILNARANG found, skipping step $white"
fi
fi
# Setup the build environment if OS is MEME
if [[ "$OS" == *"Ubuntu"* ]] || [[ "$OS" == *"Mint"* ]] || [[ "$OS" == *"Debian"* ]] || [[ "$OS" == *"Pop"* ]] || [[ "$OS" == *"Zorin"* ]] || [[ "$OS" == *"Elementary"* ]] || [[ "$OS" == *"Mx"* ]] || [[ "$OS" == *"antiX"* ]] || [[ "$OS" == *"Sparky"* ]] || [[ "$OS" == *"Parrot"* ]] || [[ "$OS" == *"Deepin"* ]] || [[ "$OS" == *"Kali"* ]] || [[ "$OS" == *"KDE"* ]] || [[ "$OS" == *"Lite"* ]]; then
echo -e "${pink} << Environment to MEME Linux >> ${white}"
# Check if $DIR exists or not
if [[ ! -d "$AKHILNARANG" ]]; then
echo -e "$yellow $AKHILNARANG not found, downloading... $white"
git clone --depth=1 https://github.com/TogoFire/scripts -b akh ${AKHILNARANG}
cd "${AKHILNARANG}" && bash setup/android_build_env.sh
cd ..
else
echo -e "$yellow $AKHILNARANG found, skipping step $white"
fi
fi
##------------------------------------------------------##
# Clone toolchain
msg $green "|| Cloning Toolchain ||" $white
if [[ -z $(ls -A | grep -E 'clang-neutron|clang-weebx|clang-greenforce|clang-trb|clang-playground|clang-zyc|clang-llvm|gcc-eva') ]]; then
echo -e "$yellow No existing Toolchain versions found. Proceeding to download... $white"
read -t 5 -p "$(tput setaf 171)π Which version of Clang would you like to use? (1) clang-neutron, (2) clang-weebx, (3) clang-greenforce, (4) clang-trb, (5) clang-playground, (6) clang-zyc, (7) clang-llvm or (8) gcc-eva.$(tput sgr0)
Type your answer here: " VERSION_CHOICE || {
echo -e "$cyan Timeout of 5 seconds reached. No input received. $white"
echo -e "$lgreen Setting choice to 2. $white"
VERSION_CHOICE=2
}
if [ "$VERSION_CHOICE" = "1" ]; then
CLANG_VERSION="clang-neutron"
elif [ "$VERSION_CHOICE" = "2" ]; then
CLANG_VERSION="clang-weebx"
elif [ "$VERSION_CHOICE" = "3" ]; then
CLANG_VERSION="clang-greenforce"
elif [ "$VERSION_CHOICE" = "4" ]; then
CLANG_VERSION="clang-trb"
elif [ "$VERSION_CHOICE" = "5" ]; then
CLANG_VERSION="clang-playground"
elif [ "$VERSION_CHOICE" = "6" ]; then
CLANG_VERSION="clang-zyc"
elif [ "$VERSION_CHOICE" = "7" ]; then
CLANG_VERSION="clang-llvm"
elif [ "$VERSION_CHOICE" = "8" ]; then
GCC_VERSION="gcc-eva"
else
echo -e "$red Please select a valid option." $white
exit 1 # Exit script if invalid choice is made
fi
echo -e "$blue << Toolchain download... >> $white"
if [ "$CLANG_VERSION" = "clang-neutron" ]; then
mkdir "${CLANG_VERSION}"
cd "${CLANG_VERSION}"
bash <(curl -s "https://raw.githubusercontent.com/Neutron-Toolchains/antman/main/antman") -S
cd ..
elif [ "$CLANG_VERSION" = "clang-weebx" ]; then
wget "$(curl -s https://raw.githubusercontent.com/XSans0/WeebX-Clang/main/main/link.txt)" -O "weebx-clang.tar.gz"
mkdir clang-weebx && tar -xf weebx-clang.tar.gz -C clang-weebx --strip-components=1 && rm -f weebx-clang.tar.gz
elif [ "$CLANG_VERSION" = "clang-greenforce" ]; then
git clone https://gitlab.com/fadlyas07/clang-llvm.git ${CLANG_VERSION} --depth=1 --single-branch --no-tags
elif [ "$CLANG_VERSION" = "clang-trb" ]; then
git clone https://gitlab.com/varunhardgamer/trb_clang.git ${CLANG_VERSION} --depth=1 --single-branch --no-tags
elif [ "$CLANG_VERSION" = "clang-playground" ]; then
git clone https://gitlab.com/PixelOS-Devices/playgroundtc.git ${CLANG_VERSION} --depth=1 --single-branch --no-tags
elif [ "$CLANG_VERSION" = "clang-zyc" ]; then
mkdir "${CLANG_VERSION}"
cd "${CLANG_VERSION}"
# Get the link from the txt file
link=$(curl -s https://raw.githubusercontent.com/ZyCromerZ/Clang/main/Clang-main-link.txt)
# Download the file
curl -o clang-zyc.tar.gz -L "$link"
# Extract the file
tar -xf clang-zyc.tar.gz
# Remove the tarball
rm clang-zyc.tar.gz
cd ..
elif [ "$CLANG_VERSION" = "clang-llvm" ]; then
# AOSP clang
CURRENT_CLANG=$(curl https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+/refs/heads/master/ | grep -oE "clang-r[0-9a-f]+" | sort -u | tail -n1)
echo -e "FETCHING $CURRENT_CLANG from AOSP..."
git clone https://gitlab.com/Neebe3289/android_prebuilts_clang_host_linux-x86.git -b $CURRENT_CLANG ${CLANG_VERSION} --depth=1 --single-branch --no-tags
#aria2c -q -j64 -x4 -s4 -k50M -c "https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+archive/refs/heads/master/$CURRENT_CLANG.tar.gz"
#wget -q -c -O $CURRENT_CLANG.tar.gz "https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+archive/refs/heads/master/$CURRENT_CLANG.tar.gz" | pv
#mkdir -p clang-llvm && tar -xf ./*.tar.gz -C /clang-llvm && rm ./*.tar.gz && rem clang-llvm
touch $CLANG_VERSION/bin/aarch64-linux-gnu-elfedit && chmod +x /$CLANG_VERSION/bin/aarch64-linux-gnu-elfedit
touch $CLANG_VERSION/bin/arm-linux-gnueabi-elfedit && chmod +x /$CLANG_VERSION/bin/arm-linux-gnueabi-elfedit
msg $green "|| Cloning Binutils ||" $white
git clone https://android.googlesource.com/platform/prebuilts/gas/linux-x86.git -b master gcc --depth=1 --single-branch --no-tags
#git clone https://github.com/LineageOS/android_prebuilts_gcc_linux-x86_aarch64_aarch64-linux-android-4.9.git --depth=1 gcc64
#git clone https://github.com/LineageOS/android_prebuilts_gcc_linux-x86_arm_arm-linux-androideabi-4.9.git --depth=1 gcc
# Toolchain Directory defaults to clang-llvm
TC_DIR=$KERNEL_DIR/${CLANG_VERSION}
GCC_DIR=$KERNEL_DIR/gcc
elif [ "$GCC_VERSION" = "gcc-eva" ]; then
git clone https://github.com/mvaisakh/gcc-arm.git gcc --depth=1 --single-branch --no-tags
git clone https://github.com/mvaisakh/gcc-arm64.git ${GCC_VERSION} --depth=1 --single-branch --no-tags
fi
else
if [ "$CLANG_VERSION" = "clang-neutron" ]; then
cd "${CLANG_VERSION}"
echo -e "$yellow $CLANG_VERSION found, checking updates & skipping step $white"
bash <(curl -s "https://raw.githubusercontent.com/Neutron-Toolchains/antman/main/antman") -U
bash <(curl -s "https://raw.githubusercontent.com/Neutron-Toolchains/antman/main/antman") -I
cd ..
fi
# Check if there is only one folder starting with "clang-"
num_dirs=$(ls -d clang-* | wc -l)
if [ $num_dirs -eq 1 ]; then
CLANG_VERSION=$(ls -d clang-*/)
echo -e "${yellow} Clang found! Skipping step ${white}"
fi
# Check if there is only one folder starting with "gcc-"
num_dirs=$(ls -d gcc-* | wc -l)
if [ $num_dirs -eq 1 ]; then
GCC_VERSION=$(ls -d gcc-*/)
echo -e "${yellow} GCC found! Skipping step ${white}"
fi
if [ -n "$CLANG_VERSION" ] && [ -n "$GCC_VERSION" ]; then
echo -e "$red ERROR: Multiple or no Clang/GCC versions found. Please specify which version to use." $white
exit 1
fi
fi
# Show which toolchain is being used
echo -e "${greenish_yellow} Currently using toolchain version: $CLANG_VERSION $GCC_VERSION ${white}"
##------------------------------------------------------##
# Clone AnyKernel3
ANYKERNEL3_VERSION="AnyKernel3"
msg $green "|| Cloning AnyKernel3 ||" $white
# Check if AnyKernel directory exists
if [[ ! -d "$ANYKERNEL3_VERSION" ]]; then
echo -e "$yellow $ANYKERNEL3_VERSION not found, downloading... $white"
# Display options and accept choice from user
echo -e "${magenta}\nπ Choose AnyKernel version: ${white}"
echo -e "${blue}1. Panda"
echo "2. NetHunter"
echo "3. NetErnels"
echo "4. KernelSU"
echo "5. GCC"
echo "6. McQuaid"
echo "7. Onion"
echo "8. Thor"
echo "9. Biogenesis"
echo -e "10. Mystique\n${white}"
read -t 5 -p "Enter your choice [1-10]: " choice || {
echo -e "$cyan Timeout of 5 seconds reached. No input received. $white"
echo -e "$lgreen Ak3 choice to 1. $white"
choice=1
}
case $choice in
1)
git clone --depth=1 https://github.com/TogoFire/AnyKernel3 -b Panda "${ANYKERNEL3_VERSION}"
;;
2)
git clone --depth=1 https://github.com/TogoFire/AnyKernel3 -b Panda-Nethunter "${ANYKERNEL3_VERSION}"
;;
3)
git clone --depth=1 https://github.com/TogoFire/AnyKernel3 -b NetErnels "${ANYKERNEL3_VERSION}"
;;
4)
git clone --depth=1 https://github.com/TogoFire/AnyKernel3 -b Panda-KSU "${ANYKERNEL3_VERSION}"
;;
5)
git clone --depth=1 https://github.com/TogoFire/AnyKernel3 -b Panda-GCC "${ANYKERNEL3_VERSION}"
;;
6)
git clone --depth=1 https://github.com/TogoFire/AnyKernel3 -b McQuaid "${ANYKERNEL3_VERSION}"
;;
7)
git clone --depth=1 https://github.com/TogoFire/AnyKernel3 -b Onion "${ANYKERNEL3_VERSION}"
;;
8)
git clone --depth=1 https://github.com/TogoFire/AnyKernel3 -b Thor "${ANYKERNEL3_VERSION}"
;;
9)
git clone --depth=1 https://github.com/TogoFire/AnyKernel3 -b Biogenesis "${ANYKERNEL3_VERSION}"
;;
10)
git clone --depth=1 https://github.com/TogoFire/AnyKernel3 -b Mystique "${ANYKERNEL3_VERSION}"
;;
*)
echo "Invalid choice, please try again."
;;
esac
else
echo -e "$yellow $ANYKERNEL3_VERSION found, skipping step $white"
fi
# Check which AnyKernel version is currently being used
cd $ANYKERNEL3_VERSION
# Get the current branch name, indicated by an asterisk (*), and extract the version number
CURRENT_VERSION=$(git branch -a | grep '*' | awk '{print $2}' | sed 's/^[[:alpha:]]\///')
if [[ -n "$CURRENT_VERSION" ]]; then
ANYK_VERSION="$CURRENT_VERSION"
echo -e "$greenish_yellow Currently being used Anykernel version: $ANYK_VERSION $white"
else
echo -e "$red Could not detect AnyKernel version! $white"
exit 1
fi
cd ..
##------------------------------------------------------##
# KernelSU
# Check if AK3 is KSU version to build KernelSU
if [[ "$ANYK_VERSION" == *"KSU"* ]]; then
sed -i 's/# CONFIG_KSU is not set/CONFIG_KSU=y/' arch/arm64/configs/daisy_defconfig
echo -e "$cyan KernelSU option selected and enabled to be built! $white"
fi
##------------------------------------------------------##
# Nethunter | NetErnels | KSU
# Check if AK3 is Nethunter version to build Kali Nethunter
if [[ "$ANYK_VERSION" == *"Nethunter"* ]] || [[ "$ANYK_VERSION" == *"Nethunter"* ]]; then
sed -i 's/# CONFIG_KSU is not set/CONFIG_KSU=y/' arch/arm64/configs/daisy_defconfig
sed -i 's/# CONFIG_NETHUNTER_SUPPORT is not set/CONFIG_NETHUNTER_SUPPORT=y/' arch/arm64/configs/daisy_defconfig
echo -e "$cyan Nethunter & KSU option selected and enabled to be built! $white"
fi
##------------------------------------------------------##
# Clean-up
echo -e "${orange_yellow} Clean-up ${white}"
rm -rf out/*
rm -rf error.log
rm -rf changelog/*
rm -rf ./*.tar.gz
##------------------------------------------------------##
# Create a filename for our changelog in a changelog directory
CHANGELOG_DIR="changelog"
CHANGELOG_FILE="$CHANGELOG_DIR/kernel-changelog.txt"
# Check if the changelog directory exists, and create it if it doesn't
if [ ! -d "$CHANGELOG_DIR" ]; then
mkdir "$CHANGELOG_DIR"
fi
# Use git log to get the most recent kernel commits
git log -n 350 --pretty=format:"%h - %s (%an)" > $CHANGELOG_FILE
# Print the location of the changelog file
echo -e "${purple} Changelog saved to $CHANGELOG_FILE ${white}"
# Add commit names to the changelog file
sed -i -e "s/^/- /" $CHANGELOG_FILE
##------------------------------------------------------##
# Calculate how long compiling compiling the kernel took
BUILD_START=$(date +"%s")
BUILD_END=$(date +"%s")
DIFF=$(($BUILD_END - $BUILD_START))
##------------------------------------------------------##
# This script will ask you if you want to compile with GCC or Clang.
echo -e "${magenta}\nπ Checking which compiler was chosen ${white}"
echo "1. Clang"
echo "2. GCC"
#read -t 4 -p "Enter your choice [1-2]: " choice || {
# echo -e "$cyan Timeout of 4 seconds reached. No input received. $white"
#}
if [[ $GCC_VERSION =~ "gcc-eva" ]]; then
choice=2
else
choice=1
fi
if [[ $choice == 2 ]]; then
echo -e "$cyan You have chosen to use GCC. $white"
else
echo -e "$cyan You have chosen to use Clang. $white"
fi
##------------------------------------------------------##
# Targets | Makefile
make O=out ARCH=arm64 daisy_defconfig
##------------------------------------------------------##
# Compile the kernel
if [ $choice -eq 1 ]; then
msg $blink_yellow "|| π¨ Started Compilation with Clang ||" $white
CLANG_ROOTDIR="$(pwd)/${CLANG_VERSION}"
TOOLCHAIN="clang"
build_kernel() {
Start=$(date +"%s")
if [ "$TOOLCHAIN" == ${TOOLCHAIN} ]; then
make -j$(nproc) ARCH=arm64 SUBARCH=arm64 O=out \
CC="${CLANG_ROOTDIR}/bin/clang" \
LD="${CLANG_ROOTDIR}/bin/ld.lld" \
AR="${CLANG_ROOTDIR}/bin/llvm-ar" \
AS="${CLANG_ROOTDIR}/bin/llvm-as" \
NM="${CLANG_ROOTDIR}/bin/llvm-nm" \
OBJCOPY="${CLANG_ROOTDIR}/bin/llvm-objcopy" \
OBJDUMP="${CLANG_ROOTDIR}/bin/llvm-objdump" \
STRIP="${CLANG_ROOTDIR}/bin/llvm-strip" \
LLVM=1 \
LLVM_IAS=1 \
CROSS_COMPILE="${CLANG_ROOTDIR}/bin/aarch64-linux-gnu-" \
CROSS_COMPILE_ARM32="${CLANG_ROOTDIR}/bin/arm-linux-gnueabi-" \
2>&1 | tee error.log
fi
End=$(date +"%s")
Diff=$(($End - $Start))
}
build_kernel
elif [ $choice -eq 2 ]; then
# GCC
msg $blink_yellow "|| π¨ Started Compilation with GCC ||" $white
GCC_ROOTDIR="$(pwd)/${GCC_VERSION}"
GCC_ARM="$(pwd)/gcc"
TOOLCHAIN="gcc"
build_kernel() {
Start=$(date +"%s")
if [ "$TOOLCHAIN" == ${TOOLCHAIN} ]; then
make -j$(nproc) ARCH=arm64 SUBARCH=arm64 O=out \
PATH=$GCC_ROOTDIR/bin:$GCC_ARM/bin:/usr/bin:${PATH} \
CROSS_COMPILE=aarch64-elf- \
CROSS_COMPILE_ARM32=arm-eabi- \
AR=aarch64-elf-ar \
NM=llvm-nm \
LD=ld.lld \
OBCOPY=llvm-objcopy \
OBJDUMP=aarch64-elf-objdump \
STRIP=aarch64-elf-strip \
2>&1 | tee error.log \
2>&1 | tee out/error.log
fi
End=$(date +"%s")
Diff=$(($End - $Start))
}
build_kernel
else
echo "Invalid choice."
exit 1
fi
##------------------------------------------------------##
# Zip up the kernel
zip_kernelimage() {
rm -rf "$(pwd)"/AnyKernel3/Image.gz-dtb
cp "$(pwd)"/out/arch/arm64/boot/Image.gz-dtb AnyKernel3
rm -rf "$(pwd)"/AnyKernel3/*.zip
BUILD_TIME=$(date +"%d%m%Y-%H%M")
cd AnyKernel3 || exit
zip -r9 "${ANYK_VERSION}"-r"${RELEASE}"-"${BUILD_TIME}".zip ./*
cd ..
}
##------------------------------------------------------##
# Get MD5SUM and SHASUM of the zipped kernel
Hash() {
SHA=$(shasum "$(pwd)"/AnyKernel3/${ANYK_VERSION}-r"${RELEASE}"-"${BUILD_TIME}".zip | cut -f 1 -d '/')
MD5=$(md5sum "$(pwd)"/AnyKernel3/${ANYK_VERSION}-r"${RELEASE}"-"${BUILD_TIME}".zip | cut -f 1 -d '/')
}
##------------------------------------------------------##
msg $green "|| Zipping into a flashable zip ||" $white
FILE="$(pwd)/out/arch/arm64/boot/Image.gz-dtb"
if [ -f "$FILE" ]; then
zip_kernelimage
Hash
echo -e "$green << Build completed in $(($Diff / 60)) minutes and $(($Diff % 60)) seconds >> \n $white"
echo -e "The kernel has successfully been compiled and can be found in $(pwd)/AnyKernel3/${greenish_yellow}${ANYK_VERSION}-r${RELEASE}-${BUILD_TIME}.zip $white"
echo -e "$greenish_yellow MD5 Checksum : $MD5 $white"
echo -e "$greenish_yellow SHA1 Checksum : $SHA $white"
rm -rf error.log
read -r -p "Press enter to continue"
msg $blink_green "|| Enjoy! ^^ ||" $white
# Upload to mega
# Asks the user if they want to upload the file
echo -e "$yellow \nπ Do you want to upload the file to megaupload? (y/n) $white"
read -t 5 -p "$(tput setaf 171) Enter your answer: " answer || {
echo -e "$cyan Timeout of 5 seconds reached. No input received. $white"
echo -e "$lgreen Setting choice to n. $white"
answer=n
}
if [[ $answer == "y" ]]; then
# Asks the user for their email and password
echo -e "$blue Enter your email address: $white"
read -p "$(tput setaf 171) Email: " email
echo -e "$blue Enter your password: $white"
read -s -p "$(tput setaf 171) Password: " password
# Uploads the file
megaput $(pwd)/AnyKernel3/${ANYK_VERSION}-r${RELEASE}-${BUILD_TIME}.zip -u $email -p $password
countdown 3
echo -e "$reset π $white"
fi
else
echo -e "$red << Failed to compile the kernel in $(($Diff / 60)) minutes and $(($Diff % 60)) seconds >> \n $white"
cat error.log | curl -F 'file=@error.log' https://bin.cyberknight777.dev
echo -e "$blink_red << Check up to find the error >> $white"
read -r -p "Press enter to continue"
msg $blink_green "|| Good luck! ||" $white
fi
##------------------------------------------------------##
# Check gcc log
if [[ $GCC_VERSION =~ "gcc-eva" ]]; then
echo -e "$cyan \nGCC log: $white"
cat out/error.log | curl -F 'file=@out/error.log' https://bin.cyberknight777.dev
fi
##------------------------------------------------------##
# Nuke Ak3
echo -e "$yellow \nπ Do you want to remove the AnyKernel3 directory? [Y/n] $white"
read -t 5 -p "$(tput setaf 171) Enter your answer: " response || {
echo -e "$cyan Timeout of 5 seconds reached. No input received. $white"
}
if [[ $response =~ ^[Yy]$ ]]; then
rm -rf AnyKernel3
else
echo -e "$lgreen AnyKernel3 directory was not removed. $white"
fi
##------------------------------------------------------##
# Nuke Toolchain
echo -e "$yellow \nπ Do you want to remove the Toolchain directory? [Y/n] $white"
read -t 5 -p "$(tput setaf 171) Enter your answer: " response || {
echo -e "$cyan Timeout of 5 seconds reached. No input received. $white"
}
if [[ $response =~ ^[Yy]$ ]]; then
rm -rf gcc
rm -rf gcc-*
rm -rf clang-*
else
echo -e "$lgreen Toolchain directory was not removed. $white"
fi
##------------------------------------------------------##