phoebus_os/installer/tests/vm/install.sh
Phoebus 297f3201ff
Some checks are pending
ci / test (push) Waiting to run
feat(sys): hardware-aware lane selection and new lanes
Replace the fixed category routing (ADR 0006) with a shared, inspectable,
hardware- and preference-aware selection policy over resolved candidates from
Portage (source/binary/vendor), Nix, Flatpak, Snap, AppImage and the Phoebus
overlay. The policy keeps base components under Portage, separates hard
constraints from preferences, honours and persists explicit choices, errors
instead of silently switching lanes, and reuses an already-installed lane.

- phoebus-core::selection: the pure policy (16 tests: base-system, low-memory
  vs high-core, sandbox requirement, GPU/arch/storage rejection, explicit
  preference, unavailable backend, reproducibility, render).
- phoebus-executor::chooser: resolves real metadata and hardware facts.
- phoebus-executor::{snap,appimage,ebuild}: new lanes. Snap detects daemon and
  confinement and installs app-containers/snapd through Portage; AppImage
  adopts images with a pinned SHA-256, checks the ELF architecture without
  executing, integrates a desktop entry and preserves user data on removal; the
  custom ebuild overlay binds approval to the ebuild content digest and builds
  through Portage's sandbox.
- Typed actions choose_package / set_package_preference / snap_* / appimage_* /
  custom_ebuild_* with strict validators; the assistant prompt and schema are
  reconciled (no category routing; custom ebuilds are untrusted).
- Installed sys: the installer locates the trusted static binary, copies it to
  /usr/local/bin/sys and proves it runs in the target chroot before the
  recovery snapshot, failing closed if absent; the VM harness fetches sys.
- docs/SYS.md: command/action reference and acceptance matrix; ADR 0006 revised.

Host gates pass: fmt, clippy (no new warnings), workspace tests, make test,
release and static sys builds. VM lane journeys remain pending (see HANDOFF).
2026-09-23 18:35:26 -07:00

70 lines
2.4 KiB
Bash
Executable file

#!/bin/bash
# Guest-side automation for a disposable VM installation.
#
# Run inside the Gentoo live environment. It fetches the static Rust installer
# and a test configuration from a host HTTP server (QEMU user networking
# reaches the host at 10.0.2.2), supplies secrets from 0600 files, and drives
# the deterministic backend with --install. It never uses the TUI.
#
# Environment:
# PHOEBUS_BASE_URL host base URL (default http://10.0.2.2:8000)
# PHOEBUS_CONFIG config file name on the server (default test.conf)
# LUKS_PASSPHRASE LUKS passphrase (kept in a 0600 temp file, never logged)
# USER_PASSWORD user password
#
# The test configuration pins STAGE3_URL to the same HTTP server so the
# stage3 checksum is verified without re-downloading from the internet.
set -u
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
export PHOEBUS_LOG_ECHO=yes
BASE="${PHOEBUS_BASE_URL:-http://10.0.2.2:8000}"
CONF="${PHOEBUS_CONFIG:-test.conf}"
echo "===PHOEBUS-DRIVER-START==="
umask 077
printf '%s' "${LUKS_PASSPHRASE:-phoebus-luks-test}" >/tmp/luks.pw
printf '%s' "${USER_PASSWORD:-phoebus-user-test}" >/tmp/user.pw
chmod 600 /tmp/luks.pw /tmp/user.pw
cd /tmp || exit 1
if ! curl -fsSL "$BASE/phoebus-installer" -o /tmp/phoebus-installer; then
echo "===FETCH-FAIL==="; poweroff -f; exit 1
fi
chmod 0755 /tmp/phoebus-installer
# The deterministic `sys` CLI is a hard requirement of the installed system, so
# the installer locates it beside itself and installs it into the target.
if ! curl -fsSL "$BASE/sys" -o /tmp/sys; then
echo "===SYS-FETCH-FAIL==="; poweroff -f; exit 1
fi
chmod 0755 /tmp/sys
curl -fsSL "$BASE/$CONF" -o /tmp/test.conf
echo "=== INSTALLER VERSION ==="
/tmp/phoebus-installer --version
echo "=== DISKS BEFORE ==="
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS
/tmp/phoebus-installer --config /tmp/test.conf --install --yes \
--luks-passphrase-file /tmp/luks.pw --user-password-file /tmp/user.pw
rc=$?
echo "===INSTALL-RC=$rc==="
LOG=/run/phoebus-installer/install.log
[ -r "$LOG" ] || LOG=/tmp/phoebus-installer/install.log
[ -r "$LOG" ] || LOG=/var/log/phoebus-installer/install.log
echo "=== LOG TAIL ==="
tail -n 60 "$LOG" 2>/dev/null
echo "===SECRET-SCAN==="
if grep -a -e "${LUKS_PASSPHRASE:-phoebus-luks-test}" \
-e "${USER_PASSWORD:-phoebus-user-test}" "$LOG" 2>/dev/null; then
echo "SECRET_LEAK_FOUND"
else
echo "NO_SECRET_LEAK"
fi
sync
echo "===POWEROFF==="
poweroff -f