#!/bin/sh # Boot a root with target vpac installed and netbase available only in the embedded feed. set -eu export PATH=/bin:/usr/bin:/sbin:/usr/sbin LC_ALL=C HOME=/root phase=identity finish() { status=$? if [ "$status" -ne 0 ]; then echo "VPAC TRANSACTION FAIL at $phase with status $status"; fi /sbin/poweroff -f } trap finish EXIT test "$(uname -o)" = Vinix mkdir -p /tmp vpac q -F name,validation local/musl >/tmp/musl grep -Eq '^validation[[:space:]]+signature$' /tmp/musl vpac o /bin/busybox | grep -q busybox arch=$(uname -m) package_command=${VPAC_TEST_PACKAGE_COMMAND:-vpac} case "$package_command" in vpac) ;; pkg) vpac o /usr/bin/pkg | grep -q vinix-pkg ;; *) echo "unknown test package command $package_command" >&2; exit 2 ;; esac install_netbase() { if [ "$package_command" = pkg ]; then pkg install netbase else vpac i --noconfirm netbase fi } install_test() { test ! -e /etc/services set -- /var/lib/vinix/repository/"$arch"/netbase-[0-9]*.pkg.tar.zst test "$#" -eq 1 && test -s "$1" archive=$1 phase=reject cp "$archive" /tmp/netbase-original # Change the Zstd magic without changing the signed archive's byte count. printf '\000' | dd of="$archive" bs=1 count=1 conv=notrunc 2>/dev/null test "$(wc -c <"$archive")" = "$(wc -c /tmp/reject.log 2>&1 || status=$? cat /tmp/reject.log test "$status" -ne 0 grep -Fiq 'invalid or corrupted package (PGP signature)' /tmp/reject.log test ! -e /etc/services for record in /var/lib/vpac/local/netbase-*; do test ! -d "$record"; done mv /tmp/netbase-original "$archive" phase=install install_netbase echo 'VPAC transaction installed authentic netbase' phase=installed-ownership vpac o /etc/services | grep -q netbase phase=installed-record vpac q -F name,validation local/netbase >/tmp/netbase grep -Eq '^name[[:space:]]+netbase$' /tmp/netbase grep -Eq '^validation[[:space:]]+signature$' /tmp/netbase grep -Eq '^ssh[[:space:]]+22/tcp' /etc/services echo 'VPAC transaction verified installed owner and signature' phase=remote-record vpac q --noconfirm -F name,version vinix/netbase >/tmp/exact grep -Eq '^name[[:space:]]+netbase$' /tmp/exact echo 'VPAC transaction resolved the exact repository record' phase=local-search vpac s --noconfirm --local --quiet netbase >/tmp/local-names grep -Fxq netbase /tmp/local-names echo 'VPAC transaction searched installed packages' phase=remote-search vpac s --noconfirm --remote --quiet netbase >/tmp/remote-names grep -Fxq netbase /tmp/remote-names vpac s --noconfirm --remote --quiet vinix-fixture-absent-port >/tmp/unknown test ! -s /tmp/unknown echo 'VPAC transaction verified package lookup' } mode=${VPAC_TEST_SCENARIO:-all} case "$mode" in install) install_test; echo 'VPAC FIXTURE GUEST PASS'; exit 0 ;; all) install_test ;; upgrade) ;; *) echo "unknown test scenario $mode" >&2; exit 2 ;; esac phase=upgrade reference=/var/lib/vinix/test-update test ! -e /etc/ssl1.1/cert.pem vpac q -F version local/ca-certificates-bundle >/tmp/bundle grep -Eq '^version[[:space:]]+20261020-2$' /tmp/bundle cp "$reference/"* "/var/lib/vinix/repository/$arch/" if [ "$package_command" = pkg ]; then pkg upgrade else vpac u --sync --noconfirm fi phase=upgraded-record vpac q -F version,validation local/ca-certificates-bundle >/tmp/upgraded grep -Eq '^version[[:space:]]+20261020-3$' /tmp/upgraded grep -Eq '^validation[[:space:]]+signature$' /tmp/upgraded test ! -d /var/lib/vpac/local/ca-certificates-bundle-20261020-2 phase=upgraded-files test "$(readlink /etc/ssl1.1/cert.pem)" = ../ssl/cert.pem cmp /etc/ssl1.1/cert.pem /etc/ssl/certs/ca-certificates.crt vpac o /etc/ssl1.1/cert.pem | grep -q ca-certificates-bundle echo 'VPAC FIXTURE GUEST PASS'