Просмотр исходного кода

ci(susfs): improve conditional header patching logic

Replace hardcoded Android version and kernel version checks with a more robust approach that detects the actual presence of the trace/hooks/blk.h header in fs/namespace.c. This ensures the patch is applied only when necessary, making the action more maintainable and version-agnostic.
TheWildJames 4 месяцев назад
Родитель
Сommit
ac6ac9b07e
1 измененных файлов с 6 добавлено и 4 удалено
  1. 6 4
      .github/actions/susfs/action.yml

+ 6 - 4
.github/actions/susfs/action.yml

@@ -86,13 +86,15 @@ runs:
         cp "${{ github.workspace }}/susfs4ksu/kernel_patches/include/linux/"* "${{ github.workspace }}/kernel/common/include/linux/"
         cp ${{ github.workspace }}/susfs4ksu/kernel_patches/50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch ./
 
-        if [[ "${{ inputs.android_version }}" == "android14" && "${{ inputs.kernel_version }}" == "6.1" ]]; then
-          sed -i '/#include <trace\/hooks\/blk.h>/d' fs/namespace.c
-        fi
+        FIX_NAMESPACE=0
+        if grep -q '^#include <trace/hooks/blk.h>$' fs/namespace.c; then
+          sed -i '/^#include <trace\/hooks\/blk.h>$/d' fs/namespace.c
+          FIX_NAMESPACE=1
+        fi 
 
         patch -p1 -F3 < 50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true
 
-        if [[ "${{ inputs.android_version }}" == "android14" && "${{ inputs.kernel_version }}" == "6.1" ]]; then
+        if [ "$FIX_NAMESPACE" = "1" ]; then
           sed -i '/^#include "internal.h"$/a #include <trace/hooks/blk.h>' fs/namespace.c
         fi