action.yml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. name: 'Setup NoMount'
  2. description: 'Integrate NoMount VFS hooks (pinned SHA or latest dev) and enable CONFIG_NOMOUNT'
  3. inputs:
  4. commit:
  5. description: 'Full immutable NoMount commit SHA (empty = latest dev branch tip)'
  6. required: false
  7. default: ''
  8. kernel_version:
  9. description: 'Kernel major/minor version (for example, 5.10 or 6.6)'
  10. required: false
  11. default: ''
  12. outputs:
  13. commit:
  14. description: 'NoMount commit SHA actually integrated'
  15. value: ${{ steps.integrate.outputs.commit }}
  16. runs:
  17. using: composite
  18. steps:
  19. - name: Integrate NoMount
  20. id: integrate
  21. shell: bash
  22. working-directory: ${{ github.workspace }}/kernel
  23. env:
  24. KERNEL_VERSION: ${{ inputs.kernel_version }}
  25. run: |
  26. set -euo pipefail
  27. KERNEL_DIR="${{ github.workspace }}/kernel/common"
  28. test -d "$KERNEL_DIR/fs" || {
  29. echo "Kernel source directory does not exist: $KERNEL_DIR" >&2
  30. exit 1
  31. }
  32. requested_commit="${{ inputs.commit }}"
  33. if [ -z "$requested_commit" ]; then
  34. # Float mode: latest dev branch tip, captured at run time
  35. echo "NoMount: no commit pinned, using latest dev branch tip"
  36. (
  37. cd "$KERNEL_DIR"
  38. curl -fsSL --retry 5 --retry-delay 5 --retry-all-errors \
  39. https://raw.githubusercontent.com/maxsteeel/nomount/refs/heads/dev/kernel/setup.sh | bash -s dev
  40. )
  41. actual_commit="$(git -C "$KERNEL_DIR/NoMount" rev-parse HEAD)"
  42. else
  43. # Pin mode: fetch the setup script at the exact SHA and verify it landed
  44. if ! [[ "$requested_commit" =~ ^[0-9a-f]{40}$ ]]; then
  45. echo "NoMount commit must be a full 40-character SHA." >&2
  46. exit 2
  47. fi
  48. setup_script="${RUNNER_TEMP}/nomount-setup-${requested_commit}.sh"
  49. curl --fail --location --silent --show-error --retry 5 --retry-delay 5 --retry-all-errors \
  50. "https://raw.githubusercontent.com/maxsteeel/nomount/${requested_commit}/kernel/setup.sh" \
  51. --output "$setup_script"
  52. test -s "$setup_script"
  53. chmod 0755 "$setup_script"
  54. # Pre-clone at the exact SHA: upstream rewinds dev often, so a
  55. # fresh clone may no longer contain the pinned tree ("unable to
  56. # read tree"). Fetching by SHA works even for orphaned commits;
  57. # setup.sh then reuses the clone and its checkout succeeds.
  58. if [ ! -d "$KERNEL_DIR/NoMount" ]; then
  59. git clone --no-checkout https://github.com/maxsteeel/nomount.git "$KERNEL_DIR/NoMount"
  60. fi
  61. git -C "$KERNEL_DIR/NoMount" fetch --depth=1 origin "$requested_commit"
  62. git -C "$KERNEL_DIR/NoMount" checkout --detach --quiet "$requested_commit"
  63. (
  64. cd "$KERNEL_DIR"
  65. "$setup_script" "$requested_commit"
  66. )
  67. actual_commit="$(git -C "$KERNEL_DIR/NoMount" rev-parse HEAD)"
  68. if [ "$actual_commit" != "$requested_commit" ]; then
  69. echo "NoMount commit mismatch: expected $requested_commit, got $actual_commit." >&2
  70. exit 1
  71. fi
  72. fi
  73. if [ ! -L "$KERNEL_DIR/fs/nomount" ]; then
  74. echo "NoMount integration failed: fs/nomount symlink missing" >&2
  75. exit 1
  76. fi
  77. echo "commit=$actual_commit" >> "$GITHUB_OUTPUT"
  78. echo "NOMOUNT_COMMIT=$actual_commit" >> "$GITHUB_ENV"
  79. echo "NoMount integrated (kernel $KERNEL_VERSION, commit $actual_commit)"
  80. - name: Enable NoMount in kernel defconfig
  81. uses: ./.github/actions/set-kernel-config
  82. with:
  83. config_list: |
  84. CONFIG_NOMOUNT=y