Przeglądaj źródła

fix(action): enhance compatibility checks and GLIBC version handling in kernel fixes

Co-authored-by: Copilot <copilot@github.com>
TheWildJames 4 miesięcy temu
rodzic
commit
c49ea5607c
1 zmienionych plików z 29 dodań i 13 usunięć
  1. 29 13
      .github/actions/kernel-fixes/action.yml

+ 29 - 13
.github/actions/kernel-fixes/action.yml

@@ -18,37 +18,53 @@ runs:
   using: composite
   steps:
     - shell: bash
+      
       run: |
         set -euo pipefail
 
-        ANDROID_VERSION="${{ inputs.android_version }}"
-        KERNEL_VERSION="${{ inputs.kernel_version }}"
-        SUBLEVEL="${{ inputs.sublevel }}"
-        OS_PATCH_LEVEL="${{ inputs.os_patch_level }}"
-
-        if { [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" && "$SUBLEVEL" -le 186 ]] || \
-             [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" && "$SUBLEVEL" -le 119 ]] || \
-             [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" && "$SUBLEVEL" -le 110 ]] || \
-             [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "6.1" && "$SUBLEVEL" -le 43 ]]; }; then
+        echo "[INFO] Checking compatibility fixes for: android_version=${{ inputs.android_version }}, kernel_version=${{ inputs.kernel_version }}, sublevel=${{ inputs.sublevel }}"
+        if [[ "${{ inputs.android_version }}" == "android13" && "${{ inputs.kernel_version }}" == "5.10" && "${{ inputs.sublevel }}" -le 186 ]]; then
+          echo "[MATCH] android13 + 5.10 + sublevel <= 186"
+        elif [[ "${{ inputs.android_version }}" == "android13" && "${{ inputs.kernel_version }}" == "5.15" && "${{ inputs.sublevel }}" -le 119 ]]; then
+          echo "[MATCH] android13 + 5.15 + sublevel <= 119"
+        elif [[ "${{ inputs.android_version }}" == "android14" && "${{ inputs.kernel_version }}" == "5.15" && "${{ inputs.sublevel }}" -le 110 ]]; then
+          echo "[MATCH] android14 + 5.15 + sublevel <= 110"
+        elif [[ "${{ inputs.android_version }}" == "android14" && "${{ inputs.kernel_version }}" == "6.1" && "${{ inputs.sublevel }}" -le 43 ]]; then
+          echo "[MATCH] android14 + 6.1 + sublevel <= 43"
+        fi
+        if [[ "${{ inputs.android_version }}" == "android13" && "${{ inputs.kernel_version }}" == "5.10" && "${{ inputs.sublevel }}" -le 186 ]] || \
+           [[ "${{ inputs.android_version }}" == "android13" && "${{ inputs.kernel_version }}" == "5.15" && "${{ inputs.sublevel }}" -le 119 ]] || \
+           [[ "${{ inputs.android_version }}" == "android14" && "${{ inputs.kernel_version }}" == "5.15" && "${{ inputs.sublevel }}" -le 110 ]] || \
+           [[ "${{ inputs.android_version }}" == "android14" && "${{ inputs.kernel_version }}" == "6.1" && "${{ inputs.sublevel }}" -le 43 ]]; then
           GLIBC_VERSION="$(ldd --version 2>/dev/null | head -n 1 | awk '{print $NF}')"
+          echo "[INFO] Detected GLIBC version: $GLIBC_VERSION"
           if [ "$(printf '%s\n' "2.38" "$GLIBC_VERSION" | sort -V | head -n 1)" = "2.38" ]; then
+            echo "[INFO] GLIBC >= 2.38, applying Makefile fix."
             cd "$GITHUB_WORKSPACE/kernel/common"
             sed -i '/\$(Q)\$(MAKE) -C \$(SUBCMD_SRC) OUTPUT=\$(abspath \$(dir \$@))\/ \$(abspath \$@)/s//$(Q)$(MAKE) -C $(SUBCMD_SRC) EXTRA_CFLAGS="$(CFLAGS)" OUTPUT=$(abspath $(dir $@))\/ $(abspath $@)/' tools/bpf/resolve_btfids/Makefile 2>/dev/null || true
-            if { [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" && "$SUBLEVEL" -le 186 ]] || \
-                 [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" && "$SUBLEVEL" -le 119 ]] || \
-                 [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" && "$SUBLEVEL" -le 110 ]]; }; then
+            if [[ "${{ inputs.android_version }}" == "android13" && "${{ inputs.kernel_version }}" == "5.10" && "${{ inputs.sublevel }}" -le 186 ]] || \
+               [[ "${{ inputs.android_version }}" == "android13" && "${{ inputs.kernel_version }}" == "5.15" && "${{ inputs.sublevel }}" -le 119 ]] || \
+               [[ "${{ inputs.android_version }}" == "android14" && "${{ inputs.kernel_version }}" == "5.15" && "${{ inputs.sublevel }}" -le 110 ]]; then
+              echo "[INFO] Applying parse-options.c fixes."
               sed -i '/char \*buf = NULL;/a int i;' tools/lib/subcmd/parse-options.c 2>/dev/null || true
               sed -i 's/for (int i = 0; subcommands\[i\]; i++) {/for (i = 0; subcommands[i]; i++) {/' tools/lib/subcmd/parse-options.c 2>/dev/null || true
               sed -i '/if (subcommands) {/a int i;' tools/lib/subcmd/parse-options.c 2>/dev/null || true
               sed -i 's/for (int i = 0; subcommands\[i\]; i++)/for (i = 0; subcommands[i]; i++)/' tools/lib/subcmd/parse-options.c 2>/dev/null || true
             fi
+          else
+            echo "[SKIP] GLIBC version < 2.38, skipping Makefile fix."
           fi
         fi
 
-        if [ "$ANDROID_VERSION" = "android15" ] && [ "$KERNEL_VERSION" = "6.6" ]; then
+        echo "[INFO] Checking for android15 + kernel 6.6 include fix..."
+        if [ "${{ inputs.android_version }}" = "android15" && "${{ inputs.kernel_version }}" = "6.6" ]; then
+          echo "[MATCH] android15 + 6.6, checking for fs.h include."
           cd "$GITHUB_WORKSPACE/kernel/common"
           if ! grep -qxF '#include <trace/hooks/fs.h>' ./fs/namespace.c; then
+            echo "[INFO] Adding missing #include <trace/hooks/fs.h> to fs/namespace.c."
             sed -i '/#include <trace\/hooks\/blk.h>/a #include <trace\/hooks\/fs.h>' ./fs/namespace.c
+          else
+            echo "[INFO] #include <trace/hooks/fs.h> already present."
           fi
         fi