phoebus_os/installer-rs/crates/phoebus-installer/tests/live_iso.rs
Phoebus bbd3d89d6a
Some checks are pending
ci / test (push) Waiting to run
feat(desktop): make Mango + DankMaterialShell the default and build a live desktop ISO
- desktop.profile defaults to mango with Flatpak on; explicit none/minimal/dwl/
  full still win. The plan shows the selected session.
- Installed login uses greetd + tuigreet (authentication required, Mango default,
  dwl selectable); live autologin is a separate live-only configuration.
- installer/live/build.sh builds a rootless Debian testing rootfs with Mango
  (pinned source build), DankMaterialShell (pinned SHA-256 release), Quickshell,
  scenefx, Qt Wayland and greetd, then splices it into the base Debian-Live boot
  equipment. Live autologin, an Install Phoebus launcher and a serial/VT
  recovery console are included and the build fails clearly if a desktop
  component is missing. Verified in a graphical seat-providing VM (Mango + DMS +
  Quickshell; DMS panel captured).
- Shared desktop assets emitted by phoebus-installer --emit-asset, a graphical
  VM driver (live-driver.py), and regression tests for defaults/overrides,
  login, live/installed separation and the live ISO guards.
- Docs updated: ADR 0005/0009, STATUS, HANDOFF, CHANGELOG, ROADMAP, DEVELOPMENT
  and VM-BOOT-VERIFICATION.
2026-09-21 06:47:22 -07:00

149 lines
5.3 KiB
Rust

//! Regression guards for the live ISO assembly and the installed defaults.
//!
//! These do not build an ISO; they pin the invariants that make the build
//! meaningful: the desktop payload is required and present in the package list,
//! the build fails clearly when it is missing, the live and installed login
//! configuration stay separate, and both session entries are shipped.
use std::path::{Path, PathBuf};
use phoebus_core::config::{DesktopProfile, InstallConfig};
use phoebus_core::system;
fn repo_root() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("../../..")
.canonicalize()
.expect("repo root")
}
fn read(rel: &str) -> String {
let path: PathBuf = repo_root().join(rel);
std::fs::read_to_string(&path).unwrap_or_else(|e| panic!("cannot read {}: {e}", path.display()))
}
#[test]
fn live_package_list_carries_the_desktop_stack() {
let list = read("installer/live/live-packages.list");
let entries: Vec<&str> = list
.lines()
.map(str::trim)
.filter(|l| !l.is_empty() && !l.starts_with('#'))
.collect();
for required in [
"quickshell",
"greetd",
"tuigreet",
// Mango is built from source, so its build dependencies must be present.
"libwlroots-0.20-dev",
"libscenefx-0.5-dev",
"meson",
// The installer and bookkeeping need these tools in the live image.
"cryptsetup-bin",
"btrfs-progs",
"flatpak",
] {
assert!(
entries.contains(&required),
"live package list is missing {required}"
);
}
}
#[test]
fn live_build_requires_the_desktop_and_fails_clearly() {
let build = read("installer/live/build.sh");
// The desktop compositor and shell must be verified before packing.
assert!(build.contains("usr/bin/mango"));
assert!(build.contains("usr/bin/dms"));
assert!(build.contains("quickshell"));
assert!(build.contains("phoebus-install.desktop"));
// Live autologin must be present in the live login config.
assert!(build.contains("initial_session"));
// The pinned releases are checksum-verified.
assert!(build.contains("releases.sha256"));
// The shared assets come from the installer, not a divergent copy.
assert!(build.contains("--emit-asset"));
}
#[test]
fn pinned_releases_are_checksummed() {
let pins = read("installer/live/releases.sha256");
assert!(pins.contains("dms-full-amd64.tar.gz"));
assert!(pins.contains("mango-0.17.2.tar.gz"));
// 64-hex digests.
for line in pins.lines() {
let line = line.trim();
if line.is_empty() || line.starts_with('#') {
continue;
}
let digest = line.split_whitespace().next().unwrap();
assert_eq!(digest.len(), 64, "not a sha256: {line}");
assert!(digest.chars().all(|c| c.is_ascii_hexdigit()));
assert!(
digest.chars().any(|c| c != '0'),
"placeholder digest: {line}"
);
}
}
#[test]
fn installed_login_is_authenticated_and_selects_mango_by_default() {
let config = system::greetd_config(system::default_session_command(DesktopProfile::Mango));
assert!(config.contains("--cmd /usr/local/bin/phoebus-session-mango"));
assert!(config.contains("--sessions /usr/share/wayland-sessions"));
assert!(
!config.contains("[initial_session]"),
"the installed system must require authentication"
);
}
#[test]
fn live_login_autologins_and_the_configs_are_separate() {
let live = system::desktop_asset("greetd-live").unwrap();
let installed = system::desktop_asset("greetd-installed").unwrap();
assert!(live.contains("[initial_session]"));
assert!(live.contains("user = \"phoebus\""));
assert!(!installed.contains("[initial_session]"));
// The live and installed configs must not be the same file content.
assert_ne!(live, installed);
}
#[test]
fn both_session_entries_are_shipped_for_the_fallback() {
let mango = system::desktop_asset("wayland-session-mango").unwrap();
let dwl = system::desktop_asset("wayland-session-dwl").unwrap();
assert!(mango.contains("Exec=/usr/local/bin/phoebus-session-mango"));
assert!(dwl.contains("Exec=/usr/local/bin/phoebus-session"));
assert_ne!(mango, dwl);
}
#[test]
fn default_config_omits_to_mango_and_overrides_are_respected() {
assert_eq!(
InstallConfig::default().desktop.profile,
DesktopProfile::Mango
);
assert!(InstallConfig::default().desktop.flatpak);
for (value, expected) in [
("none", DesktopProfile::None),
("dwl", DesktopProfile::Dwl),
("full", DesktopProfile::Full),
("mango", DesktopProfile::Mango),
] {
let cfg = InstallConfig::from_legacy(&format!("DESKTOP_PROFILE='{value}'\n")).unwrap();
assert_eq!(cfg.desktop.profile, expected);
}
}
#[test]
fn build_script_is_syntax_declared_shell() {
// A cheap guard that the checked-in script is still a bash script and not a
// stub: it must contain the mmdebstrap invocation and the ISO assembly.
let build = read("installer/live/build.sh");
assert!(build.starts_with("#!/usr/bin/env bash"));
assert!(build.contains("mmdebstrap"));
assert!(build.contains("xorriso"));
assert!(build.contains("mksquashfs"));
let _ = Path::new(".");
}