From 989591dfe42b1f82f4df8c6ad566de213bcf5291 Mon Sep 17 00:00:00 2001 From: Codex Date: Tue, 13 Oct 2026 05:10:43 +0300 Subject: [PATCH] fix(image): use compatible findmnt mount guard options --- hydra/build.py | 2 +- tests/test_image.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/hydra/build.py b/hydra/build.py index 5cce97b..6c945ee 100644 --- a/hydra/build.py +++ b/hydra/build.py @@ -60,7 +60,7 @@ sys.exit(code) def rootfs_retry_guard_script(): """Refuse deletion of a still-mounted export, including nested mountpoints.""" - return r"""mounts=$(findmnt --list --raw --noheadings --output TARGET) + return r"""mounts=$(findmnt --raw --noheadings --output TARGET) while IFS= read -r mountpoint; do case "$mountpoint" in "$root"|"$root/"*) echo 'Refusing to remove a mounted rootfs export' >&2; exit 1 ;; diff --git a/tests/test_image.py b/tests/test_image.py index 5880bdb..464e30c 100644 --- a/tests/test_image.py +++ b/tests/test_image.py @@ -128,6 +128,14 @@ class ImageTests(unittest.TestCase): self.assertEqual(actual, expected) self.assertEqual(result.returncode == 0, not failed and not cleanup_failed) + def test_retry_guard_uses_valid_real_findmnt_options(self): + from hydra.build import rootfs_retry_guard_script + self.file('.hydra-export-owned') + script = 'set -eu\nroot=' + shlex.quote(str(self.root)) + '\n' + rootfs_retry_guard_script() + result = subprocess.run(['bash', '-c', script], capture_output=True, text=True) + self.assertEqual(result.returncode, 0, result.stderr) + self.assertFalse(self.root.exists()) + def test_retry_refuses_removing_owned_rootfs_with_stale_child_mount(self): from hydra.build import rootfs_retry_guard_script marker = self.file('.hydra-export-owned')