From 5b0135e9d315dea1b363b81476bc8f88dfef003a Mon Sep 17 00:00:00 2001 From: diviocity Date: Tue, 1 Dec 2026 00:13:45 +0100 Subject: [PATCH] Stage release initramfs archives without duplicating package roots --- tests/FEED.md | 2 ++ tests/release-inputs.py | 1 + tools/release-inputs.py | 2 +- tools/stage-image.py | 18 ++++++++++++++---- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/tests/FEED.md b/tests/FEED.md index 7376f25..da7f5d4 100644 --- a/tests/FEED.md +++ b/tests/FEED.md @@ -160,6 +160,8 @@ python3 tools/stage-image.py "$arch" "$client" "$repo" "$output" "$work/audit" \ Use `$output/initramfs.tar` as `VINIX_AMD64_INITRAMFS` or `VINIX_AARCH64_INITRAMFS` in Vinix's architecture-specific ISO assembly command. Run `python3 tests/native-layer.py` for the layer regression checks. +`tools/release-inputs.py` uses `--initramfs-only` for release assembly. The temporary root shares package files when it is on the same filesystem as the cold client, and only the archive and manifests are retained. The worker assembled signed seed archives for both architectures and checked the cold clients' file hashes, ownership, permissions, inodes and link counts before and after. See `foundation/ports-initramfs-only-proof-01`, receipt SHA-256 `bd3c147af90c8237c412f6bc141748144535f92c8e2a6afcc241d9d15a49d23d`. + Run `python3 tools/check-iso-initramfs.py "$output/initramfs.tar" "$iso"` against each assembled ISO before accepting its release evidence. The checker compares the embedded tar payload byte for byte with the audited input and verifies the image identity that the ISO builder writes into the gzip header and appends to the tar. Run `python3 tests/iso-initramfs.py` to exercise rejection of altered payloads, wrong identities and added tar entries. Both architecture-specific Vinix builders assembled test ISOs with the small, signed seed fixtures and the candidate kernels. The checker verified both embedded initramfs files and rejected the x86_64 ISO when given the AArch64 input. See `foundation/ports-candidate-iso-payload-proof-01`, receipt SHA-256 `cec4ae5654fe6a4c9967fd4d6e45ccf654c11902a0c16fa81eb3ab616037b2be`. diff --git a/tests/release-inputs.py b/tests/release-inputs.py index a928718..0fb6b0d 100644 --- a/tests/release-inputs.py +++ b/tests/release-inputs.py @@ -47,6 +47,7 @@ class ReleaseInputs(unittest.TestCase): else: self.assertEqual(argv[1].name, "stage-image.py") self.assertIn("--release=iso-fixture", argv) + self.assertIn("--initramfs-only", argv) self.assertEqual(argv[-4:], ["--seed-client", self.args.graphics, "--archive-coverage", self.args.archive_coverage]) argv[5].mkdir() diff --git a/tools/release-inputs.py b/tools/release-inputs.py index a5808d1..4d4ad85 100644 --- a/tools/release-inputs.py +++ b/tools/release-inputs.py @@ -43,7 +43,7 @@ def assemble(args): subprocess.run(bundle_command, check=True) command = [sys.executable, tools / "stage-image.py", args.arch, args.desktop, args.repo, stage, args.auditor, args.fingerprint, "--native-layer", - args.native, "--initramfs", f"--release={args.release}", + args.native, "--initramfs-only", f"--release={args.release}", "--seed-client", args.graphics] if args.archive_coverage: command.extend(["--archive-coverage", args.archive_coverage]) diff --git a/tools/stage-image.py b/tools/stage-image.py index 309f694..857e417 100644 --- a/tools/stage-image.py +++ b/tools/stage-image.py @@ -176,7 +176,14 @@ def stage(args): with tempfile.TemporaryDirectory(dir=output) as directory: staging = Path(directory) root = staging / "image" - subprocess.run(["cp", "-a", "--reflink=auto", client / "root", root], check=True) + package_root = client / "root" + # Archive-only assembly reads the package files and adds files at new + # paths. The temporary root never becomes a writable output tree. + if args.initramfs_only and package_root.stat().st_dev == staging.stat().st_dev: + copy_mode = ["-al"] + else: + copy_mode = ["-a", "--reflink=auto"] + subprocess.run(["cp", *copy_mode, package_root, root], check=True) # This compares the installed certificate with the independently supplied pin. seed = Path(__file__).resolve().with_name("keyring.py") subprocess.run([sys.executable, seed, "seed", root, args.fingerprint], check=True) @@ -215,7 +222,7 @@ def stage(args): with release_file.open("x") as output_file: output_file.write(args.release + "\n") release_file.chmod(0o644) - if args.initramfs: + if args.initramfs or args.initramfs_only: if os.path.lexists(root / ".vinix-image-id"): raise ValueError("the ISO builder assigns the image identity") image = staging / "initramfs.tar" @@ -224,7 +231,8 @@ def stage(args): for artifact in ("native-layer.tsv", "initramfs.tar"): if (staging / artifact).exists(): (staging / artifact).rename(output / artifact) - root.rename(output / "root") + if not args.initramfs_only: + root.rename(output / "root") print(audit, end="") print(f"staged {len(indexed)} signed seed packages and the installed database") @@ -240,5 +248,7 @@ if __name__ == "__main__": parser.add_argument("--seed-client", type=Path, action="append", default=[], help="require the installed versions from another audited client in the seed") parser.add_argument("--archive-coverage", type=Path, help="match signed seed packages to verified release archives") - parser.add_argument("--initramfs", action="store_true", help="write a root-owned USTAR archive for the ISO builder") + media = parser.add_mutually_exclusive_group() + media.add_argument("--initramfs", action="store_true", help="also write a root-owned USTAR archive") + media.add_argument("--initramfs-only", action="store_true", help="write a root-owned USTAR archive without keeping an unpacked root") stage(parser.parse_args()) -- 2.56.1