-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkernel-build.sh
executable file
·64 lines (55 loc) · 1.97 KB
/
kernel-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
#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (C) 2018 Raphiel Rollerscaperers (raphielscape)
# Copyright (C) 2018 Rama Bondan Prakoso (rama982)
# Android Kernel Build Script
# Add Depedency
#apt-get -y install bc build-essential zip curl libstdc++6 git default-jre default-jdk wget nano python-is-python3 gcc clang libssl-dev rsync flex bison && pip3 install telegram-send
# Clean Before Build
make clean && make mrproper
# Main environtment
KERNEL_DIR=$PWD
KERN_IMG=$KERNEL_DIR/out/arch/arm64/boot/Image.gz-dtb
ZIP_DIR=$KERNEL_DIR/AnyKernel3
CONFIG=onclite-perf_defconfig
CROSS_COMPILE="aarch64-linux-gnu-"
CROSS_COMPILE_ARM32="arm-linux-gnueabi-"
PATH=:"${KERNEL_DIR}/proton-clang/bin:${PATH}:${KERNEL_DIR}/stock/bin:${PATH}:${KERNEL_DIR}/stock_32/bin:${PATH}"
# Export
export ARCH=arm64
export CROSS_COMPILE
export CROSS_COMPILE_ARM32
# Build start
START=$(date +%s)
make O=out $CONFIG
make -j$(nproc --all) O=out \
ARCH=arm64 \
CC=clang \
CLANG_TRIPLE=aarch64-linux-gnu- \
CROSS_COMPILE=aarch64-linux-android-
if ! [ -a $KERN_IMG ]; then
echo "Build error!"
exit 1
fi
cd $ZIP_DIR
make clean &>/dev/null
cd ..
# For MIUI Build
# Credit Adek Maulana <[email protected]>
OUTDIR="$KERNEL_DIR/out/"
VENDOR_MODULEDIR="$KERNEL_DIR/AnyKernel3/modules/vendor/lib/modules"
STRIP="$KERNEL_DIR/stock/bin/$(echo "$(find "$KERNEL_DIR/stock/bin" -type f -name "aarch64-*-gcc")" | awk -F '/' '{print $NF}' |\
sed -e 's/gcc/strip/')"
for MODULES in $(find "${OUTDIR}" -name '*.ko'); do
"${STRIP}" --strip-unneeded --strip-debug "${MODULES}"
"${OUTDIR}"/scripts/sign-file sha512 \
"${OUTDIR}/certs/signing_key.pem" \
"${OUTDIR}/certs/signing_key.x509" \
"${MODULES}"
find "${OUTDIR}" -name '*.ko' -exec cp {} "${VENDOR_MODULEDIR}" \;
done
echo -e "\n(i) Done moving modules"
cd $ZIP_DIR
cp $KERN_IMG zImage
make normal &>/dev/null
echo "Flashable zip generated under $ZIP_DIR."