phoebus_os/installer/tests/vm/rollback-verify.sh
Phoebus c759477c7f test(vm): automate rollback acceptance on a disposable clone
Add a serial-driver rollback mode and guest scripts that exercise the real
rollback path: record the /var/db/pkg fingerprint and a /home marker,
create a recovery point with sys snapshot, install a small package as a
controlled reversible update, run sys undo, power off, boot detached and
compare the restored package state and /home against the pre-rollback
values. Checks kernel modules, the snapshot recovery entry and sys
rollback status. sys is fetched from the host, matching the existing
harness evidence procedure; booting the recovery entry offline remains a
documented manual gate. bash -n guards for every guest script are added
to the no-VM unit tests.
2026-09-23 06:19:17 -07:00

53 lines
1.6 KiB
Bash
Executable file

#!/bin/bash
# Guest-side post-rollback verification for the disposable VM.
#
# Fetched and run by `serial-driver.py rollback` after the detached reboot. It
# records the restored root/var generation, the package-database fingerprint,
# kernel modules, the /home marker, the recovery BLS entry and `sys rollback
# status`. The host compares these against the pre-rollback markers; a marker
# alone would not prove package-state consistency.
set -uo pipefail
SYS="${SYS_BIN:-/tmp/sys}"
USER_NAME="${USERNAME:-phoebus}"
pkg_fingerprint() {
find /var/db/pkg -mindepth 2 -maxdepth 2 -type d 2>/dev/null \
| sort | sha256sum | awk '{print $1}'
}
HOME_MARKER="$(cat "/home/$USER_NAME/rollback-marker.txt" 2>/dev/null || echo missing)"
echo "===AFTER-KNOWN-GOOD pkgs=$(pkg_fingerprint) kernel=$(uname -r) home=$HOME_MARKER==="
if [ -e /etc/phoebus/rollback-broken.txt ]; then
echo "===AFTER-BROKEN-MARKER present==="
else
echo "===AFTER-BROKEN-MARKER absent==="
fi
echo "===AFTER-ROOT==="
btrfs subvolume show / 2>&1 | sed -n '1,10p'
echo "===AFTER-VAR==="
btrfs subvolume show /var 2>&1 | sed -n '1,10p'
if [ -d "/lib/modules/$(uname -r)" ]; then
echo "===AFTER-MODULES ok==="
else
echo "===AFTER-MODULES missing==="
fi
echo "===AFTER-ENTRIES==="
for d in /efi/loader/entries /boot/efi/loader/entries; do
if [ -d "$d" ]; then
ls "$d"
break
fi
done
echo "===AFTER-RECOVERY==="
cat /efi/loader/entries/phoebus-recovery.conf \
/boot/efi/loader/entries/phoebus-recovery.conf 2>/dev/null || true
echo "===AFTER-STATUS==="
"$SYS" rollback status 2>&1 || true
echo "===AFTER-DONE==="