Skip to content

Instantly share code, notes, and snippets.

@archie9211
Created July 4, 2019 14:09
Show Gist options
  • Save archie9211/c16799985803ec75e05b8d80484a3d1b to your computer and use it in GitHub Desktop.
Save archie9211/c16799985803ec75e05b8d80484a3d1b to your computer and use it in GitHub Desktop.
#! /bin/sh
#Kernel building script
function colors {
blue='\033[0;34m' cyan='\033[0;36m'
yellow='\033[0;33m'
red='\033[0;31m'
nocol='\033[0m'
}
colors;
function exports {
export KBUILD_BUILD_USER="archie"
export KBUILD_BUILD_HOST="hyperbeast"
export ARCH=arm64
export SUBARCH=arm64
export GROUP_ID="373574748"
#export GROUP_ID="-1001448043641"
export KBUILD_COMPILER_STRING=$(/home/semaphore/clang/bin/clang --version | head -n 1 | perl -pe 's/\(http.*?\)//gs' | sed -e 's/ */ /g' -e 's/[[:space:]]*$//')
}
function tg_post_msg {
curl -s -X POST "$BOT_MSG_URL" -d chat_id="$2" -d text="$1"
}
function tg_post_build {
curl -F chat_id="$2" -F document=@"$1" $BOT_BUILD_URL
}
function build_kernel {
checkout
KERNEL_DIR=$PWD
make chef_defconfig O=out
BUILD_START=$(date +"%s")
tg_post_msg "★★ Build Started on $(uname) $(uname -r) with $KBUILD_COMPILER_STRING ★★" "$GROUP_ID"
make -j8 O=out \
CC=/home/semaphore/clang/bin/clang \
CLANG_TRIPLE=aarch64-linux-gnu- \
CROSS_COMPILE=/home/semaphore/linaro/bin/aarch64-linux-android- 2>&1 | tee logcat.txt
#CROSS_COMPILE=/home/archie/datadisk/aarch64-linux-android-4.9/bin/aarch64-linux-android- 2>&1 | tee logcat.txt
BUILD_END=$(date +"%s")
BUILD_TIME=$(date +"%Y%m%d-%T")
DIFF=$(($BUILD_END - $BUILD_START))
}
function check_img {
if [ -f $KERNEL_DIR/out/arch/arm64/boot/Image.gz-dtb ]
then
echo -e "Kernel Built Successfully in $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) seconds..!!"
tg_post_msg "👍👍Kernel Built Successfully in $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) seconds..!!" "$GROUP_ID"
gen_changelog
gen_zip
else
echo -e "Kernel failed to compile after $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) seconds..!!"
tg_post_msg "☠☠Kernel failed to compile after $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) seconds..!!" "$GROUP_ID"
tg_post_build "logcat.txt" "$GROUP_ID"
fi
}
function gen_changelog {
tg_post_msg "★★ ChangeLog --
$(git log --oneline --decorate --color --pretty=%s --first-parent -19)" "$GROUP_ID"
}
function gen_zip {
if [ -f $KERNEL_DIR/out/arch/arm64/boot/Image.gz-dtb ]
then
echo "Zipping Files.."
mv $KERNEL_DIR/out/arch/arm64/boot/Image.gz-dtb anykernel/Image.gz-dtb
cd anykernel
zip -r9 DarkOne-chef-$BUILD_TIME * -x .git README.md
tg_post_build "DarkOne-chef-$BUILD_TIME.zip" "$GROUP_ID"
cd ..
fi
}
exports
build_kernel
check_img
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment