Last active
November 27, 2023 06:49
-
-
Save neilchetty/919fb4b746e6935ec3ba304641a646e4 to your computer and use it in GitHub Desktop.
Kernel Build Script For Realme X7 Max
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 | |
function setup() { | |
ccache -M 50G | |
source ~/.bashrc && source ~/.profile | |
export Image=out/arch/arm64/boot/Image.gz-dtb | |
export DEFCONFIG=k6893v1_64_k419_defconfig | |
export LC_ALL=C && export USE_CCACHE=1 | |
export KBUILD_BUILD_HOST=kernel-build && export KBUILD_BUILD_USER=neil | |
export RANDOM=$(date +%s) && export FILENAME=OSS-KERNEL-CUPIDA-$RANDOM.zip | |
} | |
function clone() { | |
if ! [ -d "clang" ]; then git clone --depth=1 https://gitlab.com/neilchetty/platform_prebuilts_clang_host_linux-x86_clang.git clang ; fi | |
if ! [ -d "assembler" ]; then git clone --depth=1 https://gitlab.com/neilchetty/platform_prebuilts_gas_linux-x86.git assembler ; fi | |
if ! [ -d "AnyKernel" ]; then git clone --depth=1 https://github.com/neilchetty/AnyKernel3.git AnyKernel ; fi | |
} | |
function compile() { | |
[ -d "out" ] || mkdir -p out | |
! [ -d "out" ] || rm -rf $Image | |
make O=out $DEFCONFIG | |
PATH="${PWD}/clang/bin:${PATH}:${PWD}/assembler/:${PATH}" \ | |
make -j$(nproc --all) O=out \ | |
CC=clang \ | |
CROSS_COMPILE=aarch64-linux-gnu- \ | |
CROSS_COMPILE_ARM32=arm-linux-gnueabi- \ | |
LLVM=1 \ | |
LLVM_IAS=1 \ | |
CONFIG_NO_ERROR_ON_MISMATCH=y | |
if ! [ -a $Image ]; | |
then | |
echo "Failed To Compile Kernel" | |
exit | |
else | |
echo "Kernel Compile Successful" | |
fi | |
} | |
function release() { | |
cp $Image AnyKernel/ | |
cd AnyKernel | |
rm *.zip | |
zip -r9 $FILENAME * && upload $FILENAME | |
cd ../ | |
} | |
function upload() { | |
MINPARAMS=1 | |
PDSERVER="https://pixeldrain.com" | |
for FILE in "$@" | |
do | |
FILENAME="${FILE##*/}" | |
echo "Uploading $FILENAME ... " | |
RESPONSE=$(curl -# -F "name=$FILENAME" -F "file=@$FILE" $PDSERVER/api/file) | |
FILEID=$(echo $RESPONSE | grep -Po '(?<="id":")[^"]*') | |
echo "Your file URL: $PDSERVER/u/$FILEID" | |
echo "" | |
done | |
} | |
if [[ $1 = "-s" || $1 = "--setup" ]]; then | |
clone | |
exit | |
fi | |
if [[ $1 = "-c" || $1 = "--clean" ]]; then | |
! [ -d "out" ] || rm -rf out | |
! [ -d "AnyKernel" ] || rm -rf AnyKernel | |
! [ -d "assembler" ] || rm -rf assembler | |
! [ -d "clang" ] || rm -rf clang | |
make mrproper | |
exit | |
fi | |
if [[ $1 = "-r" || $1 = "--regenrate" ]]; then | |
setup | |
make mrproper | |
[ -d "out" ] || mkdir -p out | |
make $DEFCONFIG O=out | |
make savedefconfig O=out | |
cp out/defconfig arch/arm64/configs/$DEFCONFIG | |
exit | |
fi | |
setup | |
compile | |
release |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment