-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathbuild
executable file
·55 lines (41 loc) · 1.79 KB
/
build
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
#!/bin/sh
set -e -x
WORK="${HOME}/work"
KERNEL_SRC="${WORK}/kernel-msm"
CLANG_TAR_URL="https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+archive/refs/heads/android11-release/clang-r383902.tar.gz"
BINUTILS_GIT="https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9"
BINUTILS_32_GIT="https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9"
KERNEL_SOURCE_URL="https://github.com/thecatvoid/android_kernel_motorola_guamp"
ANYKERNEL_GIT="https://github.com/thecatvoid/AnyKernel3.git"
mkdir -p "${WORK}"
cd "${WORK}" || exit 1
# Setup stuff
if [ ! -d clang ]; then mkdir clang && curl -Lsq "${CLANG_TAR_URL}" -o clang.tgz && tar -xzf clang.tgz -C clang; fi
[ ! -d binutils ] && git clone --depth=1 "${BINUTILS_GIT}" -b android11-release binutils
[ ! -d binutils-32 ] && git clone --depth=1 "${BINUTILS_32_GIT}" -b android11-release binutils-32
[ ! -d kernel-msm ] && git clone --depth=1 "${KERNEL_SOURCE_URL}" kernel-msm
# Set toolchain path
PATH="${WORK}/clang/bin:${WORK}/binutils/bin:${WORK}/binutils-32/bin:/bin"
# Build kernel
cd "${KERNEL_SRC}" || exit 1
# Android cross compile make function
make_fun() {
make O=out ARCH=arm64 \
CC=clang HOSTCC=clang \
CLANG_TRIPLE=aarch64-linux-gnu- \
CROSS_COMPILE=aarch64-linux-android- \
CROSS_COMPILE_ARM32=arm-linux-androideabi- "$@"
}
# Make defconfig
make_fun vendor/guamp_defconfig
# Make kernel
make_fun -j"$(nproc --all)" || make_fun -j1
# Upload built kernel
cd "${WORK}" || exit
[ ! -d ANY ] && git clone --depth=1 "${ANYKERNEL_GIT}" ANY
cd ANY || exit 1
rm -rf ./*Image* ./*.zip
cp "${KERNEL_SRC}/out/arch/arm64/boot/Image.gz-dtb" ./
dates="$(date +%F+%T%z)"
zip -r9 "${dates}.zip" ./* -x .git README.md ./*placeholder
curl -T "${dates}.zip" temp.sh