phoebus_os/installer/tests/vm/snap-guest.sh
Phoebus 084c315117
Some checks are pending
ci / test (push) Waiting to run
fix(sys): stream package output and harden package lanes
2026-10-01 10:23:41 -07:00

80 lines
2.7 KiB
Bash

#!/bin/bash
# Snap lane acceptance on an installed, disposable Phoebus qcow2 only.
# Run as root through serial-driver.py BOOT_AUTHENTICATE=1.
set -uo pipefail
SYS=/tmp/phoebus-snap-sys
SYS_URL="${SYS_URL:-http://10.0.2.2:8000/sys}"
case "$(findmnt -n -o SOURCE /)" in
/dev/mapper/*) ;;
*) echo 'CASE snap-target FAIL root is not the installed encrypted VM'; exit 1 ;;
esac
if curl -fsSL "$SYS_URL" -o "$SYS" && chmod 755 "$SYS" && "$SYS" --version; then
echo 'CASE snap-sys PASS current static sys is available'
else
echo 'CASE snap-sys FAIL could not fetch current static sys'
exit 1
fi
# Gentoo's snapd ebuild requires these two scoped squashfs-tools flags. The
# minimal VM profile omits them, so record the prerequisite explicitly.
install -d -m 0755 /etc/portage/package.use
printf '%s\n' 'sys-fs/squashfs-tools lzma lzo' \
> /etc/portage/package.use/phoebus-snap
if compgen -G '/var/db/pkg/app-containers/snapd-*' >/dev/null; then
echo 'CASE snap-portage PASS snapd already installed through Portage'
elif "$SYS" -y install app-containers/snapd --legacy --portage; then
echo 'CASE snap-portage PASS reviewed snapd install'
else
echo 'CASE snap-portage FAIL reviewed snapd install failed'
exit 1
fi
if "$SYS" -y enable snapd.socket --legacy && "$SYS" -y start snapd.socket --legacy \
&& systemctl is-active --quiet snapd.socket; then
echo 'CASE snap-socket PASS enabled and active'
else
echo 'CASE snap-socket FAIL socket did not become active'
exit 1
fi
if snap debug confinement; then
echo 'CASE snap-confinement PASS daemon reported confinement'
else
echo 'CASE snap-confinement FAIL could not determine confinement'
exit 1
fi
if snap list hello-world >/dev/null 2>&1; then
echo 'CASE snap-install PASS snap already installed by sys'
elif "$SYS" -y install hello-world --legacy --snap | tee /tmp/phoebus-snap-install.out \
&& snap list hello-world; then
echo 'CASE snap-install PASS installed via reviewed sys plan'
if grep -q '^protective snapshot: ' /tmp/phoebus-snap-install.out; then
echo 'CASE snap-snapshot PASS coordinated recovery point recorded'
else
echo 'CASE snap-snapshot FAIL no protective snapshot for Snap install'
fi
else
echo 'CASE snap-install FAIL install or inventory failed'
exit 1
fi
if "$SYS" -y snap refresh hello-world --legacy; then
echo 'CASE snap-refresh PASS refresh path completed'
else
echo 'CASE snap-refresh FAIL refresh path failed'
exit 1
fi
if "$SYS" -y snap remove hello-world --legacy && ! snap list hello-world >/dev/null 2>&1; then
echo 'CASE snap-remove PASS snap removed'
else
echo 'CASE snap-remove FAIL removal or absence check failed'
exit 1
fi
echo '===SNAP-ACCEPTANCE-DONE==='