Skip to content

Build Kernel - Mi 11 Ultra (WildKSU) #44

Build Kernel - Mi 11 Ultra (WildKSU)

Build Kernel - Mi 11 Ultra (WildKSU) #44

name: Build Kernel - Mi 11 Ultra (WildKSU)
on:
workflow_dispatch:
inputs:
KERNEL_SOURCE:
description: 'Kernel source repo'
required: true
default: 'palazik/kernel_xiaomi_mars'
KERNEL_BRANCH:
description: 'Kernel source branch'
required: true
default: 'twelve'
SELINUX_MODE:
description: 'SELinux mode'
required: true
default: 'enforcing'
type: choice
options:
- 'enforcing'
- 'permissive'
DISABLE_REAR_DISPLAY:
description: 'Disable rear display'
required: true
default: 'true'
type: choice
options:
- 'true'
- 'false'
jobs:
build:
runs-on: ubuntu-latest
env:
ARCH: arm64
TC_DIR: ${{ github.workspace }}/toolchain
KERNEL_DIR: ${{ github.workspace }}/kernel
OUT_DIR: ${{ github.workspace }}/out
ANYKERNEL_DIR: ${{ github.workspace }}/anykernel
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Swap (16GB)
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 16
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y --no-install-recommends \
bc bison build-essential curl flex git gnupg \
libelf-dev libssl-dev lld llvm make python3 \
tar perl lz4 jq zip unzip wget
- name: Clone Clang (v15)
run: |
mkdir -p $TC_DIR
CLANG_URL=$(curl -s https://raw.githubusercontent.com/ZyCromerZ/Clang/main/Clang-15-link.txt)
wget -q "$CLANG_URL" -O $TC_DIR/clang.tar.gz
tar -xf $TC_DIR/clang.tar.gz -C $TC_DIR
echo "$TC_DIR/bin" >> $GITHUB_PATH
- name: Clone Source
run: |
git clone --depth=1 -b ${{ github.event.inputs.KERNEL_BRANCH }} \
https://github.com/${{ github.event.inputs.KERNEL_SOURCE }}.git $KERNEL_DIR
- name: Detect Defconfig
working-directory: ${{ env.KERNEL_DIR }}
run: |
CONF=$(find arch/arm64/configs/ -name "*star*_defconfig" -o -name "*mars*_defconfig" | head -n 1)
if [ -z "$CONF" ]; then echo "ERROR: No config!" && exit 1; fi
DEFCONFIG=$(echo "$CONF" | sed 's|arch/arm64/configs/||')
echo "DEFCONFIG=$DEFCONFIG" >> $GITHUB_ENV
- name: Integrate WildKSU & SuSFS
working-directory: ${{ env.KERNEL_DIR }}
run: |
curl -LSs "https://raw.githubusercontent.com/WildKernels/Wild_KSU/refs/heads/stable/kernel/setup.sh" | bash -s stable
git clone --depth=1 https://gitlab.com/simonpunk/susfs4ksu.git -b kernel-5.4
PATCH_FILE=$(find susfs4ksu/kernel_patches/ -name "*5.4*.patch" | head -n 1)
[ -f "$PATCH_FILE" ] && patch -p1 < "$PATCH_FILE"
cp -f susfs4ksu/kernel_patches/fs/susfs.c fs/
cp -f susfs4ksu/kernel_patches/include/linux/susfs.h include/linux/
cp -f susfs4ksu/kernel_patches/include/linux/susfs_def.h include/linux/
rm -rf susfs4ksu
- name: Patch DTS
if: ${{ github.event.inputs.DISABLE_REAR_DISPLAY == 'true' }}
working-directory: ${{ env.KERNEL_DIR }}
run: |
find arch/arm64/boot/dts/ -name "*star*.dts" -o -name "*mars*.dts" | while read f; do
printf '\n&sde_dsi1 { status = "disabled"; };\n' >> "$f"
printf '&dsi_display1 { /delete-property/ qcom,dsi-display-active; };\n' >> "$f"
done
- name: Configure Kconfig
working-directory: ${{ env.KERNEL_DIR }}
run: |
DCFG="arch/arm64/configs/$DEFCONFIG"
if [ "${{ github.event.inputs.SELINUX_MODE }}" = "permissive" ]; then
SEL="CONFIG_SECURITY_SELINUX_BOOTPARAM=y"
else
SEL="# CONFIG_SECURITY_SELINUX_BOOTPARAM is not set"
fi
cat >> "$DCFG" << EOF
CONFIG_KSU=y
CONFIG_WILD_KSU=y
CONFIG_KSU_SUSFS=y
CONFIG_KSU_SUSFS_HAS_MAGIC_MOUNT=y
CONFIG_KSU_SUSFS_SUS_MOUNT=y
CONFIG_KSU_SUSFS_SPOOF_UNAME=y
CONFIG_KSU_SUSFS_ENABLE_LOG=y
CONFIG_KSU_SUSFS_HIDE_KSU_SUSFS_SYMBOLS=y
$SEL
CONFIG_LOCALVERSION="-palaziks-wild"
CONFIG_LTO_NONE=y
EOF
- name: Build
working-directory: ${{ env.KERNEL_DIR }}
run: |
mkdir -p $OUT_DIR
ARGS="ARCH=arm64 O=$OUT_DIR CC=clang CLANG_TRIPLE=aarch64-linux-gnu- CROSS_COMPILE=aarch64-linux-gnu- CROSS_COMPILE_ARM32=arm-linux-gnueabi-"
make $ARGS $DEFCONFIG
make -j$(nproc --all) $ARGS Image.gz-dtb || make -j$(nproc --all) $ARGS Image.gz
- name: Package
run: |
git clone --depth=1 https://github.com/osm0sis/AnyKernel3.git $ANYKERNEL_DIR
if [ -f "$OUT_DIR/arch/arm64/boot/Image.gz-dtb" ]; then
cp "$OUT_DIR/arch/arm64/boot/Image.gz-dtb" "$ANYKERNEL_DIR/Image"
else
cp "$OUT_DIR/arch/arm64/boot/Image.gz" "$ANYKERNEL_DIR/Image"
fi
sed -i 's/do.devicecheck=1/do.devicecheck=0/g' $ANYKERNEL_DIR/anykernel.sh
ZIP_NAME="WildKSU_SuSFS_${{ github.event.inputs.SELINUX_MODE }}_$(date +%d%m).zip"
cd $ANYKERNEL_DIR && zip -r9 "${GITHUB_WORKSPACE}/${ZIP_NAME}" ./*
echo "ZIP_NAME=${ZIP_NAME}" >> $GITHUB_ENV
- name: Upload
uses: actions/upload-artifact@v4
with:
name: ${{ env.ZIP_NAME }}
path: ${{ github.workspace }}/${{ env.ZIP_NAME }}