-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
121 lines (109 loc) · 4.41 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
#!/usr/bin/env bash
# Source Configs
source $CONFIG
cd ${KERNEL_DIR}
function info() {
KERNEL_VERSION=$(cat $KERNEL_DIR/out/.config | grep Linux/arm | cut -d " " -f3)
UTS_VERSION=$(cat $KERNEL_DIR/out/include/generated/compile.h | grep UTS_VERSION | cut -d '"' -f2)
TOOLCHAIN_VERSION=$(cat $KERNEL_DIR/out/include/generated/compile.h | grep LINUX_COMPILER | cut -d '"' -f2)
TRIGGER_SHA="$(git rev-parse HEAD)"
LATEST_COMMIT="$(git log --pretty=format:'%s' -1)"
COMMIT_BY="$(git log --pretty=format:'by %an' -1)"
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
}
function push() {
cd ${HOME}
ZIP=$(echo *.zip)
curl -F document=@$ZIP "https://api.telegram.org/bot$TG_TOKEN/sendDocument" \
-F chat_id="$TG_CHAT_ID" \
-F "disable_web_page_preview=true" \
-F "parse_mode=html" \
-F caption="
==========================
<b>👤 Owner:</b> $KBUILD_BUILD_USER
<b>🏚️ Linux version:</b> $KERNEL_VERSION
<b>🌿 Branch:</b> $KERNEL_BRANCH
<b>🎁 Top commit:</b> $LATEST_COMMIT
<b>🧧 SHA1:</b> $(sha1sum "$ZIP" | cut -d' ' -f1)
<b>📚 MD5:</b> $(md5sum "$ZIP" | cut -d' ' -f1)
<b>👩💻 Commit author:</b> $COMMIT_BY
<b>🐧 UTS version:</b> $UTS_VERSION
<b>💡 Compiler:</b> $TOOLCHAIN_VERSION
==========================
<b>🔋 For all change, look in:</b> <a href=\"$KERNEL_SOURCE/commits/$KERNEL_BRANCH\">Here</a>
Compile took $((SECONDS / 60)) minute(s) and $((SECONDS % 60)) second(s) !"
}
function finerr() {
cd ${HOME}
curl -s -X POST "https://api.telegram.org/bot$TG_TOKEN/sendMessage" -d chat_id="$TG_CHAT_ID" \
-d "disable_web_page_preview=true" \
-d "parse_mode=html" \
-d text="==============================%0A<b> Building Kernel Failed [❌]</b>%0A=============================="
curl -s -X POST "https://api.telegram.org/bot$TG_TOKEN/sendSticker" \
-d sticker="CAACAgIAAx0CXjGT1gACDRRhYsUKSwZJQFzmR6eKz2aP30iKqQACPgADr8ZRGiaKo_SrpcJQIQQ" \
-d chat_id="$TG_CHAT_ID"
curl -F document=@${HOME}/build.log "https://api.telegram.org/bot$TG_TOKEN/sendDocument" \
-F chat_id="$TG_CHAT_ID" \
-F "disable_web_page_preview=true" \
-F "parse_mode=html" \
-F caption="Error log❗"
exit 1
}
if [[ $1 = "-r" || $1 = "--regen" ]]; then
make O=out ARCH=arm $DEFCONFIG savedefconfig
cp out/defconfig arch/arm/configs/$DEFCONFIG
exit
fi
if [[ $1 = "-c" || $1 = "--clean" ]]; then
rm -rf out
fi
KBUILD_COMPILER_STRING="$("$TC_DIR"/bin/arm-linux-androideabi-gcc --version | head -n 1 | perl -pe 's/\(http.*?\)//gs' | sed -e 's/ */ /g' -e 's/[[:space:]]*$//')"
echo ================================================
echo " __ ______ ______ "
echo " / |/ / _ \/_ __/ "
echo " __ / /|_/ / , _/ / / __ "
echo " /_/ /_/ /_/_/|_| /_/ /_/ "
echo " ___ ___ ____ _________________ "
echo " / _ \/ _ \/ __ \__ / / __/ ___/_ __/ "
echo " / ___/ , _/ /_/ / // / _// /__ / / "
echo " /_/ /_/|_|\____/\___/___/\___/ /_/ "
echo ================================================
echo BUILDER NAME = ${KBUILD_BUILD_USER}
echo BUILDER HOSTNAME = ${KBUILD_BUILD_HOST}
echo CONFIG NAME = ${DEFCONFIG}
echo TOOLCHAIN VERSION = ${KBUILD_COMPILER_STRING}
echo DATE = $(TZ=Asia/Jakarta date +"%Y%m%d-%H%M")
echo ================================================
mkdir -p out
make O=out ARCH=arm $DEFCONFIG
msg -e "\nStarting compilation...\n"
make -j$(nproc --all) O=out ARCH=arm \
CROSS_COMPILE=${TC_DIR}/bin/arm-linux-androideabi- \
CROSS_COMPILE_ARM32=${TC_DIR}/bin/arm-linux-androideabi-
if ! [ -f "out/arch/arm/boot/zImage" ]; then
finerr
fi
if [ -f "out/arch/arm/boot/zImage" ]; then
msg -e "\nKernel compiled succesfully! Zipping up...\n"
if [ -d "$AK3_DIR" ]; then
cp -r $AK3_DIR AnyKernel3
elif ! git clone -q ${AK3_SOURCE}; then
msg1 -e "\nAnyKernel3 repo not found locally and cloning failed! Aborting..."
exit 1
fi
cp out/arch/arm/boot/zImage AnyKernel3
rm -f *zip
cd AnyKernel3
git checkout master &> /dev/null
zip -r9 "${HOME}/${ZIPNAME}" * -x '*.git*' README.md *placeholder
cd ..
rm -rf AnyKernel3
rm -rf out/arch/arm/boot
msg -e "\nCompleted in $((SECONDS / 60)) minute(s) and $((SECONDS % 60)) second(s) !"
msg "Zip: ${ZIPNAME}"
info
push
else
msg1 -e "\nCompilation failed!"
exit 1
fi