Skip to content

Build OnePlus_SukiSU Ultra All #10

Build OnePlus_SukiSU Ultra All

Build OnePlus_SukiSU Ultra All #10

name: Build OnePlus_SukiSU Ultra All
on:
workflow_dispatch:
inputs:
FEIL:
type: choice
description: "配置文件"
required: true
default: oneplus_ace2_pro_v
options:
- oneplus_nord_ce4_v
- oneplus_ace_3v_v
- oneplus_nord_4_v
- oneplus_10_pro_v
- oneplus_10t_v
- oneplus_11r_v
- oneplus_ace2_v
- oneplus_ace_pro_v
- oneplus_11_v
- oneplus_12r_v
- oneplus_ace2_pro_v
- oneplus_ace3_v
- oneplus_open_v
- oneplus12_v
- oneplus_13r
- oneplus_ace3_pro_v
- oneplus_ace5
- oneplus_pad2_v
- oneplus_pad_pro_v
- oneplus_13
- oneplus_ace5_pro
- oneplus_13t
- oneplus_13s
- oneplus_pad_2_pro
- oneplus_pad_3
BUILD_METHOD:
type: choice
description: "编译方式"
required: true
default: gki
options:
- gki
- perf
SUSFS_CI:
type: choice
description: "下载SUSFS模块调用方式"
required: true
default: CI
options:
- CI
- Release
- NoN
SUFFIX:
type: string
description: "自定义内核后缀 (留空则使用随机字符串)"
required: false
default: ""
BUILD_TIME:
type: string
description: "自定义构建时间 (留空则使用当前时间)"
required: false
default: "Fri May 30 04:01:05 UTC 2025"
FAST_BUILD:
type: boolean
description: "是否启用极速构建?"
required: true
default: true
VFS:
type: boolean
description: "是否启用手动钩子(VFS)?"
required: true
default: true
KPM:
type: boolean
description: "是否启用内核模块(KPM)?"
required: true
default: true
SCHED:
type: boolean
description: "是否添加风驰驱动?"
required: true
default: false
ZRAM:
type: boolean
description: "是否添加更多的ZRAM算法?"
required: true
default: false
jobs:
get-config:
uses: ./.github/workflows/feil-map.yml
with:
FEIL: ${{ inputs.FEIL }}
secrets: inherit
build:
needs: get-config
name: ${{ github.event.inputs.FAST_BUILD == 'true' && ' [FAST]' || '' }}${{ github.event.inputs.SCHED == 'true' && ' [SCHED]' || '' }}${{ github.event.inputs.ZRAM == 'true' && ' [ZRAM]' || '' }}For ${{ github.event.inputs.FEIL }} ${{ github.event.inputs.BUILD_METHOD }} ${{ github.event.inputs.SUFFIX }}
runs-on: ubuntu-latest
env:
CPU: ${{ needs.get-config.outputs.CPU }}
CPUD: ${{ needs.get-config.outputs.CPUD }}
ANDROID_VERSION: ${{ needs.get-config.outputs.ANDROID_VERSION }}
KERNEL_VERSION: ${{ needs.get-config.outputs.KERNEL_VERSION }}
CCACHE_COMPILERCHECK: "%compiler% -dumpmachine; %compiler% -dumpversion"
CCACHE_NOHASHDIR: "true"
CCACHE_HARDLINK: "true"
CCACHE_MAXSIZE: 8G
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check Disk Space
run: df -h
- name: Maximize Build Space
uses: easimon/maximize-build-space@master
with:
root-reserve-mb: 8192
temp-reserve-mb: 2048
remove-dotnet: 'true'
remove-android: 'true'
remove-haskell: 'true'
remove-codeql: 'true'
- name: Create and Enable 3G Swap
run: |
sudo swapoff -a
sudo fallocate -l 3G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
free -h
- name: Set Cache Environment
run: |
echo "CCACHE_DIR=$HOME/.ccache_${{ github.event.inputs.FEIL }}" >> $GITHUB_ENV
mkdir -p "$HOME/.ccache_${{ github.event.inputs.FEIL }}"
echo "set: $HOME/.ccache_${{ github.event.inputs.FEIL }}"
- name: Configure Git
run: |
git config --global user.name "Numbersf"
git config --global user.email "263623064@qq.com"
- name: Configure APTC
run: |
APT_CACHE_DIR="$HOME/apt-cache"
mkdir -p "$APT_CACHE_DIR"/{archives,lists/partial}
echo "Dir::Cache \"$APT_CACHE_DIR\";" | sudo tee /etc/apt/apt.conf.d/90user-cache
echo "Dir::Cache::archives \"$APT_CACHE_DIR/archives\";" | sudo tee -a /etc/apt/apt.conf.d/90user-cache
echo "Dir::State::lists \"$APT_CACHE_DIR/lists\";" | sudo tee -a /etc/apt/apt.conf.d/90user-cache
echo "Acquire::Check-Valid-Until \"false\";" | sudo tee -a /etc/apt/apt.conf.d/90user-cache
echo "Acquire::Languages \"none\";" | sudo tee -a /etc/apt/apt.conf.d/90user-cache
sudo chown -R $USER:$USER "$APT_CACHE_DIR"
- name: Set APT Cache
uses: actions/cache@v3
with:
path: ${{ env.HOME }}/apt-cache
key: ${{ runner.os }}-apt-${{ hashFiles('.github/workflows/Build SukiSU Ultra OnePlus.yml') }}
restore-keys: |
${{ runner.os }}-apt-
- name: Debug Show Selected Inputs
run: |
echo "Selected CPU: ${{ needs.get-config.outputs.CPU }}"
echo "Selected FEIL: ${{ github.event.inputs.FEIL }}"
echo "Selected CPUD: ${{ needs.get-config.outputs.CPUD }}"
echo "Selected ANDROID_VERSION: ${{ needs.get-config.outputs.ANDROID_VERSION }}"
echo "Selected KERNEL_VERSION: ${{ needs.get-config.outputs.KERNEL_VERSION }}"
echo "Selected BUILD_METHOD: ${{ github.event.inputs.BUILD_METHOD }}"
echo "Custom SUFFIX: ${{ github.event.inputs.SUFFIX }}"
echo "Selected SUSFS_CI: ${{ github.event.inputs.SUSFS_CI }}"
echo "Selected VFS: ${{ github.event.inputs.VFS }}"
echo "Selected KPM: ${{ github.event.inputs.KPM }}"
echo "Selected FAST_BUILD: ${{ github.event.inputs.FAST_BUILD }}"
echo "Selected ZRAM: ${{ github.event.inputs.ZRAM }}"
echo "Selected SCHED: ${{ github.event.inputs.SCHED }}"
- name: Install Dependencies
run: |
sudo rm -f /var/lib/apt/lists/lock /var/lib/dpkg/lock
APT_CACHE_DIR="$HOME/apt-cache"
mkdir -p "$APT_CACHE_DIR/lists/partial"
sudo apt -o Dir::Cache="$APT_CACHE_DIR" update -qq
sudo DEBIAN_FRONTEND=noninteractive apt -o Dir::Cache="$APT_CACHE_DIR" install -yq --no-install-recommends \
python3 git curl ccache libelf-dev \
build-essential flex bison libssl-dev \
libncurses-dev liblz4-tool zlib1g-dev \
libxml2-utils rsync unzip
- name: Restore Ccache
uses: actions/cache@v3
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-${{ runner.os }}-${{ github.ref_name }}-${{ github.event.inputs.FEIL }}-${{ github.event.inputs.BUILD_METHOD }}-${{ github.event.inputs.FAST_BUILD == 'true' && 'alpha' || 'beta' }}-10
- name: Initialize Ccache
run: |
INIT_FLAG="${{ env.CCACHE_DIR }}/.ccache_initialized"
if command -v ccache >/dev/null 2>&1; then
if [ ! -f "$INIT_FLAG" ]; then
echo "初始化 ccache (${{ env.CCACHE_DIR }})..."
mkdir -p "${{ env.CCACHE_DIR }}"
ccache -M ${{ env.CCACHE_MAXSIZE }}
touch "$INIT_FLAG"
echo "ccache 初始化完成"
else
echo "ccache 已初始化,跳过"
fi
else
echo "未安装 ccache,跳过"
fi
ccache -s
- name: Install Repo Tool
run: |
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/repo
chmod a+x ~/repo
sudo mv ~/repo /usr/local/bin/repo
- name: Initialize Repo and Sync
run: |
mkdir kernel_workspace && cd kernel_workspace
repo init -u https://github.com/OnePlusOSS/kernel_manifest.git -b refs/heads/oneplus/${{ needs.get-config.outputs.CPU }} -m ${{ github.event.inputs.FEIL }}.xml --depth=1
repo sync -c -j$(nproc --all) --no-tags --no-clone-bundle --force-sync
if [ -e kernel_platform/common/BUILD.bazel ]; then
sed -i '/^[[:space:]]*"protected_exports_list"[[:space:]]*:[[:space:]]*"android\/abi_gki_protected_exports_aarch64",$/d' kernel_platform/common/BUILD.bazel
fi
if [ -e kernel_platform/msm-kernel/BUILD.bazel ]; then
sed -i '/^[[:space:]]*"protected_exports_list"[[:space:]]*:[[:space:]]*"android\/abi_gki_protected_exports_aarch64",$/d' kernel_platform/msm-kernel/BUILD.bazel
fi
rm kernel_platform/common/android/abi_gki_protected_exports_* || echo "No protected exports!"
rm kernel_platform/msm-kernel/android/abi_gki_protected_exports_* || echo "No protected exports!"
# 自定义内核后缀
- name: Custom Kernel Suffix if set
if: ${{ github.event.inputs.SUFFIX != '' }}
run: |
cd kernel_workspace
SUFFIX="${{ github.event.inputs.SUFFIX }}"
ANDROID_VERSION="${{ needs.get-config.outputs.ANDROID_VERSION }}"
FAST_BUILD="${{ github.event.inputs.FAST_BUILD }}"
for path in \
kernel_platform/common/scripts/setlocalversion \
kernel_platform/msm-kernel/scripts/setlocalversion \
kernel_platform/external/dtc/scripts/setlocalversion; do
[ -f "$path" ] || continue
echo "Modifying: $path"
# 删除 -dirty
sed -i 's/ -dirty//g' "$path"
sed -i '$i res=$(echo "$res" | sed '\''s/-dirty//g'\'')' "$path"
if grep -q 'KERNELVERSION.*scm_version' "$path"; then
echo "Detected NEW setlocalversion format"
sed -i "s|echo \"\${KERNELVERSION}.*scm_version}\"|echo \"\${KERNELVERSION}-${ANDROID_VERSION}-${SUFFIX}\"|" "$path"
elif grep -q 'echo "\$res"' "$path"; then
echo "Detected OLD setlocalversion format"
if [ "$FAST_BUILD" = "true" ]; then
echo "FAST_BUILD enabled: using static res"
sed -i "s/^res=.*/res=\"-${ANDROID_VERSION}-${SUFFIX}\"/" "$path"
else
echo "Standard build: injecting suffix via cut/echo"
if [[ -f ./kernel_platform/build_with_bazel.py ]]; then
echo "使用官方脚本编译且当使用 build_with_bazel 时,可能受特殊符号数量限制,编译失败请修改"
echo "When using the official script and building with build_with_bazel, the build may fail due to a limit on the number of special characters. Please modify the configuration if that happens."
fi
tac "$path" | sed "0,/echo \"\\\$res\"/s//res=\\\$(echo \\\$res | cut -d- -f1-2)-${SUFFIX}; echo \"\\\$res\";/" | tac > "$path.tmp" && mv "$path.tmp" "$path"
fi
else
echo "Unknown format, appending echo manually"
echo "echo \"\$res-${SUFFIX}\"" >> "$path"
fi
chmod +x "$path"
done
git add -A
git commit -m "Custom suffix & removed -dirty"
# 自动生成随机后缀(仅在 SUFFIX 未设置时生效)*
- name: Custom Kernel Random Suffix if empty
if: ${{ github.event.inputs.SUFFIX == '' }}
run: |
cd kernel_workspace
ANDROID_VERSION="${{ needs.get-config.outputs.ANDROID_VERSION }}"
FAST_BUILD="${{ github.event.inputs.FAST_BUILD }}"
# 生成随机数字和随机hash后缀
RANDOM_DIGIT=$(od -An -N1 -tu1 < /dev/urandom | tr -d '[:space:]' | awk '{print $1 % 11}')
RANDOM_HASH=$(od -An -N7 -tx1 /dev/urandom | tr -d ' \n')
RANDOM_SUFFIX="${RANDOM_DIGIT}-o-g${RANDOM_HASH}"
for path in \
kernel_platform/common/scripts/setlocalversion \
kernel_platform/msm-kernel/scripts/setlocalversion \
kernel_platform/external/dtc/scripts/setlocalversion; do
[ -f "$path" ] || continue
echo "Modifying: $path"
# 删除 -dirty
sed -i 's/ -dirty//g' "$path"
sed -i '$i res=$(echo "$res" | sed '\''s/-dirty//g'\'')' "$path"
if grep -q 'KERNELVERSION.*scm_version' "$path"; then
echo "Detected NEW setlocalversion format"
sed -i "s|echo \"\${KERNELVERSION}.*scm_version}\"|echo \"\${KERNELVERSION}-${ANDROID_VERSION}-${RANDOM_SUFFIX}\"|" "$path"
elif grep -q 'echo "\$res"' "$path"; then
echo "Detected OLD setlocalversion format"
if [ "$FAST_BUILD" = "true" ]; then
echo "FAST_BUILD enabled: using static res with random suffix"
sed -i "s/^res=.*/res=\"-${ANDROID_VERSION}-${RANDOM_SUFFIX}\"/" "$path"
else
echo "Standard build: injecting random suffix via cut/echo"
tac "$path" | sed "0,/echo \"\\\$res\"/s//res=\\\$(echo \\\$res | cut -d- -f1-2)-${RANDOM_SUFFIX}; echo \"\\\$res\";/" | tac > "$path.tmp" && mv "$path.tmp" "$path"
fi
else
echo "Unknown format, appending echo manually"
echo "echo \"\$res-${RANDOM_SUFFIX}\"" >> "$path"
fi
chmod +x "$path"
done
git add -A
git commit -m "Random suffix & remove -dirty"
- name: Download kernel-manifest
id: fetch_manifest
run: |
feil="${{ github.event.inputs.FEIL }}"
cpu="${{ needs.get-config.outputs.CPU }}"
mkdir -p .repo/manifests_fallback
echo "Downloading manifest $feil.xml from branch oneplus/$cpu..."
curl -LO --retry 5 --retry-delay 2 --retry-connrefused "https://raw.githubusercontent.com/OnePlusOSS/kernel_manifest/oneplus/$cpu/$feil.xml"
mv "$feil.xml" ".repo/manifests_fallback/${feil}.xml"
- name: Add SukiSU Ultra
run: |
cd kernel_workspace/kernel_platform
curl -LSs "https://raw.githubusercontent.com/SukiSU-Ultra/SukiSU-Ultra/main/kernel/setup.sh" | bash -s susfs-main
cd ./KernelSU
KSU_VERSION=$(expr $(/usr/bin/git rev-list --count main) "+" 10700)
echo "KSUVER=$KSU_VERSION" >> $GITHUB_ENV
export KSU_VERSION=$KSU_VERSION
sed -i "s/DKSU_VERSION=12800/DKSU_VERSION=${KSU_VERSION}/" kernel/Makefile
- name: Apply Patches SukiSU Ultra
run: |
cd kernel_workspace
git clone https://gitlab.com/simonpunk/susfs4ksu.git -b gki-${{ needs.get-config.outputs.ANDROID_VERSION }}-${{ needs.get-config.outputs.KERNEL_VERSION }}
git clone https://github.com/ShirkNeko/SukiSU_patch.git
cd kernel_platform
echo "正在拉取susfs补丁"
cp ../susfs4ksu/kernel_patches/50_add_susfs_in_gki-${{ needs.get-config.outputs.ANDROID_VERSION }}-${{ needs.get-config.outputs.KERNEL_VERSION }}.patch ./common/
cp ../susfs4ksu/kernel_patches/fs/* ./common/fs/
cp ../susfs4ksu/kernel_patches/include/linux/* ./common/include/linux/
if [ "${{ github.event.inputs.ZRAM }}" = "true" ]; then
echo "正在拉取zram补丁"
cp -r ../SukiSU_patch/other/zram/lz4k/include/linux/* ./common/include/linux
cp -r ../SukiSU_patch/other/zram/lz4k/lib/* ./common/lib
cp -r ../SukiSU_patch/other/zram/lz4k/crypto/* ./common/crypto
cp -r ../SukiSU_patch/other/zram/lz4k_oplus ./common/lib/
fi
cd ./common
GKI_V="${{ needs.get-config.outputs.ANDROID_VERSION }}-${{ needs.get-config.outputs.KERNEL_VERSION }}"
SUBLEVEL=$(grep '^SUBLEVEL *=' Makefile | head -n1 | cut -d= -f2 | tr -d ' ')
if [ "$GKI_V" == "android13-5.15" ] && [ "$SUBLEVEL" -lt 123 ]; then
echo "修复内核版本5.15.0到5.15.123可能存在的一些遗留问题"
curl -Lo fix_5.15.legacy.patch --retry 5 --retry-delay 2 --retry-connrefused https://raw.githubusercontent.com/Numbersf/Action-Build/SukiSU-Ultra/patches/fix_5.15.legacy
patch -p1 < fix_5.15.legacy.patch
echo "fix_5.15_patch完成"
fi
KERNEL_VERSION="${{ needs.get-config.outputs.KERNEL_VERSION }}"
feil="${{ github.event.inputs.FEIL }}"
TRUSTY_EXISTS="false"
if [[ "$KERNEL_VERSION" == "6.6" ]]; then
if grep -qr 'common-modules/trusty' "$GITHUB_WORKSPACE/.repo/manifests_fallback/${feil}.xml"; then
TRUSTY_EXISTS="true"
fi
echo "trusty_exists=$TRUSTY_EXISTS" >> $GITHUB_OUTPUT
if [[ "$TRUSTY_EXISTS" == "false" ]]; then
echo "修复内核版本6.6部分机型susfs的问题"
sed -i 's/-32,12 +32,38/-32,11 +32,37/g' 50_add_susfs_in_gki-${{ needs.get-config.outputs.ANDROID_VERSION }}-${KERNEL_VERSION}.patch
sed -i '/#include <trace\/hooks\/fs.h>/d' 50_add_susfs_in_gki-${{ needs.get-config.outputs.ANDROID_VERSION }}-${KERNEL_VERSION}.patch
fi
fi
echo "正在打susfs补丁"
patch -p1 < 50_add_susfs_in_gki-${{ needs.get-config.outputs.ANDROID_VERSION }}-${{ needs.get-config.outputs.KERNEL_VERSION }}.patch || true
echo "susfs_patch完成"
- name: Apply Hide Stuff Patches
run: |
cd kernel_workspace/kernel_platform/common
cp ../../SukiSU_patch/69_hide_stuff.patch ./
echo "正在打隐藏应用补丁"
patch -p1 -F 3 < 69_hide_stuff.patch
echo "隐藏应用_patch完成"
# OGKI转换GKI,无需修改 dtbo 开机
- name: Apply Convert HMBIRD_OGKI to HMBIRD_GKI
if: ${{ needs.get-config.outputs.KERNEL_VERSION == '6.6' }}
run: |
cd kernel_workspace/kernel_platform/common
sed -i '1iobj-y += hmbird_patch.o' drivers/Makefile
wget https://github.com/Numbersf/Action-Build/raw/SukiSU-Ultra/patches/hmbird_patch.patch
echo "正在打OGKI转换GKI补丁"
patch -p1 -F 3 < hmbird_patch.patch
echo "OGKI转换GKI_patch完成"
- name: Apply VFS
if: ${{ github.event.inputs.VFS == 'true' }}
run: |
cd kernel_workspace/kernel_platform/common
cp ../../SukiSU_patch/hooks/syscall_hooks.patch ./
echo "正在打vfs补丁"
patch -p1 -F 3 < syscall_hooks.patch
echo "vfs_patch完成"
- name: Apply ZRAM
if: ${{ github.event.inputs.ZRAM == 'true' }}
run: |
cd kernel_workspace/kernel_platform/common
cp ../../SukiSU_patch/other/zram/zram_patch/${{ needs.get-config.outputs.KERNEL_VERSION }}/lz4kd.patch ./
echo "正在打lz4kd补丁"
patch -p1 -F 3 < lz4kd.patch || true
echo 'lz4kd_patch完成'
cp ../../SukiSU_patch/other/zram/zram_patch/${{ needs.get-config.outputs.KERNEL_VERSION }}/lz4k_oplus.patch ./
echo "正在打lz4k_oplus补丁"
patch -p1 -F 3 < lz4k_oplus.patch || true
echo 'lz4k_oplus_patch完成'
# 配置信息
- name: Add Configuration Settings
run: |
cd kernel_workspace/kernel_platform
CONFIG_FILE=./common/arch/arm64/configs/gki_defconfig
KERNEL_VERSION="${{ needs.get-config.outputs.KERNEL_VERSION }}"
# SukiSU Ultra配置
echo "CONFIG_KSU=y" >> "$CONFIG_FILE"
echo "CONFIG_KPM=y" >> "$CONFIG_FILE"
# VFS配置
if [ "${{ github.event.inputs.VFS }}" = "true" ]; then
echo "CONFIG_KSU_SUSFS_SUS_SU=n" >> "$CONFIG_FILE"
echo "CONFIG_KSU_MANUAL_HOOK=y" >> "$CONFIG_FILE"
else
echo "CONFIG_KPROBES=y" >> "$CONFIG_FILE"
fi
# SUSFS配置
if [ "${{ github.event.inputs.VFS }}" = "true" ]; then
echo "CONFIG_KSU_SUSFS=y" >> "$CONFIG_FILE"
echo "CONFIG_KSU_SUSFS_HAS_MAGIC_MOUNT=y" >> "$CONFIG_FILE"
echo "CONFIG_KSU_SUSFS_SUS_PATH=y" >> "$CONFIG_FILE"
echo "CONFIG_KSU_SUSFS_SUS_MOUNT=y" >> "$CONFIG_FILE"
echo "CONFIG_KSU_SUSFS_AUTO_ADD_SUS_KSU_DEFAULT_MOUNT=y" >> "$CONFIG_FILE"
echo "CONFIG_KSU_SUSFS_AUTO_ADD_SUS_BIND_MOUNT=y" >> "$CONFIG_FILE"
echo "CONFIG_KSU_SUSFS_SUS_KSTAT=y" >> "$CONFIG_FILE"
echo "CONFIG_KSU_SUSFS_SUS_OVERLAYFS=n" >> "$CONFIG_FILE"
echo "CONFIG_KSU_SUSFS_TRY_UMOUNT=y" >> "$CONFIG_FILE"
echo "CONFIG_KSU_SUSFS_AUTO_ADD_TRY_UMOUNT_FOR_BIND_MOUNT=y" >> "$CONFIG_FILE"
echo "CONFIG_KSU_SUSFS_SPOOF_UNAME=y" >> "$CONFIG_FILE"
echo "CONFIG_KSU_SUSFS_ENABLE_LOG=y" >> "$CONFIG_FILE"
echo "CONFIG_KSU_SUSFS_HIDE_KSU_SUSFS_SYMBOLS=y" >> "$CONFIG_FILE"
echo "CONFIG_KSU_SUSFS_SPOOF_CMDLINE_OR_BOOTCONFIG=y" >> "$CONFIG_FILE"
echo "CONFIG_KSU_SUSFS_OPEN_REDIRECT=y" >> "$CONFIG_FILE"
else
echo "CONFIG_KSU_SUSFS_SUS_SU=y" >> "$CONFIG_FILE"
fi
# TMPFS配置*
echo "CONFIG_TMPFS_XATTR=y" >> "$CONFIG_FILE"
echo "CONFIG_TMPFS_POSIX_ACL=y" >> "$CONFIG_FILE"
# BBR配置*
echo "CONFIG_TCP_CONG_ADVANCED=y" >> "$CONFIG_FILE"
echo "CONFIG_TCP_CONG_BBR=y" >> "$CONFIG_FILE"
echo "CONFIG_NET_SCH_FQ=y" >> "$CONFIG_FILE"
echo "CONFIG_TCP_CONG_BIC=n" >> "$CONFIG_FILE"
echo "CONFIG_TCP_CONG_WESTWOOD=n" >> "$CONFIG_FILE"
echo "CONFIG_TCP_CONG_HTCP=n" >> "$CONFIG_FILE"
# ECN配置*
echo "CONFIG_IP_ECN=y" >> "$CONFIG_FILE"
echo "CONFIG_TCP_ECN=y" >> "$CONFIG_FILE"
echo "CONFIG_IPV6_ECN=y" >> "$CONFIG_FILE"
echo "CONFIG_IP_NF_TARGET_ECN=y" >> "$CONFIG_FILE"
# ZRAM配置*
if [ "${{ github.event.inputs.ZRAM }}" = "true" ]; then
echo "CONFIG_CRYPTO_LZ4HC=y" >> "$CONFIG_FILE"
echo "CONFIG_CRYPTO_LZ4K=y" >> "$CONFIG_FILE"
echo "CONFIG_CRYPTO_LZ4KD=y" >> "$CONFIG_FILE"
echo "CONFIG_CRYPTO_842=y" >> "$CONFIG_FILE"
echo "CONFIG_CRYPTO_LZ4K_OPLUS=y" >> "$CONFIG_FILE"
echo "CONFIG_ZRAM_WRITEBACK=y" >> "$CONFIG_FILE"
fi
# 移除构建审查
sed -i 's/check_defconfig//' ./common/build.config.gki
# 风驰内核,以 sm8750 为主体,其他 CPU 可能无效或者无法跑出
- name: Add sched_ext
if: ${{ github.event.inputs.SCHED == 'true' }}
run: |
cd kernel_workspace/kernel_platform/
git clone https://github.com/HanKuCha/sched_ext.git
cp -r ./sched_ext/* ./common/kernel/sched
rm -rf ./sched_ext/.git
cd common/kernel/sched
- name: Set KBUILD_BUILD_TIMESTAMP
run: |
if [ -n "${{ github.event.inputs.BUILD_TIME }}" ]; then
echo "KBUILD_BUILD_TIMESTAMP=${{ github.event.inputs.BUILD_TIME }}" >> $GITHUB_ENV
fi
- name: Enable lto=thin For FAST
if: ${{ (needs.get-config.outputs.KERNEL_VERSION == '5.10' || needs.get-config.outputs.KERNEL_VERSION == '5.15') && github.event.inputs.FAST_BUILD == 'true' }}
run: |
cd kernel_workspace/kernel_platform
DEFCONFIG=./common/arch/arm64/configs/gki_defconfig
echo "Enabling ThinLTO in $DEFCONFIG"
# 开启 CONFIG_LTO
sed -i 's/^CONFIG_LTO=n/CONFIG_LTO=y/' "$DEFCONFIG"
# 替换 FULL/NONE 为 THIN,防止冲突
sed -i 's/^CONFIG_LTO_CLANG_FULL=y/CONFIG_LTO_CLANG_THIN=y/' "$DEFCONFIG"
sed -i 's/^CONFIG_LTO_CLANG_NONE=y/CONFIG_LTO_CLANG_THIN=y/' "$DEFCONFIG"
# 添加 THIN(若未设置)
grep -q '^CONFIG_LTO_CLANG_THIN=y' "$DEFCONFIG" || echo 'CONFIG_LTO_CLANG_THIN=y' >> "$DEFCONFIG"
- name: Build Kernel FAST
if: ${{ github.event.inputs.FAST_BUILD == 'true' }}
id: fast_build
run: |
KERNEL_VERSION="${{ needs.get-config.outputs.KERNEL_VERSION }}"
# 判断内核版本并设置对应 clang 路径
if [[ "$KERNEL_VERSION" == "6.6" ]]; then
CLANG_PATH="clang-r510928"
CLANG_DIR="prebuilts"
elif [[ "$KERNEL_VERSION" == "6.1" ]]; then
CLANG_PATH="clang-r487747c"
CLANG_DIR="prebuilts"
elif [[ "$KERNEL_VERSION" == "5.15" ]]; then
CLANG_PATH="clang-r450784e"
CLANG_DIR="prebuilts"
elif [[ "$KERNEL_VERSION" == "5.10" ]]; then
CLANG_PATH="clang-r416183b"
CLANG_DIR="prebuilts-master"
USE_LLVM_IAS=true
else
echo "fallback=true" >> "$GITHUB_OUTPUT"
echo "⚠️ 当前内核版本 \"$KERNEL_VERSION\" 没有对应 clang 工具链,回退使用官方构建脚本"
echo "请考虑关闭 FAST_BUILD 或补充该版本 clang 路径"
exit 0
fi
export PATH="$GITHUB_WORKSPACE/kernel_workspace/kernel_platform/$CLANG_DIR/clang/host/linux-x86/$CLANG_PATH/bin:$PATH"
export PATH="/usr/lib/ccache:$PATH"
export CC="ccache clang"
# 安装依赖工具
sudo apt install -y libelf-dev ccache
cd kernel_workspace/kernel_platform/common
# 拼接构建参数
MAKE_ARGS="LLVM=1 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- \
RUSTC=../../prebuilts/rust/linux-x86/1.73.0b/bin/rustc \
PAHOLE=../../prebuilts/kernel-build-tools/linux-x86/bin/pahole \
LD=ld.lld HOSTLD=ld.lld KCFLAGS+=-Wno-error"
# 如果是 5.10,添加 LLVM_IAS=1
if [[ "$USE_LLVM_IAS" == "true" ]]; then
MAKE_ARGS="LLVM_IAS=1 $MAKE_ARGS"
fi
# 可选清理 ccache 缓存(不清理可注释)
# ccache -C
# 配置内核
make -j$(nproc --all) O=out $MAKE_ARGS gki_defconfig
# 构建内核
make -j$(nproc --all) O=out $MAKE_ARGS
# 显示 ccache 统计信息
ccache -s
- name: Fallback to Build Kernel
if: ${{ github.event.inputs.FAST_BUILD == 'false' || steps.fast_build.outputs.fallback == 'true' }}
run: |
cd kernel_workspace
if [ -f ./kernel_platform/build_with_bazel.py ]; then
./kernel_platform/oplus/bazel/oplus_modules_variant.sh ${{ needs.get-config.outputs.CPUD }} ${{ github.event.inputs.BUILD_METHOD }}
./kernel_platform/build_with_bazel.py --lto=thin -t ${{ needs.get-config.outputs.CPUD }} ${{ github.event.inputs.BUILD_METHOD }}
else
LTO=thin SYSTEM_DLKM_RE_SIGN=0 BUILD_SYSTEM_DLKM=0 KMI_SYMBOL_LIST_STRICT_MODE=0 \
./kernel_platform/oplus/build/oplus_build_kernel.sh ${{ needs.get-config.outputs.CPUD }} ${{ github.event.inputs.BUILD_METHOD }}
fi
- name: Make AnyKernel3
run: |
git clone https://github.com/Numbersf/AnyKernel3 --depth=1
rm -rf ./AnyKernel3/.git
mkdir -p kernel_workspace/kernel_platform/out/FinalImageFind/
dir1=""
dir2=""
image_path=$(find "./kernel_workspace/kernel_platform/common/out/" -name "Image" | head -n 1)
if [ -n "$image_path" ]; then
dir1=$(dirname "$image_path")/
echo "使用 make 编译的统一路径,成功找到 Image 文件"
else
image_path=$(find "./kernel_workspace/kernel_platform/out/" -name "Image" | head -n 1)
if [ -n "$image_path" ]; then
dir2=$(dirname "$image_path")/
echo "使用官方脚本编译,成功找到 Image 文件"
else
echo "未找到 Image 文件,构建失败" >&2
exit 1
fi
fi
# 复制 Image 到 AnyKernel3
if [ -n "$image_path" ] && [ -f "$image_path" ]; then
echo "Image file finally located at: $image_path"
cp "$image_path" ./AnyKernel3/Image
cp "$image_path" kernel_workspace/kernel_platform/out/FinalImageFind/Image
fi
# 使用官方脚本编译的 sm8750,选择性复制其它镜像文件
if [ -n "$dir2" ] && [ "${{ needs.get-config.outputs.CPU }}" = "sm8750" ] && [ "${{ github.event.inputs.FAST_BUILD }}" = "false" ]; then
echo "当前正在使用官方脚本构建 sm8750,需额外复制一些其它镜像文件:dtbo.img、system_dlkm.img、vendor_dlkm.img、vendor_boot.img。请注意,如果你在刷完官方脚本构建后想换成极速构建,请还原这些分区!"
echo "You are currently building sm8750 with the official script. Additional image files will be copied: dtbo.img, system_dlkm.img, vendor_dlkm.img, vendor_boot.img. Please note: If you switch to fast build after flashing this build, make sure to restore these partitions!"
for file in dtbo.img system_dlkm.erofs.img vendor_dlkm.img vendor_boot.img; do
if [ -f "$dir2$file" ]; then
target_name="$file"
# 特殊处理 system_dlkm.erofs.img 的目标名
if [ "$file" = "system_dlkm.erofs.img" ]; then
target_name="system_dlkm.img"
fi
cp "$dir2$file" "./AnyKernel3/$target_name"
else
echo "$file 不存在,跳过复制"
fi
done
fi
- name: Apply patch_linux and replace Image
if: ${{ github.event.inputs.KPM == 'true' }}
run: |
cd kernel_workspace/kernel_platform/out/FinalImageFind
curl -LO --retry 5 --retry-delay 2 --retry-connrefused https://raw.githubusercontent.com/Numbersf/Action-Build/SukiSU-Ultra/patches/patch_linux
chmod +x patch_linux
./patch_linux
rm -f Image
mv oImage Image
cp Image $GITHUB_WORKSPACE/AnyKernel3/Image
# 下载 SUSFS 模块(CI)
- name: Download Latest SUSFS Module from CI
if: ${{ github.event.inputs.SUSFS_CI == 'CI' }}
continue-on-error: true
run: |
LATEST_RUN_ID=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/sidex15/susfs4ksu-module/actions/runs?status=success" | \
jq -r '.workflow_runs[] | select(.head_branch == "v1.5.2+") | .id' | head -n 1)
if [ -z "$LATEST_RUN_ID" ]; then
echo "No successful run found for branch v1.5.2+"
else
ARTIFACT_URL=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/sidex15/susfs4ksu-module/actions/runs/$LATEST_RUN_ID/artifacts" | jq -r '.artifacts[0].archive_download_url')
if [ -n "$ARTIFACT_URL" ]; then
curl -L -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -o ksu_module_susfs_1.5.2+_CI.zip "$ARTIFACT_URL"
cp ksu_module_susfs_1.5.2+_CI.zip ./AnyKernel3/
else
echo "Failed to fetch artifact URL"
fi
fi
# 下载 SUSFS 模块(Release)*
- name: Download Latest SUSFS Module from Release
if: ${{ github.event.inputs.SUSFS_CI == 'Release' }}
continue-on-error: true
run: |
wget -O ksu_module_susfs_1.5.2+_Release.zip https://github.com/sidex15/ksu_module_susfs/releases/latest/download/ksu_module_susfs_1.5.2+.zip
cp ksu_module_susfs_1.5.2+_Release.zip ./AnyKernel3/
# 解压 SukiSU Ultra(CI)(不自动安装)
- name: Download Latest SukiSU-Ultra APK from CI
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
run_id=$(gh api \
"repos/SukiSU-Ultra/SukiSU-Ultra/actions/workflows/build-manager.yml/runs?branch=main&status=success&per_page=1" \
--jq '.workflow_runs[0].id' || echo "")
if [[ -z "$run_id" ]]; then
echo "No successful workflow run found. Skipping artifact download."
else
artifact_url=$(gh api \
"repos/SukiSU-Ultra/SukiSU-Ultra/actions/runs/$run_id/artifacts" | \
jq -r '.artifacts[] | select(.name == "manager") | .archive_download_url' | head -n1)
if [[ -z "$artifact_url" ]]; then
echo "No 'manager' artifact found in run $run_id. Skipping download."
else
echo "Downloading from: $artifact_url"
curl -fL -H "Authorization: token $GITHUB_TOKEN" -o manager.zip "$artifact_url"
unzip -j manager.zip "*.apk" -d ./AnyKernel3/
fi
fi
- name: Set zip suffix
id: suffix
run: |
echo "value=${{ github.event.inputs.VFS == 'true' && '_VFS' || '' }}${{ github.event.inputs.ZRAM == 'true' && '_LZ4KD' || '' }}${{ github.event.inputs.KPM == 'true' && '_KPM' || '' }}${{ github.event.inputs.SCHED== 'true' && '_SCHED' || '' }}" >> $GITHUB_OUTPUT
# 从一加源码中获取适用的 Android 版本信息,注意是系统 Android 版本而非你填写的内核 Android 版本,非一加官方源码可能需要修改或删除这一步
- name: Auto map FEIL to Android version by manifest
id: feil_clean
run: |
feil="${{ github.event.inputs.FEIL }}"
cpu="${{ needs.get-config.outputs.CPU }}"
xml=".repo/manifests_fallback/${feil}.xml"
cd $GITHUB_WORKSPACE
# 去掉末尾的 _x(只删一个)
feil_base=$(echo "$feil" | sed -E 's/_[a-z]$//')
# 提取 revision 并解析 Android 版本
revision_full=$(grep -oP '<project[^>]*name="android_kernel[^"]*"[^>]*revision="\K[^"]+' "$xml" | head -n1 || true)
if [ -n "$revision_full" ]; then
android_ver=$(echo "$revision_full" | grep -oP '_v?_?\K([0-9]+\.[0-9]+(?:\.[0-9]+)?)' || true)
if [ -n "$android_ver" ]; then
clean_feil="${feil_base}_Android${android_ver}"
else
clean_feil="${feil_base}_AndroidUnknown"
fi
else
clean_feil="${feil_base}_AndroidUnknown"
fi
echo "value=$clean_feil" >> "$GITHUB_OUTPUT"
- name: Upload AnyKernel3
uses: actions/upload-artifact@v4
with:
name: AnyKernel3_SukiSUUltra_${{ env.KSUVER }}_${{ steps.feil_clean.outputs.value }}${{ steps.suffix.outputs.value }}
path: ./AnyKernel3/*
- name: Download and Unzip ZRAM
if: ${{ github.event.inputs.ZRAM == 'true' }}
run: |
set -e
sudo apt install -y unzip
curl -s https://api.github.com/repos/FurLC/ZRAM-Module/releases/latest | \
grep "browser_download_url" | grep "ZRAM-Module-.*\.zip" | cut -d '"' -f 4 | xargs wget -N
unzip "$(ls -t ZRAM-Module-*.zip | head -1)" -d ZRAM-Module
target="./ZRAM-Module/zram/zram.ko"
echo "查找 zram.ko 模块文件..."
# 优先查找常见目录
search_paths=(
"./kernel_workspace/kernel_platform/out"
"./kernel_workspace/device/qcom"
)
zram_path=""
for path in "${search_paths[@]}"; do
zram_path=$(find "$path" -type f -name "zram.ko" | head -n 1)
[ -n "$zram_path" ] && break
done
# 若以上未找到,广泛查找整个 workspace
if [ -z "$zram_path" ]; then
zram_path=$(find "./kernel_workspace" -type f -name "zram.ko" | head -n 1)
fi
if [ -n "$zram_path" ] && [ -f "$zram_path" ]; then
echo " ZRAM module file finally located at: $zram_path "
mkdir -p "$(dirname "$target")"
if [ "$(realpath "$zram_path")" != "$(realpath "$target")" ]; then
cp "$zram_path" "$target"
else
echo "源文件与目标路径相同,跳过复制"
fi
else
echo "未找到 zram.ko 文件,可能是未支持的内核版本或者未成功构建"
exit 1
fi
- name: Upload ZRAM Module
if: ${{ github.event.inputs.ZRAM == 'true' }}
uses: actions/upload-artifact@v4
with:
name: ZRAM-Module_${{ needs.get-config.outputs.KERNEL_VERSION }}_${{ steps.feil_clean.outputs.value }}
path: ZRAM-Module/*
- name: Post-build disk check
run: df -h