forked from Sakurajima07/kernel_builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·72 lines (63 loc) · 2.51 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·72 lines (63 loc) · 2.51 KB
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
#!/bin/bash
#
# idk lmao
export maindir="$(pwd)"
export outside="${maindir}/.."
source "${outside}/$2env"
[ -z "$NJOBS" ] && export NJOBS=$(nproc --all) || :
pack() {
if [ ! -d ${zipper} ]; then
git clone ${zipper_repo} -b ${zipper_branch} "${zipper}" --single-branch --depth=1
cd "${zipper}" || exit 1
else
cd "${zipper}" || exit 1
git reset --hard
git checkout ${zipper_branch}
git fetch origin ${zipper_branch}
git reset --hard origin/${zipper_branch}
fi
cp -af "${out_image}" "${zipper}"
cp -af "${out_dtb}" "${zipper}/dtb"
find "${maindir}/out" -name '*.ko' > module_list.txt
xargs -d '\n' cp -v -t "${zipper}/modules/system/lib/modules/" < module_list.txt
[ -n "${out_dtbo}" ] && cp -af "${out_dtbo}" "${zipper}/dtbo.img"
if [ -e ${maindir}/banner_append ]; then
cat ${maindir}/banner_append >> ${zipper}/banner
if grep KernelSU ${maindir}/banner_append ; then
sed -i 's/do.skipmagisk=0/do.skipmagisk=1/g' ${zipper}/anykernel.sh || :
fi
fi
zip -r9 "$1" ./* -x .git README.md ./*placeholder
if apksigner version && [ -f "$SIGN_PK8" ] && [ -f "$SIGN_PEM" ] ; then
apksigner sign --min-sdk-version 30 --key "$SIGN_PK8" --cert "$SIGN_PEM" "$1" && SIGNED=1
fi
rm -f ${maindir}/banner_append "${out_image}"
cd "${maindir}"
}
# build
for toolchain in $1; do
#rm -rf out
bash -x "${outside}/toolchains/${toolchain}.sh" setup
BUILD_START=$(date +"%s")
export CUR_TOOLCHAIN="${toolchain}"
bash -x "${outside}/toolchains/${toolchain}.sh" build ${defconfig} || exit 1
if [ -e "${out_image}" ]; then
BUILD_END=$(date +"%s")
DIFF=$((BUILD_END - BUILD_START))
pack ${zip_name}
echo "build succeeded in $((DIFF / 60))m, $((DIFF % 60))s" > "${zip_name}.info"
echo "md5: <code>$(md5sum "${zip_name}" | cut -d' ' -f1)</code>" >> "${zip_name}.info"
echo "compiler: $(cat ${toolchain}.info)" >> "${zip_name}.info"
if [ "$SIGNED" = "1" ] ; then
echo "signed by <code>apksigner sign --min-sdk-version 30 --key $SIGN_PK8 --cert $SIGN_PEM</code>" >> "${zip_name}.info"
fi
echo "build succeeded in $((DIFF / 60))m, $((DIFF % 60))s" > "${toolchain}.log.info"
echo "ak3 zip file: <code>${zip_name}</code>" >> "${toolchain}.log.info"
echo "compiler: $(cat ${toolchain}.info)" >> "${toolchain}.log.info"
else
BUILD_END=$(date +"%s")
DIFF=$((BUILD_END - BUILD_START))
echo "build failed in $((DIFF / 60))m, $((DIFF % 60))s" > "${toolchain}.log.info"
echo "compiler: $(cat ${toolchain}.info)" >> "${toolchain}.log.info"
fi
done