forked from vantoman/kernel_xiaomi_sm6150
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sh
81 lines (65 loc) · 2.2 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
#!/bin/bash
#
# Compile script for kernel
#
SECONDS=0 # builtin bash timer
# Allowed codenames
ALLOWED_CODENAMES=("sweet" "courbet" "tucana" "toco" "phoenix" "davinci")
# Prompt user for device codename
read -p "Enter device codename: " DEVICE
# Check if the entered codename is in the allowed list
if [[ ! " ${ALLOWED_CODENAMES[@]} " =~ " ${DEVICE} " ]]; then
echo "Error: Invalid codename. Allowed codenames are: ${ALLOWED_CODENAMES[*]}"
exit 1
fi
ZIPNAME="${DEVICE}-$(date '+%Y%m%d-%H%M').zip"
export ARCH=arm64
export KBUILD_BUILD_USER=aryan
export KBUILD_BUILD_HOST=celeste
export PATH="/home/celeste/aryan/linux-x86/clang-r510928/bin/:$PATH"
if [[ $1 = "-c" || $1 = "--clean" ]]; then
rm -rf out
echo "Cleaned output folder"
fi
echo -e "\nStarting compilation for $DEVICE...\n"
make O=out ARCH=arm64 ${DEVICE}_defconfig
make -j$(nproc) \
O=out \
ARCH=arm64 \
LLVM=1 \
LLVM_IAS=1 \
CROSS_COMPILE=aarch64-linux-gnu- \
CROSS_COMPILE_ARM32=arm-linux-gnueabi-
kernel="out/arch/arm64/boot/Image.gz"
dtbo="out/arch/arm64/boot/dtbo.img"
dtb="out/arch/arm64/boot/dtb.img"
if [ ! -f "$kernel" ] || [ ! -f "$dtbo" ] || [ ! -f "$dtb" ]; then
echo -e "\nCompilation failed!"
exit 1
fi
echo -e "\nKernel compiled successfully! Zipping up...\n"
if [ -d "$AK3_DIR" ]; then
cp -r $AK3_DIR AnyKernel3
else
if ! git clone -q https://github.com/basamaryan/AnyKernel3 -b master AnyKernel3; then
echo -e "\nAnyKernel3 repo not found locally and couldn't clone from GitHub! Aborting..."
exit 1
fi
fi
# Modify anykernel.sh to replace device names
sed -i "s/device\.name1=.*/device.name1=${DEVICE}/" AnyKernel3/anykernel.sh
sed -i "s/device\.name2=.*/device.name2=${DEVICE}in/" AnyKernel3/anykernel.sh
cp $kernel AnyKernel3
cp $dtbo AnyKernel3
cp $dtb AnyKernel3
cd AnyKernel3
zip -r9 "../$ZIPNAME" * -x .git
cd ..
rm -rf AnyKernel3
echo -e "\nCompleted in $((SECONDS / 60)) minute(s) and $((SECONDS % 60)) second(s) !"
echo "Zip: $ZIPNAME"
if test -z "$(git rev-parse --show-cdup 2>/dev/null)" &&
head=$(git rev-parse --verify HEAD 2>/dev/null); then
HASH="$(echo $head | cut -c1-8)"
fi
telegram -f $ZIPNAME -M "Completed in $((SECONDS / 60)) minute(s) and $((SECONDS % 60)) second(s) ! Latest commit: $HASH"