vinix-ports / tests / FEED.md
119 lines · 88 sloc · 8.67 KB · a460689c8c1ac0a540ff58d0d70017577afdaea8
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

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.