vinix-ports / tests / FEED.md
144 lines · 103 sloc · 11.99 KB · 365cf92c9cdfd3838ff5b45c687b33d996bdcf59
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/.

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.

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 uses the locked root account from Vinix’s own account service. On a builder configured for native vpac builds, this fixture creates two private signed snapshots. The second snapshot adds a vendor group to the package defaults.

PATH="$work:$PATH" python3 tests/accounts-upgrade.py vinix-accounts/PKGBUILD.vile \
    "$work/keys" "$work/accounts-upgrade" x86_64

The worker installed the first snapshot, added a locked fixture account and upgraded the same root. vpac kept all three edited databases, retained mode 0600 on shadow and wrote the changed default group to /etc/group.pacnew. The receipt at foundation/receipts/accounts-upgrade-01.log has SHA-256 34a898a73168702748ae211a6d1b673a445b99e063f5ed8880583f612d46e294.

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.

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.

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

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.

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.