| 1 | #!/bin/sh |
| 2 | # Boot a root with target vpac installed and netbase available only in the embedded feed. |
| 3 | set -eu |
| 4 | export PATH=/bin:/usr/bin:/sbin:/usr/sbin LC_ALL=C HOME=/root |
| 5 | phase=identity |
| 6 | finish() { |
| 7 | status=$? |
| 8 | if [ "$status" -ne 0 ]; then echo "VPAC TRANSACTION FAIL at $phase with status $status"; fi |
| 9 | /sbin/poweroff -f |
| 10 | } |
| 11 | trap finish EXIT |
| 12 | test "$(uname -o)" = Vinix |
| 13 | mkdir -p /tmp |
| 14 | vpac q -F name,validation local/musl >/tmp/musl |
| 15 | grep -Eq '^validation[[:space:]]+signature$' /tmp/musl |
| 16 | vpac o /bin/busybox | grep -q busybox |
| 17 | arch=$(uname -m) |
| 18 | install_test() { |
| 19 | test ! -e /etc/services |
| 20 | set -- /var/lib/vinix/repository/"$arch"/netbase-[0-9]*.pkg.tar.zst |
| 21 | test "$#" -eq 1 && test -s "$1" |
| 22 | archive=$1 |
| 23 | |
| 24 | phase=reject |
| 25 | cp "$archive" /tmp/netbase-original |
| 26 | # Change the Zstd magic without changing the signed archive's byte count. |
| 27 | printf '\000' | dd of="$archive" bs=1 count=1 conv=notrunc 2>/dev/null |
| 28 | test "$(wc -c <"$archive")" = "$(wc -c </tmp/netbase-original)" |
| 29 | if cmp -s "$archive" /tmp/netbase-original; then exit 1; fi |
| 30 | status=0 |
| 31 | vpac i --noconfirm netbase >/tmp/reject.log 2>&1 || status=$? |
| 32 | cat /tmp/reject.log |
| 33 | test "$status" -ne 0 |
| 34 | grep -Fiq 'invalid or corrupted package (PGP signature)' /tmp/reject.log |
| 35 | test ! -e /etc/services |
| 36 | for record in /var/lib/vpac/local/netbase-*; do test ! -d "$record"; done |
| 37 | mv /tmp/netbase-original "$archive" |
| 38 | |
| 39 | phase=install |
| 40 | vpac i --noconfirm netbase |
| 41 | echo 'VPAC transaction installed authentic netbase' |
| 42 | phase=installed-ownership |
| 43 | vpac o /etc/services | grep -q netbase |
| 44 | phase=installed-record |
| 45 | vpac q -F name,validation local/netbase >/tmp/netbase |
| 46 | grep -Eq '^name[[:space:]]+netbase$' /tmp/netbase |
| 47 | grep -Eq '^validation[[:space:]]+signature$' /tmp/netbase |
| 48 | grep -Eq '^ssh[[:space:]]+22/tcp' /etc/services |
| 49 | |
| 50 | echo 'VPAC transaction verified installed owner and signature' |
| 51 | phase=remote-record |
| 52 | vpac q --noconfirm -F name,version vinix/netbase >/tmp/exact |
| 53 | grep -Eq '^name[[:space:]]+netbase$' /tmp/exact |
| 54 | echo 'VPAC transaction resolved the exact repository record' |
| 55 | phase=local-search |
| 56 | vpac s --noconfirm --local --quiet netbase >/tmp/local-names |
| 57 | grep -Fxq netbase /tmp/local-names |
| 58 | echo 'VPAC transaction searched installed packages' |
| 59 | phase=remote-search |
| 60 | vpac s --noconfirm --remote --quiet netbase >/tmp/remote-names |
| 61 | grep -Fxq netbase /tmp/remote-names |
| 62 | vpac s --noconfirm --remote --quiet vinix-fixture-absent-port >/tmp/unknown |
| 63 | test ! -s /tmp/unknown |
| 64 | |
| 65 | echo 'VPAC transaction verified package lookup' |
| 66 | } |
| 67 | |
| 68 | mode=${VPAC_TEST_SCENARIO:-all} |
| 69 | case "$mode" in |
| 70 | install) install_test; echo 'VPAC FIXTURE GUEST PASS'; exit 0 ;; |
| 71 | all) install_test ;; |
| 72 | upgrade) ;; |
| 73 | *) echo "unknown test scenario $mode" >&2; exit 2 ;; |
| 74 | esac |
| 75 | phase=upgrade |
| 76 | reference=/var/lib/vinix/test-update |
| 77 | test ! -e /etc/ssl1.1/cert.pem |
| 78 | vpac q -F version local/ca-certificates-bundle >/tmp/bundle |
| 79 | grep -Eq '^version[[:space:]]+20261020-2$' /tmp/bundle |
| 80 | cp "$reference/"* "/var/lib/vinix/repository/$arch/" |
| 81 | vpac u --sync --noconfirm |
| 82 | phase=upgraded-record |
| 83 | vpac q -F version,validation local/ca-certificates-bundle >/tmp/upgraded |
| 84 | grep -Eq '^version[[:space:]]+20261020-3$' /tmp/upgraded |
| 85 | grep -Eq '^validation[[:space:]]+signature$' /tmp/upgraded |
| 86 | test ! -d /var/lib/vpac/local/ca-certificates-bundle-20261020-2 |
| 87 | phase=upgraded-files |
| 88 | test "$(readlink /etc/ssl1.1/cert.pem)" = ../ssl/cert.pem |
| 89 | cmp /etc/ssl1.1/cert.pem /etc/ssl/certs/ca-certificates.crt |
| 90 | vpac o /etc/ssl1.1/cert.pem | grep -q ca-certificates-bundle |
| 91 | echo 'VPAC FIXTURE GUEST PASS' |
| 92 | |