action.yml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. name: Build pinned NoMount metamodule
  2. description: Package a flashable NoMount metamodule from the exact kernel integration SHA
  3. inputs:
  4. commit:
  5. description: 'Full immutable NoMount commit SHA'
  6. required: true
  7. outputs:
  8. module_path:
  9. description: 'Path to the flashable metamodule ZIP'
  10. value: ${{ steps.package.outputs.module_path }}
  11. module_dir:
  12. description: 'Path to the extracted metamodule directory (module.prop, bin/, ...)'
  13. value: ${{ steps.package.outputs.module_dir }}
  14. commit:
  15. description: 'Verified NoMount source SHA'
  16. value: ${{ steps.package.outputs.commit }}
  17. runs:
  18. using: composite
  19. steps:
  20. - name: Set up Zig
  21. uses: jetsung/setup-zig@v0.0.4
  22. with:
  23. version: master
  24. - name: Build and package matching metamodule
  25. id: package
  26. shell: bash
  27. run: |
  28. set -euo pipefail
  29. expected_commit="${{ inputs.commit }}"
  30. if ! [[ "$expected_commit" =~ ^[0-9a-f]{40}$ ]]; then
  31. echo "NoMount commit must be a full 40-character SHA." >&2
  32. exit 2
  33. fi
  34. source_dir="${RUNNER_TEMP}/nomount-module-source"
  35. module_dir="${RUNNER_TEMP}/nomount-metamodule"
  36. module_zip="${RUNNER_TEMP}/NoMount-${expected_commit}.zip"
  37. git clone --no-checkout https://github.com/maxsteeel/nomount.git "$source_dir"
  38. git -C "$source_dir" fetch --depth=1 origin "$expected_commit"
  39. git -C "$source_dir" checkout --detach "$expected_commit"
  40. actual_commit="$(git -C "$source_dir" rev-parse HEAD)"
  41. if [ "$actual_commit" != "$expected_commit" ]; then
  42. echo "NoMount module source mismatch: expected $expected_commit, got $actual_commit." >&2
  43. exit 1
  44. fi
  45. mkdir -p "$source_dir/bin"
  46. (
  47. cd "$source_dir/userspace/src"
  48. zig cc -target aarch64-linux -Oz -mcmodel=tiny -static -nostdlib \
  49. -ffreestanding -fno-unwind-tables -fno-ident -Wno-invalid-noreturn \
  50. -Wl,--entry=_start nm.c -o ../../bin/nm-arm64
  51. zig cc -target arm-linux -Oz -static -nostdlib -ffreestanding \
  52. -fno-unwind-tables -fno-ident -Wno-invalid-noreturn \
  53. -ffunction-sections -fdata-sections -Wl,--gc-sections \
  54. -Wl,--entry=_start nm.c -o ../../bin/nm-arm
  55. )
  56. cp -a "$source_dir/module" "$module_dir"
  57. mkdir -p "$module_dir/bin"
  58. install -m 0755 "$source_dir/bin/nm-arm64" "$module_dir/bin/nm-arm64"
  59. install -m 0755 "$source_dir/bin/nm-arm" "$module_dir/bin/nm-arm"
  60. sed -i "s/^versionCode=.*/versionCode=1/" "$module_dir/module.prop"
  61. printf '%s\n' "$actual_commit" > "$module_dir/NOMOUNT_SOURCE_COMMIT"
  62. (
  63. cd "$module_dir"
  64. zip -qr "$module_zip" .
  65. )
  66. sha256sum "$module_zip" > "${module_zip}.sha256"
  67. echo "module_path=$module_zip" >> "$GITHUB_OUTPUT"
  68. echo "module_dir=$module_dir" >> "$GITHUB_OUTPUT"
  69. echo "commit=$actual_commit" >> "$GITHUB_OUTPUT"