-
Notifications
You must be signed in to change notification settings - Fork 5
/
kernel-60Hz.sh
173 lines (138 loc) · 5.37 KB
/
kernel-60Hz.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
#!/usr/bin/env bash
export TZ="Asia/Kolkata";
# Kernel compiling script
function check_toolchain() {
export TC="$(find ${TOOLCHAIN}/bin -type f -name *-gcc)";
if [[ -f "${TC}" ]]; then
export CROSS_COMPILE="${TOOLCHAIN}/bin/$(echo ${TC} | awk -F '/' '{print $NF'} |\
sed -e 's/gcc//')";
echo -e "Using toolchain: $(${CROSS_COMPILE}gcc --version | head -1)";
else
echo -e "No suitable toolchain found in ${TOOLCHAIN}";
exit 1;
fi
}
function transfer() {
zipname="$(echo $1 | awk -F '/' '{print $NF}')";
url="$(curl -# -T $1 https://transfer.sh)";
printf '\n';
echo -e "Download ${zipname} at ${url}";
# curl -s -X POST https://api.telegram.org/bot$BOT_API_KEY/sendMessage -d text="$url" -d chat_id="-1001263315920"
}
if [[ -z ${KERNELDIR} ]]; then
echo -e "Please set KERNELDIR";
exit 1;
fi
export DEVICE=$1;
if [[ -z ${DEVICE} ]]; then
export DEVICE="HM4X";
fi
mkdir -p ${KERNELDIR}/aroma
mkdir -p ${KERNELDIR}/files
export SRCDIR="${KERNELDIR}";
export OUTDIR="${KERNELDIR}/out";
export ANYKERNEL="${KERNELDIR}/AnyKernel2/";
export AROMA="${KERNELDIR}/aroma/";
export ARCH="arm64";
export SUBARCH="arm64";
export KBUILD_BUILD_USER="QuantumMech2000"
export KBUILD_BUILD_HOST="TeamQuantum"
export TOOLCHAIN="${HOME}/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu/";
export DEFCONFIG="santoni_defconfig";
export ZIP_DIR="${HOME}/${KERNELDIR}/files";
export IMAGE="${OUTDIR}/arch/${ARCH}/boot/Image.gz-dtb";
export CC=$HOME/clang/bin/clang
export CLANG_VERSION=$($CC --version | head -n 1 | perl -pe 's/\(http.*?\)//gs' | sed -e 's/ */ /g' -e 's/[[:space:]]*$//')
export CLANG_TRIPLE=aarch64-linux-gnu-
export CLANG_LD_PATH=$HOME/clang/lib
export LLVM_DIS=$HOME/clang/bin/llvm-dis
export MAKE_TYPE="Treble"
if [[ -z "${JOBS}" ]]; then
export JOBS="$(nproc --all)";
# export JOBS=64;
fi
export MAKE="make O=${OUTDIR}";
check_toolchain;
export TCVERSION1="$(${CROSS_COMPILE}gcc --version | head -1 |\
awk -F '(' '{print $2}' | awk '{print tolower($1)}')"
export TCVERSION2="$(${CROSS_COMPILE}gcc --version | head -1 |\
awk -F ')' '{print $2}' | awk '{print tolower($1)}')"
export ZIPNAME="${KERNELNAME}-5.7-${DEVICE}-TREBLE-60Hz-$(date +%Y%m%d-%H%M).zip"
export FINAL_ZIP="${ZIP_DIR}/${ZIPNAME}"
[ ! -d "${ZIP_DIR}" ] && mkdir -pv ${ZIP_DIR}
[ ! -d "${OUTDIR}" ] && mkdir -pv ${OUTDIR}
cd "${SRCDIR}";
rm -fv ${IMAGE};
MAKE_STATEMENT=make
# Menuconfig configuration
# ================
# If -no-menuconfig flag is present we will skip the kernel configuration step.
# Make operation will use santoni_defconfig directly.
if [[ "$*" == *"-no-menuconfig"* ]]
then
NO_MENUCONFIG=1
MAKE_STATEMENT="$MAKE_STATEMENT KCONFIG_CONFIG=./arch/arm64/configs/santoni_defconfig"
fi
if [[ "$@" =~ "mrproper" ]]; then
${MAKE} mrproper
fi
if [[ "$@" =~ "clean" ]]; then
${MAKE} clean
fi
# curl -s -X POST https://api.telegram.org/bot$BOT_API_KEY/sendSticker -d sticker="CAADBQADFgADx8M3D8ZwwIWZRWcwAg" -d chat_id=$CHAT_ID
curl -s -X POST https://api.telegram.org/bot$BOT_API_KEY/sendMessage -d text="#Awoo
Build Scheduled for $KERNELNAME Kernel (Treble-60Hz)" -d chat_id=$CHAT_ID
${MAKE} $DEFCONFIG;
START=$(date +"%s");
echo -e "Using ${JOBS} threads to compile"
${MAKE} -j${JOBS};
exitCode="$?";
END=$(date +"%s")
DIFF=$(($END - $START))
echo -e "Build took $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) seconds.";
if [[ ! -f "${IMAGE}" ]]; then
echo -e "Build failed :P";
curl -s -X POST https://api.telegram.org/bot$BOT_API_KEY/sendMessage -d text="$KERNELNAME Kernel stopped due to an error, @vvreddy @infinitEplus Please take a Look" -d chat_id="-1001406849717"
# curl -s -X POST https://api.telegram.org/bot$BOT_API_KEY/sendSticker -d sticker="CAADBQADHwADx8M3DyJi1SWaX6BdAg" -d chat_id="-1001263315920"
success=false;
exit 1;
else
echo -e "Build Succesful!";
success=true;
fi
echo -e "Copying kernel image";
cp -v "${IMAGE}" "${ANYKERNEL}/";
cd -;
cd ${ANYKERNEL};
mv Image.gz-dtb zImage
zip -r9 ${FINAL_ZIP} *;
cd -;
if [ -f "$FINAL_ZIP" ];
then
echo -e "$ZIPNAME zip can be found at $FINAL_ZIP";
if [[ ${success} == true ]]; then
echo -e "Uploading ${ZIPNAME} to https://transfer.sh/";
transfer "${FINAL_ZIP}";
curl -T ${FINAL_ZIP} ftp://VvRRockStar:af5jEgUhyhgI@uploads.androidfilehost.com
echo -e "UPLOAD SUCCESSFUL";
echo -e "Please push the build to AFH Manually";
message="Wolf Kernel - Treble Version."
compatible="AOSP PIE/OREO - Treble ONLY"
time="Build took $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) seconds."
# curl -s -X POST https://api.telegram.org/bot$BOT_API_KEY/sendMessage -d text="$(git log --pretty=format:'%h : %s' -5)" -d chat_id=$CHAT_ID
curl -F chat_id="-1001263315920" -F document=@"${ZIP_DIR}/$ZIPNAME" -F caption="$message $compatible $time" https://api.telegram.org/bot$BOT_API_KEY/sendDocument
curl -s -X POST https://api.telegram.org/bot$BOT_API_KEY/sendMessage -d text="
♔♔♔♔♔♔♔BUILD-DETAILS♔♔♔♔♔♔♔
🖋️ Author : vvrRockStar
🛠️ Make-Type : $MAKE_TYPE
🗒️ Buld-Type : 60Hz
⌚ Build-Time : $time
🗒️ Zip-Name : $ZIPNAME
" -d chat_id="-1001406849717"
# curl -s -X POST https://api.telegram.org/bot$BOT_API_KEY/sendSticker -d sticker="CAADBQADFQADIIRIEhVlVOIt6EkuAgc" -d chat_id=$CHAT_ID
# curl -F document=@$url caption="Latest Build." https://api.telegram.org/bot$BOT_API_KEY/sendDocument -d chat_id=$CHAT_ID
rm -rf ${ZIP_DIR}/${ZIPNAME}
fi
else
echo -e "Zip Creation Failed ";
fi