Skip to content

Instantly share code, notes, and snippets.

@Yttehs-HDX
Last active June 1, 2024 12:57
Show Gist options
  • Save Yttehs-HDX/e90672dbb846a109c7173f9b8bdceebd to your computer and use it in GitHub Desktop.
Save Yttehs-HDX/e90672dbb846a109c7173f9b8bdceebd to your computer and use it in GitHub Desktop.
Universal Android Kernel Building Script
#!/bin/bash
# _ _ _ _ _ _
# / \ _ __ __| |_ __ ___ (_) __| | | | _____ _ __ _ __ ___| |
# / _ \ | '_ \ / _` | '__/ _ \| |/ _` | | |/ / _ \ '__| '_ \ / _ \ |
# / ___ \| | | | (_| | | | (_) | | (_| | | < __/ | | | | | __/ |
# /_/ \_\_| |_|\__,_|_| \___/|_|\__,_| |_|\_\___|_| |_| |_|\___|_|
# +---------------------------------+
# | Build script for Android kernel |
# | Author: Yttehs-HDX@Github |
# +---------------------------------+
# kernel
DEFCONFIG="defconfig"
O="out"
ARCH="arm64"
# clang
# 
# ├──  kernel_root
# └──  toolchains
CLANG_VERSION="17"
CLANG_PATH="$(pwd)/../toolchains/zyc-${CLANG_VERSION}"
PATH="$PATH:${CLANG_PATH}/bin"
GREEN="\033[0;32m"
BLUE="\033[0;34m"
YELLOW="\033[0;33m"
RED="\033[0;31m"
RESET="\033[0m"
# clean environment
echo -e "${YELLOW}-> make mrproper ...${RESET}"
rm -rf $O
make mrproper
# build kernel
echo -e "${YELLOW}-> make ${DEFCONFIG} ...${RESET}"
make O=$O ARCH=$ARCH $DEFCONFIG
echo -e "${BLUE}=> CLANG_PATH = ${CLANG_PATH}${RESET}"
echo -e "${YELLOW}-> make ...${RESET}"
make -j$(nproc --all) O=$O \
ARCH=$ARCH \
CC=clang \
CLANG_TRIPLE=aarch64-linux-gnu- \
CROSS_COMPILE=aarch64-linux-gnu- \
CROSS_COMPILE_ARM32=arm-linux-gnueabi
#!/bin/bash
# _ _ __ _ _____
# / \ _ __ _ _| |/ /___ _ __ _ __ ___| |___ /
# / _ \ | '_ \| | | | ' // _ \ '__| '_ \ / _ \ | |_ \
# / ___ \| | | | |_| | . \ __/ | | | | | __/ |___) |
# /_/ \_\_| |_|\__, |_|\_\___|_| |_| |_|\___|_|____/
# |___/
# +--------------------------+
# | AnyKernel3 pakage script |
# +--------------------------+
VERSION_CODE="v1.0"
O="out"
FILES=("Image.gz-dtb")
YELLOW='\033[1;33m'
GREEN='\033[1;32m'
BLUE='\033[1;34m'
RESET='\033[0m'
# clone AnyKernel3
if ! [ -d AnyKernel3 ]; then
echo -e "${YELLOW}=> Clone AnyKernel3 ...${RESET}"
git clone https://github.com/osm0sis/AnyKernel3.git --depth=1
fi
# copy files
for file in $FILES; do
cp $O/arch/arm64/boot/${file} AnyKernel3/
echo -e "${YELLOW}-> Copy ${file}${RESET}"
done
# zip files
cd AnyKernel3/
zip -r9 "Kernel-polaris-lineageOS-${VERSION_CODE}-$(date +%Y-%m-%d-%H_%M).zip" * -x .git README.md LICENCE *.zip
@Yttehs-HDX
Copy link
Author

Yttehs-HDX commented Apr 20, 2024

Usage

  • Modify the scripts to suit your kernel.

For Build

mv build.sh /path/to/kernel/root
chmod +x build.sh
./build.sh

For Pakage

mv pack.sh /path/to/kernel/root
chmod +x pack.sh
./pack.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment