Build KernelSU Next SUSFS All #4
This file contains hidden or 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 KernelSU Next SUSFS All | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| FILE: | |
| type: choice | |
| description: "配置文件" | |
| required: true | |
| default: oneplus_ace2_pro_v | |
| options: | |
| - oneplus_nord_ce4_lite_5g_v | |
| - oneplus_nord_ce4_v | |
| - oneplus_nord_4_v | |
| - oneplus_ace_3v_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_pad_pro_v | |
| - oneplus_pad2_v | |
| - oneplus_nord_5 | |
| - oneplus_ace5_pro | |
| - oneplus_13 | |
| - oneplus_13t | |
| - oneplus_13s | |
| - oneplus_pad_2_pro | |
| - oneplus_pad_3 | |
| SUSFS_CI: | |
| type: choice | |
| description: "下载SUSFS模块调用方式" | |
| required: true | |
| default: CI | |
| options: | |
| - CI | |
| - Release | |
| - NoN | |
| BUILD_TIME: | |
| type: string | |
| description: "自定义构建时间 (输入F使用当前时间)" | |
| required: false | |
| default: "Mon Aug 18 09:30:24 UTC 2025" | |
| SUFFIX: | |
| type: string | |
| description: "自定义内核后缀 (不输入使用随机字符串)" | |
| required: false | |
| default: "" | |
| FAST_BUILD: | |
| type: boolean | |
| description: "是否启用极速构建?" | |
| required: true | |
| default: true | |
| SCHED: | |
| type: boolean | |
| description: "是否添加风驰驱动?" | |
| required: true | |
| default: false | |
| jobs: | |
| build: | |
| name: ${{ github.event.inputs.FAST_BUILD == 'true' && ' [FAST]' || '' }}${{ github.event.inputs.SCHED == 'true' && ' [SCHED]' || '' }}${{ github.event.inputs.KPM == 'true' && ' [KPM]' || '' }}For ${{ github.event.inputs.FILE }} ${{ github.event.inputs.SUFFIX }} | |
| runs-on: ubuntu-latest | |
| env: | |
| CCACHE_COMPILERCHECK: "%compiler% -dumpmachine; %compiler% -dumpversion" | |
| CCACHE_NOHASHDIR: "true" | |
| CCACHE_HARDLINK: "true" | |
| CCACHE_MAXSIZE: 8G | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - 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: Extract OnePlus Manifest Info | |
| id: extract_info | |
| run: | | |
| set -e | |
| cd "$GITHUB_WORKSPACE" | |
| FILE="${{ github.event.inputs.FILE }}" | |
| if [[ "$FILE" =~ ^(.+)_([a-zA-Z])$ ]]; then | |
| FILE_CONF="${BASH_REMATCH[1]}" | |
| else | |
| FILE_CONF="$FILE" | |
| fi | |
| FILE_BASE=$(echo "$FILE_CONF" | sed -E 's/_([a-zA-Z0-9])/\U\1/g; s/^oneplus/OnePlus/') | |
| mkdir -p ".repo/manifests_fallback" | |
| XML_PATH=".repo/manifests_fallback/${FILE}.xml" | |
| README_PATH=".repo/manifests_fallback/README.md" | |
| echo "处理 FILE=$FILE, CONF=$FILE_CONF, BASE=$FILE_BASE" | |
| echo "FILE_CONF=$FILE_CONF" >> $GITHUB_ENV | |
| echo "FILE_BASE=$FILE_BASE" >> $GITHUB_ENV | |
| echo "🌐 拉取 OnePlus Manifest 分支列表..." | |
| BRANCHES=$(curl -s https://api.github.com/repos/OnePlusOSS/kernel_manifest/branches | jq -r '.[].name') | |
| FOUND="" | |
| for BRANCH in $BRANCHES; do | |
| XML_URL="https://raw.githubusercontent.com/OnePlusOSS/kernel_manifest/$BRANCH/${FILE}.xml" | |
| README_URL="https://raw.githubusercontent.com/OnePlusOSS/kernel_manifest/$BRANCH/README.md" | |
| if curl -sf --head "$XML_URL" > /dev/null; then | |
| echo "✅ XML: $BRANCH" | |
| curl -s -o "$XML_PATH" "$XML_URL" | |
| curl -s -o "$README_PATH" "$README_URL" | |
| FOUND="$BRANCH" | |
| break | |
| fi | |
| done | |
| if [[ -z "$FOUND" || ! -s "$XML_PATH" ]]; then | |
| echo "❌ 无法找到 ${FILE}.xml" | |
| exit 1 | |
| fi | |
| echo "📥 下载完成,开始提取 revision..." | |
| # 解析 revision 字符串 | |
| REVISION=$(grep -oP '<project[^>]+revision="\K[^"]+' "$XML_PATH" | head -n1 || true) | |
| echo "解析 FILE 获取 CPU 和 ANDROID_VERSION..." | |
| # 提取 CPU | |
| CPU=$(echo "$REVISION" | sed -E 's#^oneplus/([^_]+).*#\1#') | |
| # 提取 ANDROID_VERSION | |
| ANDROID_VERSION=$(echo "$REVISION" | grep -oP '\d{1,2}\.\d{1,2}(\.\d{1,2})?') | |
| if [[ -n "$CPU" && -n "$ANDROID_VERSION" ]]; then | |
| echo "✅ CPU=$CPU, ANDROID_VERSION=$ANDROID_VERSION" | |
| echo "CPU=$CPU" >> $GITHUB_ENV | |
| echo "ANDROID_VERSION=$ANDROID_VERSION" >> $GITHUB_ENV | |
| # 获取短位 Android 版本号 | |
| echo "ANDROID_SHORT_VERSION=${ANDROID_VERSION%%.*}" >> $GITHUB_ENV | |
| else | |
| echo "❌ 无法从 revision 中提取 CPU 或 ANDROID_VERSION" | |
| exit 1 | |
| fi | |
| echo "解析 README.md 获取 CPUD 和 BUILD_METHOD..." | |
| if [[ -s "$README_PATH" ]]; then | |
| BUILD_LINE=$(grep -m1 'oplus_build_kernel.sh' "$README_PATH" || true) | |
| if [[ -n "$BUILD_LINE" ]]; then | |
| CPUD=$(echo "$BUILD_LINE" | awk '{print $(NF-1)}') | |
| BUILD_METHOD=$(echo "$BUILD_LINE" | awk '{print $NF}') | |
| echo "✅ CPUD=$CPUD, BUILD_METHOD=$BUILD_METHOD" | |
| echo "CPUD=$CPUD" >> $GITHUB_ENV | |
| echo "BUILD_METHOD=$BUILD_METHOD" >> $GITHUB_ENV | |
| else | |
| echo "❌ README.md 中未找到构建命令" | |
| fi | |
| else | |
| echo "❌ README.md 下载失败或为空" | |
| fi | |
| # 传递组合信息 | |
| echo "value=${FILE_BASE}_Android${ANDROID_VERSION}" >> "$GITHUB_OUTPUT" | |
| - name: Debug Show Selected Inputs | |
| run: | | |
| echo "-----------------------" | |
| echo "Selected CPU: ${{ env.CPU }}" | |
| echo "Selected CPUD: ${{ env.CPUD }}" | |
| echo "Selected ANDROID_VERSION: ${{ env.ANDROID_VERSION }}" | |
| echo "Selected BUILD_METHOD: ${{ env.BUILD_METHOD }}" | |
| echo "Selected FILE: ${{ github.event.inputs.FILE }}" | |
| echo "Custom SUFFIX: ${{ github.event.inputs.SUFFIX }}" | |
| echo -n "SUFFIX Unicode: " | |
| python3 -c "print(''.join(f'U+{ord(c):04X} ' for c in '''${{ github.event.inputs.SUFFIX }}'''))" | |
| echo "Custom BUILD_TIME: ${{ github.event.inputs.BUILD_TIME }}" | |
| echo -n "BUILD_TIME Unicode: " | |
| python3 -c "print(''.join(f'U+{ord(c):04X} ' for c in '''${{ github.event.inputs.BUILD_TIME }}'''))" | |
| echo "Selected SUSFS_CI: ${{ github.event.inputs.SUSFS_CI }}" | |
| echo "Selected FAST_BUILD: ${{ github.event.inputs.FAST_BUILD }}" | |
| echo "Selected SCHED: ${{ github.event.inputs.SCHED }}" | |
| echo "-----------------------" | |
| - name: Check Disk Space | |
| run: df -h | |
| - 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.FILE }}" >> $GITHUB_ENV | |
| mkdir -p "$HOME/.ccache_${{ github.event.inputs.FILE }}" | |
| echo "set: $HOME/.ccache_${{ github.event.inputs.FILE }}" | |
| - name: Configure Git | |
| run: | | |
| git config --global user.name "Numbersf" | |
| git config --global user.email "[email protected]" | |
| - 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 KernelSU Next OnePlus.yml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-apt- | |
| - 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.FILE }}-${{ env.BUILD_METHOD }}-${{ github.event.inputs.FAST_BUILD == 'true' && 'alpha' || 'beta' }}-C-11 | |
| - 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 | |
| mkdir -p .repo/manifests | |
| FILE="${{ github.event.inputs.FILE }}" | |
| cp "$GITHUB_WORKSPACE/.repo/manifests_fallback/${FILE}.xml" ".repo/manifests/${FILE}.xml" | |
| repo init -u https://github.com/OnePlusOSS/kernel_manifest.git -b oneplus/${{env.CPU}} -m "${FILE}.xml" --repo-rev=v2.16 --depth=1 --no-clone-bundle --no-tags | |
| repo sync -c -j$(nproc) --no-clone-bundle --no-tags --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: Kernel Version Handling | |
| run: | | |
| cd kernel_workspace/kernel_platform | |
| # 获取内核 Android 版本号(KANDROID_VERSION)以及内核版本号(KERNEL_VERSION) | |
| for f in ./common/build.config.constants ./common/build.config.common; do | |
| if [ -f "$f" ]; then | |
| BRANCH=$(grep -m1 '^BRANCH=' "$f" | cut -d= -f2) | |
| [ -n "$BRANCH" ] && break | |
| fi | |
| done | |
| if [ -n "$BRANCH" ]; then | |
| echo "KANDROID_VERSION=${BRANCH%-*}" >> $GITHUB_ENV | |
| echo "KERNEL_VERSION=${BRANCH#*-}" >> $GITHUB_ENV | |
| else | |
| echo "No BRANCH found in build.config files" | |
| fi | |
| # 从 Makefile 获取完整内核版本号(TKERNEL_VERSION)以及可选的修改内核等级 | |
| ORIG_VERSION=$(awk '/^VERSION =/ {v=$3} /^PATCHLEVEL =/ {p=$3} /^SUBLEVEL =/ {s=$3} END {print v"."p"."s}' ./common/Makefile) | |
| # 强制修改 SUBLEVEL(内核等级),默认关闭 | |
| # sed -i 's/^SUBLEVEL[[:space:]]*=[[:space:]]*.*/SUBLEVEL = 99/' ./common/Makefile | |
| # 读取修改后的版本 | |
| NEW_VERSION=$(awk '/^VERSION =/ {v=$3} /^PATCHLEVEL =/ {p=$3} /^SUBLEVEL =/ {s=$3} END {print v"."p"."s}' ./common/Makefile) | |
| if [ "$ORIG_VERSION" != "$NEW_VERSION" ]; then | |
| echo "Kernel Version:$ORIG_VERSION->$NEW_VERSION" | |
| echo "TKERNEL_VERSION=$NEW_VERSION" >> $GITHUB_ENV | |
| else | |
| echo "Kernel Version:$ORIG_VERSION No changes" | |
| echo "TKERNEL_VERSION=$ORIG_VERSION" >> $GITHUB_ENV | |
| fi | |
| # 自定义内核后缀 | |
| - name: Custom Kernel Suffix if set | |
| if: ${{ github.event.inputs.SUFFIX != '' }} | |
| run: | | |
| cd kernel_workspace | |
| SUFFIX="${{ github.event.inputs.SUFFIX }}" | |
| KANDROID_VERSION="${{ env.KANDROID_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" | |
| # Remove -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}-${KANDROID_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=\"-${KANDROID_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 | |
| KANDROID_VERSION="${{ env.KANDROID_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" | |
| # Remove -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}-${KANDROID_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=\"-${KANDROID_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: Add KernelSU Next | |
| run: | | |
| cd kernel_workspace/kernel_platform | |
| curl -LSs "https://raw.githubusercontent.com/pershoot/KernelSU-Next/next-susfs/kernel/setup.sh" | bash -s next-susfs | |
| cd KernelSU-Next | |
| KSU_VERSION=$(expr $(curl -sI "https://api.github.com/repos/KernelSU-Next/KernelSU-Next/commits?sha=next&per_page=1" | grep -i "link:" | sed -n 's/.*page=\([0-9]*\)>; rel="last".*/\1/p') "+" 10200) | |
| echo "KSUVER=$KSU_VERSION" >> $GITHUB_ENV | |
| sed -i "s/DKSU_VERSION=11998/DKSU_VERSION=${KSU_VERSION}/" kernel/Makefile | |
| - name: Apply Patches KernelSU Next | |
| run: | | |
| cd kernel_workspace | |
| git clone https://gitlab.com/simonpunk/susfs4ksu.git -b gki-${{ env.KANDROID_VERSION }}-${{ env.KERNEL_VERSION }} | |
| git clone https://github.com/WildPlusKernel/kernel_patches.git | |
| cd kernel_platform | |
| echo "正在拉取susfs补丁" | |
| cp ../susfs4ksu/kernel_patches/50_add_susfs_in_gki-${{ env.KANDROID_VERSION }}-${{ env.KERNEL_VERSION }}.patch ./common/ | |
| cp ../kernel_patches/next/scope_min_manual_hooks_v1.4.patch ./common/ | |
| cp ../susfs4ksu/kernel_patches/fs/* ./common/fs/ | |
| cp ../susfs4ksu/kernel_patches/include/linux/* ./common/include/linux/ | |
| cd ./common | |
| GKI_V="${{ env.KANDROID_VERSION }}-${{ env.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仅支持旧版C库造成的一些bug" | |
| 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="${{ env.KERNEL_VERSION }}" | |
| TKERNEL_VERSION="${{ env.TKERNEL_VERSION }}" | |
| file="${{ github.event.inputs.FILE }}" | |
| TRUSTY_EXISTS="false" | |
| if [[ "$KERNEL_VERSION" == "6.6" ]]; then | |
| if grep -q 'common-modules/trusty' "$GITHUB_WORKSPACE/.repo/manifests_fallback/${file}.xml"; then | |
| TRUSTY_EXISTS="true" | |
| fi | |
| echo "trusty_exists=$TRUSTY_EXISTS" >> $GITHUB_OUTPUT | |
| if [[ "$TRUSTY_EXISTS" == "false" && "$(printf '%s\n' "$TKERNEL_VERSION" "6.6.30" | sort -V | head -n1)" = "$TKERNEL_VERSION" ]]; then | |
| echo "修复内核版本6.6部分机型缺失Trusty OS导致的susfs的报错" | |
| sed -i 's/-32,12 +32,38/-32,11 +32,37/g' 50_add_susfs_in_gki-${{ env.KANDROID_VERSION }}-${KERNEL_VERSION}.patch | |
| sed -i '/#include <trace\/hooks\/fs.h>/d' 50_add_susfs_in_gki-${{ env.KANDROID_VERSION }}-${KERNEL_VERSION}.patch | |
| fi | |
| fi | |
| echo "正在打susfs补丁" | |
| patch -p1 < 50_add_susfs_in_gki-${{ env.KANDROID_VERSION }}-${{ env.KERNEL_VERSION }}.patch || true | |
| echo "susfs_patch完成" | |
| # Replace next_hooks.patch with syscall_hooks.patch | |
| cp ../../kernel_patches/69_hide_stuff.patch ./ | |
| patch -p1 -F 3 < 69_hide_stuff.patch | |
| patch -p1 --fuzz=3 < scope_min_manual_hooks_v1.4.patch | |
| # OGKI转换GKI,无需修改 dtbo 开机 | |
| - name: Apply Convert HMBIRD_OGKI to HMBIRD_GKI | |
| if: ${{ env.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 new hook and add configuration | |
| run: | | |
| cd kernel_workspace/kernel_platform | |
| CONFIG_FILE=./common/arch/arm64/configs/gki_defconfig | |
| KERNEL_VERSION="${{ env.KERNEL_VERSION }}" | |
| echo "CONFIG_KSU=y" >> "$CONFIG_FILE" | |
| echo "CONFIG_KSU_KPROBES_HOOK=n" >> "$CONFIG_FILE" | |
| echo "CONFIG_KSU_SUSFS_SUS_SU=n" >> "$CONFIG_FILE" | |
| 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" | |
| # 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" | |
| # 移除构建审查 | |
| 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 | |
| # Custom kernel build time, without adding #1 SMP PREEMPT 自定义内核构建时间,不要加入#1 SMP PREEMPT | |
| - name: Custom BUILD_TIME | |
| shell: bash | |
| run: | | |
| INPUT_TIME="${{ github.event.inputs.BUILD_TIME }}" | |
| if [[ -n "$INPUT_TIME" && "$INPUT_TIME" != "F" && "$INPUT_TIME" != "f" ]]; then | |
| DATESTR="$INPUT_TIME" | |
| echo "Using input BUILD_TIME: $DATESTR" | |
| else | |
| DATESTR="$(TZ='UTC' date +'%a %b %d %T %Z %Y')" | |
| echo "Using UTC time as fallback: $DATESTR" | |
| fi | |
| echo "KBUILD_BUILD_TIMESTAMP=${DATESTR}" >> "$GITHUB_ENV" | |
| echo "KBUILD_BUILD_VERSION=1" >> "$GITHUB_ENV" | |
| cd kernel_workspace/kernel_platform/ | |
| for f in common/scripts/mkcompile_h msm-kernel/scripts/mkcompile_h; do | |
| if [ -f "$f" ]; then | |
| echo "Patching mkcompile_h with BUILD_TIME=$DATESTR" | |
| if grep -q 'UTS_VERSION=' "$f"; then | |
| perl -pi -e "s{UTS_VERSION=\"\\\$\\(.*?\\)\"}{UTS_VERSION=\"#1 SMP PREEMPT $DATESTR\"}" "$f" | |
| else | |
| perl -0777 -pi -e "s{cat <<EOF}{cat <<EOF\n#undef UTS_VERSION\n#define UTS_VERSION \"#1 SMP PREEMPT $DATESTR\" } unless /UTS_VERSION/" "$f" | |
| fi | |
| fi | |
| done | |
| - name: Enable lto=thin For FAST | |
| if: ${{ (env.KERNEL_VERSION == '5.10' || env.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" | |
| sed -i 's/^CONFIG_LTO=n/CONFIG_LTO=y/' "$DEFCONFIG" | |
| 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" | |
| 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="${{ env.KERNEL_VERSION }}" | |
| cd kernel_workspace/kernel_platform | |
| # 自动检测 LLVM_IAS | |
| if [[ -f ./common/build.config.arm ]] && grep -q '^LLVM_IAS=1' ./common/build.config.arm; then | |
| USE_LLVM_IAS=true | |
| else | |
| USE_LLVM_IAS=false | |
| fi | |
| # 从 build.config.common 读取 CLANG_PREBUILT_BIN | |
| CLANG_PREBUILT_BIN=$(grep '^CLANG_PREBUILT_BIN=' ./common/build.config.common | cut -d'=' -f2 || true) | |
| if [[ -z "$CLANG_PREBUILT_BIN" ]]; then | |
| echo "⚠️ CLANG_PREBUILT_BIN 未在 build.config.common 中找到,回退至官方构建脚本" | |
| echo "fallback=true" >> "$GITHUB_OUTPUT" | |
| echo "请考虑关闭 FAST_BUILD 并提交问题" | |
| exit 0 | |
| fi | |
| # 优先尝试从 CLANG_PREBUILT_BIN 提取 clang-r 版本 | |
| if [[ "$CLANG_PREBUILT_BIN" =~ (clang-r[0-9a-z]+) ]]; then | |
| CLANG_VERSION="${BASH_REMATCH[1]}" | |
| else | |
| # 如果未匹配到,尝试从 build.config.constants 提取 | |
| if [[ -f ./common/build.config.constants ]]; then | |
| CLANG_VERSION=$(grep '^CLANG_VERSION=' ./common/build.config.constants | cut -d'=' -f2 || true) | |
| fi | |
| fi | |
| if [[ -z "$CLANG_VERSION" ]]; then | |
| echo "⚠️ 未能从 CLANG_PREBUILT_BIN 或 build.config.constants 获取到 Clang 版本,回退至官方构建脚本" | |
| echo "fallback=true" >> "$GITHUB_OUTPUT" | |
| echo "请考虑关闭 FAST_BUILD 并提交问题" | |
| exit 0 | |
| fi | |
| # 替换成新的 CLANG_VERSION 值 | |
| CLANG_PREBUILT_BIN=${CLANG_PREBUILT_BIN/\$\{CLANG_VERSION\}/$CLANG_VERSION} | |
| # 获取 CLANG_PREBUILT_BIN 的第一个目录名,赋值给 CLANG_DIR | |
| CLANG_DIR=$(echo "$CLANG_PREBUILT_BIN" | cut -d'/' -f1) | |
| # 获取 CLANG_PREBUILT_BIN 的上一级目录名,赋值给 CLANG_PATH | |
| CLANG_PATH=$(basename "$(dirname "$CLANG_PREBUILT_BIN")") | |
| echo "✅ CLANG_VERSION=$CLANG_VERSION" | |
| echo "✅ CLANG_DIR=$CLANG_DIR" | |
| echo "✅ CLANG_PATH=$CLANG_PATH" | |
| echo "✅ USE_LLVM_IAS=$USE_LLVM_IAS" | |
| export PATH="$GITHUB_WORKSPACE/kernel_workspace/kernel_platform/$CLANG_PREBUILT_BIN:$PATH" | |
| export PATH="/usr/lib/ccache:$PATH" | |
| export CC="ccache clang" | |
| sudo apt install -y libelf-dev ccache | |
| cd ./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" | |
| if [[ "$USE_LLVM_IAS" == "true" ]]; then | |
| MAKE_ARGS="LLVM_IAS=1 $MAKE_ARGS" | |
| fi | |
| make -j$(nproc --all) O=out $MAKE_ARGS gki_defconfig | |
| make -j$(nproc --all) O=out $MAKE_ARGS | |
| 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 ${{ env.CPUD }} ${{ env.BUILD_METHOD }} | |
| ./kernel_platform/build_with_bazel.py --lto=thin -t ${{ env.CPUD }} ${{ env.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 ${{ env.CPUD }} ${{ env.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/Final-Image-Find/ | |
| 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 | |
| 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/Final-Image-Find/Image | |
| fi | |
| if [ -n "$dir2" ] && [ "${{ env.CPU }}" = "sm8750" ] && [ "${{ github.event.inputs.FAST_BUILD }}" = "false" ]; then | |
| echo "当前正在使用官方脚本构建 sm8750,需额外复制一些其它镜像文件:dtbo.img、system_dlkm.img。请注意,如果你在刷完官方脚本构建后想换成极速构建,请还原这些分区!" | |
| echo "You are currently building sm8750 with the official script. Additional image files will be copied: dtbo.img, system_dlkm.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; do | |
| if [ -f "$dir2$file" ]; then | |
| target_name="$file" | |
| 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: 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 | |
| - 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/ | |
| - name: Upload AnyKernel3 | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: AnyKernel3_KernelSU_Next_${{ env.KSUVER }}_${{ steps.extract_info.outputs.value }}(${{ env.TKERNEL_VERSION }})${{ steps.suffix.outputs.value }} | |
| path: ./AnyKernel3/* |