-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sh
126 lines (109 loc) · 4.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
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
#!/bin/bash
#
# Copyright (C) 2020 azrim.
# All rights reserved.
# Init
KERNEL_DIR="${PWD}"
KERN_IMG="${KERNEL_DIR}"/out/arch/arm64/boot/Image.gz
KERN_DTB_NONTB="${KERNEL_DIR}"/out/arch/arm64/boot/dts/qcom/msm8953-qrd-sku3-tissot-nontreble.dtb
KERN_DTB_TB="${KERNEL_DIR}"/out/arch/arm64/boot/dts/qcom/msm8953-qrd-sku3-tissot-treble.dtb
ANYKERNEL="${HOME}"/anykernel
# Repo URL
CLANG_REPO="https://github.com/silont-project/silont-clang.git"
ANYKERNEL_REPO="https://github.com/yincen17/AnyKernel3.git"
ANYKERNEL_BRANCH="tissot"
# Compiler
CLANG_DIR="$HOME/proton-clang"
if ! [ -d "${CLANG_DIR}" ]; then
git clone "$CLANG_REPO" --depth=1 "$CLANG_DIR"
fi
# git clone https://github.com/baalajimaestro/aarch64-maestro-linux-android.git -b 07032020-9.2.1 --depth=1 "${KERNEL_DIR}/gcc"
# git clone https://github.com/baalajimaestro/arm-maestro-linux-gnueabi.git -b 07032020-9.2.1 --depth=1 "${KERNEL_DIR}/gcc32"
# Defconfig
DEFCONFIG="tissot_defconfig"
REGENERATE_DEFCONFIG="true" # unset if don't want to regenerate defconfig
# Costumize
KERNEL="SiLonT"
DEVICE="Tissot"
KERNELTYPE="4.9-Q-Rebase"
KERNELNAME="${KERNEL}-${DEVICE}-${KERNELTYPE}-$(TZ=Asia/Jakarta date +%y%m%d-%H%M)"
TEMPZIPNAME="${KERNELNAME}-unsigned.zip"
ZIPNAME="${KERNELNAME}.zip"
# Telegram
CHATIDQ="-561797338"
CHATID="-561797338" # Group/channel chatid (use rose/userbot to get it)
TELEGRAM_TOKEN="" # Get from botfather
# Export Telegram.sh
TELEGRAM_FOLDER="${HOME}"/telegram
if ! [ -d "${TELEGRAM_FOLDER}" ]; then
git clone https://github.com/fabianonline/telegram.sh/ "${TELEGRAM_FOLDER}"
fi
TELEGRAM="${TELEGRAM_FOLDER}"/telegram
tg_cast() {
"${TELEGRAM}" -t "${TELEGRAM_TOKEN}" -c "${CHATID}" -H \
"$(
for POST in "${@}"; do
echo "${POST}"
done
)"
}
# Regenerating Defconfig
regenerate() {
cp out/.config arch/arm64/configs/"${DEFCONFIG}"
git add arch/arm64/configs/"${DEFCONFIG}"
git commit -m "defconfig: Regenerate"
}
# Building
makekernel() {
export PATH="$HOME/proton-clang/bin:$PATH"
# export CROSS_COMPILE=${KERNEL_DIR}/gcc/bin/aarch64-maestro-linux-gnu-
# export CROSS_COMPILE_ARM32=${KERNEL_DIR}/gcc32/bin/arm-maestro-linux-gnueabi-
rm -rf "${KERNEL_DIR}"/out/arch/arm64/boot # clean previous compilation
mkdir -p out
make O=out ARCH=arm64 ${DEFCONFIG}
if [[ "${REGENERATE_DEFCONFIG}" =~ "true" ]]; then
regenerate
fi
make -j$(nproc --all) CC=clang CROSS_COMPILE=aarch64-linux-gnu- CROSS_COMPILE_ARM32=arm-linux-gnueabi- O=out ARCH=arm64
# Check If compilation is success
if ! [ -f "${KERN_IMG}" ]; then
END=$(TZ=Asia/Jakarta date +"%s")
DIFF=$(( END - START ))
echo -e "Kernel compilation failed, See buildlog to fix errors"
tg_cast "Build for ${DEVICE} <b>failed</b> in $((DIFF / 60)) minute(s) and $((DIFF % 60)) second(s)! Check Instance for errors @Yincen"
exit 1
fi
}
# Packing kranul
packingkernel() {
# Copy compiled kernel
if [ -d "${ANYKERNEL}" ]; then
rm -rf "${ANYKERNEL}"
fi
git clone "$ANYKERNEL_REPO" -b "$ANYKERNEL_BRANCH" "${ANYKERNEL}"
mkdir "${ANYKERNEL}"/kernel/
cp "${KERN_IMG}" "${ANYKERNEL}"/kernel/Image.gz
mkdir "${ANYKERNEL}"/dtb-nontreble/
cp "${KERN_DTB_NONTB}" "${ANYKERNEL}"/dtb-nontreble/msm8953-qrd-sku3-tissot-nontreble.dtb
mkdir "${ANYKERNEL}"/dtb-treble/
cp "${KERN_DTB_TB}" "${ANYKERNEL}"/dtb-treble/msm8953-qrd-sku3-tissot-treble.dtb
# Zip the kernel, or fail
cd "${ANYKERNEL}" || exit
zip -r9 "${TEMPZIPNAME}" ./*
# Sign the zip before sending it to Telegram
curl -sLo zipsigner-3.0.jar https://raw.githubusercontent.com/baalajimaestro/AnyKernel2/master/zipsigner-3.0.jar
java -jar zipsigner-3.0.jar "${TEMPZIPNAME}" "${ZIPNAME}"
# Ship it to the CI channel
"${TELEGRAM}" -f "$ZIPNAME" -t "${TELEGRAM_TOKEN}" -c "${CHATIDQ}"
}
# Starting
tg_cast "<b>STARTING KERNEL BUILD</b>" \
"Device: ${DEVICE}" \
"Kernel: <code>${KERNEL}, ${KERNELTYPE}</code>" \
"Linux Version: <code>$(make kernelversion)</code>"
START=$(TZ=Asia/Jakarta date +"%s")
makekernel
packingkernel
END=$(TZ=Asia/Jakarta date +"%s")
DIFF=$(( END - START ))
tg_cast "Build for ${DEVICE} with ${COMPILER_STRING} <b>succeed</b> took $((DIFF / 60)) minute(s) and $((DIFF % 60)) second(s)! @Yincen"