action.yml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. name: 'Remove Protected Exports'
  2. description: 'Remove ABI protected exports and protected modules for Bazel builds with verification'
  3. runs:
  4. using: "composite"
  5. steps:
  6. - name: Remove Protected Exports (Bazel)
  7. shell: bash
  8. working-directory: ${{ github.workspace }}/kernel
  9. run: |
  10. set -euo pipefail
  11. if [ -f "build/build.sh" ]; then
  12. exit 0
  13. fi
  14. rm -rf common/android/abi_gki_protected_exports_*
  15. if ls -1 common/android/abi_gki_protected_exports_* >/dev/null 2>&1; then
  16. echo "Error: abi_gki_protected_exports_* still exists after removal"
  17. ls -la common/android/abi_gki_protected_exports_* || true
  18. exit 1
  19. fi
  20. if grep -q '"protected_exports_list"[[:space:]]*:[[:space:]]*"android/abi_gki_protected_exports_aarch64"' common/BUILD.bazel; then
  21. BEFORE_BUILD_BAZEL_SHA="$(sha256sum common/BUILD.bazel | awk '{print $1}')"
  22. perl -pi -e 's/^\s*"protected_exports_list"\s*:\s*"android\/abi_gki_protected_exports_aarch64",\s*$//;' common/BUILD.bazel
  23. AFTER_BUILD_BAZEL_SHA="$(sha256sum common/BUILD.bazel | awk '{print $1}')"
  24. if [ "$BEFORE_BUILD_BAZEL_SHA" = "$AFTER_BUILD_BAZEL_SHA" ]; then
  25. echo "Error: common/BUILD.bazel was not modified"
  26. exit 1
  27. fi
  28. if grep -q '"protected_exports_list"[[:space:]]*:[[:space:]]*"android/abi_gki_protected_exports_aarch64"' common/BUILD.bazel; then
  29. echo "Error: protected_exports_list reference still present in common/BUILD.bazel"
  30. exit 1
  31. fi
  32. fi
  33. if grep -q '^protected_modules = ' common/modules.bzl; then
  34. BEFORE_MODULES_BZL_SHA="$(sha256sum common/modules.bzl | awk '{print $1}')"
  35. sed -i 's/protected_modules = \[.*\]/protected_modules = []/' common/modules.bzl
  36. AFTER_MODULES_BZL_SHA="$(sha256sum common/modules.bzl | awk '{print $1}')"
  37. if [ "$BEFORE_MODULES_BZL_SHA" = "$AFTER_MODULES_BZL_SHA" ]; then
  38. echo "Error: common/modules.bzl was not modified"
  39. exit 1
  40. fi
  41. if ! grep -q '^protected_modules = \[\]' common/modules.bzl; then
  42. echo "Error: protected_modules was not set to [] in common/modules.bzl"
  43. exit 1
  44. fi
  45. fi
  46. # Remove protected_module_names_list for 6.12+ kernels (Bazel build system)
  47. if grep -q 'protected_module_names_list' common/BUILD.bazel; then
  48. BEFORE_BUILD_BAZEL_SHA="$(sha256sum common/BUILD.bazel | awk '{print $1}')"
  49. perl -pi -e 's/^\s*protected_module_names_list\s*=\s*":gki_(?:aarch64|x86_64)_protected_module_names",\s*$//;' common/BUILD.bazel
  50. AFTER_BUILD_BAZEL_SHA="$(sha256sum common/BUILD.bazel | awk '{print $1}')"
  51. if [ "$BEFORE_BUILD_BAZEL_SHA" = "$AFTER_BUILD_BAZEL_SHA" ]; then
  52. echo "Warning: common/BUILD.bazel was not modified for protected_module_names_list (may not be present)"
  53. fi
  54. if grep -q 'protected_module_names_list' common/BUILD.bazel; then
  55. echo "Error: protected_module_names_list reference still present in common/BUILD.bazel"
  56. grep -n 'protected_module_names_list' common/BUILD.bazel || true
  57. exit 1
  58. fi
  59. fi