action.yml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. name: 'Kernel Fixes'
  2. description: 'Applies compatibility fixes based on android/kernel/sublevel'
  3. inputs:
  4. android_version:
  5. required: true
  6. type: string
  7. kernel_version:
  8. required: true
  9. type: string
  10. sublevel:
  11. required: true
  12. type: string
  13. os_patch_level:
  14. required: true
  15. type: string
  16. runs:
  17. using: composite
  18. steps:
  19. - shell: bash
  20. if: true
  21. run: |
  22. set -euo pipefail
  23. GLIBC_VERSION="$(ldd --version 2>/dev/null | head -n 1 | awk '{print $NF}')"
  24. echo "[INFO] Detected GLIBC version: $GLIBC_VERSION"
  25. if [ "$(printf '%s\n' "2.38" "$GLIBC_VERSION" | sort -V | head -n 1)" = "2.38" ]; then
  26. echo "[INFO] GLIBC >= 2.38, applying Makefile fix."
  27. cd "$GITHUB_WORKSPACE/kernel/common"
  28. 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
  29. if [[ "${{ inputs.android_version }}" == "android13" && "${{ inputs.kernel_version }}" == "5.10" && "${{ inputs.sublevel }}" -le 186 ]] || \
  30. [[ "${{ inputs.android_version }}" == "android13" && "${{ inputs.kernel_version }}" == "5.15" && "${{ inputs.sublevel }}" -le 119 ]] || \
  31. [[ "${{ inputs.android_version }}" == "android14" && "${{ inputs.kernel_version }}" == "5.15" && "${{ inputs.sublevel }}" -le 110 ]]; then
  32. echo "[INFO] Applying parse-options.c fixes."
  33. sed -i '/char \*buf = NULL;/a int i;' tools/lib/subcmd/parse-options.c 2>/dev/null || true
  34. 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
  35. sed -i '/if (subcommands) {/a int i;' tools/lib/subcmd/parse-options.c 2>/dev/null || true
  36. 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
  37. fi
  38. else
  39. echo "[SKIP] GLIBC version < 2.38, skipping Makefile fix."
  40. fi
  41. echo "[INFO] Checking for android15 + kernel 6.6 include fix..."
  42. if [ "${{ inputs.android_version }}" = "android15" && "${{ inputs.kernel_version }}" = "6.6" ]; then
  43. echo "[MATCH] android15 + 6.6, checking for fs.h include."
  44. cd "$GITHUB_WORKSPACE/kernel/common"
  45. if ! grep -qxF '#include <trace/hooks/fs.h>' ./fs/namespace.c; then
  46. echo "[INFO] Adding missing #include <trace/hooks/fs.h> to fs/namespace.c."
  47. sed -i '/#include <trace\/hooks\/blk.h>/a #include <trace\/hooks\/fs.h>' ./fs/namespace.c
  48. else
  49. echo "[INFO] #include <trace/hooks/fs.h> already present."
  50. fi
  51. fi
  52. - shell: bash
  53. if: ${{ (inputs.kernel_version == '5.10' && inputs.android_version == 'android12' && inputs.sublevel == 226) || (inputs.kernel_version == '5.10' && inputs.android_version == 'android13' && inputs.sublevel == 223) || (inputs.kernel_version == '5.15' && inputs.android_version == 'android13' && inputs.sublevel == 167) || (inputs.kernel_version == '5.10' && inputs.android_version == 'android13' && inputs.sublevel == 223) || (inputs.kernel_version == '5.15' && inputs.android_version == 'android14' && inputs.sublevel == 167) }}
  54. working-directory: ${{ github.workspace }}/kernel/common
  55. run: |
  56. sed -i 's/\s*vm_flags_clear(new_vma, VM_PAD_MASK);/ new_vma->vm_flags \&= ~VM_PAD_MASK;/' mm/mmap.c