-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·95 lines (93 loc) · 4.22 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
#!/bin/bash
source config.sh
export SUBARCH="${ARCH}"
if [ "${ARCH}" == "arm" ]; then
export kernel_toolchain="arm-linux-androideabi-"
export kernel_clang_triple="arm-linux-gnu-"
elif [ "${ARCH}" == "arm64" ]; then
export kernel_toolchain="aarch64-linux-android-"
export kernel_clang_triple="aarch64-linux-gnu-"
fi
if [ "${clang}" == "false" ]; then
export CROSS_COMPILE="$(pwd)/gcc/bin/${kernel_toolchain}"
if [ "${ARCH}" == "arm64" ]; then
export CROSS_COMPILE_ARM32="$(pwd)/gcc32/bin/arm-linux-androideabi-"
fi
elif [ "${clang}" == "true" ]; then
export CROSS_COMPILE="${kernel_toolchain}"
if [ -z "${clang_version}" ]; then
export clang_version="r412851"
fi
if [ "${ARCH}" == "arm64" ]; then
export PATH="$(pwd)/clang/clang-${clang_version}/bin:$(pwd)/gcc/bin:$(pwd)/gcc32/bin:${PATH}"
export CROSS_COMPILE_ARM32="arm-linux-androideabi-"
else
export PATH="$(pwd)/clang/clang-${clang_version}/bin:$(pwd)/gcc/bin:${PATH}"
fi
fi
if [ -z "${name}" ]; then
export name="Generic ${device} kernel"
fi
BUILD_START=$(date +"%s")
cd kernel
telegram -M "Build started for ${device}"
if [ "${clang}" == "true" ]; then
make O=out "${defconfig}"
make -j$(nproc --all) O=out CC=clang CLANG_TRIPLE="${kernel_clang_triple}"
else
mkdir -p out
make O=out "${defconfig}"
make O=out -j$(nproc --all)
fi
cd ..
function pack_zip () {
export zip_name="kernel-$(date +%Y%m%d-%H%M)-${device}.zip"
cd AnyKernel
if [ "${device_is_ab}" == "true" ]; then
sed -i 's|is_slot_device=0|is_slot_device=1|g' anykernel.sh
fi
sed -i "s|device_name1=|device_name1=${device}|g" anykernel.sh
sed -i "s|kernel_string=|kernel_string=${name}|g" anykernel.sh
zip -r9 "${zip_name}" * "${zip_name}"
cd ..
}
if [ "${ARCH}" == "arm" ]; then
if [ -f kernel/out/arch/arm/boot/Image ]; then
if [ -f kernel/out/arch/arm/boot/zImage-dtb ]; then
cp kernel/out/arch/arm/boot/zImage-dtb AnyKernel/
else
cp kernel/out/arch/arm/boot/zImage AnyKernel/
fi
pack_zip
BUILD_END=$(date +"%s")
BUILD_DIFF=$((BUILD_END - BUILD_START))
curl -v -F "chat_id=$TELEGRAM_CHAT" -F document="@AnyKernel/${zip_name}" -F "parse_mode=html" -F caption="Build completed successfully in $((BUILD_DIFF / 60)) minute(s) and $((BUILD_DIFF % 60)) seconds" "https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendDocument"
curl --data parse_mode=HTML --data chat_id=$TELEGRAM_CHAT --data sticker=CAADBQADGgEAAixuhBPbSa3YLUZ8DBYE --request POST https://api.telegram.org/bot$TELEGRAM_TOKEN/sendSticker
else
BUILD_END=$(date +"%s")
BUILD_DIFF=$((BUILD_END - BUILD_START))
telegram -M "Build failed in $((BUILD_DIFF / 60)) minute(s) and $((BUILD_DIFF % 60)) seconds"
curl --data parse_mode=HTML --data chat_id=$TELEGRAM_CHAT --data sticker=CAADBQADGgEAAixuhBPbSa3YLUZ8DBYE --request POST https://api.telegram.org/bot$TELEGRAM_TOKEN/sendSticker
exit 1
fi
fi
if [ "${ARCH}" == "arm64" ]; then
if [ -f kernel/out/arch/arm64/boot/Image ]; then
if [ -f kernel/out/arch/arm64/boot/Image.gz-dtb ]; then
cp kernel/out/arch/arm64/boot/Image.gz-dtb AnyKernel/
else
cp kernel/out/arch/arm64/boot/Image.gz AnyKernel/
fi
pack_zip
BUILD_END=$(date +"%s")
BUILD_DIFF=$((BUILD_END - BUILD_START))
curl -v -F "chat_id=$TELEGRAM_CHAT" -F document="@AnyKernel/${zip_name}" -F "parse_mode=html" -F caption="Build completed successfully in $((BUILD_DIFF / 60)) minute(s) and $((BUILD_DIFF % 60)) seconds" "https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendDocument"
curl --data parse_mode=HTML --data chat_id=$TELEGRAM_CHAT --data sticker=CAADBQADGgEAAixuhBPbSa3YLUZ8DBYE --request POST https://api.telegram.org/bot$TELEGRAM_TOKEN/sendSticker
else
BUILD_END=$(date +"%s")
BUILD_DIFF=$((BUILD_END - BUILD_START))
telegram -M "Build failed in $((BUILD_DIFF / 60)) minute(s) and $((BUILD_DIFF % 60)) seconds"
curl --data parse_mode=HTML --data chat_id=$TELEGRAM_CHAT --data sticker=CAADBQADGgEAAixuhBPbSa3YLUZ8DBYE --request POST https://api.telegram.org/bot$TELEGRAM_TOKEN/sendSticker
exit 1
fi
fi