-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild-notb.sh
181 lines (155 loc) · 5.71 KB
/
build-notb.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
#!/bin/bash
#
# Copyright (C) 2020 azrim.
# All rights reserved.
# Init
KERNEL_DIR="${PWD}"
KERN_IMG="${KERNEL_DIR}"/out/arch/arm64/boot/Image.gz-dtb
KERNEL_DIR="$(basename $PWD)"
DISTRO=$(source /etc/os-release && echo ${NAME})
KERVER=$(make kernelversion)
BRANCH=$(git rev-parse --abbrev-ref HEAD)
COMMIT_HEAD=$(git log --oneline -1)
ANYKERNEL="${HOME}"/kernel/anykernel
# Repo URL
CLANG_REPO="https://gitlab.com/LeCmnGend/proton-clang"
CLANG_DIR="${HOME}"/kernel/clang-proton
COMPILER_STRING="Proton Clang 15.0.0"
ANYKERNEL_REPO="https://github.com/zhantech/Anykernel3-tissot.git"
ANYKERNEL_BRANCH="Anykernel3"
ANYKERNEL="${HOME}"/kernel/anykernel
# Cleaning
rm -rf "${KERNEL_DIR}"/out
# Compiler
if ! [ -d "${CLANG_DIR}" ]; then
git clone "$CLANG_REPO" -b clang-15 --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="false" # unset if don't want to regenerate defconfig
# Costumize
KERNEL="Pringgodani"
RELEASE_VERSION="2.2"
DEVICE="Tissot"
KERNEL_SUPPORT="10 - 13"
KERNELNAME="${KERNEL}-${RELEASE_VERSION}-${DEVICE}-${BRANCH}-$(TZ=Asia/Jakarta date +%y%m%d-%H%M)"
TEMPZIPNAME="${KERNELNAME}.zip"
ZIPNAME="${KERNELNAME}.zip"
# Telegram
CHATIDQ="-1001308839345"
CHATID="-1001308839345" # Group/channel chatid (use rose/userbot to get it)
TELEGRAM_TOKEN="5988732593:AAEn7SJOoh5x8VWtevuPGO25-TRnygaLsoM" # Get from botfather
# Export Telegram.sh
TELEGRAM_FOLDER="${HOME}"/telegram
if ! [ -d "${TELEGRAM_FOLDER}" ]; then
git clone https://github.com/zhantech/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() {
echo ".........................."
echo ". Building Kernel ."
echo ".........................."
export PATH="${CLANG_DIR}"/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 @zh4ntech"
exit 1
fi
}
# Packing kranul
packingkernel() {
echo "........................"
echo ". Packing Kernel ."
echo "........................"
# 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}"/Image.gz-dtb
# mkdir "${ANYKERNEL}"/dtb-nontreble/
# cp "${KERN_DTB_NONTB}" "${ANYKERNEL}"/dtb-nontreble/msm8953-qrd-sku3-tissot-nontreble.dtb
# mkdir "${ANYKERNEL}"/dtb-treble/
# cp "${KERN_DTB_NONTB}" "${ANYKERNEL}"/dtb-treble/msm8953-qrd-sku3-tissot-nontreble.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}"
while true; do
read -p "Do you want to upload kernel? (y/n) " yn
case $yn in
[yY] )
# Ship it to the CI channel
"${TELEGRAM}" -f "$ZIPNAME" -t "${TELEGRAM_TOKEN}" -c "${CHATIDQ}"
echo "Kernel uploaded to telegram..."
scp "$ZIPNAME" [email protected]:/home/frs/project/zhantech/Pringgodani/tissot
echo "Kernel uploaded to sourceforge..."
rm -rf "$ZIPNAME"
rm -rf "${KERNEL_DIR}"/out
break;;
[nN] )
echo ".........................."
echo ". Build Finished ."
echo ".........................."
exit;;
* ) echo invalid response;;
esac
done
}
# Starting
tg_cast "<b>STARTING KERNEL BUILD</b>" \
"Docker OS: ${DISTRO}" \
"Device: ${DEVICE}" \
"Kernel Name: <code>${KERNEL}</code>" \
"Release Version: ${RELEASE_VERSION}" \
"Kernel Version : ${KERVER}" \
"Android Supported: ${KERNEL_SUPPORT}" \
"Branch : <code>$BRANCH</code>" \
"Last Commit : <code>$COMMIT_HEAD</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)! by @zh4ntech"
tg_cast "<b>Changelog :</b>" \
"- Compile with Proton Clang 15.0.0" \
"- Bump ${RELEASE_VERSION}" \
"- Add Android 14 Support" \
"- Update KernelSU" \
"- More Changelogs : https://github.com/zhantech/android_kernel_msm8953/commits/Pringgodani"
echo "........................"
echo ". Build Finished ."
echo "........................"