Browse Source

refactor(bypass): extract bypass hack into standalone action, disabled by default

- Create .github/actions/bypass-kernel with bypass input (default false)
- Remove Activate Bypass step from build-kernel action
- Add bypass input to build.yml and prepare.yml, default false
- Wire bypass-kernel into build.yml before normal kernel build
- Bypass build step already disabled with if: false
TheWildJames 2 tuần trước cách đây
mục cha
commit
32ba07352e

+ 0 - 23
.github/actions/build-kernel/action.yml

@@ -11,29 +11,6 @@ inputs:
 runs:
   using: composite
   steps:
-  - name: 'Activate Bypass'
-    shell: bash
-    working-directory: ${{ github.workspace }}/kernel
-    run: |
-      set -euo pipefail
-      if [ "${{ inputs.bypass }}" = "true" ]; then
-        if [[ ${{ inputs.version }} == "android14-6.1" || ${{ inputs.version }} == "android15-6.6" || ${{ inputs.version }} == "android16-6.12" ]]; then
-          TARGET_FILE="${{ github.workspace }}/kernel/common/kernel/module/version.c"
-        else
-          TARGET_FILE="${{ github.workspace }}/kernel/common/kernel/module.c"
-        fi
-
-        sed -i '/bad_version:/{:a;n;/return 0;/{s/return 0;/return 1;/;b};ba}' "$TARGET_FILE"
-
-        if ! grep -A 5 "bad_version:" "$TARGET_FILE" | grep -q "return 1;"; then
-          echo "Patch failed! 'return 1;' not found at bad_version:"
-          grep -A 10 "bad_version:" "$TARGET_FILE" || true
-          exit 1
-        fi
-      else
-        echo "Bypass hack not applied as per input parameter."
-      fi
-
   - name: Setup Kernel Configs
     if: false
     uses: ./.github/actions/set-kernel-config

+ 40 - 0
.github/actions/bypass-kernel/action.yml

@@ -0,0 +1,40 @@
+name: Apply Kernel Bypass Hack
+description: >
+  Patches the kernel version-check path (bad_version) to return 1 instead of 0,
+  allowing kernels that would otherwise reject the build to boot.
+  Disabled by default; enable by passing bypass: true at the workflow level.
+inputs:
+  bypass:
+    description: 'Whether to apply the bypass hack'
+    required: false
+    type: boolean
+    default: false
+  version:
+    description: 'Kernel config version (e.g., android14-6.1)'
+    required: true
+runs:
+  using: composite
+  steps:
+    - name: Activate Bypass
+      if: ${{ inputs.bypass == 'true' }}
+      shell: bash
+      working-directory: ${{ github.workspace }}/kernel
+      run: |
+        set -euo pipefail
+
+        if [[ "${{ inputs.version }}" == "android14-6.1" \
+            || "${{ inputs.version }}" == "android15-6.6" \
+            || "${{ inputs.version }}" == "android16-6.12" ]]; then
+          TARGET_FILE="${{ github.workspace }}/kernel/common/kernel/module/version.c"
+        else
+          TARGET_FILE="${{ github.workspace }}/kernel/common/kernel/module.c"
+        fi
+
+        sed -i '/bad_version:/{:a;n;/return 0;/{s/return 0;/return 1;/;b};ba}' "$TARGET_FILE"
+
+        if ! grep -A 5 "bad_version:" "$TARGET_FILE" | grep -q "return 1;"; then
+          echo "Patch failed! 'return 1;' not found at bad_version:" >&2
+          grep -A 10 "bad_version:" "$TARGET_FILE" || true
+          exit 1
+        fi
+        echo "Bypass hack applied to $TARGET_FILE"

+ 12 - 1
.github/workflows/build.yml

@@ -67,6 +67,10 @@ on:
         required: false
         type: boolean
         default: true
+      bypass:
+        required: false
+        type: boolean
+        default: false
 
 jobs:
   build-gki:
@@ -457,6 +461,13 @@ jobs:
     - name: Initialize Config Fragment
       run: touch "${{ github.workspace }}/wild_gki.fragment"
 
+    - name: Apply Kernel Bypass Hack
+      if: ${{ inputs.bypass == 'true' }}
+      uses: ./.github/actions/bypass-kernel
+      with:
+        version: ${{ inputs.version }}
+        bypass: true
+
     - name: Build Normal Kernel
       env:
         SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}
@@ -494,7 +505,7 @@ jobs:
         github_token: ${{ secrets.MY_GITHUB_TOKEN }}
 
     - name: Build Bypass Kernel
-      if: ${{ inputs.build_bypass }}
+      if: false
       env:
         SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}
         KBUILD_BUILD_TIMESTAMP: ${{ env.KBUILD_BUILD_TIMESTAMP }}

+ 6 - 0
.github/workflows/prepare.yml

@@ -61,6 +61,11 @@ on:
         required: false
         type: boolean
         default: true
+      bypass:
+        description: "Apply the kernel version-check bypass hack (disabled by default)"
+        required: false
+        type: boolean
+        default: false
       os_patch_level:
         description: "Optional filter: patch date (YYYY-MM), kernel sublevel, lts (LTS branch), or all"
         required: false
@@ -175,4 +180,5 @@ jobs:
       droidspaces_commit: ${{ inputs.droidspaces_commit }}
       brand_name: ${{ inputs.brand_name }}
       build_bypass: ${{ inputs.build_bypass }}
+      bypass: ${{ inputs.bypass }}
     secrets: inherit