Last active
July 11, 2021 15:04
-
-
Save rama982/ce23f44d9d92940d601aa7f33a2d2318 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# kernel build script (kanged from somewhere i forgot) | |
# fill the vars yourself | |
DEFCONFIG=lancelot_defconfig | |
AK=https://github.com/rama982/AnyKernel3 | |
ZIPNAME="Genom-OSS-lancelot-BETA" | |
# telegram env | |
ID=-1001459070028 | |
TOKEN=$1 | |
echo "Prepare dependencies" | |
mkdir /root/clang-llvm | |
mkdir /root/gcc64-aosp | |
mkdir /root/gcc32-aosp | |
wget https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+archive/refs/heads/master/clang-r383902.tar.gz | |
tar -C /root/clang-llvm/ -zxvf clang-r383902.tar.gz | |
wget https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/+archive/refs/tags/android-11.0.0_r35.tar.gz | |
tar -C /root/gcc64-aosp/ -zxvf android-11.0.0_r35.tar.gz | |
wget http://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/+archive/refs/tags/android-11.0.0_r34.tar.gz | |
tar -C /root/gcc32-aosp/ -zxvf android-11.0.0_r34.tar.gz | |
git clone $AK --depth=1 /root/AnyKernel | |
echo "Done" | |
export TZ="Asia/Jakarta" | |
KERNEL_DIR=$(pwd) | |
IMAGE="/root/arch/arm64/boot/Image.gz-dtb" | |
TANGGAL=$(date +"%Y%m%d-%H") | |
BRANCH="$(git rev-parse --abbrev-ref HEAD)" | |
PATH="/root/clang-llvm/bin:/root/gcc-aosp/bin:${PATH}" | |
export KBUILD_COMPILER_STRING="$(/root/clang-llvm/bin/clang --version | head -n 1 | perl -pe 's/\(http.*?\)//gs' | sed -e 's/ */ /g')" | |
export ARCH=arm64 | |
export KBUILD_BUILD_USER=rama982 | |
make O=/root ARCH=arm64 $DEFCONFIG | |
# Compile plox | |
compile() { | |
make -j$(nproc) O=/root \ | |
ARCH=arm64 \ | |
CC=clang \ | |
CLANG_TRIPLE=aarch64-linux-gnu- \ | |
CROSS_COMPILE=aarch64-linux-android- | |
} | |
ls /root/arch/arm64/boot | |
ls /root/AnyKernel/ | |
# Zipping | |
zipping() { | |
cd /root/AnyKernel || exit 1 | |
rm *.zip *-dtb *dtbo.img | |
cp /root/arch/arm64/boot/Image.gz-dtb . | |
cp /root/arch/arm64/boot/dtbo.img . | |
zip -r9 $ZIPNAME-${TANGGAL}.zip * | |
cd - | |
} | |
function start() { | |
curl -s -X POST "https://api.telegram.org/bot$TOKEN/sendMessage" \ | |
-d chat_id="$ID" \ | |
-d "disable_web_page_preview=true" \ | |
-d "parse_mode=html" \ | |
-d text="Build started on $(date) with $KBUILD_COMPILER_STRING" | |
} | |
# Push kernel to channel | |
function push() { | |
cd /root/AnyKernel | |
ZIP=$(echo *.zip) | |
curl -F document=@$ZIP "https://api.telegram.org/bot$TOKEN/sendDocument" \ | |
-F chat_id="$ID" \ | |
-F "disable_web_page_preview=true" \ | |
-F "parse_mode=html" \ | |
-F caption="OSS Kernel | Build finished on $(date)" | |
} | |
# Fin Error | |
function finerr() { | |
curl -s -X POST "https://api.telegram.org/bot$TOKEN/sendMessage" \ | |
-d chat_id="$ID" \ | |
-d "disable_web_page_preview=true" \ | |
-d "parse_mode=markdown" \ | |
-d text="Build throw an error(s)" | |
exit 1 | |
} | |
start | |
compile | |
zipping | |
if [[ -f /root/AnyKernel/Image.gz-dtb ]]; then | |
push | |
else | |
finerr | |
fi | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment