Build GKI #38
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
name: Build GKI | |
on: | |
workflow_dispatch: | |
inputs: | |
KSU: | |
description: "KSU?" | |
required: true | |
default: "true" | |
type: boolean | |
SUSFS: | |
description: "SUSFS?" | |
required: true | |
default: "true" | |
type: boolean | |
jobs: | |
build: | |
name: Build GKI by ${{ github.actor }} | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Check out | |
uses: actions/checkout@v4 | |
- name: Read the configuration | |
run: | | |
CONFIG_ENV=$GITHUB_WORKSPACE/config.properties.gki_12510 | |
grep -v '^#' "$CONFIG_ENV" | grep '=' | while IFS= read -r line; do | |
key=$(echo "$line" | cut -d'=' -f1) | |
value=$(echo "$line" | cut -d'=' -f2-) | |
echo "$key=$value" >> $GITHUB_ENV | |
done | |
- name: Setting up the kernel compilation environment | |
run: | | |
echo "BUILD_TIME=$(TZ=Asia/Makassar date "+%Y%m%d-%H%M")" >> $GITHUB_ENV | |
sudo apt update | |
sudo apt install -y git ccache automake flex lzop bison gperf build-essential zip curl zlib1g-dev g++-multilib libxml2-utils bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush schedtool dpkg-dev liblz4-tool make optipng maven libssl-dev pwgen libswitch-perl policycoreutils minicom libxml-sax-base-perl libxml-simple-perl bc libc6-dev-i386 lib32ncurses5-dev libx11-dev lib32z-dev libgl1-mesa-dev xsltproc unzip device-tree-compiler python2 rename libelf-dev dwarves zstd | |
sudo apt list --upgradable | |
sudo apt upgrade | |
mkdir -p $GITHUB_WORKSPACE/kernel_workspace | |
chmod +x $GITHUB_WORKSPACE/*.sh | |
- name: Set Swap | |
uses: pierotofy/set-swap-space@master | |
with: | |
swap-size-gb: 12 | |
- name: Download AOSP Clang | |
if: env.USE_AOSP_CLANG == 'true' && env.USE_CUSTOM_CLANG == 'false' | |
run: | | |
cd $GITHUB_WORKSPACE/kernel_workspace | |
mkdir clang | |
wget https://android.googlesource.com/platform/prebuilts/clang/host/${{ env.AOSP_CLANG_SYSTEM }}/+archive/refs/heads/${{ env.AOSP_CLANG_BRANCH }}/clang-${{ env.AOSP_CLANG_VERSION }}.tar.gz | |
tar -C clang/ -zxf clang-${{ env.AOSP_CLANG_VERSION }}.tar.gz | |
rm -rf clang-${{ env.AOSP_CLANG_VERSION }}.tar.gz | |
- name: Download Custom Clang | |
if: env.USE_AOSP_CLANG == 'false' && env.USE_CUSTOM_CLANG == 'true' | |
run: | | |
cd $GITHUB_WORKSPACE/kernel_workspace | |
if [[ ${{ env.CUSTOM_CLANG_SOURCE }} =~ git ]]; then | |
if [[ ${{ env.CUSTOM_CLANG_SOURCE }} == *'.tar.'* ]]; then | |
wget ${{ env.CUSTOM_CLANG_SOURCE }} | |
mkdir clang | |
tar -C clang/ -xf *.tar.* | |
rm -f *.tar.* | |
else | |
git clone ${{ env.CUSTOM_CLANG_SOURCE }} -b ${{ env.CUSTOM_CLANG_BRANCH }} clang --depth=1 | |
fi | |
else | |
if [[ -n "${{ env.CUSTOM_CLANG_COMMAND }}" ]]; then | |
bash -c "${{ env.CUSTOM_CLANG_COMMAND }}" | |
else | |
echo "[ERROR] You must specify CUSTOM_CLANG_COMMAND in config file!" | |
exit 1 | |
fi | |
fi | |
- name: Download AOSP GCC | |
if: env.USE_CUSTOM_GCC_64 == 'false' && env.USE_CUSTOM_GCC_32 == 'false' && env.ENABLE_AOSP_GCC_ARM64 == 'true' || env.ENABLE_AOSP_GCC_ARM32 == 'true' | |
run: | | |
cd $GITHUB_WORKSPACE/kernel_workspace | |
if [ ${{ env.ENABLE_AOSP_GCC_ARM64 }} = true ]; then | |
mkdir gcc-64 | |
wget https://android.googlesource.com/platform/prebuilts/gcc/${{ env.AOSP_GCC_SYSTEM }}/aarch64/${{ env.AOSP_GCC_ARM64_VERSION }}/+archive/refs/tags/android-${{ env.AOSP_GCC_ANDROID_VERSION }}_${{ env.AOSP_GCC_RELEASE }}.tar.gz | |
tar -C ./gcc-64/ -zxf *.tar.gz | |
echo "GCC_64=CROSS_COMPILE=$GITHUB_WORKSPACE/kernel_workspace/gcc-64/bin/aarch64-linux-android-" >> $GITHUB_ENV | |
fi | |
if [ ${{ env.ENABLE_AOSP_GCC_ARM32 }} = true ]; then | |
mkdir gcc-32 | |
wget https://android.googlesource.com/platform/prebuilts/gcc/${{ env.AOSP_GCC_SYSTEM }}/arm/${{ env.AOSP_GCC_ARM32_VERSION }}/+archive/refs/tags/android-${{ env.AOSP_GCC_ANDROID_VERSION }}_${{ env.AOSP_GCC_RELEASE }}.tar.gz | |
tar -C ./gcc-32/ -zxf *.tar.gz | |
echo "GCC_32=CROSS_COMPILE_ARM32=$GITHUB_WORKSPACE/kernel_workspace/gcc-32/bin/arm-linux-androideabi-" >> $GITHUB_ENV | |
fi | |
rm -f *.tar.gz | |
- name: Download Custom Gcc | |
if: env.USE_CUSTOM_GCC_64 == 'true' || env.USE_CUSTOM_GCC_32 == 'true' && env.ENABLE_AOSP_GCC_ARM32 == 'false' && env.ENABLE_AOSP_GCC_ARM64 == 'false' | |
run: | | |
cd $GITHUB_WORKSPACE/kernel_workspace | |
if [ ${{ env.USE_CUSTOM_GCC_64 }} = true ]; then | |
if [[ ${{ env.CUSTOM_GCC_64_SOURCE }} =~ git ]]; then | |
if [[ ${{ env.CUSTOM_GCC_64_SOURCE }} == *'.tar.'* ]]; then | |
wget ${{ env.CUSTOM_CLANG_SOURCE }} | |
mkdir gcc-64 | |
tar -C gcc-64/ -xf *.tar.* | |
else | |
git clone ${{ env.CUSTOM_GCC_64_SOURCE }} -b ${{ env.CUSTOM_GCC_64_BRANCH }} gcc-64 --depth=1 | |
fi | |
else | |
wget -O gcc-64.zip ${{ env.CUSTOM_GCC_64_SOURCE }} | |
mkdir gcc-64 | |
unzip gcc-64.zip -d gcc-64/ | |
fi | |
echo "GCC_64=CROSS_COMPILE=$GITHUB_WORKSPACE/kernel_workspace/gcc-64/bin/${{ env.CUSTOM_GCC_64_BIN }}" >> $GITHUB_ENV | |
fi | |
if [ ${{ env.USE_CUSTOM_GCC_32 }} = true ]; then | |
if [[ ${{ env.CUSTOM_GCC_32_SOURCE }} =~ git ]]; then | |
if [[ ${{ env.CUSTOM_GCC_32_SOURCE }} == *'.tar.'* ]]; then | |
wget ${{ env.CUSTOM_CLANG_SOURCE }} | |
mkdir gcc-32 | |
tar -C gcc-32/ -xf *.tar.* | |
else | |
git clone ${{ env.CUSTOM_GCC_32_SOURCE }} -b ${{ env.CUSTOM_GCC_32_BRANCH }} gcc-32 --depth=1 | |
fi | |
else | |
wget -O gcc-32.zip ${{ env.CUSTOM_GCC_32_SOURCE }} | |
mkdir gcc-32 | |
unzip gcc-32.zip -d gcc-32/ | |
fi | |
echo "GCC_32=CROSS_COMPILE_ARM32=$GITHUB_WORKSPACE/kernel_workspace/gcc-32/bin/${{ env.CUSTOM_GCC_32_BIN }}" >> $GITHUB_ENV | |
fi | |
rm -f *.tar.* | |
rm -f *.zip | |
- name: Download the kernel source code | |
run: | | |
cd $GITHUB_WORKSPACE/kernel_workspace | |
git clone ${{ env.KERNEL_SOURCE }} -b ${{ env.KERNEL_SOURCE_BRANCH }} android-kernel --depth=1 | |
cd $GITHUB_WORKSPACE/kernel_workspace/android-kernel | |
echo "KVER=$(make kernelversion 2>/dev/null)" >> $GITHUB_ENV | |
- name: Download the AnyKernel | |
run: | | |
git clone --depth=1 ${{ env.ANYKERNEL_REPO }} -b ${{ env.ANYKERNEL_BRANCH }} $GITHUB_WORKSPACE/kernel_workspace/anykernel | |
- name: Setup KernelSU | |
if: inputs.KSU == true | |
run: | | |
cd $GITHUB_WORKSPACE/kernel_workspace/android-kernel | |
curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash - | |
echo "ZIP_NAME=$(echo "${{ env.ZIP_NAME }}" | sed "s/OPTION1/KSU/g")" >> $GITHUB_ENV | |
- name: Setup SUSFS for KSU | |
if: inputs.KSU == true && inputs.SUSFS == true | |
run: | | |
cd $GITHUB_WORKSPACE/kernel_workspace | |
git clone --depth=1 "https://gitlab.com/simonpunk/susfs4ksu" -b "gki-android12-5.10" | |
SUSFS_PATCHES="$GITHUB_WORKSPACE/kernel_workspace/susfs4ksu/kernel_patches" | |
SUSFS_MODULE="$GITHUB_WORKSPACE/kernel_workspace/susfs4ksu/ksu_module_susfs" | |
cd "$GITHUB_WORKSPACE/kernel_workspace/android-kernel" | |
cp "$SUSFS_PATCHES/50_add_susfs_in_gki-android12-5.10.patch" . | |
cp "$SUSFS_PATCHES/fs/susfs.c" ./fs/ | |
cp "$SUSFS_PATCHES/include/linux/susfs.h" ./include/linux/ | |
cp "$SUSFS_PATCHES/fs/sus_su.c" ./fs/ | |
cp "$SUSFS_PATCHES/include/linux/sus_su.h" ./include/linux/ | |
cd "$GITHUB_WORKSPACE/kernel_workspace/android-kernel/KernelSU" | |
cp "$SUSFS_PATCHES/KernelSU/10_enable_susfs_for_ksu.patch" . | |
patch -p1 <10_enable_susfs_for_ksu.patch || exit 1 | |
cd "$GITHUB_WORKSPACE/kernel_workspace/android-kernel" | |
patch -p1 <50_add_susfs_in_gki-android12-5.10.patch || exit 1 | |
echo "SUSFS_MODULE=$GITHUB_WORKSPACE/kernel_workspace/susfs4ksu/ksu_module_susfs" >> $GITHUB_ENV | |
echo "SUSFS_MODULE_ZIP=ksu_module_susfs.zip" >> $GITHUB_ENV | |
echo "ZIP_NAME=$(echo "${{ env.ZIP_NAME }}" | sed "s/KSU/KSUxSUSFS/g")" >> $GITHUB_ENV | |
- name: Build kernel | |
run: | | |
cd $GITHUB_WORKSPACE/kernel_workspace/android-kernel | |
export PATH="$GITHUB_WORKSPACE/kernel_workspace/clang/bin:$GITHUB_WORKSPACE/kernel_workspace/gcc-64/bin:$GITHUB_WORKSPACE/kernel_workspace/gcc-32/bin:$PATH" | |
export KBUILD_BUILD_HOST=gacorprjkt | |
export KBUILD_BUILD_USER=${{ github.actor }} | |
make -j$(nproc --all) CC=clang O=out ARCH=${{ env.ARCH }} ${{ env.TC_CUSTOM_CMDS }} ${{ env.EXTRA_CMDS }} ${{ env.GCC_64 }} ${{ env.GCC_32 }} ${{ env.KERNEL_CONFIG }} | |
make -j$(nproc --all) CC=clang O=out ARCH=${{ env.ARCH }} ${{ env.TC_CUSTOM_CMDS }} ${{ env.EXTRA_CMDS }} ${{ env.GCC_64 }} ${{ env.GCC_32 }} 2>&1 | tee $GITHUB_WORKSPACE/kernel_workspace/build.log | |
- name: Checking the kernel compilation product | |
run: | | |
cd $GITHUB_WORKSPACE/kernel_workspace | |
if [ ! -f android-kernel/out/arch/${{ env.ARCH }}/boot/${{ env.KERNEL_IMAGE_NAME }} ]; then | |
export TOKEN="${{ secrets.TOKEN }}" | |
export CHAT_ID="${{ secrets.CHAT_ID }}" | |
$GITHUB_WORKSPACE/upload_to_tg.sh "$GITHUB_WORKSPACE/kernel_workspace/build.log" | |
exit 1 | |
fi | |
- name: Replace Placeholder | |
run: | | |
set -x | |
if [[ "${{ inputs.KSU }}" == "false" ]]; then | |
echo "ZIP_NAME=$(echo "${{ env.ZIP_NAME }}" | sed "s/OPTION1-//g")" >> $GITHUB_ENV | |
fi | |
echo "ZIP_NAME=$(echo "${{ env.ZIP_NAME }}" | sed "s/OPTION2/${{ env.BUILD_TIME }}/g; s/KVER/${{ env.KVER }}/g")" >> $GITHUB_ENV | |
cd $GITHUB_WORKSPACE/kernel_workspace/anykernel | |
sed -i "s/DUMMY1/${{ env.KVER }}/g" anykernel.sh | |
if [[ "${{ inputs.KSU }}" == "false" ]]; then | |
sed -i "s/KSUDUMMY2 //g" anykernel.sh | |
elif [[ "${{ inputs.SUSFS }}" == "true" ]]; then | |
sed -i "s/DUMMY2/xSUSFS/g" anykernel.sh | |
elif [[ "${{ inputs.SUSFS }}" == "false" ]]; then | |
sed -i "s/DUMMY2//g" anykernel.sh | |
fi | |
sed -i "s/DUMMY3/${{ env.BUILD_TIME }}/g" anykernel.sh | |
set +x | |
- name: Zipping Kernel | |
run: | | |
set -x | |
cp $GITHUB_WORKSPACE/kernel_workspace/android-kernel/out/arch/${{ env.ARCH }}/boot/${{ env.KERNEL_IMAGE_NAME }} $GITHUB_WORKSPACE/kernel_workspace/anykernel | |
cd $GITHUB_WORKSPACE/kernel_workspace/anykernel | |
zip -r9 "${{ env.ZIP_NAME }}" * -x LICENSE | |
mv "${{ env.ZIP_NAME }}" $GITHUB_WORKSPACE/kernel_workspace | |
set +x | |
- name: Zipping SUSFS module | |
if: inputs.SUSFS == true && inputs.KSU == true | |
run: | | |
cd ${{ env.SUSFS_MODULE }} | |
zip -r9 ${{ env.SUSFS_MODULE_ZIP }} * | |
mv ${{ env.SUSFS_MODULE_ZIP }} $GITHUB_WORKSPACE/kernel_workspace | |
- name: Upload to Telegram (Kernel) | |
run: | | |
ls -lh $GITHUB_WORKSPACE/kernel_workspace | |
export TOKEN="${{ secrets.TOKEN }}" | |
export CHAT_ID="${{ secrets.CHAT_ID }}" | |
$GITHUB_WORKSPACE/upload_to_tg.sh "$GITHUB_WORKSPACE/kernel_workspace/${{ env.ZIP_NAME }}" | |
$GITHUB_WORKSPACE/upload_to_tg.sh "$GITHUB_WORKSPACE/kernel_workspace/build.log" | |
- name: Upload to Telegram (susfs module) | |
if: inputs.SUSFS == true && inputs.KSU == true | |
run: | | |
export TOKEN="${{ secrets.TOKEN }}" | |
export CHAT_ID="${{ secrets.CHAT_ID }}" | |
$GITHUB_WORKSPACE/upload_to_tg.sh "$GITHUB_WORKSPACE/kernel_workspace/${{ env.SUSFS_MODULE_ZIP }}" |