Install the signed foundation libraries together on both architectures
@@ -1,7 +1,7 @@
11defpkgbuild(libassuan,
22 #:pkgname, "libassuan",
33 #:pkgver, "2.5.7",
4- #:pkgrel, 1,
4+ #:pkgrel, 2,
55 #:pkgdesc, "Assuan IPC library for GnuPG and GPGME",
66 #:arch, [#:x86-64, #:aarch64],
77 #:url, "https://www.gnupg.org/software/libassuan/",
@@ -19,6 +19,7 @@ defpkgbuild(libassuan,
1919 },
2020 #:package, fn() {
2121 run("make", "install", string-append("DESTDIR=", pkgdir()))
22+ run("rm", "-f", string-append(pkgdir(), "/usr/share/info/dir"))
2223 run("find", pkgdir(), "-name", "*.la", "-delete")
2324 run("install", "-Dm644", "libassuan-2.5.7/COPYING.LIB", string-append(pkgdir(), "/usr/share/licenses/libassuan/COPYING.LIB"))
2425 })
@@ -1,7 +1,7 @@
11defpkgbuild(libgcrypt,
22 #:pkgname, "libgcrypt",
33 #:pkgver, "1.10.3",
4- #:pkgrel, 1,
4+ #:pkgrel, 2,
55 #:pkgdesc, "Cryptographic primitives for GnuPG",
66 #:arch, [#:x86-64, #:aarch64],
77 #:url, "https://www.gnupg.org/software/libgcrypt/",
@@ -22,6 +22,7 @@ defpkgbuild(libgcrypt,
2222 },
2323 #:package, fn() {
2424 run("make", "install", string-append("DESTDIR=", pkgdir()))
25+ run("rm", "-f", string-append(pkgdir(), "/usr/share/info/dir"))
2526 run("find", pkgdir(), "-name", "*.la", "-delete")
2627 run("install", "-Dm644", "libgcrypt-1.10.3/COPYING.LIB", string-append(pkgdir(), "/usr/share/licenses/libgcrypt/COPYING.LIB"))
2728 })
@@ -1,7 +1,7 @@
11defpkgbuild(libgpg-error,
22 #:pkgname, "libgpg-error",
33 #:pkgver, "1.51",
4- #:pkgrel, 1,
4+ #:pkgrel, 2,
55 #:pkgdesc, "Common error codes and runtime support for GnuPG",
66 #:arch, [#:x86-64, #:aarch64],
77 #:url, "https://www.gnupg.org/software/libgpg-error/",
@@ -21,6 +21,7 @@ defpkgbuild(libgpg-error,
2121 },
2222 #:package, fn() {
2323 run("make", "install", string-append("DESTDIR=", pkgdir()))
24+ run("rm", "-f", string-append(pkgdir(), "/usr/share/info/dir"))
2425 run("find", pkgdir(), "-name", "*.la", "-delete")
2526 run("install", "-Dm644", "libgpg-error-1.51/COPYING.LIB", string-append(pkgdir(), "/usr/share/licenses/libgpg-error/COPYING.LIB"))
2627 })
@@ -1,7 +1,7 @@
11defpkgbuild(libunistring,
22 #:pkgname, "libunistring",
33 #:pkgver, "1.2",
4- #:pkgrel, 1,
4+ #:pkgrel, 2,
55 #:pkgdesc, "Unicode string validation, conversion and normalization",
66 #:arch, [#:x86-64, #:aarch64],
77 #:url, "https://www.gnu.org/software/libunistring/",
@@ -20,6 +20,7 @@ defpkgbuild(libunistring,
2020 },
2121 #:package, fn() {
2222 run("make", "install", string-append("DESTDIR=", pkgdir()))
23+ run("rm", "-f", string-append(pkgdir(), "/usr/share/info/dir"))
2324 run("find", pkgdir(), "-name", "*.la", "-delete")
2425 run("install", "-Dm644", "libunistring-1.2/COPYING.LIB", string-append(pkgdir(), "/usr/share/licenses/libunistring/COPYING.LIB"))
2526 })
@@ -71,6 +71,17 @@ The worker installed the first snapshot, added a locked fixture account and upgr
7171
7272### Reuse a signed SDK
7373
74+Use the combined-feed fixture to select one version per package from receipted builds, sign the selected archives, install every package by name and audit the resulting root. An input can be a `feed publish` package table, a directory of SHA-256 receipts or an individual receipt. Identically versioned archives must have the same digest. Architecture-independent archives can be reused between target feeds.
75+
76+```sh
77+PATH="$work:$PATH" python3 tests/combined-feed.py "$arch" "$work/keys" \
78+ "$work/audit" "$work/combined" "$first_repo/packages.tsv" "$later_artifacts"
79+```
80+
81+In the x86_64 run, vpac originally refused to install four libraries together because they all shipped the generated `/usr/share/info/dir`. The rebuilt libgpg-error, libassuan, libgcrypt and libunistring packages each retain their own manuals. The combined installation then passed with 66 signed records, 13,518 owned files and links, and 217 target ELFs. The worker keeps the selection, publish, install and audit logs under `foundation/combined-02`. The receipt manifest at `foundation/receipts/combined-02.sha256` has SHA-256 `5a3ea7383f19cc4fcc247ea75e87ada4f0e857c9ac56cbee3f3bf973012122dc`.
82+
83+The arm64 run combined the signed musl and Linux header SDK with GMP, MPFR, MPC, the BSD compatibility headers, CA data, the public keyring and the Vinix account, filesystem and network defaults. The clean-root audit found 11 signed package records, 1,346 owned files and links, and nine target ELFs. Its four dependency stages and the filesystem policy check are under `foundation/arm-base-01`. The receipt manifest has SHA-256 `2ec471799105369ea1ba4b9c18b8c3ecfd13083beff91a4efbd359950f0faf41`.
84+
7485For a later SDK, publish the cumulative archive set to a new repository directory and install the desired package names into a new SDK. A remote builder can unpack a relative snapshot and set `VPAC_MAKEPKG_ROOT` and `VPAC_MAKEPKG_DB` to its extracted `root` and `db` directories.
7586
7687```sh
@@ -129,3 +140,5 @@ python3 tools/stage-image.py "$arch" "$client" "$repo" "$output" "$work/audit" "
129140The tool audits the package-owned root, makes a separate copy, and seeds the verification keyring using the distributor's fingerprint. It copies the local package records into `/var/lib/vpac/local`, checks their versions against the signed database, and installs the repository under `/var/lib/vinix/repository/$arch`. It verifies the database, file index and each included package signature, and compares the payload hashes with the signed database. The sync cache receives independent copies of the database and signature. Assembly exposes the final root only after these checks pass.
130141
131142On both targets, the worker installed musl and the public key package, then assembled a three-package offline repository. Using the build-box vpac with its paths directed into each resulting image, it installed the third package, `netbase`, from the embedded repository and recorded its ownership in that image. The logs are in `foundation/offline-stage-01` with receipt manifest SHA-256 `98bfcbdaed3aa81690bcdac5a8b0edbdfd91f5ab6ae8a7cc9f3fdd50e6252fb1`.
143+
144+Changing the netbase archive after signing caused assembly to fail its signed index checksum check before exposing the output root. The rejection log in `foundation/offline-stage-rejection-01` has receipt manifest SHA-256 `e15be9b8ba76c5c115a622e7fa57997c1bcb9ca99a3319e18b3daf489ecc3c8d`.
@@ -0,0 +1,96 @@
1+"""Install the latest receipted native packages together and audit their complete root."""
2+import argparse
3+import csv
4+import hashlib
5+import re
6+import subprocess
7+from pathlib import Path
8+
9+
10+def archives(location, arch):
11+ if location.is_dir() or location.suffix == ".sha256":
12+ receipts = sorted(location.glob("*.sha256")) if location.is_dir() else [location]
13+ for receipt in receipts:
14+ for line in receipt.read_text().splitlines():
15+ digest, name = line.split(maxsplit=1)
16+ if name.endswith(".pkg.tar.zst"):
17+ if Path(name).name != name:
18+ raise ValueError(f"expected a package basename in {receipt}")
19+ yield receipt.parent / name, digest
20+ else:
21+ with location.open() as index:
22+ for row in csv.DictReader(index, delimiter="\t"):
23+ if Path(row["archive"]).name != row["archive"]:
24+ raise ValueError(f"invalid package name in {location}")
25+ if row["arch"] not in (arch, "any"):
26+ continue
27+ path = location.parent / arch / row["archive"]
28+ if row["arch"] == "any" and not path.is_file():
29+ # Data packages in a single-target feed live in its architecture directory.
30+ siblings = [directory / row["archive"] for directory in location.parent.iterdir()
31+ if directory.is_dir() and (directory / row["archive"]).is_file()]
32+ if not siblings:
33+ raise ValueError(f"missing architecture-independent package {row['archive']}")
34+ for sibling in siblings:
35+ yield sibling, row["sha256"]
36+ else:
37+ yield path, row["sha256"]
38+
39+
40+def collect(sources, arch):
41+ selected = {}
42+ for source in sources:
43+ for archive, expected in archives(source, arch):
44+ if not archive.name.endswith((f"-{arch}.pkg.tar.zst", "-any.pkg.tar.zst")):
45+ continue
46+ with archive.open("rb") as stream:
47+ digest = hashlib.file_digest(stream, "sha256").hexdigest()
48+ if digest != expected:
49+ raise ValueError(f"checksum mismatch for {archive}")
50+ metadata = subprocess.check_output(["bsdtar", "-xOf", archive, ".PKGINFO"], text=True)
51+ fields = dict(line.split(" = ", 1) for line in metadata.splitlines() if " = " in line)
52+ name, version, machine = (fields[k] for k in ("pkgname", "pkgver", "arch"))
53+ if machine not in ("any", arch) or not re.fullmatch(r"[A-Za-z0-9@._+][A-Za-z0-9@._+-]*", name):
54+ raise ValueError(f"invalid target package metadata: {archive}")
55+ if archive.name != f"{name}-{version}-{machine}.pkg.tar.zst":
56+ raise ValueError(f"archive filename does not match its metadata: {archive}")
57+ if name in selected:
58+ old, old_digest, _ = selected[name]
59+ newer = int(subprocess.check_output(["vercmp", version, old], text=True))
60+ if newer == 0 and digest != old_digest:
61+ raise ValueError(f"distinct archives have the same {name} version {version}")
62+ if newer <= 0:
63+ continue
64+ selected[name] = version, digest, archive
65+ if not selected:
66+ raise ValueError("no packages with checksums for this architecture")
67+ return selected
68+
69+
70+def run(args):
71+ args.work.mkdir()
72+ selected = collect(args.sources, args.arch)
73+ names = sorted(selected)
74+ with (args.work / "selection.tsv").open("w") as output:
75+ table = csv.writer(output, delimiter="\t", lineterminator="\n")
76+ table.writerow(["name", "version", "sha256", "archive"])
77+ table.writerows((name, *selected[name]) for name in names)
78+ repo, client = args.work / "repo", args.work / "client"
79+ for label, command in [
80+ ("publish", ["feed", "publish", args.keys, repo, args.arch, *[selected[n][2] for n in names]]),
81+ ("install", ["feed", "install", args.keys, repo, args.arch, client, "--fakeroot", *names]),
82+ ("audit", [args.auditor, args.arch, client]),
83+ ]:
84+ with (args.work / (label + ".log")).open("w") as log:
85+ subprocess.run(command, check=True, stdout=log, stderr=subprocess.STDOUT)
86+ print((args.work / "audit.log").read_text(), end="")
87+
88+
89+if __name__ == "__main__":
90+ parser = argparse.ArgumentParser(description=__doc__)
91+ parser.add_argument("arch", choices=["x86_64", "aarch64"])
92+ for option in ["keys", "auditor", "work"]:
93+ parser.add_argument(option, type=lambda x: Path(x).resolve())
94+ parser.add_argument("sources", nargs="+", type=lambda x: Path(x).resolve(),
95+ help="artifact directory, individual .sha256 receipt, or signed feed's packages.tsv")
96+ run(parser.parse_args())