action.yml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. - name: 'Apply Makefile and parse-options.c fixes for GLIBC >= 2.38'
  20. working-directory: ${{ github.workspace }}/kernel/common
  21. shell: bash
  22. run: |
  23. set -euo pipefail
  24. GLIBC_VERSION="$(ldd --version 2>/dev/null | head -n 1 | awk '{print $NF}')"
  25. echo "[INFO] Detected GLIBC version: $GLIBC_VERSION"
  26. if [ "$(printf '%s\n' "2.38" "$GLIBC_VERSION" | sort -V | head -n 1)" = "2.38" ]; then
  27. echo "[INFO] GLIBC >= 2.38, applying Makefile fix."
  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. - name: 'Create GitHub Summary for Makefile changes'
  42. shell: bash
  43. working-directory: ${{ github.workspace }}/kernel/common
  44. run: |
  45. echo "## Makefile and parse-options.c Fixes Applied" >> $GITHUB_STEP_SUMMARY
  46. echo "" >> $GITHUB_STEP_SUMMARY
  47. echo "### GLIBC Check" >> $GITHUB_STEP_SUMMARY
  48. GLIBC_VERSION="$(ldd --version 2>/dev/null | head -n 1 | awk '{print $NF}')"
  49. echo "- Detected GLIBC Version: **$GLIBC_VERSION**" >> $GITHUB_STEP_SUMMARY
  50. echo "" >> $GITHUB_STEP_SUMMARY
  51. if [ "$(printf '%s\n' "2.38" "$GLIBC_VERSION" | sort -V | head -n 1)" = "2.38" ]; then
  52. echo "### Changes Made" >> $GITHUB_STEP_SUMMARY
  53. # Check if Makefile was modified
  54. if grep -q "EXTRA_CFLAGS" tools/bpf/resolve_btfids/Makefile; then
  55. echo "✅ **Makefile Modified**: Added EXTRA_CFLAGS to MAKE command" >> $GITHUB_STEP_SUMMARY
  56. echo '```' >> $GITHUB_STEP_SUMMARY
  57. grep "EXTRA_CFLAGS" tools/bpf/resolve_btfids/Makefile | head -n 1 >> $GITHUB_STEP_SUMMARY
  58. echo '```' >> $GITHUB_STEP_SUMMARY
  59. else
  60. echo "⚠️ **Makefile Not Modified**: Pattern not found or sed failed" >> $GITHUB_STEP_SUMMARY
  61. fi
  62. echo "" >> $GITHUB_STEP_SUMMARY
  63. # Check parse-options.c changes
  64. if grep -q "^int i;" tools/lib/subcmd/parse-options.c; then
  65. echo "✅ **parse-options.c Modified**: Added variable declarations and fixed loop syntax" >> $GITHUB_STEP_SUMMARY
  66. else
  67. echo "⚠️ **parse-options.c Not Modified**: Conditions not met or sed failed" >> $GITHUB_STEP_SUMMARY
  68. fi
  69. else
  70. echo "### No Changes" >> $GITHUB_STEP_SUMMARY
  71. echo "- GLIBC < 2.38, skipping all fixes" >> $GITHUB_STEP_SUMMARY
  72. fi
  73. - name: 'Apply mmap.c fix for specific versions'
  74. shell: bash
  75. if: ${{ inputs.kernel_version == '6.6' && inputs.android_version == 'android15' && inputs.sublevel <= '58' }}
  76. working-directory: ${{ github.workspace }}/kernel/common
  77. run: |
  78. echo "[INFO] Checking for android15 + kernel 6.6 include fix..."
  79. if [[ "${{ inputs.android_version }}" == "android15" && "${{ inputs.kernel_version }}" == "6.6" ]]; then
  80. echo "[MATCH] android15 + 6.6, checking for fs.h include."
  81. cd "$GITHUB_WORKSPACE/kernel/common"
  82. if ! grep -qxF '#include <trace/hooks/fs.h>' ./fs/namespace.c; then
  83. echo "[INFO] Adding missing #include <trace/hooks/fs.h> to fs/namespace.c."
  84. sed -i '/#include <trace\/hooks\/blk.h>/a #include <trace\/hooks\/fs.h>' ./fs/namespace.c
  85. else
  86. echo "[INFO] #include <trace/hooks/fs.h> already present."
  87. fi
  88. fi
  89. - name: 'Apply mmap.c fix for specific versions'
  90. shell: bash
  91. 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) }}
  92. working-directory: ${{ github.workspace }}/kernel/common
  93. run: |
  94. sed -i 's/\s*vm_flags_clear(new_vma, VM_PAD_MASK);/ new_vma->vm_flags \&= ~VM_PAD_MASK;/' mm/mmap.c