Prepare audited Vinix ports inputs for ISO releases
@@ -166,6 +166,18 @@ The cold and staged roots are archived in `foundation/archived-native-layer-proo
166166
167167The separate service build in `foundation/vpac-desktop-services-02` used the SDK extracted from the signed x86_64 release root. Vinix's desktop service builder linked `vinix-session`, `vinix-timesync` and `vinix-service-runner` as static x86_64 ELFs against the source-built GCC and musl packages. The receipt SHA-256 is `68b1094001b212c2ec7996d15dc249ccaec5fc75fa296bbb58cad24f3909c139`.
168168
169+For Vinix's release driver with `--ports-inputs` support, prepare one directory per architecture. Use a signed feed containing both desktop and X11, a cold desktop client, and a second client with X11 installed in addition to the same desktop versions. Pass a native layer built from the selected Vinix source revision and the release signer's independently obtained fingerprint.
170+
171+```sh
172+python3 tools/release-inputs.py "$arch" "$repo" "$desktop_client" "$desktop_x11_client" \
173+ "$native_layer" "$auditor" "$release_inputs/$release_arch" \
174+ "$fingerprint" "$vinix_commit" "$release_tag"
175+```
176+
177+Use `amd64` or `arm64` for `release_arch`. The tool checks the native desktop and login ELF targets, requires the signed seed to contain the installed versions from both clients, and adds the release tag to the initramfs. It writes the initramfs, X11 overlay, build info and checksum files together. The ISO driver checks the checksums and build info against its selected release before building the kernel.
178+
179+`python3 tests/release-inputs.py` covers the output format and wrong-architecture rejection. The worker also confirmed the tag in a signed test initramfs and rejected a second client requiring a package missing from the signed seed. See `foundation/ports-release-inputs-contract-02`, receipt SHA-256 `75e7b4ae23a4f0ea27f93dfd740d37d1ed3abc4cfbea906ec957186c65a1e543`.
180+
169181To publish only the runtime closure selected by the release plan, use `tools/release-feed.py` with the matching `coverage.tsv`. It follows runtime dependency edges and rechecks every planned archive's version and SHA-256 before signing. The worker cold-installed `busybox-init` by name from this feed and audited six packages, 832 owned paths and 15 ELFs. The same test refused an incomplete X11 closure and a changed archive digest before creating either repository. See `foundation/exact-release-feed-proof-01`, receipt SHA-256 `e50d2c759f1e0045a9ef6e42522e02e6de4cfd03d9f51d6b5d6045d23d5cbdc3`.
170182
171183```sh
@@ -0,0 +1,70 @@
1+"""Check the file contract between the ports worker and Vinix's ISO builder."""
2+
3+import argparse
4+import hashlib
5+from importlib import import_module
6+from pathlib import Path
7+import sys
8+import tempfile
9+import unittest
10+from unittest.mock import patch
11+
12+
13+sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "tools"))
14+release_inputs = import_module("release-inputs")
15+
16+
17+class ReleaseInputs(unittest.TestCase):
18+ def setUp(self):
19+ temp = tempfile.TemporaryDirectory()
20+ self.addCleanup(temp.cleanup)
21+ root = Path(temp.name)
22+ self.args = argparse.Namespace(
23+ arch="aarch64", native=root / "native", output=root / "arm64", release="iso-fixture",
24+ commit="a" * 40, repo=root / "repo", desktop=root / "desktop",
25+ graphics=root / "graphics", auditor=root / "audit", fingerprint="a" * 40)
26+ for name in ("bin/vinix-desktop", "sbin/vinix-session", "sbin/vinix-authd",
27+ "sbin/vinix-system", "sbin/vinix-account"):
28+ path = self.args.native / "usr" / name
29+ path.parent.mkdir(parents=True, exist_ok=True)
30+ path.write_bytes(b"\x7fELF\x02\x01" + bytes(12) + (183).to_bytes(2, "little"))
31+ path.chmod(0o755)
32+
33+ def test_freezes_checked_inputs_and_passes_release_tag(self):
34+ names = ["initramfs.tar", "vinix-x11-arm64.tar.gz", "vinix-x11-arm64.tar.gz.sha256", "build-info"]
35+
36+ def stage(argv, check):
37+ self.assertTrue(check)
38+ if argv[1].name == "bundle-x11.py":
39+ target = argv[-1]
40+ target.mkdir()
41+ sidecar = target / names[1]
42+ sidecar.write_bytes(b"sidecar")
43+ digest = hashlib.sha256(sidecar.read_bytes()).hexdigest()
44+ (target / names[2]).write_text(f"{digest} {sidecar.name}\n")
45+ else:
46+ self.assertEqual(argv[1].name, "stage-image.py")
47+ self.assertIn("--release=iso-fixture", argv)
48+ self.assertEqual(argv[-2:], ["--seed-client", self.args.graphics])
49+ argv[5].mkdir()
50+ (argv[5] / names[0]).write_bytes(b"initramfs")
51+
52+ with patch.object(release_inputs.subprocess, "run", side_effect=stage):
53+ release_inputs.assemble(self.args)
54+ output = self.args.output
55+ self.assertEqual((output / "build-info").read_text(),
56+ f"commit={self.args.commit}\nrelease=iso-fixture\narch=arm64\n")
57+ self.assertEqual((output / "SHA256SUMS").read_text().splitlines(), [
58+ f"{hashlib.sha256((output / name).read_bytes()).hexdigest()} {name}"
59+ for name in sorted(names)
60+ ])
61+
62+ def test_rejects_native_program_for_the_other_cpu(self):
63+ self.args.arch = "x86_64"
64+ with self.assertRaisesRegex(ValueError, "wrong ELF architecture"):
65+ release_inputs.assemble(self.args)
66+ self.assertFalse(self.args.output.exists())
67+
68+
69+if __name__ == "__main__":
70+ unittest.main()
@@ -0,0 +1,64 @@
1+"""Prepare the audited initramfs and X11 sidecar consumed by deploy-iso.sh."""
2+
3+import argparse
4+import hashlib
5+import os
6+from pathlib import Path
7+import re
8+import subprocess
9+import sys
10+import tempfile
11+
12+
13+def assemble(args):
14+ output = args.output
15+ if output.exists() or output.is_symlink():
16+ raise FileExistsError(output)
17+ arch = "amd64" if args.arch == "x86_64" else "arm64"
18+ if not re.fullmatch(r"[0-9a-f]{40}", args.commit):
19+ raise ValueError("expected the full Vinix source commit")
20+ if args.release and not re.fullmatch(r"[A-Za-z0-9][A-Za-z0-9._-]*", args.release):
21+ raise ValueError("invalid Vinix release tag")
22+ programs = ["usr/bin/vinix-desktop", "usr/sbin/vinix-account", "usr/sbin/vinix-authd",
23+ "usr/sbin/vinix-session", "usr/sbin/vinix-system"]
24+ machine = 62 if args.arch == "x86_64" else 183
25+ for program in programs:
26+ path = args.native / program
27+ if path.is_symlink() or not path.is_file() or not os.access(path, os.X_OK):
28+ raise ValueError(f"native layer is missing executable /{program}")
29+ with path.open("rb") as stream:
30+ header = stream.read(20)
31+ if header[:6] != b"\x7fELF\x02\x01" or int.from_bytes(header[18:20], "little") != machine:
32+ raise ValueError(f"native layer executable has the wrong ELF architecture: /{program}")
33+
34+ tools = Path(__file__).resolve().parent
35+ with tempfile.TemporaryDirectory(prefix=".ports-inputs-", dir=output.parent) as temporary:
36+ work = Path(temporary)
37+ bundle = work / "bundle"
38+ stage = work / "image"
39+ subprocess.run([sys.executable, tools / "bundle-x11.py", args.arch, args.desktop,
40+ args.graphics, args.auditor, bundle], check=True)
41+ subprocess.run([sys.executable, tools / "stage-image.py", args.arch, args.desktop,
42+ args.repo, stage, args.auditor, args.fingerprint, "--native-layer",
43+ args.native, "--initramfs", f"--release={args.release}",
44+ "--seed-client", args.graphics], check=True)
45+ (stage / "initramfs.tar").rename(bundle / "initramfs.tar")
46+ info = bundle / "build-info"
47+ info.write_text(f"commit={args.commit}\nrelease={args.release}\narch={arch}\n")
48+ assets = sorted(bundle.iterdir())
49+ with (bundle / "SHA256SUMS").open("x") as manifest:
50+ for path in assets:
51+ with path.open("rb") as stream:
52+ digest = hashlib.file_digest(stream, "sha256").hexdigest()
53+ manifest.write(f"{digest} {path.name}\n")
54+ bundle.rename(output)
55+
56+
57+if __name__ == "__main__":
58+ parser = argparse.ArgumentParser(description=__doc__)
59+ parser.add_argument("arch", choices=("x86_64", "aarch64"))
60+ for name in ("repo", "desktop", "graphics", "native", "auditor", "output"):
61+ parser.add_argument(name, type=lambda path: Path(path).absolute())
62+ for name in ("fingerprint", "commit", "release"):
63+ parser.add_argument(name)
64+ assemble(parser.parse_args())
@@ -155,10 +155,14 @@ def stage(args):
155155 indexed = snapshot(repo / args.arch, package_dir, root / "usr/share/vpac/keyrings/vinix.gpg",
156156 args.arch, gpg_home)
157157 records = client / "db/local"
158- for description in records.glob("*/desc"):
159- info = package_fields(description.read_text())
160- if indexed.get(info["NAME"]) != info["VERSION"]:
161- raise ValueError(f"installed package missing from seed at its exact version: {info['NAME']}")
158+ for database in [records, *(root / "db/local" for root in args.seed_client)]:
159+ descriptions = sorted(database.glob("*/desc"))
160+ if not descriptions:
161+ raise ValueError(f"client has no package records at {database}")
162+ for description in descriptions:
163+ info = package_fields(description.read_text())
164+ if indexed.get(info["NAME"]) != info["VERSION"]:
165+ raise ValueError(f"installed package missing from seed at its exact version: {info['NAME']}")
162166 db = write_directory(root, "var/lib/vpac")
163167 if any(db.iterdir()):
164168 raise ValueError("package database directory is already populated")
@@ -174,6 +178,11 @@ def stage(args):
174178 table = csv.writer(records, delimiter="\t", lineterminator="\n")
175179 table.writerow(("path", "type", "mode", "sha256_or_link"))
176180 install_native_layer(native, root, table)
181+ if args.release:
182+ release_file = write_directory(root, "etc") / "vinix-release"
183+ with release_file.open("x") as output_file:
184+ output_file.write(args.release + "\n")
185+ release_file.chmod(0o644)
177186 if args.initramfs:
178187 if os.path.lexists(root / ".vinix-image-id"):
179188 raise ValueError("the ISO builder assigns the image identity")
@@ -195,5 +204,8 @@ if __name__ == "__main__":
195204 parser.add_argument(arg, type=Path)
196205 parser.add_argument("fingerprint", help="trusted distributor fingerprint from outside the feed")
197206 parser.add_argument("--native-layer", type=Path, help="Vinix-built programs and assets to add to the image")
207+ parser.add_argument("--release", default="", help="release tag stored in /etc/vinix-release")
208+ parser.add_argument("--seed-client", type=Path, action="append", default=[],
209+ help="require the installed versions from another audited client in the seed")
198210 parser.add_argument("--initramfs", action="store_true", help="write a root-owned USTAR archive for the ISO builder")
199211 stage(parser.parse_args())