action.yml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. name: apply susfs patches
  2. description: apply susfs patches
  3. inputs:
  4. nomount:
  5. description: 'nomount'
  6. required: true
  7. runs:
  8. using: composite
  9. steps:
  10. - name: clone susfs
  11. shell: bash
  12. run: |
  13. SUSFS_BRANCH="gki-$ANDROID_VER-$KERNEL_VER"
  14. git clone https://gitlab.com/simonpunk/susfs4ksu.git -b "$SUSFS_BRANCH"
  15. git config --global user.name "github-actions[bot]"
  16. git config --global user.email "41898282+github-actions[bot]@://github.com"
  17. cd susfs4ksu
  18. git fetch https://gitlab.com/pershoot/susfs4ksu.git gki-android14-6.1-dev
  19. git log ..FETCH_HEAD --oneline -n 2 | awk '{print $1}' | tac | xargs git cherry-pick
  20. #cd susfs4ksu
  21. #if [[ "$ANDROID_VER-$KERNEL_VER" == "android12-5.10" ]]; then
  22. #COMMIT=ce2c2b2dea28c89d33f61af898cc18a93bf65ae9
  23. #elif [[ "$ANDROID_VER-$KERNEL_VER" == "android13-5.15" ]]; then
  24. # COMMIT=529919fbc9f8aee6ee70eb3a8890ef33af0a109c
  25. #elif [[ "$ANDROID_VER-$KERNEL_VER" == "android14-6.1" ]]; then
  26. #COMMIT=d1327b62e0854603cfc26e2226e0a993ec9b0656
  27. #elif [[ "$ANDROID_VER-$KERNEL_VER" == "android15-6.6" ]]; then
  28. #COMMIT=676d202ed2cc322a2f90bcb2b56bc4f6a864acb8
  29. #fi
  30. #git checkout "$COMMIT"
  31. SUSFS4KSU="$ROOT/susfs4ksu"
  32. echo "SUSFS4KSU=$SUSFS4KSU" >> $GITHUB_ENV
  33. - name: Apply to KSUN
  34. shell: bash
  35. run: |
  36. #cd "$COMMON/KernelSU-Next"
  37. #SUSFS_VERSION="v2.1.0"
  38. # Apply SUSFS to KernelSU-Next
  39. #cp "$SUSFS4KSU/kernel_patches/KernelSU/10_enable_susfs_for_ksu.patch" .
  40. #patch -p1 < 10_enable_susfs_for_ksu.patch || true
  41. #rm -rf 10_enable_susfs_for_ksu.patch
  42. #Fix rejects from adding susfs to KSUN
  43. #cp "$KERNEL_PATCHES/next/susfs_fix_patches/$SUSFS_VERSION/"*.patch .
  44. #rm -rf multi_manager.patch
  45. #for p in *.patch; do
  46. # patch -p1 < "$p"
  47. # rm -f "$p"
  48. #done
  49. - name: Copy required files
  50. shell: bash
  51. run: |
  52. # Apply SUSFS to kernel
  53. cd "$COMMON"
  54. cp "$SUSFS4KSU/kernel_patches/fs/"* ./fs/
  55. cp "$SUSFS4KSU/kernel_patches/include/linux/"* ./include/linux/
  56. cp "$SUSFS4KSU/kernel_patches/50_add_susfs_in_gki-$ANDROID_VER-$KERNEL_VER.patch" ./
  57. - name: prepare namespace and open.c for susfs patch because scamsung
  58. shell: bash
  59. run: |
  60. cd "$COMMON"
  61. #Prepare open.c for susfs patching
  62. sed -i '/#ifdef CONFIG_SECURITY_DEFEX/,/^#endif/d' fs/open.c
  63. #Prepare namespace.c for susfs patching
  64. sed -i '/copy_flags = CL_COPY_UNBINDABLE | CL_EXPIRE;/,/#endif/ {
  65. /#ifdef CONFIG_KDP_NS/,/#endif/ {
  66. /#else/,/#endif/!d
  67. /#else/d
  68. /#endif/d
  69. }
  70. }' fs/namespace.c
  71. - name: apply susfs patch and fix if necessary
  72. shell: bash
  73. run: |
  74. cd "$COMMON"
  75. # Apply SUSFS core patch
  76. patch -p1 < 50_add_susfs_in_gki-$ANDROID_VER-$KERNEL_VER.patch || true
  77. rm -rf 50_add_susfs_in_gki-$ANDROID_VER-$KERNEL_VER.patch
  78. shopt -s nullglob
  79. patches=("$KERNEL_PATCHES/samsung/$BRANCH"/*.patch)
  80. if [ ${#patches[@]} -gt 0 ]; then
  81. echo "Patches found, applying..."
  82. cp "${patches[@]}" ./
  83. # Fix SUSFS rejects
  84. for p in *.patch; do
  85. patch -p1 < "$p"
  86. rm -f "$p"
  87. done
  88. shopt -u nullglob
  89. else
  90. echo "No patch file found, skipping"
  91. fi
  92. # SUSFS's OPEN_REDIRECT code unconditionally calls VMA_PAD_START(), which
  93. # only exists on GKI branches that carry Google's page-size-migration
  94. # feature (added to each android version's kernel/common branch at a
  95. # different, sometime later, os_patch_level). Older os_patch_levels in
  96. # our build matrix predate it, so fall back to a no-padding definition
  97. # when the real header/macro isn't present. This is version-agnostic and
  98. # a no-op wherever the real header already provides it.
  99. if grep -q 'VMA_PAD_START(' fs/proc/task_mmu.c && ! grep -qE '#include <linux/pgsize_migration(_inline)?\.h>|define VMA_PAD_START' fs/proc/task_mmu.c; then
  100. sed -i '1a #ifndef VMA_PAD_START\n#define VMA_PAD_START(vma) ((vma)->vm_end)\n#endif' fs/proc/task_mmu.c
  101. echo "Added VMA_PAD_START fallback definition to fs/proc/task_mmu.c"
  102. fi
  103. # Same story for __fold_filemap_fixup_entry(), declared in page_size_compat.h.
  104. if grep -q '__fold_filemap_fixup_entry' fs/proc/task_mmu.c && ! grep -q '#include <linux/page_size_compat.h>' fs/proc/task_mmu.c; then
  105. sed -i '/#include <linux\/pkeys.h>/a #include <linux/page_size_compat.h>' fs/proc/task_mmu.c
  106. echo "Added page_size_compat.h include to fs/proc/task_mmu.c"
  107. fi
  108. - name: add ksu-susfs to config
  109. shell: bash
  110. run: |
  111. "$COMMON/scripts/config" --file "$GKI_DEFCONFIG" --enable CONFIG_KSU_SUSFS
  112. - name: remove open redirect if nomount is enabled
  113. if: inputs.nomount == 'true'
  114. shell: bash
  115. run: |
  116. "$COMMON/scripts/config" --file "$GKI_DEFCONFIG" --disable CONFIG_KSU_SUSFS_OPEN_REDIRECT