Verify signed upgrades through the Vinix pkg command
@@ -159,4 +159,6 @@ Run the target vpac binary on the release kernel with `python3 tests/vpac-guest.
159159
160160For the public `pkg` command, install `vinix-pkg`, `busybox-init`, `vinix-keyring`, `vinix-accounts` and `vinix-filesystem` from a signed feed that also contains `netbase`. Stage the installed root under `umask 077` and boot it using `python3 tests/disk-root.py "$arch" "$image/root" tests/userland/pkg.sh "$iso" "$boot" "$output"`. The x86_64 guest refreshed the signed seed index, looked up an exact name and an unmatched prefix, installed `netbase` with signature validation, checked file ownership, and removed the package. The worker verified 41 signed installed records and a 43-package seed. The directory and index modes allow the unprivileged downloader to read the seed and reach its sync work directory. The GnuPG home has mode 0700. See `foundation/vinix-pkg-guest-02`, receipt SHA-256 `695cd4c4b62a2554363b733683985ea7d655bc848e24ecec7368a944eb551c47`.
161161
162+Run `vpac-guest.py` with `--scenario upgrade --package-command pkg` to exercise the public upgrade path. The initial feed needs `vinix-pkg`. Pass `--staged-root "$image/root"` to reuse a clean staged image from the same signed feed on the build volume. The x86_64 replay upgraded the CA bundle to `20261020-3` and checked the signature validation record, the new certificate link and its owner. The original staged root retained release 2. The runner rejected a staged root with a different signed database before creating a guest image. See `foundation/vinix-pkg-upgrade-01` and `foundation/vinix-pkg-upgrade-mismatched-root-01`, receipt SHA-256 `efa7b96701b2f2aeb7afd3ac8398adb3859b818d1dbf90efc1856e44f9059038` and `b670332301bc1005b8dff21a1a6e4342147015a9e6723da2e0b09ddd35f3fe7b`.
163+
162164To exercise the original release binaries against the installed libraries on a worker of the same architecture, run `python3 tests/exec-linkage.py "$arch" "$client" "$auditor" --proot "$proot" --release "$archive" "$sha256" "$report"`. The probe binds one original executable over its guest path and runs the installed musl loader with `--list`. A negative control changed a library import in the original input and verified that the installed loader diagnosed the changed SONAME. In the 129-package x86_64 root, 52 of 95 dynamic image executables relocated, 27 reported failures and 16 fixed-address executables needed direct execution. Twelve of 17 X11 sidecar executables relocated. See `foundation/release-binary-relocation-02`, receipt SHA-256 `8483666ef4294f1ac5d44c1eb637a8f5200be4e613e635d835ef4f86e7ffa37b`. Directly starting the release `cpp` and `cc1` in that root expanded `__SIZEOF_POINTER__` to 8. See `foundation/release-original-exec-02`, receipt SHA-256 `b9f1659e4669df9f3d4aeddea37fd9b85abc40f9d55045fff1fc7096f091a209`.
@@ -15,6 +15,21 @@ vpac q -F name,validation local/musl >/tmp/musl
15grep -Eq '^validation[[:space:]]+signature$' /tmp/musl
116vpac o /bin/busybox | grep -q busybox
217arch=$(uname -m)
18+package_command=${VPAC_TEST_PACKAGE_COMMAND:-vpac}
19+case "$package_command" in
20+ vpac) ;;
21+ pkg) vpac o /usr/bin/pkg | grep -q vinix-pkg ;;
22+ *) echo "unknown test package command $package_command" >&2; exit 2 ;;
23+esac
24+
25+install_netbase() {
26+ if [ "$package_command" = pkg ]; then
27+ pkg install netbase
28+ else
29+ vpac i --noconfirm netbase
30+ fi
31+}
32+
333install_test() {
434 test ! -e /etc/services
535 set -- /var/lib/vinix/repository/"$arch"/netbase-[0-9]*.pkg.tar.zst
@@ -28,7 +43,7 @@ install_test() {
2843 test "$(wc -c <"$archive")" = "$(wc -c </tmp/netbase-original)"
2944 if cmp -s "$archive" /tmp/netbase-original; then exit 1; fi
3045 status=0
31- vpac i --noconfirm netbase >/tmp/reject.log 2>&1 || status=$?
46+ install_netbase >/tmp/reject.log 2>&1 || status=$?
3247 cat /tmp/reject.log
3348 test "$status" -ne 0
3449 grep -Fiq 'invalid or corrupted package (PGP signature)' /tmp/reject.log
@@ -37,7 +52,7 @@ install_test() {
3752 mv /tmp/netbase-original "$archive"
3853
3954 phase=install
40- vpac i --noconfirm netbase
55+ install_netbase
4156 echo 'VPAC transaction installed authentic netbase'
4257 phase=installed-ownership
4358 vpac o /etc/services | grep -q netbase
@@ -78,7 +93,11 @@ test ! -e /etc/ssl1.1/cert.pem
93vpac q -F version local/ca-certificates-bundle >/tmp/bundle
194grep -Eq '^version[[:space:]]+20261020-2$' /tmp/bundle
295cp "$reference/"* "/var/lib/vinix/repository/$arch/"
3-vpac u --sync --noconfirm
96+if [ "$package_command" = pkg ]; then
97+ pkg upgrade
98+else
99+ vpac u --sync --noconfirm
100+fi
4101phase=upgraded-record
5102vpac q -F version,validation local/ca-certificates-bundle >/tmp/upgraded
6103grep -Eq '^version[[:space:]]+20261020-3$' /tmp/upgraded
@@ -1,5 +1,6 @@
11"""Boot a staged vpac image and test rejection, install and upgrade using the guest binary."""
22import argparse
3+from filecmp import cmp
34import hashlib
45import os
56import shutil
@@ -10,6 +11,8 @@ from pathlib import Path
1011
1112def run(args):
1213 work = args.work
14+ if args.staged_root and work.is_relative_to(args.staged_root):
15+ raise ValueError("put test output outside the staged root")
1316 work.mkdir()
1417 arch = args.arch
1518 tests = Path(__file__).resolve().parent
@@ -18,20 +21,30 @@ def run(args):
1821 repo = args.repo
1922 client = work / "client"
2023 image = work / "image"
24+ root = image / "root"
2125
2226 def log(name, argv, **options):
2327 with (work / (name + ".log")).open("x") as output:
2428 subprocess.run(argv, stdout=output, stderr=subprocess.STDOUT, check=True, **options)
2529
2630 log("trust", ["feed", "trust", trust, repo / "test-signer.asc", pin])
27- log("install", ["feed", "install", trust, repo, arch, client, "--fakeroot",
28- "vpac", "busybox-init", "vinix-keyring", "vinix-accounts", "vinix-filesystem"])
29- log("stage", [sys.executable, tests.parent / "tools/stage-image.py", arch, client, repo,
30- image, args.auditor, pin])
31+ if args.staged_root:
32+ seed = args.staged_root / "var/lib/vinix/repository" / arch
33+ for file in ("vinix.db", "vinix.db.sig"):
34+ if not cmp(seed / file, repo / arch / file, shallow=False):
35+ raise ValueError(f"staged root has a different seed {file}")
36+ log("staged-input", ["sha256sum", seed / "vinix.db", seed / "vinix.db.sig"])
37+ # The disk runner copies this tree before the guest writes to it.
38+ shutil.copytree(args.staged_root, root, symlinks=True, copy_function=os.link)
39+ else:
40+ package = "vinix-pkg" if args.package_command == "pkg" else "vpac"
41+ log("install", ["feed", "install", trust, repo, arch, client, "--fakeroot",
42+ package, "busybox-init", "vinix-keyring", "vinix-accounts", "vinix-filesystem"])
43+ log("stage", [sys.executable, tests.parent / "tools/stage-image.py", arch, client, repo,
44+ image, args.auditor, pin])
3145
3246 # The updater receives a second complete signed index. Only its changed files
3347 # have to be added to the guest image alongside the first verified snapshot.
34- root = image / "root"
3548 initial = root / "var/lib/vinix/repository" / arch
3649 old = initial / "ca-certificates-bundle-20261020-2-any.pkg.tar.zst"
3750 if not old.is_file() or not list(initial.glob("netbase-*.pkg.tar.zst")):
@@ -48,12 +61,15 @@ def run(args):
4861 log("publish-update", ["feed", "publish", args.keys, update, arch, new, *siblings])
4962 delta = root / "var/lib/vinix/test-update"
5063 delta.mkdir()
64+ delta.chmod(0o755)
5165 for base in ("vinix.db", "vinix.files", new.name):
5266 for name in (base, base + ".sig"):
53- shutil.copyfile(update / arch / name, delta / name)
67+ target = delta / name
68+ shutil.copyfile(update / arch / name, target)
69+ target.chmod(0o644)
5470
5571 fixture = work / "fixture.sh"
56- fixture.write_bytes(f"VPAC_TEST_SCENARIO={args.scenario}\n".encode()
72+ fixture.write_bytes(f"VPAC_TEST_SCENARIO={args.scenario}\nVPAC_TEST_PACKAGE_COMMAND={args.package_command}\n".encode()
5773 + (tests / "userland/vpac.sh").read_bytes())
5874 disk = work / "disk"
5975 env = os.environ.copy()
@@ -71,6 +87,9 @@ if __name__ == "__main__":
7187 parser = argparse.ArgumentParser(description=__doc__)
7288 parser.add_argument("arch", choices=("x86_64", "aarch64"))
7389 parser.add_argument("--scenario", choices=("all", "install", "upgrade"), default="all")
90+ parser.add_argument("--package-command", choices=("vpac", "pkg"), default="vpac")
91+ parser.add_argument("--staged-root", type=lambda path: Path(path).resolve(),
92+ help="reuse a staged root from the same feed and build volume")
7493 for option in ("repo", "keys", "fingerprint", "update_receipt", "auditor", "boot", "iso", "work"):
7594 parser.add_argument(option, type=lambda path: Path(path).resolve())
7695 run(parser.parse_args())