| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- name: Setup Wild KSU
- description: Download and configure Wild KSU with version tracking
- inputs:
- ksu_branch:
- description: 'KernelSU branch or commit (empty = latest dev-susfs branch tip)'
- required: false
- default: ""
- runs:
- using: composite
- steps:
- - name: Download Wild KSU
- shell: bash
- working-directory: ${{ github.workspace }}/kernel
- run: |
- set -euo pipefail
- # Retry transient network errors (up to 5 attempts, 5s backoff).
- # Diagnostics go to stderr so pipes to grep are not polluted.
- retry() {
- local n=0
- until [ "$n" -ge 5 ]; do
- "$@" && return 0
- n=$((n+1))
- echo "retry $n/5 failed for: $*" >&2
- sleep 5
- done
- return 1
- }
- KSU_REPO="https://github.com/pershoot/KernelSU-Next.git"
- KSU_INPUT="${{ inputs.ksu_branch }}"
- if [ -z "$KSU_INPUT" ]; then
- KSU_INPUT="dev-susfs"
- fi
- # Try as branch first, fall back to commit
- if retry git ls-remote --heads "$KSU_REPO" "$KSU_INPUT" | grep -q .; then
- echo "Using KernelSU-Next branch: $KSU_INPUT"
- curl -LSs --retry 5 --retry-delay 5 --retry-all-errors "https://raw.githubusercontent.com/pershoot/KernelSU-Next/dev-susfs/kernel/setup.sh" | bash -s dev-susfs
- retry git -C KernelSU-Next/kernel fetch --depth=50 origin "$KSU_INPUT"
- git -C KernelSU-Next/kernel checkout "origin/$KSU_INPUT"
- else
- echo "Using KernelSU-Next commit: $KSU_INPUT"
- curl -LSs --retry 5 --retry-delay 5 --retry-all-errors "https://raw.githubusercontent.com/pershoot/KernelSU-Next/dev-susfs/kernel/setup.sh" | bash -s dev-susfs
- retry git -C KernelSU-Next/kernel fetch --depth=50 origin "$KSU_INPUT"
- git -C KernelSU-Next/kernel checkout "$KSU_INPUT"
- fi
- cd KernelSU-Next/kernel
-
- COMMITS_COUNT=$(/usr/bin/git rev-list --count HEAD)
- BASE_VERSION=30000
- KSU_VERSION=$(expr $COMMITS_COUNT "+" $BASE_VERSION)
- sed -i "s/^KSU_VERSION_FALLBACK := 1$/KSU_VERSION_FALLBACK := ${KSU_VERSION}/" Kbuild
- KSU_GIT_TAG="$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.1")"
- sed -i "s/^KSU_VERSION_TAG_FALLBACK := v0.0.1$/KSU_VERSION_TAG_FALLBACK := ${KSU_GIT_TAG}/" Kbuild
-
- - name: Extract KSU Version Info
- id: ksu-version
- shell: bash
- working-directory: ${{ github.workspace }}/kernel/KernelSU-Next
- run: |
- # Get the base branch name by stripping suffixes (e.g., dev-susfs -> dev)
- BASE_BRANCH=$(git rev-parse --abbrev-ref HEAD | sed 's:-.*::' 2>/dev/null)
- # Find the merge-base with the official origin branch to exclude local commits
- BASE_COMMIT=$(git merge-base HEAD refs/remotes/origin/$BASE_BRANCH 2>/dev/null || git merge-base HEAD refs/remotes/origin/main 2>/dev/null || echo HEAD)
- KSU_GIT_VERSION=$(git rev-list --count $BASE_COMMIT 2>/dev/null)
- KSU_GIT_TAG=$(git describe --tags --abbrev=0 $BASE_COMMIT 2>/dev/null || echo "")
- KSU_COMMIT=$(git rev-parse --short HEAD 2>/dev/null)
- KSU_VERSION=$((30000 + KSU_GIT_VERSION))
-
- echo "KSU_GIT_TAG=$KSU_GIT_TAG" >> $GITHUB_ENV
- echo "KSU_VERSION=$KSU_VERSION" >> $GITHUB_ENV
- echo "KSU_COMMIT=$KSU_COMMIT" >> $GITHUB_ENV
- - name: 'Fix KernelSU-Next'
- shell: bash
- working-directory: ${{ github.workspace }}/kernel/KernelSU-Next
- run: |
- set -euo pipefail
- cp ${{ github.action_path }}/patches/static.patch "${{ github.workspace }}/kernel/KernelSU-Next/static.patch"
- patch -p1 < static.patch
- - name: Enable Kernel Configs
- uses: ./.github/actions/set-kernel-config
- with:
- config_list: |
- CONFIG_KSU=y
|