vinix-ports / tests / FEED.md
173 lines · 119 sloc · 20.28 KB · a802c802ec8af1958b21c7bd269ad19326ec2020
Raw

Signed package integration test

Run the fixture on a Linux build machine with V, vpac, GnuPG, bsdtar, repo-add, sha256sum and unprivileged user/network namespaces. Set archives to the directory containing the source-built package archives.

work=$(mktemp -d)
v -o "$work/feed" tests/feed.v
"$work/feed" keys "$work/keys"
"$work/feed" publish "$work/keys" "$work/repo" x86_64 \
    "$archives"/musl-*.pkg.tar.zst "$archives"/busybox-*.pkg.tar.zst
"$work/feed" install "$work/keys" "$work/repo" x86_64 "$work/sdk" musl busybox

Each destination must be new. The publisher verifies each package signature, embeds signatures in the signed repository database, verifies both index signatures and records archive SHA-256 values in repo/packages.tsv. The installer checks the database and package signatures through vpac while syncing and resolving package names. Its isolated client keeps the root, database, cache, configuration and log under sdk/.

combined-feed.py can publish a larger package pool and ask vpac to install specific roots. Pass --install NAME once for each requested root. The default installs every package in the selection. On both architectures, the worker published four packages and requested only musl and netbase. The clean clients contained exactly those two validated package records. The receipts are in foundation/partial-install-01, SHA-256 0067690951845492e39732b5bb932a6cbfe619b7f51bbbf6dcf63b9e2a763898.

A builder with its own unprivileged service account and private state directory can use feed install KEY_STATE REPO ARCH NEW_CLIENT --fakeroot PACKAGE_NAME... when user namespaces are unavailable. This runs vpac under fakeroot and keeps the same signed file repository and new client directory.

Target post-transaction hooks need permission to enter the installed root. For the worker's x86_64 font test, systemd granted the dynamic user CAP_SYS_CHROOT within its private user namespace using PrivateUsers=yes, CapabilityBoundingSet=CAP_SYS_CHROOT and AmbientCapabilities=CAP_SYS_CHROOT. The install fixture also checks vpac's transaction log for hook errors. Without that capability, vpac returned zero after a hook failed and the fixture rejected the result.

For a separate consumer, transfer the repository directory and obtain the expected fingerprint independently from the test owner. Import the public key into a client-only keyring.

"$work/feed" trust "$work/client-keys" "$work/repo/test-signer.asc" "$fingerprint"
"$work/feed" install "$work/client-keys" "$work/repo" x86_64 "$work/client" musl busybox

Reject damaged signatures and packages

The rejection test needs a test signing key, the corresponding consumer keyring and a published feed with at least two packages. It installs a dependency-free package from the pristine feed, then uses independent repository copies and fresh roots for three negative transactions.

PATH="$work:$PATH" python3 tests/feed-rejection.py "$work/keys" "$work/repo" "$work/rejection" x86_64 musl

The copies contain a database signed for another index, a one-byte change to a package, or an intact package carrying another package’s signature. In the last case the fixture signs the modified database with the trusted test key. Each rejected transaction must report an integrity error and leave the root and local package records empty. The worker recorded all four outcomes under foundation/rejection-02/.

Upgrade an installed root

The worker tested BusyBox 1.38.0-3 upgrading to 1.38.0-4, followed by the first install of vinix-release. The earlier recipe is at cab3ed4:busybox/PKGBUILD.vile. With these archives in archives and test keys from the first step, publish two snapshots and keep the same client directory for both transactions.

old="$work/upgrade-old"
new="$work/upgrade-new"
client="$work/upgrade-client"
"$work/feed" publish "$work/keys" "$old" x86_64 \
    "$archives"/musl-*.pkg.tar.zst "$archives"/busybox-1.38.0-3-x86_64.pkg.tar.zst
"$work/feed" install "$work/keys" "$old" x86_64 "$client" --fakeroot musl busybox
test -d "$client/db/local/busybox-1.38.0-3"
"$work/feed" publish "$work/keys" "$new" x86_64 \
    "$archives"/musl-*.pkg.tar.zst "$archives"/busybox-1.38.0-4-x86_64.pkg.tar.zst \
    "$archives"/vinix-release-0.1.0-1-any.pkg.tar.zst
sed 's|/upgrade-old/|/upgrade-new/|' "$client/config.vile" > "$client/upgrade.vile"
fakeroot -- vpac --config "$client/upgrade.vile" u --sync --noconfirm
fakeroot -- vpac --config "$client/upgrade.vile" i --noconfirm vinix-release
test -d "$client/db/local/busybox-1.38.0-4"
test ! -d "$client/db/local/busybox-1.38.0-3"
grep -Fx bin/uname "$client/db/local/busybox-1.38.0-4/files"
grep -Fx usr/bin/uname "$client/db/local/vinix-release-0.1.0-1/files"
test "$(readlink "$client/root/usr/bin/uname")" = ../../bin/uname
grep -Fx ID=vinix "$client/root/etc/os-release"

Preserve account databases on upgrade

The account seed keeps Vinix's locked root account and supplies a locked nobody account for vpac downloads. The fixture signs and installs the actual release 1 and release 2 archives in separate repositories.

PATH="$work:$PATH" python3 tests/accounts-upgrade.py "$old_accounts_archive" \
    "$new_accounts_archive" "$work/keys" "$work/accounts-upgrade" "$arch"

The worker installed and upgraded fresh clients for both target architectures. vpac kept their locally edited databases, retained mode 0600 on shadow and wrote the new defaults into the matching .pacnew files. The release 2 cold installs independently validated nobody with UID and GID 65534, a locked shadow entry and /bin/false as its shell. See foundation/actual-account-upgrade-02 and foundation/sandbox-user-accounts-01, receipt SHA-256 89fb3e0ec55471b79580ec5fe16d0585f4048a0b36c3157f8c9296a018eabc04 and 21df3c7374876be520ba8fac62f6fb47a46255bac27b7618a56cf1bfc422fb60.

Reuse a signed SDK

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.

PATH="$work:$PATH" python3 tests/combined-feed.py "$arch" "$work/keys" \
    "$work/audit" "$work/combined" "$first_repo/packages.tsv" "$later_artifacts"

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.

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.

The larger x86_64 root in foundation/combined-hooks-03 passed a cold install of 106 signed packages. Its generated /usr/share/fonts/X11/misc/fonts.dir indexed 335 fonts. The audit checked 17,128 owned files and links and 273 target ELFs. All 106 packages had their dependency providers in the feed. Of the 3,899 matching published input/layer/path observations, 1,133 had an expected owner in this root, 117 had a different owner and 2,649 still lacked an owner. The receipt manifest has SHA-256 fc1aa7c5b7f6f126d5c3df984844b6f98dd994514146d796f0df559d00527b8b.

For 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.

tar --format=ustar --owner=0 --group=0 --zstd -cf "$work/sdk.tar.zst" -C "$work/sdk" root db
sha256sum "$work/sdk.tar.zst"

To boot the packages, pass an existing Vinix amd64 BIOS ISO to the diskless test. The runner uses the ISO's kernel and Limine boot files. Its --musl mode links a V probe with the installed musl SDK, checks its loader checksum in Vinix and exercises the Vinix malloc_trim implementation. BusyBox supplies PID 1, ash and the applets. The serial transcript is written to guest/serial.log.

v -o "$work/boot" tests/busybox/boot.v
"$work/boot" "$work/sdk/root" "$vinix_iso" "$work/guest" --musl

Boot the packaged command-line userland

Publish the following 27 target packages to a fresh feed. The November 29 run used BusyBox 1.38.0-4 and Zsh 5.9.2-2. Select one archive per name. Run from the ports checkout on the worker with bsdtar, xorriso, timeout and QEMU on PATH.

set -- musl linux-headers busybox vinix-release ca-certificates-bundle zlib bzip2 \
  brotli zstd xz expat libffi libcap libuuid ncurses pkgconf vim make openssl \
  pcre2 gmp libpng nghttp2 c-ares zsh scanelf musl-utils
"$work/feed" install "$work/client-keys" "$userland_feed" x86_64 "$work/userland" --fakeroot "$@"
v -o "$work/audit" tests/installed-root.v
"$work/audit" x86_64 "$work/userland"
v -o "$work/boot" tests/busybox/boot.v
"$work/boot" "$work/userland/root" "$vinix_iso" "$work/userland-guest" --userland

The x86_64 audit verified 27 signed package records, 9,583 owned files and links, and 110 target ELFs. Inside Vinix, the fixture loaded Zsh modules, edited a file with Vim, ran a Makefile, round-tripped compressed files, resolved pkg-config modules, parsed XML and verified the packaged ISRG root through OpenSSL. The serial log ends with VPAC USERLAND GUEST PASS. The worker keeps it under musl-busybox-CqkBEA/foundation/userland-guest-01/serial.log (SHA-256 237592ae4c71ca99438e4fba943472c44c6890f60495a43204202c7ba2eb0837). Boot harness revision 0a0ab0a supports this run.

To run another package fixture in the same boot environment, use boot ROOT ISO OUTPUT --fixture SCRIPT on x86_64 or --aarch64-fixture SCRIPT on arm64. BusyBox init invokes the script on the guest console. The test must print VPAC FIXTURE GUEST PASS on a line by itself and shut down the guest. The x86_64 worker replayed the userland checks through this entry point in foundation/fixture-replay-01. Its receipt manifest has SHA-256 9aefb17b4cce7db8ec99f96e297b8acc244ee61a55401fb3165213a01f02f55d.

Seed a fresh image with a distributor's verification key

Provide a public OpenPGP certificate and its full fingerprint from the trusted release configuration. Choose a new numeric package version each time the public material changes. Prepare the source port in worker state, build it through Vile and install it into the new image using the builder's existing trusted keyring.

python3 tools/keyring.py prepare "$public_certificate" "$trusted_fingerprint" "$version" "$work/vinix-keyring"
vpac --native-build "$work/vinix-keyring/PKGBUILD.vile" "$work/keyring.manifest"
# Include the archive listed in keyring.manifest when publishing the signed feed.
feed install "$builder_keys" "$repo" x86_64 "$work/new-client" --fakeroot musl vinix-keyring
python3 tools/keyring.py seed "$work/new-client/root" "$trusted_fingerprint"

vinix-keyring owns the public certificate and fingerprint in /usr/share/vpac/keyrings/. Image assembly initializes the mutable GnuPG keybox and trust database under /etc/vpac.d/gnupg/. The seed operation accepts a new destination or the empty directory installed by the vpac port. The builder compares the independently supplied fingerprint before packaging and again before seeding.

The worker used a disposable test signer in foundation/keyring-04. It rejected a wrong pin, installed the signed keyring, seeded an empty vpac key directory, verified the signed database and used that keyring alone for an offline vpac install of musl into another empty root. A second seed attempt preserved the existing keyring. The checksum manifest has SHA-256 3ffb71fb6832d43af1cb2ec588d2d6a75ece24060d22bd1e70be59392a64d30d. The target-vpac guest transaction and provisioning the release signer's public certificate remain release checks.

Assemble an image with an offline repository

A public-only consumer can live below a long staging path. feed trust checks the fingerprint in a short private GnuPG directory and copies the public keybox and trust database to the consumer. Fresh clients for both architectures installed four packages from the signed layout feed. A wrong fingerprint and a by-name attempt to install the absent vinix-release-desktop both failed. The worker keeps the successful install receipts in foundation/public-trust-install-03/consumer-with-a-deep-image-generation-directory, manifest SHA-256 28b5580486b8c36bd67df12b3e51924f96685aae447326aaacca88e6a32fede5, and the partial-feed rejection in foundation/partial-desktop-reject-03, manifest SHA-256 ad53b5e5fdcd0461ee72b5a9b9c0fb3c4a8b7e878c100f722c3e3c54ddf7dbc8.

Start with a fresh feed install client that includes vinix-keyring. Run this on the build worker with GNU cp, GnuPG and the installed-root auditor. The resulting $output/root is the input to the architecture's image builder.

python3 tools/stage-image.py "$arch" "$client" "$repo" "$output" "$work/audit" "$trusted_fingerprint"

The 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.

To 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.

python3 tools/release-feed.py "$arch" "$worker" "$plan" "$coverage" \
    "$key_state" "$repo" vinix-release-desktop

On 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.

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.

The installed-root auditor checks each nonempty ELF load segment against the released kernel page size, 4 KiB on x86_64 and 16 KiB on aarch64. It also checks required symbol-version namespaces against the actual resolved package-owned provider using GNU readelf and objdump. The 106-package x86_64 root and the corrected arm64 loader passed. An old arm64 BusyBox failed its segment congruence check. An x86_64 libcrypto with its original SONAME and a changed version tag failed the OpenSSL consumer check. See foundation/load-and-versions-02, receipt SHA-256 fd32f6b69db215ff6b79ec1f58c8457cf7f514dd162fbde410d9f6882072b979. Use tests/exec-linkage.py as well to exercise actual dynamic symbol resolution.

Run the target vpac binary on the release kernel with python3 tests/vpac-guest.py "$arch" "$repo" "$test_keys" "$fingerprint_file" "$update_receipt" "$auditor" "$boot" "$iso" "$output". Use a signed initial feed containing netbase and CA bundle release 2 and pass the receipt for CA bundle release 3. The guest has no network interface. The fixture tests a same-length package modification, authentic installation, local and remote lookup, and a signed in-place upgrade. Pass --scenario install or --scenario upgrade to replay either operation on a fresh copy of the same image inputs. The runner defaults to 720 seconds under QEMU TCG. VINIX_QEMU_TIMEOUT overrides that limit in seconds. Set VINIX_QEMU_ACCEL=kvm when the host matches the guest architecture and the worker can open /dev/kvm.

For 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.

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.

The original ext2 files from vinix-pkg-guest-01, vinix-pkg-upgrade-01 and vpac-transaction-08 are compressed in foundation/archived-pkg-fixture-disks-01. Its restore.tsv gives their original paths, uncompressed checksums, modes and timestamps. Restore each needed file with zstd -d --sparse before rerunning its disk receipt checks. Each expanded archive matched the original checksum before relocation. The archive receipt manifest has SHA-256 c5b49fbb69cddfe2fcb3828cd1b7316d48b4f1ef90a155fa369f2ba63a32bbf9.

To 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.