-
Notifications
You must be signed in to change notification settings - Fork 5
/
travis.sh
161 lines (130 loc) · 4.95 KB
/
travis.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
#!/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=$CHAT_ID
}
if [[ -z ${KERNELDIR} ]]; then
echo -e "Please set KERNELDIR";
exit 1;
fi
export DEVICE=$1;
if [[ -z ${DEVICE} ]]; then
export DEVICE="Santoni";
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.3.1-2018.05-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}/dragontc-8.0/bin/clang"
export CLANG_TRIPLE=aarch64-linux-gnu- \
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}-${DEVICE}-TREBLE-BUILD-$(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="Beta Build Scheduled for $KERNELNAME Kernel (Treble) in Travis CI..." -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="CI build for $KERNELNAME Kernel stopped due to an error" -d chat_id=$CHAT_ID
curl -s -X POST https://api.telegram.org/bot$BOT_API_KEY/sendSticker -d sticker="CAADBQADHwADx8M3DyJi1SWaX6BdAg" -d chat_id=$CHAT_ID
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}";
message="CI build of Wolf Kernel completed with the latest commit."
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="-1001406849717" -F document=@"${ZIP_DIR}/$ZIPNAME" -F caption="$message $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 : New Year Special
⌚ Build-Time : $time
🗒️ Zip-Name : $ZIPNAME
" -d chat_id=$CHAT_ID
# 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