From bbd3d89d6a05140e63e8aade11b9162de19367a0 Mon Sep 17 00:00:00 2001 From: Phoebus Date: Mon, 21 Sep 2026 06:47:22 -0700 Subject: [PATCH] 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. --- docs/CHANGELOG.md | 29 ++ docs/DEVELOPMENT.md | 43 ++- docs/HANDOFF.md | 37 ++- docs/ROADMAP.md | 11 +- docs/STATUS.md | 27 +- docs/VM-BOOT-VERIFICATION.md | 122 ++++++-- docs/adr/0005-debian-live-appliance.md | 7 + .../0009-mango-dankmaterialshell-desktop.md | 39 ++- .../crates/phoebus-core/src/config.rs | 53 +++- .../crates/phoebus-core/src/system.rs | 255 +++++++++++++++- .../crates/phoebus-executor/src/desktop.rs | 104 ++++++- .../crates/phoebus-installer/src/main.rs | 18 ++ .../phoebus-installer/src/orchestrate.rs | 1 + .../phoebus-installer/tests/golden/plan.txt | 2 +- .../phoebus-installer/tests/live_iso.rs | 149 +++++++++ installer/live/README.md | 102 ++++--- installer/live/build.sh | 284 +++++++++++++----- installer/live/live-packages.list | 101 +++++++ installer/live/livefs-hook.sh | 121 ++++++++ installer/live/releases.sha256 | 11 + .../tests/vm/appliance-test.conf.example | 7 +- installer/tests/vm/live-driver.py | 132 ++++++++ installer/tests/vm/test.conf.example | 7 +- 23 files changed, 1449 insertions(+), 213 deletions(-) create mode 100644 installer-rs/crates/phoebus-installer/tests/live_iso.rs create mode 100644 installer/live/live-packages.list create mode 100644 installer/live/livefs-hook.sh create mode 100644 installer/live/releases.sha256 create mode 100644 installer/tests/vm/live-driver.py diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 7ae3e71..bd2e5d9 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -7,6 +7,35 @@ Format: Keep a Changelog. Dates are UTC. ## Unreleased +### Changed +- **Mango + DankMaterialShell is now the default desktop** for both the + installation ISO and the installed system (explicit owner decision). Omitted + `desktop.profile` selects `mango`; Flatpak and PipeWire are on by default. + Explicit `none`, `minimal`, `dwl` and `full` continue to work unchanged + (ADR 0009). +- **Installed login uses greetd + tuigreet.** Authentication is always + required; the default session is Mango and the dwl entry remains selectable + (`--sessions /usr/share/wayland-sessions`). Live autologin is a separate, + live-only configuration and is never written to an installed system. + +### Added +- **Live desktop ISO**: `installer/live/build.sh` now builds a rootless Debian + testing rootfs containing Mango (built from a pinned source release), + DankMaterialShell (pinned, SHA-256-verified release tarball), Quickshell, + scenefx, wlroots 0.20, greetd/tuigreet and the desktop integration, then + splices it into the base Debian-Live boot equipment. The live user autologins + into Mango, an "Install Phoebus" launcher opens the unchanged installer UI, + and a serial/VT recovery console is retained. The build fails clearly if a + required desktop component is missing. Debian packages never enter the Gentoo + target. The built ISO was booted in a graphical, seat-providing VM: Mango + + DankMaterialShell + Quickshell ran and a `screendump` captured the DMS panel + and welcome window (`docs/VM-BOOT-VERIFICATION.md`). +- Shared desktop assets are emitted from one source of truth by + `phoebus-installer --emit-asset` and used by both the installer and the live + build. Regression tests cover the default/overrides, login configuration, + live/installed separation, session entries, pinned checksums and the live ISO + desktop-payload guards. + ### Added - **Mango + DankMaterialShell desktop option** (`desktop.profile = "mango"`): `gui-wm/mangowm` 0.17.2 (wlroots 0.20) plus `gui-apps/dankmaterialshell` diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.md index 54c56c2..7cc1f39 100644 --- a/docs/DEVELOPMENT.md +++ b/docs/DEVELOPMENT.md @@ -165,20 +165,21 @@ Record the result (date, kernel, GPU, pass/fail per step) in `docs/VM-BOOT-VERIFICATION.md`. A headless wlroots session is not physical-seat verification. -### Mango + DankMaterialShell +### Mango + DankMaterialShell (default) -Select the profile with `DESKTOP_PROFILE='mango'` (or `[desktop] profile = -"mango"`). The installer writes GURU's `repos.conf`, installs `dev-vcs/git`, -syncs the overlay with `emaint sync -r guru`, and installs Mango, DMS, -Quickshell and scenefx with **scoped** `~amd64` keywords. To return to dwl, -select `desktop.profile = "dwl"` (the dwl session and the dwl package set are -also installed by the Mango profile as a fallback, so both session entries exist -at the login screen). +Mango + DankMaterialShell is the default desktop: omitting `desktop.profile` +selects `mango`. The installer writes GURU's `repos.conf`, installs +`dev-vcs/git`, syncs the overlay with `emaint sync -r guru`, and installs Mango, +DMS, Quickshell and scenefx with **scoped** `~amd64` keywords. It also installs +and enables `greetd` (with `tuigreet`) for authenticated login; the default +session is Mango and `phoebus-dwl.desktop` remains selectable. -Session entry points: +To choose another profile (including `none` or the dwl fallback), set +`DESKTOP_PROFILE='dwl'` (or `[desktop] profile = "dwl"`); the login manager +still lets you pick between the installed sessions. ```sh -/usr/local/bin/phoebus-session-mango # Mango + DMS +/usr/local/bin/phoebus-session-mango # Mango + DMS (default) /usr/local/bin/phoebus-session # dwl fallback ``` @@ -189,8 +190,26 @@ To inspect the resolved effect of the transition before installing, use `~amd64` switch. **Acceptance is a graphical VM with a real seat.** Headless compositor tests do -not qualify. The gates are listed in `docs/VM-BOOT-VERIFICATION.md`; until they -pass, Mango is selectable but not the default. +not qualify. The gates are listed in `docs/VM-BOOT-VERIFICATION.md`; the default +was an explicit owner decision and no desktop stability is claimed until they +pass. + +### Building the live desktop ISO + +```sh +cd installer-rs +RUSTFLAGS="-C target-feature=+crt-static" \ + cargo build --release -p phoebus-installer --target x86_64-unknown-linux-gnu +cd .. +installer/live/build.sh +``` + +This builds a rootless Debian testing rootfs with Mango (source build) + +DankMaterialShell (pinned release), live autologin, the "Install Phoebus" +launcher and a serial/VT recovery console, then splices it into the base +Debian-Live ISO. See `installer/live/README.md` for the full description, +including the world-traversable `WORKDIR` requirement of the unprivileged user +namespace. ## Inspecting the reference ISO without booting diff --git a/docs/HANDOFF.md b/docs/HANDOFF.md index 3cd8d6d..65f56e6 100644 --- a/docs/HANDOFF.md +++ b/docs/HANDOFF.md @@ -3,30 +3,35 @@ Rolling note between work sessions. **Update this file before you finish**, then commit it. It should be short and current; use `git log` for detail. -- **Last updated:** commit `b12b276` + this session (2026-09-21) -- **Current focus:** coherent rollback/recovery, the installed AI assistant with - an OS-level sandbox, Nix build isolation, resolved package effects, desktop - completeness, and release gates. A new **Mango + DankMaterialShell** desktop - profile (`desktop.profile = "mango"`, ADR 0009) is implemented and selectable - with a dwl fallback; it is **not yet graphical-VM verified** and is not the - default. -- **Last verified:** static Rust binary install + detached boot - (`docs/VM-BOOT-VERIFICATION.md`); in this session additionally: a fresh - Debian-Live appliance install on a disposable qcow2 (`INSTALL-RC=0`, - `NO_SECRET_LEAK`, detached boot with 0 failed units and the coordinated - initial known-good snapshot + recovery entry), plus unit/functional tests for - rollback, effects, transactions, the assistant schema, the sandbox argv, and - the desktop helpers. +- **Last updated:** commit `639cb33` + this session (2026-09-21) +- **Current focus:** Mango + DankMaterialShell as the default desktop. The + installed default is `desktop.profile = "mango"` with greetd authenticated + login (Mango default, dwl fallback), and `installer/live/build.sh` now builds + a Mango live desktop ISO from a rootless Debian testing rootfs plus pinned + Mango/DMS releases. Graphical VM verification of the installed desktop and + the built ISO is the remaining evidence gap. +- **Last verified:** static Rust binary install + detached boot and the 2026-09-21 + appliance baseline (`INSTALL-RC=0`, `NO_SECRET_LEAK`, coordinated initial + snapshot + recovery entry) in `docs/VM-BOOT-VERIFICATION.md`; unit/functional + tests for the Mango default, explicit overrides, greetd login, live/installed + separation, session entries, pinned release checksums and the live ISO guards; + and the built Mango live ISO booted in a graphical seat-providing VM (Mango + + DMS + Quickshell running, DMS panel/welcome captured by `screendump`). - **Public repo:** (remote `origin`, SSH port 2222). ## Next actions (in order) -1. **Rollback VM acceptance**: deliberately break an update in the disposable +1. **Mango graphical verification** (default, so highest priority): install the + default profile and boot the built live ISO in a graphical, seat-providing + VM; verify the panel/launcher/terminal/Install-Phoebus entry, audio/network, + lock/idle, logout/reboot and the dwl fallback, plus authenticated login on + the installed system (`docs/VM-BOOT-VERIFICATION.md`). +2. **Rollback VM acceptance**: deliberately break an update in the disposable VM, run `sys undo`, reboot detached, verify package-state consistency (`/var/db/pkg` matches `/`), then boot the snapshot recovery entry with no network or model (ADR 0007). -2. **Live AI provider call**: exercise `sys ask` with a real 0600 key file and +3. **Live AI provider call**: exercise `sys ask` with a real 0600 key file and confirm the `systemd-run` sandbox properties apply; the path is fixture-verified only. 3. **Physical-seat desktop**: run `phoebus-session` on a real VT/seat and check diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 4744642..bd259a2 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -10,7 +10,7 @@ more interesting. Status vocabulary: **Done**, **Partial**, **Next**, **Later**. | 3 | Port the deterministic core | Done | `phoebus-core` (config, plan, policy, validation, models) | | 4 | Port the destructive backend | Done | `phoebus-executor` (storage, LUKS2, Btrfs, Portage, boot, users, services) | | 5 | **Rust VM boot parity** | Done | Full encrypted UEFI install + boot, zero failed units, 10.7 s | -| 6 | Finish the desktop | Partial | dwl helpers, lock, idle/suspend and Waybar controls added; Mango + DankMaterialShell profile added via GURU (selectable, dwl fallback); graphical-VM verification of both sessions pending | +| 6 | Finish the desktop | Partial | **Mango + DankMaterialShell is the default** (dwl fallback); greetd login; live ISO builds a Mango desktop; graphical-VM verification pending | | 7 | Finish Flatpak | Partial | `flatpak 1.18.1` installed, flathub configured; bounded typed `flatpak_*` actions added; no app installed yet | | 8 | Instrument source/binary policy | Done | measured compile times harvested from `emerge.log` (326 entries); resolved-effect previews added | | 9 | Background update preparation | Partial | distfile fetch VM-verified; `--buildpkgonly` skipped while deps need merging (recorded Ready); activation explicit | @@ -31,10 +31,11 @@ more interesting. Status vocabulary: **Done**, **Partial**, **Next**, **Later**. `seatd`-backed session) and verify kitty, wofi, `phoebus-menu`, `phoebus-idle`, the polkit agent, logout and reboot interactively (`docs/DEVELOPMENT.md`). -2. **Mango + DankMaterialShell acceptance**: install the `mango` profile in a - graphical, seat-providing VM and run the gates in - `docs/VM-BOOT-VERIFICATION.md`; only then consider promoting it to the - default desktop. The profile is selectable now (ADR 0009). +2. **Mango + DankMaterialShell graphical verification**: Mango is now the + default (ADR 0009). Install the `mango` profile and boot the Mango live ISO + in a graphical, seat-providing VM and run the gates in + `docs/VM-BOOT-VERIFICATION.md`. Default promotion was an explicit owner + decision; verification is still required to claim stability. 3. **Rollback VM acceptance**: deliberately break an update in the disposable VM, run `sys undo`, reboot detached, verify package-state consistency, then boot the recovery entry with no network or model (ADR 0007). diff --git a/docs/STATUS.md b/docs/STATUS.md index 1c4d699..6b3fd6b 100644 --- a/docs/STATUS.md +++ b/docs/STATUS.md @@ -84,7 +84,10 @@ still not VM-verified. | Transaction log | yes | yes | no | no | | Flatpak/Nix bounded typed actions | yes | yes | no | no | | Desktop session helpers (menu/lock/idle) | yes | yes | functional test (stubs) | no | -| Mango + DankMaterialShell profile | yes | yes | no (graphical VM gate pending) | no | +| Mango + DankMaterialShell profile | yes | yes | live graphical VM yes; installed no | no | +| Mango is the default desktop | yes | yes | install pending | no | +| greetd login (Mango default, dwl fallback) | yes | yes | no | no | +| Live desktop ISO (Mango + DMS) | yes | guards tested | graphical VM verified | no | | GURU packaging (scoped keywords) | yes | yes | no (build/install unverified) | no | | Release gates + atomic publish | yes | yes | no | n/a | | `sys` verbs | yes | yes | yes | no | @@ -111,13 +114,21 @@ still not VM-verified. detached reboot -> package-state check -> recovery with no network/model) has not been run. `sys undo` is present; treat VM verification as the gate before relying on it. -- **Mango + DankMaterialShell** is implemented as `desktop.profile = "mango"` - (Mango 0.17.2, DMS 1.5.3, Quickshell 0.3.1, scenefx 0.5 via the GURU overlay), - with a dwl fallback session and scoped `~amd64` keywords. It has not been - installed or booted in a graphical VM: no build, no seat, no interactive - verification. It is therefore **selectable, not default**, and no desktop - stability is claimed. The exact gates are listed in - `docs/VM-BOOT-VERIFICATION.md`. +- **Mango + DankMaterialShell** is the default desktop + (`desktop.profile = "mango"`, Flatpak on). It is implemented with Mango + 0.17.2, DMS (pinned release), Quickshell 0.3.1 and scenefx 0.5 from the GURU + overlay, a dwl fallback session and scoped `~amd64` keywords. The default is + set by explicit owner decision; it has not been installed or booted in a + graphical VM, so **no desktop stability is claimed**. `docs/STATUS.md` + distinguishes "default in configuration", "successfully built" and + "graphically verified". +- **The live desktop ISO** (`installer/live/build.sh`) builds a Debian testing + rootfs with Mango + DMS, live-only autologin and an "Install Phoebus" + launcher. Its desktop-payload guards are unit-tested, and the built ISO + (`sha256 c235b873…`) was booted in a graphical, seat-providing VM: Mango, + DMS and Quickshell were running and a `screendump` showed the DMS panel and + welcome window. The **installed** Mango system (GURU + compiled + Quickshell/DMS) and the dwl fallback in a VM are not yet verified. - **AI sandbox** is implemented (`systemd-run` hardening properties, tested at the argv level) and fails closed without `systemd-run`; it has not been exercised in a VM. Only typed actions and the privacy boundary were previously diff --git a/docs/VM-BOOT-VERIFICATION.md b/docs/VM-BOOT-VERIFICATION.md index 9b71ab4..ea6e96d 100644 --- a/docs/VM-BOOT-VERIFICATION.md +++ b/docs/VM-BOOT-VERIFICATION.md @@ -399,45 +399,103 @@ Not yet verified for this baseline: `sys undo`, a deliberately broken update, a detached rollback reboot, and recovery with no network/model (the rollback acceptance gate). -## Mango + DankMaterialShell acceptance (NOT RUN) +## Mango + DankMaterialShell verification (IN PROGRESS) -The `mango` profile (ADR 0009) is implemented and source-tested but has not been -installed or booted. These gates must pass in a **graphical, seat-providing** -disposable VM before the profile is promoted to default. Headless wlroots tests -do not count. +### Live ISO — graphical VM (verified 2026-09-21) -Prerequisites: the `mango` install needs the GURU overlay to sync (git) and -Quickshell/DMS/scenefx to compile; the base install alone is tens of minutes. +Artifact: `installer/live/build.sh` output +`phoebus-mango-amd64.iso`, +sha256 `c235b873bc04a90c91ff4be361a605907997c509c4021e611645336c23f924d9` +(1.6 GiB). The image was built rootlessly from the signed Debian testing +archive plus pinned Mango 0.17.2 and DankMaterialShell 1.6.2 releases +(`installer/live/releases.sha256`). -1. Fresh install with `DESKTOP_PROFILE='mango'` reaches `systemctl - is-system-running = running` with 0 failed units; `emerge --pretend` shows - only the reviewed `~amd64` atoms. -2. Detached encrypted boot; LUKS unlock; login on a real seat. -3. `phoebus-mango.desktop` starts the session; exactly one compositor (mango), - one shell (dms), one lock/idle (DMS) and one polkit agent are running; no +Booted in a disposable QEMU/OVMF VM with a **graphical device** +(`-device virtio-gpu-pci`, no `-vga`, serial console still attached) — a real +DRM node and logind seat, not a headless compositor: + +- `uname -r` -> `7.1.13+deb14-amd64`; `systemctl is-system-running` -> running; + `/dev/dri/card0` and `/dev/dri/renderD128` present. +- Live autologin ran as an unprivileged `phoebus` user in session `c1` on + `seat0`/tty7; `mango` (compositor), `/usr/bin/dms run --session` and + `qs` (Quickshell) were running under the user manager + (`mango-session.target` and `dms.service` both **active**). +- No dwl helpers (`waybar`/`mako`/`swayidle`/`swaylock`) were started. +- A framebuffer `screendump` showed the DankMaterialShell desktop: the DMS + panel (clock, weather, tray, network/battery/volume/power) and the DMS + first-run "Welcome to DankMaterialShell" window, composited by Mango. This is + the acceptance evidence for "the ISO boots into a usable Mango + + DankMaterialShell live desktop". +- The "Install Phoebus" application entry and `/usr/local/bin/phoebus-install` + are installed by the build; the launcher runs the installer UI and passes no + `--yes`/`--install`/`--no-ai` (unit-tested), so opening it cannot start a + destructive operation automatically. The serial console and a spare VT + remain available as a recovery path. + +Fixes found by this test (all committed): the live kernel/initrd must replace +the base ISO's **versioned** `/live/vmlinuz-*` paths; setuid bits must be +restored when packing as an unprivileged user (for `sudo`); `virtio_gpu` must +be autoloaded; greetd's `greeter` account must exist even with an +`initial_session`; greetd must run on VT7 to avoid the `getty@tty1` conflict; +live-config autologin (`noautologin`) must be disabled in favour of greetd; and +the Mango session must not export `WAYLAND_DISPLAY` before the compositor +starts (wlroots would pick its nested backend instead of DRM) and needs the Qt +Wayland shell-integration packages for Quickshell. + +### Installed system — not yet run + +A default install (`desktop.profile = "mango"`; the default) and a detached +encrypted boot to the greetd login are **not yet verified in a VM**: the Mango +transaction syncs the GURU overlay and compiles Quickshell/DMS/scenefx/Qt, +which was not feasible here. The configuration and login behaviour are covered +by unit tests (`live_iso.rs`, `system::installed_login_*`, `desktop.rs`), and +the plan renders the session. Verify with the harness once a full Mango build +is affordable: + +```sh +python3 installer/tests/vm/appliance-driver.py install # DESKTOP_PROFILE=mango +python3 installer/tests/vm/appliance-driver.py boot +``` + +Remaining graphical checks (installed system and live): panel interactions and +launcher, notifications, polkit prompt, lock/unlock, idle/suspend and resume, +display changes, clipboard/screenshots/terminal/file manager, a Flatpak app +launch + file chooser + screen sharing, logout/reboot, the dwl fallback, shell +restart, and idle memory/CPU versus dwl. + +Known prerequisites/limits: the installed `mango` transaction needs the GURU +overlay (git) and compiles Quickshell/DMS/scenefx; the live build needs the +signed Debian testing archive. A graphical VM must provide a real seat (for +example `-device virtio-gpu-pci` with the serial console still attached); +`-display none` alone is not sufficient evidence of a graphical session. + +1. Live ISO boots to Mango + DMS (screenshot/`screendump` evidence, not just + process names); panel, launcher and terminal work; "Install Phoebus" opens + the installer UI without starting a destructive operation. +2. Live text-console recovery (serial and a spare VT) remains accessible. +3. Fresh install with the default profile reaches `systemctl is-system-running + = running` with 0 failed units; `emerge --pretend` shows only the reviewed + `~amd64` atoms. +4. Detached encrypted boot; LUKS unlock; **authenticated** login on a real seat; + Mango is the default session. +5. `phoebus-mango.desktop` starts the session; exactly one compositor (mango), + one shell (dms), one lock/idle (DMS) and one polkit agent run; no waybar/mako/swaybg/swayidle/swaylock processes. -4. Panel, launcher (Mod+Space), notifications, tray, and the DMS settings panel - work; the shortcut guide matches the packaged config. -5. Audio output/input selection, volume, mic mute (WirePlumber); network and - Bluetooth controls from the panel. -6. Lock (Mod+Alt+L) and unlock; idle lock/suspend; repeated suspend/resume. +6. Panel, launcher (Mod+Space), notifications, tray and the DMS settings panel; + audio/network/Bluetooth controls; lock/unlock; idle/suspend and resume. 7. Display configuration/scaling and a second monitor if the VM supports one. -8. Clipboard history (Mod+V), screenshots, kitty terminal, file manager, and - `phoebus-assistant` opening `sys ask` (no model required for deterministic - `sys`). +8. Clipboard history, screenshots, terminal, file manager, and `phoebus-assistant`. 9. An actual Flatpak app: launch, file chooser, and portal screen sharing. -10. Logout reaps DMS and session processes without touching the dwl fallback; - reboot; then boot the `phoebus-dwl.desktop` session and confirm it still - works. -11. Shell-failure handling: kill `dms` and confirm the compositor keeps running - and locking still locks; restart the shell without losing windows. -12. Upgrade from an existing dwl install keeps user configuration - (`~/.config/mango/config.conf`, DMS fragments, `~/.config/waybar`) intact. -13. Idle memory/CPU and startup time measured against the dwl session under - comparable conditions. +10. Logout reaps session processes; reboot; select the `phoebus-dwl.desktop` + fallback and confirm it still works. +11. Shell-failure handling (kill `dms`, compositor survives, locking still + locks), and default-selection behaviour: omitting the profile selects Mango, + explicit `none`/`dwl` are respected, and an existing explicit choice is not + overwritten. +12. Idle memory/CPU and startup measured against the dwl session. -Until this list is recorded here with results, the Mango profile is selectable -but not default, and no desktop stability is claimed. +Until results are recorded here, the default stands by owner decision but no +stability is claimed. ## Known remaining work diff --git a/docs/adr/0005-debian-live-appliance.md b/docs/adr/0005-debian-live-appliance.md index d8481d3..3a3d4ba 100644 --- a/docs/adr/0005-debian-live-appliance.md +++ b/docs/adr/0005-debian-live-appliance.md @@ -2,6 +2,13 @@ - **Status:** Accepted - **Date:** 2026-09-20 +- **Updated:** 2026-09-21 — the live medium now ships a full Mango + + DankMaterialShell desktop. The overlay-only layout (`tools.list`, `/phoebus` + payload) is superseded by a Debian **testing** rootfs built with mmdebstrap + (`installer/live/build.sh`, `installer/live/live-packages.list`); the old + overlay files are retained only for reference. The Gentoo-only target, + replaceable-plumbing principle and signature policy are unchanged. See ADR + 0009. ## Context diff --git a/docs/adr/0009-mango-dankmaterialshell-desktop.md b/docs/adr/0009-mango-dankmaterialshell-desktop.md index 9ce85a9..069b2d9 100644 --- a/docs/adr/0009-mango-dankmaterialshell-desktop.md +++ b/docs/adr/0009-mango-dankmaterialshell-desktop.md @@ -65,9 +65,25 @@ promote Mango to the default only after verification. wired up; updates continue through `sys`/Portage. The assistant is reachable from a launcher (`phoebus-assistant`) that simply runs `sys ask`, keeping the typed-action and approval boundary. -7. **Default promotion is gated on verification.** Until the graphical-VM gates - in `docs/VM-BOOT-VERIFICATION.md` pass, the Mango profile is *selectable*, - not the default; `desktop.profile = "dwl"` remains the recommended default. +7. **Mango + DankMaterialShell is the default desktop (explicit owner decision, + 2026-09-21).** `desktop.profile` defaults to `mango`, Flatpak is on by + default, and the default login experience selects the Mango session. + Explicit values — including `none` and `dwl` — are still respected. This + supersedes the earlier "verify before default promotion" policy; the + graphical-VM gates below are still tracked honestly, but they no longer gate + the default. `dwl` remains shipped as a fallback and selectable at login. + +## Live medium + +The installer ISO boots into the same Mango + DankMaterialShell desktop. The +live image is a Debian testing rootfs (wlroots 0.20, scenefx 0.5, quickshell) +plus a pinned Mango source build and a pinned DMS release; it autologins as an +unprivileged `phoebus` user, exposes a serial/VT recovery console, and provides +an "Install Phoebus" launcher that opens the uninstrumented installer UI. The +installed target is Gentoo and never receives Debian packages. See +`installer/live/README.md`. The live and installed login configurations are +generated from the same assets but differ in one property: the live config has +`[initial_session]` (autologin) and the installed config never does. ## Update procedure @@ -91,9 +107,16 @@ their maintainers (see each `metadata.xml`). ## Verification status -Unit and source-level tests cover the profile, package set, keyword scope, -generated session scripts, config seeding and the two session entries. The -graphical-VM acceptance gates (real seat, launcher/panel/notifications/polkit, +Unit and source-level tests cover the default configuration and explicit +overrides, the profile and package set, keyword scope, generated session +scripts, config seeding, the two session entries, the greetd configuration, the +live/installed login separation, and the live ISO's desktop-payload guards. The +ISO is built by `installer/live/build.sh` (see the evidence recorded in +`docs/VM-BOOT-VERIFICATION.md`). + +Graphical-VM acceptance gates (real seat, panel/launcher/notifications/polkit, lock/unlock, shell restart, logout cleanup, suspend/resume, Flatpak portals, -idle/memory under load) are **not yet passed**; the profile therefore stays -selectable and is not promoted to default. See `docs/STATUS.md`. +idle/memory under load) are tracked in `docs/VM-BOOT-VERIFICATION.md` and are +**not all passed**. The default is set by explicit owner decision, not because +those gates passed; `docs/STATUS.md` distinguishes "default in configuration", +"successfully built" and "graphically verified". diff --git a/installer-rs/crates/phoebus-core/src/config.rs b/installer-rs/crates/phoebus-core/src/config.rs index 787f7c6..a6bfdd2 100644 --- a/installer-rs/crates/phoebus-core/src/config.rs +++ b/installer-rs/crates/phoebus-core/src/config.rs @@ -62,6 +62,18 @@ string_enum!(KernelProfile { Safe => "safe", Optimized => "optimized", Aggressiv string_enum!(PackagePolicy { Balanced => "balanced", SourceFirst => "source_first", BinaryFirst => "binary_first" }); string_enum!(DesktopProfile { None => "none", Minimal => "minimal", Dwl => "dwl", Mango => "mango", Full => "full" }); +impl DesktopProfile { + /// Whether this profile installs a graphical session. + pub fn is_desktop(self) -> bool { + !matches!(self, DesktopProfile::None) + } + + /// Whether the profile's session entry point is the Mango one. + pub fn is_mango(self) -> bool { + matches!(self, DesktopProfile::Mango) + } +} + impl Bootloader { pub fn default_systemd_boot() -> Self { Bootloader::SystemdBoot @@ -339,8 +351,11 @@ pub struct DesktopConfig { impl Default for DesktopConfig { fn default() -> Self { Self { - profile: DesktopProfile::None, - flatpak: false, + // Mango + DankMaterialShell is the default desktop. An explicit + // `DESKTOP_PROFILE`/`profile` value (including `none`) is respected. + profile: DesktopProfile::Mango, + // Flatpak and PipeWire are part of the default desktop experience. + flatpak: true, audio_stack: "pipewire".into(), } } @@ -601,6 +616,40 @@ mod tests { assert!(!c.packages.policy.eq(&PackagePolicy::SourceFirst)); } + #[test] + fn default_desktop_is_mango_with_flatpak_and_pipewire() { + let c = InstallConfig::default(); + assert_eq!(c.desktop.profile, DesktopProfile::Mango); + assert!(c.desktop.flatpak); + assert_eq!(c.desktop.audio_stack, "pipewire"); + assert!(c.desktop.profile.is_desktop()); + assert!(c.desktop.profile.is_mango()); + } + + #[test] + fn omitting_the_desktop_key_selects_mango_but_explicit_values_win() { + // Legacy format with no DESKTOP_PROFILE key -> default (Mango). + let implicit = + InstallConfig::from_legacy("HOSTNAME='box'\nTARGET_DISK='/dev/vda'\n").unwrap(); + assert_eq!(implicit.desktop.profile, DesktopProfile::Mango); + // Explicit values, including `none`, are respected. + for (value, expected) in [ + ("none", DesktopProfile::None), + ("minimal", DesktopProfile::Minimal), + ("dwl", DesktopProfile::Dwl), + ("mango", DesktopProfile::Mango), + ("full", DesktopProfile::Full), + ] { + let text = format!("HOSTNAME='box'\nDESKTOP_PROFILE='{value}'\n"); + let cfg = InstallConfig::from_legacy(&text).unwrap(); + assert_eq!(cfg.desktop.profile, expected, "value {value}"); + } + // TOML: a bare `[desktop]` section without `profile` keeps the default. + let toml = InstallConfig::from_toml("[desktop]\nflatpak = false\n").unwrap(); + assert_eq!(toml.desktop.profile, DesktopProfile::Mango); + assert!(!toml.desktop.flatpak); + } + #[test] fn legacy_config_parses_flat_keys() { let text = "\ diff --git a/installer-rs/crates/phoebus-core/src/system.rs b/installer-rs/crates/phoebus-core/src/system.rs index 50672cf..ea6fcde 100644 --- a/installer-rs/crates/phoebus-core/src/system.rs +++ b/installer-rs/crates/phoebus-core/src/system.rs @@ -76,6 +76,10 @@ pub fn dwl_desktop_packages() -> Vec<&'static str> { "net-misc/networkmanager", "sys-auth/polkit", "gnome-extra/polkit-gnome", + // Login: greetd authenticates and runs the selected Wayland session + // (Mango by default, dwl selectable). tuigreet is the greeter. + "gui-libs/greetd", + "gui-apps/tuigreet", // Desktop portals: required by Flatpak (file chooser, screencast, // screenshots) and expected by many Wayland apps. "sys-apps/xdg-desktop-portal", @@ -123,6 +127,12 @@ pub fn desktop_services(profile: DesktopProfile) -> Vec<&'static str> { out } +/// Services enabled only after the desktop packages are installed (greetd is +/// not present until `desktop_install`). +pub fn desktop_login_services() -> Vec<&'static str> { + vec!["greetd"] +} + /// The services that should be enabled in the target, deduplicated. pub fn target_services(config: &InstallConfig) -> Vec { let mut out: Vec = Vec::new(); @@ -701,9 +711,10 @@ if [ ! -d "$XDG_RUNTIME_DIR" ]; then exit 1 fi -# Deterministic socket name so the environment exported to the systemd user -# manager matches the compositor. -export WAYLAND_DISPLAY="${WAYLAND_DISPLAY:-wayland-0}" +# Do NOT set WAYLAND_DISPLAY before starting the compositor: wlroots would +# select its nested Wayland backend instead of the DRM backend and fail. The +# compositor creates the socket; it is discovered and exported afterwards (for +# the systemd user manager and the shell). export XDG_SESSION_TYPE=wayland export XDG_CURRENT_DESKTOP=mango export XDG_SESSION_DESKTOP=mango @@ -731,7 +742,6 @@ for f in colors layout outputs; do [ -e "$HOME/.config/mango/dms/$f.conf" ] || : > "$HOME/.config/mango/dms/$f.conf" done -socket="${XDG_RUNTIME_DIR}/${WAYLAND_DISPLAY}" HELPERS="" start_helper() { @@ -754,14 +764,25 @@ trap cleanup EXIT INT TERM mango & MANGO_PID=$! +# Discover the socket the compositor creates (don't constrain its name) and +# only then export WAYLAND_DISPLAY for the shell and the user manager. +socket="" waited=0 -while [ ! -S "$socket" ]; do +while [ -z "$socket" ]; do + for candidate in "$XDG_RUNTIME_DIR"/wayland-*; do + if [ -S "$candidate" ]; then + socket="$candidate" + export WAYLAND_DISPLAY="$(basename "$candidate")" + break + fi + done + [ -n "$socket" ] && break if ! kill -0 "$MANGO_PID" 2>/dev/null; then - echo "phoebus-session-mango: mango exited before creating $socket" >&2 + echo "phoebus-session-mango: mango exited before creating a Wayland socket" >&2 exit 1 fi if [ "$waited" -ge 100 ]; then - echo "phoebus-session-mango: timed out waiting for $socket" >&2 + echo "phoebus-session-mango: timed out waiting for a Wayland socket" >&2 kill "$MANGO_PID" 2>/dev/null || true exit 1 fi @@ -909,6 +930,147 @@ pub fn wayland_session_entry(profile: DesktopProfile) -> Option<(&'static str, S } } +/// The installed-system greetd configuration: authenticate, then run the +/// selected session. `default_cmd` is the session used when the user does not +/// pick another from the session list, so Mango is the default and the dwl +/// entry remains selectable. There is deliberately **no** `[initial_session]`: +/// the installed system always requires authentication (unlike the live ISO). +pub fn greetd_config(default_cmd: &str) -> String { + format!( + "# /etc/greetd/config.toml - Phoebus login (generated by the installer).\n\ + # Authentication is always required; the live ISO uses a separate\n\ + # autologin configuration.\n\ + [terminal]\n\ + vt = 7\n\ + \n\ + [default_session]\n\ + command = \"tuigreet --time --remember --remember-session \\\n\ + --sessions /usr/share/wayland-sessions --cmd {default_cmd}\"\n\ + user = \"greeter\"\n" + ) +} + +/// The live-ISO greetd configuration: a live-only automatic login into the +/// desktop, with a greeter fallback. This must never be written to an installed +/// system. +pub fn greetd_config_live(live_user: &str, session_cmd: &str) -> String { + format!( + "# /etc/greetd/config.toml - Phoebus live session (LIVE ONLY).\n\ + # Automatic login is intentional on the live medium and is not copied\n\ + # to an installed system.\n\ + [terminal]\n\ + vt = 7\n\ + \n\ + [initial_session]\n\ + command = \"{session_cmd}\"\n\ + user = \"{live_user}\"\n\ + \n\ + [default_session]\n\ + command = \"tuigreet --time --sessions /usr/share/wayland-sessions --cmd {session_cmd}\"\n\ + user = \"greeter\"\n" + ) +} + +/// The session command used as the default desktop for a profile. +pub fn default_session_command(profile: DesktopProfile) -> &'static str { + match profile { + DesktopProfile::Mango => "/usr/local/bin/phoebus-session-mango", + _ => "/usr/local/bin/phoebus-session", + } +} + +/// The live ISO's unprivileged user. +pub const LIVE_USER: &str = "phoebus"; + +/// A named desktop asset, so the live ISO build and the installer use exactly +/// the same configuration and session scripts. `None` for an unknown name. +pub fn desktop_asset(name: &str) -> Option { + let default_cmd = default_session_command(DesktopProfile::Mango); + let live_cmd = "/usr/local/bin/phoebus-session-mango"; + Some(match name { + "session-mango" => PHOEBUS_MANGO_SESSION_SCRIPT.to_string(), + "session-dwl" => PHOEBUS_SESSION_SCRIPT.to_string(), + "assistant" => PHOEBUS_ASSISTANT_SCRIPT.to_string(), + "install" => PHOEBUS_INSTALL_SCRIPT.to_string(), + "menu" => PHOEBUS_MENU_SCRIPT.to_string(), + "lock" => PHOEBUS_LOCK_SCRIPT.to_string(), + "idle" => PHOEBUS_IDLE_SCRIPT.to_string(), + "waybar-config" => WAYBAR_CONFIG.to_string(), + "waybar-style" => WAYBAR_STYLE.to_string(), + "mango-config" => MANGO_CONFIG_DEFAULT.to_string(), + "mango-session-target" => MANGO_SESSION_TARGET.to_string(), + "install-desktop" => PHOEBUS_INSTALL_DESKTOP_ENTRY.to_string(), + "greetd-installed" => greetd_config(default_cmd), + "greetd-live" => greetd_config_live(LIVE_USER, live_cmd), + "wayland-session-mango" => wayland_session_entry(DesktopProfile::Mango)?.1, + "wayland-session-dwl" => wayland_session_entry(DesktopProfile::Dwl)?.1, + _ => return None, + }) +} + +/// `phoebus-install`: open the existing installer UI. It never starts a +/// destructive operation by itself: the plan, disk protection, AI requirement, +/// credential handling and the ERASE confirmation all stay in force. +pub const PHOEBUS_INSTALL_SCRIPT: &str = r#"#!/bin/bash +# Open the Phoebus installer. This only launches the installer UI; the user +# still reviews the plan, supplies credentials and confirms ERASE. +set -u +conf="/etc/phoebus/install.conf" +args=() +[ -f "$conf" ] && args+=(--config "$conf") + +run() { + local installer="" + for candidate in \ + /run/live/medium/phoebus/bin/phoebus \ + /phoebus/bin/phoebus \ + /usr/local/bin/phoebus-installer \ + phoebus-installer; do + if command -v "$candidate" >/dev/null 2>&1; then + installer="$candidate" + break + fi + done + if [ -z "$installer" ]; then + echo "phoebus-install: installer not found" >&2 + return 1 + fi + if [ "$(id -u)" -eq 0 ]; then + "$installer" "${args[@]}" + else + sudo -n "$installer" "${args[@]}" + fi +} + +# Re-entrant wrapper: the inner invocation (inside the terminal) just runs. +if [ "${1:-}" = "--in-terminal" ]; then + run + rc=$? + echo + read -rp "Press Enter to close" _ || true + exit "$rc" +fi + +if command -v kitty >/dev/null 2>&1; then + exec kitty --title "Install Phoebus" -e "$0" --in-terminal +fi +run +"#; + +/// The application entry that makes the installer discoverable in the desktop +/// launcher ("Install Phoebus"). +pub const PHOEBUS_INSTALL_DESKTOP_ENTRY: &str = "\ +[Desktop Entry]\n\ +Type=Application\n\ +Name=Install Phoebus\n\ +Comment=Install Phoebus OS to disk\n\ +Exec=/usr/local/bin/phoebus-install\n\ +TryExec=/usr/local/bin/phoebus-install\n\ +Icon=system-software-install\n\ +Terminal=false\n\ +Categories=System;\n\ +Keywords=install;phoebus;\n"; + /// Btrfs mount options, matching the proven behavior. pub fn btrfs_mount_opts(compress: &str, ssd: bool) -> String { let mut opts = format!("noatime,compress={compress},space_cache=v2"); @@ -1195,10 +1357,15 @@ mod tests { #[test] fn desktop_selects_desktop_systemd_profile() { let mut cfg = InstallConfig::default(); + // The default profile is a desktop, so it selects the desktop profile. + assert_eq!(cfg.desktop.profile, DesktopProfile::Mango); + assert_eq!(selected_profile(&cfg), PROFILE_SYSTEMD_DESKTOP); + // An explicit `none` keeps the minimal systemd profile. + cfg.desktop.profile = DesktopProfile::None; assert_eq!(selected_profile(&cfg), PROFILE_SYSTEMD_MINIMAL); cfg.desktop.profile = DesktopProfile::Dwl; assert_eq!(selected_profile(&cfg), PROFILE_SYSTEMD_DESKTOP); - // An explicit non-default profile is respected. + // An explicit non-default Gentoo profile is respected. cfg.stage3.gentoo_profile = "default/linux/amd64/23.0/hardened/systemd".into(); assert_eq!( selected_profile(&cfg), @@ -1337,6 +1504,14 @@ mod tests { assert!(script.contains("if [ ! -e \"$mango_conf\" ]")); assert!(script.contains("dbus-update-activation-environment --systemd")); assert!(script.contains("wait \"$MANGO_PID\"")); + // WAYLAND_DISPLAY must not be set before the compositor starts, or + // wlroots selects its nested Wayland backend instead of DRM. + let mango_at = script.find("mango &").unwrap(); + let wayland_at = script.find("WAYLAND_DISPLAY=").unwrap(); + assert!( + wayland_at > mango_at, + "WAYLAND_DISPLAY must only be set after mango starts" + ); let config = MANGO_CONFIG_DEFAULT; assert!(config.contains("dms ipc call lock lock")); @@ -1350,4 +1525,68 @@ mod tests { assert_eq!(name, "phoebus-mango.desktop"); assert!(entry.contains("Exec=/usr/local/bin/phoebus-session-mango")); } + + #[test] + fn installed_login_authenticates_and_defaults_to_mango() { + let cfg = greetd_config("/usr/local/bin/phoebus-session-mango"); + assert!(cfg.contains("[terminal]")); + assert!(cfg.contains("vt = 7")); + assert!(cfg.contains("[default_session]")); + // The installed system must never autologin. + assert!(!cfg.contains("[initial_session]")); + assert!(cfg.contains("tuigreet")); + assert!(cfg.contains("--sessions /usr/share/wayland-sessions")); + assert!(cfg.contains("--cmd /usr/local/bin/phoebus-session-mango")); + + // The live configuration is separate and does autologin. + let live = greetd_config_live("phoebus", "/usr/local/bin/phoebus-session-mango"); + assert!(live.contains("[initial_session]")); + assert!(live.contains("user = \"phoebus\"")); + assert!(live.contains("[default_session]")); + + assert_eq!( + default_session_command(DesktopProfile::Mango), + "/usr/local/bin/phoebus-session-mango" + ); + assert_eq!( + default_session_command(DesktopProfile::Dwl), + "/usr/local/bin/phoebus-session" + ); + } + + #[test] + fn install_launcher_is_discoverable_but_not_automatic() { + assert!(PHOEBUS_INSTALL_DESKTOP_ENTRY.contains("Name=Install Phoebus")); + assert!(PHOEBUS_INSTALL_DESKTOP_ENTRY.contains("Exec=/usr/local/bin/phoebus-install")); + // It may run the installer UI, never an unattended destructive install. + assert!(!PHOEBUS_INSTALL_SCRIPT.contains("--yes")); + assert!(!PHOEBUS_INSTALL_SCRIPT.contains("--install")); + assert!(!PHOEBUS_INSTALL_SCRIPT.contains("--no-ai")); + assert!(PHOEBUS_INSTALL_SCRIPT.contains("sudo -n")); + } + + #[test] + fn desktop_assets_are_shared_between_live_and_installed() { + assert!(desktop_asset("session-mango").unwrap().contains("dms run")); + assert!(desktop_asset("mango-config") + .unwrap() + .contains("dms ipc call")); + // The live and installed greetd configs differ only in autologin. + assert!(desktop_asset("greetd-live") + .unwrap() + .contains("[initial_session]")); + assert!(!desktop_asset("greetd-installed") + .unwrap() + .contains("[initial_session]")); + assert!(desktop_asset("greetd-installed") + .unwrap() + .contains("phoebus-session-mango")); + assert!(desktop_asset("wayland-session-dwl") + .unwrap() + .contains("phoebus-session")); + assert!(desktop_asset("install-desktop") + .unwrap() + .contains("Install Phoebus")); + assert!(desktop_asset("does-not-exist").is_none()); + } } diff --git a/installer-rs/crates/phoebus-executor/src/desktop.rs b/installer-rs/crates/phoebus-executor/src/desktop.rs index d8d9995..56d56e1 100644 --- a/installer-rs/crates/phoebus-executor/src/desktop.rs +++ b/installer-rs/crates/phoebus-executor/src/desktop.rs @@ -64,6 +64,18 @@ pub fn write_session_script(exec: &Exec, config: &InstallConfig) -> Result<()> { sysgen::PHOEBUS_ASSISTANT_SCRIPT, )?; + // "Install Phoebus": discoverable in the launcher, opens the installer UI + // without starting any destructive operation. + write_script( + &target, + "usr/local/bin/phoebus-install", + sysgen::PHOEBUS_INSTALL_SCRIPT, + )?; + target.write( + "usr/share/applications/phoebus-install.desktop", + sysgen::PHOEBUS_INSTALL_DESKTOP_ENTRY, + )?; + match config.desktop.profile { DesktopProfile::Mango => { write_mango_session(exec, &target)?; @@ -156,6 +168,54 @@ fn write_mango_session(exec: &Exec, target: &phoebus_core::TargetRoot) -> Result Ok(()) } +/// Configure authenticated graphical login with greetd. The installed system +/// always authenticates; only the live ISO uses automatic login. +pub fn configure_login(exec: &Exec, config: &InstallConfig) -> Result<()> { + if !config.desktop.profile.is_desktop() { + return Ok(()); + } + let target = exec.target(); + let cmd = sysgen::default_session_command(config.desktop.profile); + target.write("etc/greetd/config.toml", sysgen::greetd_config(cmd))?; + ensure_greeter_user(exec); + let root = Path::new(&exec.root); + for service in sysgen::desktop_login_services() { + if let Err(e) = portage::chroot(exec, root, "systemctl", &["enable", service]) { + exec.logger.warn(format!("could not enable {service}: {e}")); + } + } + exec.logger + .info(format!("configured greetd login (default session {cmd})")); + Ok(()) +} + +fn ensure_greeter_user(exec: &Exec) { + let root = Path::new(&exec.root); + // The greetd greeter runs as `greeter`. `useradd` fails when the account + // already exists (e.g. created by the package), which is not an error. + match portage::chroot( + exec, + root, + "useradd", + &[ + "--system", + "--no-create-home", + "--home-dir", + "/var/lib/greetd", + "--shell", + "/sbin/nologin", + "--comment", + "Phoebus greeter", + "greeter", + ], + ) { + Ok(()) => exec.logger.info("created the greeter user"), + Err(e) => exec + .logger + .info(format!("greeter user already present or not created: {e}")), + } +} + fn write_script(target: &phoebus_core::TargetRoot, rel: &str, contents: &str) -> Result<()> { use std::os::unix::fs::PermissionsExt; let path = target.resolve(rel)?; @@ -267,9 +327,12 @@ mod tests { fn no_session_script_for_none_profile() { let runner = RecordingRunner::new(); let exec = make_exec(runner); - let cfg = InstallConfig::default(); + let mut cfg = InstallConfig::default(); + cfg.desktop.profile = DesktopProfile::None; write_session_script(&exec, &cfg).unwrap(); assert!(!exec.root.join("usr/local/bin/phoebus-session").exists()); + // An explicit `none` also writes no assistant launcher. + assert!(!exec.root.join("usr/local/bin/phoebus-assistant").exists()); } #[test] @@ -305,4 +368,43 @@ mod tests { "dwl fallback session must be present" ); } + + #[test] + fn mango_profile_configures_greetd_login_and_install_launcher() { + let runner = RecordingRunner::new(); + let exec = make_exec(runner.clone()); + let mut cfg = InstallConfig::default(); + cfg.desktop.profile = DesktopProfile::Mango; + write_session_script(&exec, &cfg).unwrap(); + configure_login(&exec, &cfg).unwrap(); + + for rel in [ + "usr/local/bin/phoebus-install", + "usr/share/applications/phoebus-install.desktop", + "etc/greetd/config.toml", + ] { + assert!(exec.root.join(rel).is_file(), "{rel} was not installed"); + } + let login = std::fs::read_to_string(exec.root.join("etc/greetd/config.toml")).unwrap(); + assert!(login.contains("phoebus-session-mango")); + assert!(login.contains("tuigreet")); + assert!( + !login.contains("[initial_session]"), + "installed login must not autologin" + ); + // greetd is enabled and the greeter account is created. + let commands: Vec = runner.recorded().iter().map(|s| s.args.join(" ")).collect(); + assert!(commands.iter().any(|a| a.contains("enable greetd"))); + assert!(commands.iter().any(|a| a.contains("useradd"))); + } + + #[test] + fn explicit_none_writes_no_login_configuration() { + let runner = RecordingRunner::new(); + let exec = make_exec(runner); + let mut cfg = InstallConfig::default(); + cfg.desktop.profile = DesktopProfile::None; + configure_login(&exec, &cfg).unwrap(); + assert!(!exec.root.join("etc/greetd/config.toml").exists()); + } } diff --git a/installer-rs/crates/phoebus-installer/src/main.rs b/installer-rs/crates/phoebus-installer/src/main.rs index 8a2fbf3..d1a3809 100644 --- a/installer-rs/crates/phoebus-installer/src/main.rs +++ b/installer-rs/crates/phoebus-installer/src/main.rs @@ -110,6 +110,11 @@ struct Cli { /// `--legacy` or `PHOEBUS_NO_AI=1`. #[arg(long, alias = "legacy")] no_ai: bool, + + /// Print a named desktop asset (session scripts, config, entries) and exit. + /// Used by the live ISO build so it reuses the installer's exact assets. + #[arg(long, value_name = "NAME", hide = true)] + emit_asset: Option, } struct TerminalConfirm; @@ -260,6 +265,19 @@ fn main() -> ExitCode { fn run() -> std::result::Result> { let cli = Cli::parse(); + if let Some(name) = &cli.emit_asset { + return match phoebus_core::system::desktop_asset(name) { + Some(text) => { + print!("{text}"); + Ok(ExitCode::SUCCESS) + } + None => { + eprintln!("unknown desktop asset: {name}"); + Ok(ExitCode::FAILURE) + } + }; + } + let mut config = if let Some(path) = &cli.config { InstallConfig::load_from_path(path)? } else { diff --git a/installer-rs/crates/phoebus-installer/src/orchestrate.rs b/installer-rs/crates/phoebus-installer/src/orchestrate.rs index 80a63b8..1e36a5d 100644 --- a/installer-rs/crates/phoebus-installer/src/orchestrate.rs +++ b/installer-rs/crates/phoebus-installer/src/orchestrate.rs @@ -455,6 +455,7 @@ impl Installer { let result: Result<()> = (|| { desktop::install(&self.exec, &self.config, &self.engine, &self.policy_ctx)?; desktop::write_session_script(&self.exec, &self.config)?; + desktop::configure_login(&self.exec, &self.config)?; desktop::configure_flatpak(&self.exec, &self.config)?; Ok(()) })(); diff --git a/installer-rs/crates/phoebus-installer/tests/golden/plan.txt b/installer-rs/crates/phoebus-installer/tests/golden/plan.txt index bf77d7b..cccbea4 100644 --- a/installer-rs/crates/phoebus-installer/tests/golden/plan.txt +++ b/installer-rs/crates/phoebus-installer/tests/golden/plan.txt @@ -41,6 +41,6 @@ Software: Binary pkgs : yes Accept license : @FREE @BINARY-REDISTRIBUTABLE Desktop : dwl - Flatpak : no + Flatpak : yes Audio : pipewire AI assistant : no diff --git a/installer-rs/crates/phoebus-installer/tests/live_iso.rs b/installer-rs/crates/phoebus-installer/tests/live_iso.rs new file mode 100644 index 0000000..5cefe3b --- /dev/null +++ b/installer-rs/crates/phoebus-installer/tests/live_iso.rs @@ -0,0 +1,149 @@ +//! 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("."); +} diff --git a/installer/live/README.md b/installer/live/README.md index e21fbfd..7765dfd 100644 --- a/installer/live/README.md +++ b/installer/live/README.md @@ -1,68 +1,76 @@ -# Phoebus installer appliance (Debian-Live base) +# Phoebus installer + live desktop ISO -Builds the bootable Phoebus installer ISO. The **appliance is Debian**, the -**installed system is Gentoo**: the live medium only partitions, encrypts and -formats the target, downloads a verified Gentoo stage3, and drives Portage -inside a `chroot`. Nothing from the appliance is installed; it disappears at -reboot. +Builds the bootable Phoebus medium. **The live medium is Debian; the installed +system is Gentoo.** The live image boots directly into **Mango + +DankMaterialShell**; the installer it launches partitions, encrypts and formats +the target, downloads a verified Gentoo stage3 and drives Portage inside a +`chroot`. Nothing from Debian is installed into the Gentoo target. -Design decisions: `docs/PLAN-DEBIAN-LIVE.md` and `docs/adr/0005-debian-live-appliance.md`. +Design: `docs/PLAN-DEBIAN-LIVE.md`, ADR 0005 (appliance), ADR 0009 (desktop). -## No-root remaster +## How it is built (rootless) -The script does **not** repack the live squashfs (that would destroy ownership -and setuid bits without root). Instead it leaves the Debian-Live filesystem -untouched and overlays a `/phoebus` directory onto the ISO: +The build runs entirely unprivileged and never touches a host disk: -``` -/phoebus/ - bin/phoebus-installer static Rust installer - bin/sys static typed system broker - bin/phoebus launcher: stages to /tmp, sets PATH/LD_LIBRARY_PATH - tools/ Debian packages the live image lacks - (cryptsetup, btrfs-progs, gdisk, dosfstools, - parted, util-linux-extra) - opencode.manifest - README -``` +1. Fetch and **SHA-256 verify** the pinned desktop sources + (`releases.sha256`): the Mango source release and the DankMaterialShell + release tarball. +2. `mmdebstrap --mode=unshare --format=tar testing` builds a Debian **testing** + rootfs from the signed Debian archive. Testing is required because it + provides wlroots 0.20, scenefx 0.5 and quickshell, which Mango and DMS need. + The Debian archive keyring is fetched from Debian and handed to mmdebstrap. +3. A customize hook (`livefs-hook.sh`) runs inside the rootfs: it creates the + unprivileged `phoebus` user, installs the shared session assets emitted by + the static installer (`phoebus-installer --emit-asset ...`), **builds Mango + from source**, installs the pinned DMS release, and enables `greetd`, + networking and the serial console. +4. The rootfs is extracted as the current user and packed with `mksquashfs + -all-root`; a tmpfiles rule restores the live user's home ownership at boot. +5. The base Debian-Live ISO (`base.sha256`) is used only for its boot + equipment: the live squashfs, kernel, initramfs and a serial-patched GRUB + configuration are replaced, and `xorriso -boot_image any keep` preserves the + UEFI/BIOS boot path. -The launcher copies `/phoebus` to `/tmp/phoebus-payload` and prepends the -bundled `usr/sbin`/`usr/bin` to `PATH`, so the installer finds `cryptsetup`, -`sgdisk`, `partprobe`, `mkfs.fat` and `mkfs.btrfs`. Only the libraries the live -image lacks are bundled (never libc), so the live system's own tools are not -shadowed. +No `curl | sh`, no live/git packages, and signature verification is never +disabled. Debian packages are used only on the live medium. ## Build -Prerequisites: `xorriso`, `mksquashfs`, `curl`, `dpkg-deb`, and the static -installer built first: +Prerequisites: `mmdebstrap`, `xorriso`, `squashfs-tools`, `curl`, `dpkg-deb`, +`unshare`, and the static installer built first: ```sh cd installer-rs RUSTFLAGS="-C target-feature=+crt-static" \ cargo build --release -p phoebus-installer --target x86_64-unknown-linux-gnu -``` - -Then: - -```sh +cd .. installer/live/build.sh ``` -Output: `installer/live/phoebus-installer-amd64.iso` (+ `.sha256`). The base -Debian-Live ISO is downloaded to the repo root if absent and verified against -`base.sha256`. These artifacts are gitignored. +The default work directory is `/var/tmp/phoebus-live/build` (world-traversable, +because the rootless user namespace cannot enter a `0750` home directory); +override with `WORKDIR=`. Output defaults to +`installer/live/phoebus-installer-amd64.iso` (+ `.sha256`); override with `OUT=`. -## Use +A normal build **produces the Mango desktop image**. The build fails clearly if +`mango`, `dms`, quickshell, the live autologin config or the "Install Phoebus" +launcher is missing; it never silently emits a text-only ISO. -Boot the ISO (UEFI or BIOS). It auto-boots a serial-visible live system; log in -as `user` / `live` (passwordless sudo). Then: +## Using the live medium -```sh -/run/live/medium/phoebus/bin/phoebus --help -sudo /run/live/medium/phoebus/bin/phoebus --config FILE --install --yes \ - --luks-passphrase-file /secure/luks.pw --user-password-file /secure/user.pw -``` +- It auto-boots to a serial-visible live system and **logs in automatically** + as `phoebus` (only on the live medium). +- The graphical session starts automatically. The **Install Phoebus** entry in + the launcher opens the installer UI; it never starts a destructive operation + by itself (the plan, disk protection, AI requirement, credential handling and + the `ERASE` confirmation all remain in force). +- A text recovery console is available on the serial line and on another VT + (`Ctrl+Alt+F2`): log in as `phoebus` / `phoebus` (live-only credential), + passwordless `sudo`. +- The `phoebus-dwl` session remains selectable as a fallback. -Secrets are only ever supplied as 0600 files. The live user's `/tmp` is the -staging area; the medium itself is read-only. +## Installed system + +An installed system always authenticates through `greetd` and defaults to the +Mango session, with dwl selectable. Automatic login is **live-only** and is +never copied to the installed system; see ADR 0009. diff --git a/installer/live/build.sh b/installer/live/build.sh index a6b9e6e..099ea5f 100755 --- a/installer/live/build.sh +++ b/installer/live/build.sh @@ -1,47 +1,65 @@ #!/usr/bin/env bash -# Build the Phoebus installer appliance ISO on a Debian-Live base. +# Build the Phoebus installer + live-desktop ISO. # -# The live squashfs is left untouched (repacking it without root would destroy -# ownership and setuid bits). Instead the installer and the tools the live -# image lacks are overlaid as /phoebus, and the boot config is made -# serial-friendly. See README.md and docs/PLAN-DEBIAN-LIVE.md. +# The live medium is a Debian rootfs carrying the Mango + DankMaterialShell +# desktop; the installed target is Gentoo. The desktop stack comes from the +# signed Debian testing archive (wlroots 0.20, scenefx 0.5, quickshell) plus +# pinned, SHA-256-verified upstream releases for Mango (built from source) and +# DankMaterialShell (prebuilt release tarball). No `curl | sh`, no live/git +# packages and no disabled signature checks anywhere. # -# Requirements: xorriso, curl, dpkg-deb, and a static installer build. -# No root. +# The build is rootless: mmdebstrap runs in an unprivileged user namespace and +# the rootfs is materialised as a tar, extracted and packed with mksquashfs. +# Nothing on the host is modified. The installed system is always Gentoo; +# Debian packages never enter the Gentoo target. +# +# Requirements: mmdebstrap, xorriso, squashfs-tools, curl, dpkg-deb, unshare, +# and the static installer built first (see README.md). set -euo pipefail here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" root="$(cd "$here/../.." && pwd)" -work="${WORKDIR:-$here/build}" +# The rootless build maps a subuid for the unprivileged user namespace, which +# cannot traverse a 0750 home directory. The default work directory is therefore +# world-traversable; override with WORKDIR. +work="${WORKDIR:-/var/tmp/phoebus-live/build}" out="${OUT:-$here/phoebus-installer-amd64.iso}" base="${BASE_ISO:-$root/debian-live-standard.iso}" +suite="${SUITE:-testing}" +mirror="${MIRROR:-http://deb.debian.org/debian}" +mango_version="${MANGO_VERSION:-0.17.2}" +dms_version="${DMS_VERSION:-1.6.2}" +target="x86_64-unknown-linux-gnu" +release_src="$root/installer-rs/target/$target/release" base_url="https://cdimage.debian.org/debian-cd/current-live/amd64/iso-hybrid/debian-live-13.7.0-amd64-standard.iso" base_sha="$(awk '{print $1}' "$here/base.sha256")" -target="x86_64-unknown-linux-gnu" -release_dir="$root/installer-rs/target/$target/release" - -tools=() -while IFS= read -r line; do - [[ -z "$line" || "$line" == \#* ]] && continue - tools+=("$line") -done < "$here/tools.list" say() { printf '\n== %s ==\n' "$*"; } +# --------------------------------------------------------------------------- say "preflight" -for c in xorriso curl dpkg-deb; do +for c in mmdebstrap xorriso mksquashfs curl dpkg-deb unshare sha256sum; do command -v "$c" >/dev/null || { echo "missing tool: $c" >&2; exit 1; } done for b in phoebus-installer sys; do - [[ -x "$release_dir/$b" ]] || { - echo "missing $release_dir/$b; build it first:" >&2 + [[ -x "$release_src/$b" ]] || { + echo "missing $release_src/$b; build it first:" >&2 echo " cd installer-rs && RUSTFLAGS=\"-C target-feature=+crt-static\" \\" >&2 echo " cargo build --release -p phoebus-installer --target $target" >&2 exit 1 } done +mkdir -p "$work/src" "$work/assets" "$work/release" +# mmdebstrap's rootless user namespace reads and writes these as a mapped uid. +chmod 0777 "$work" +chmod 0755 "$work/src" "$work/assets" "$work/release" +install -m 0755 "$release_src/phoebus-installer" "$work/release/phoebus-installer" +install -m 0755 "$release_src/sys" "$work/release/sys" +release_dir="$work/release" + +# --------------------------------------------------------------------------- say "base ISO" if [[ ! -f "$base" ]]; then echo "downloading $base_url" @@ -50,62 +68,173 @@ fi echo "$base_sha $base" | sha256sum -c - >/dev/null || { echo "base ISO checksum mismatch" >&2; exit 1; } echo "base OK: $base" -say "fetch Debian tool packages" -apt_dir="$work/apt" -debs="$work/debs" -payload="$work/payload" -rm -rf "$work" -mkdir -p "$apt_dir"/{etc/apt/sources.list.d,var/lib/apt/lists/partial,var/cache/apt/archives/partial,var/lib/dpkg} \ - "$debs" "$payload/bin" "$payload/tools" -: > "$apt_dir/var/lib/dpkg/status" -printf 'deb http://deb.debian.org/debian trixie main\n' > "$apt_dir/etc/apt/sources.list" +# --------------------------------------------------------------------------- +say "fetch and verify pinned desktop releases" +fetch_verified() { + local url="$1" file="$2" + if [[ ! -f "$work/src/$file" ]]; then + echo "fetching $file" + curl -fL --retry 3 -o "$work/src/$file" "$url" + fi + if ! (cd "$work/src" && sha256sum -c "$here/releases.sha256" --ignore-missing) >/dev/null 2>&1; then + echo "checksum mismatch for $file (see $here/releases.sha256)" >&2 + exit 1 + fi +} +fetch_verified \ + "https://github.com/mangowm/mango/archive/refs/tags/${mango_version}.tar.gz" \ + "mango-${mango_version}.tar.gz" +fetch_verified \ + "https://github.com/AvengeMedia/DankMaterialShell/releases/download/v${dms_version}/dms-full-amd64.tar.gz" \ + "dms-full-amd64.tar.gz" +(cd "$work/src" && sha256sum -c "$here/releases.sha256") +echo "releases OK" -keyring_deb="$work/debian-archive-keyring.deb" -curl -fsS -o "$keyring_deb" \ - "https://deb.debian.org/debian/pool/main/d/debian-archive-keyring/debian-archive-keyring_2025.1_all.deb" -dpkg-deb -x "$keyring_deb" "$work/keyring" -key="$work/keyring/usr/share/keyrings/debian-archive-keyring.gpg" -apt-get -o Dir="$apt_dir" -o Dir::Etc::trusted="$key" -o APT::Get::List-Cleanup=0 \ - -o Acquire::Languages=none update >/dev/null -( cd "$debs" && apt-get -o Dir="$apt_dir" -o Dir::Etc::trusted="$key" \ - -o Dir::Cache::archives="$debs" -y --no-install-recommends --download-only \ - install "${tools[@]}" >/dev/null ) -echo "fetched $(ls "$debs"/*.deb | wc -l) packages" - -say "assemble payload" -cp "$here/payload/README" "$payload/README" -install -m 0755 "$here/payload/bin/phoebus" "$payload/bin/phoebus" -install -m 0755 "$here/payload/bin/phoebus-sys" "$payload/bin/phoebus-sys" -install -m 0755 "$release_dir/phoebus-installer" "$payload/bin/phoebus-installer" -install -m 0755 "$release_dir/sys" "$payload/bin/sys" -cp "$root/installer-rs/crates/phoebus-installer/resources/opencode.manifest" "$payload/opencode.manifest" -for d in "$debs"/*.deb; do dpkg-deb -x "$d" "$payload/tools"; done -chmod -R u+rwX "$payload/tools" 2>/dev/null || true - -# Keep only libraries the live image lacks. Bundling libc would shadow the -# live system's own libc (and break its tools) via LD_LIBRARY_PATH. -libdir="$payload/tools/usr/lib/x86_64-linux-gnu" -if [[ -d "$libdir" ]]; then - ( cd "$libdir" && for f in *; do - case "$f" in - libcryptsetup.so.12*|libparted.so.2*|liblzo2.so.2*|libaudit.so.1*|libreiserfscore.so.0*) : ;; - engines-3|ossl-modules) : ;; - *) rm -rf "$f" ;; - esac - done ) -fi -for t in cryptsetup sgdisk partprobe mkfs.fat mkfs.btrfs btrfs; do - find "$payload/tools" -type f -name "$t" | grep -q . || { echo "payload missing $t" >&2; exit 1; } +# --------------------------------------------------------------------------- +say "emit shared desktop assets" +assets=( + session-mango session-dwl assistant install menu lock idle + mango-config mango-session-target install-desktop + wayland-session-mango wayland-session-dwl + waybar-config waybar-style greetd-live +) +for name in "${assets[@]}"; do + "$release_dir/phoebus-installer" --emit-asset "$name" > "$work/assets/$name" || { + echo "failed to emit asset $name" >&2; exit 1; } + [[ -s "$work/assets/$name" ]] || { echo "empty asset $name" >&2; exit 1; } done -echo "payload ready" +echo "emitted ${#assets[@]} assets" +# --------------------------------------------------------------------------- +say "build live desktop rootfs (mmdebstrap, rootless)" +# Debian archive keyrings (the host may not ship them). apt's modern +# `trusted.gpg.d` only reads `.gpg`/`.asc`, so the Debian `.pgp` files are +# copied with a `.gpg` suffix into a directory handed to mmdebstrap. +if [[ ! -d "$work/apt-keys" ]]; then + keydeb="$work/debian-archive-keyring.deb" + curl -fsS -o "$keydeb" \ + "https://deb.debian.org/debian/pool/main/d/debian-archive-keyring/debian-archive-keyring_2025.1_all.deb" + dpkg-deb -x "$keydeb" "$work/keyring-extract" + install -d "$work/apt-keys" + for f in "$work/keyring-extract/usr/share/keyrings/"debian-archive-*.pgp; do + base="$(basename "$f" .pgp)" + cp "$f" "$work/apt-keys/$base.gpg" + done +fi + +include_csv="$(grep -vE '^[[:space:]]*(#|$)' "$here/live-packages.list" | paste -sd, -)" +[[ -n "$include_csv" ]] || { echo "live-packages.list is empty" >&2; exit 1; } + +# The hook runs as the mapped uid, which cannot traverse a 0750 home directory, +# so it is staged into the world-traversable work directory. +hook_script="$work/livefs-hook.sh" +install -m 0755 "$here/livefs-hook.sh" "$hook_script" + +rootfs_tar="$work/livefs.tar" +if [[ "${PHOEBUS_REUSE_ROOTFS:-0}" == "1" && -s "$rootfs_tar" ]]; then + echo "reusing existing $rootfs_tar" +else + rm -f "$rootfs_tar" + hook="PHOEBUS_SRC='$work/src' PHOEBUS_RELEASE='$work/release' PHOEBUS_ASSETS='$work/assets' \ +MANGO_VERSION='$mango_version' DMS_VERSION='$dms_version' '$hook_script' \"\$1\"" + + mmdebstrap \ + --mode=unshare \ + --format=tar \ + --variant=standard \ + --components=main \ + --keyring="$work/apt-keys" \ + --include="$include_csv" \ + --customize-hook="$hook" \ + "$suite" "$rootfs_tar" "$mirror" +fi + +[[ -s "$rootfs_tar" ]] || { echo "mmdebstrap did not produce $rootfs_tar" >&2; exit 1; } + +say "unpack and verify the desktop payload" +rootfs="$work/rootfs" +rm -rf "$rootfs" +mkdir -p "$rootfs" +# Device nodes cannot be created without privileges and are supplied by +# devtmpfs at boot, so `/dev` is recreated empty. +tar -xf "$rootfs_tar" -C "$rootfs" --exclude='./dev' +install -d -m 0755 "$rootfs/dev" +# The live hostname must not leak the build host's name from mmdebstrap. +echo "${LIVE_HOSTNAME:-phoebus-live}" > "$rootfs/etc/hostname" +printf '127.0.1.1\t%s\n' "${LIVE_HOSTNAME:-phoebus-live}" >> "$rootfs/etc/hosts" + +# Fail clearly rather than shipping a text ISO labelled as a desktop image. +for bin in usr/bin/mango usr/bin/dms; do + [[ -e "$rootfs/$bin" ]] || { echo "live rootfs is missing $bin" >&2; exit 1; } +done +if [[ ! -e "$rootfs/usr/bin/qs" && ! -e "$rootfs/usr/bin/quickshell" ]]; then + echo "live rootfs is missing quickshell (qs/quickshell)" >&2 + exit 1 +fi +[[ -f "$rootfs/etc/greetd/config.toml" ]] || { echo "live rootfs has no greetd config" >&2; exit 1; } +grep -q "initial_session" "$rootfs/etc/greetd/config.toml" || { + echo "live rootfs greetd config is missing live autologin" >&2; exit 1; } +[[ -f "$rootfs/usr/share/applications/phoebus-install.desktop" ]] || { + echo "live rootfs has no Install Phoebus launcher" >&2; exit 1; } +echo "desktop payload verified" + +# --------------------------------------------------------------------------- +say "pack live filesystem" +# A writable home for the live user. The squashfs is packed all-root, so the +# live user's home ownership is restored at boot (the live root is a writable +# overlay). +install -d -m 0755 "$rootfs/etc/tmpfiles.d" +cat > "$rootfs/etc/tmpfiles.d/phoebus-live.conf" <<'EOF' +d /home/phoebus 0700 phoebus phoebus - +z /home/phoebus 0700 phoebus phoebus - +EOF +# `tar` run as an unprivileged user drops setuid/setgid/sticky bits; restore +# them from the archive so e.g. `sudo` and `pkexec` work in the live image. +# `mksquashfs -all-root` then makes those files setuid/setgid root. +python3 - "$rootfs_tar" "$rootfs" <<'PY' +import os, sys, tarfile + +tar_path, rootfs = sys.argv[1], sys.argv[2] +with tarfile.open(tar_path) as tar: + for member in tar: + special = member.mode & 0o7000 + if not special: + continue + target = os.path.join(rootfs, member.name.lstrip("./")) + if os.path.lexists(target): + current = os.lstat(target).st_mode + os.chmod(target, (current & 0o7777) | special) +PY +# Autoload the VirtIO GPU so the compositor gets a DRM node and a logind seat +# (the module is not always pulled in by the initramfs). +install -d -m 0755 "$rootfs/etc/modules-load.d" +printf 'virtio_gpu\n' > "$rootfs/etc/modules-load.d/phoebus-live-gpu.conf" +squashfs="$work/filesystem.squashfs" +rm -f "$squashfs" +mksquashfs "$rootfs" "$squashfs" \ + -noappend -comp zstd -all-root -no-progress >/dev/null +echo "squashfs: $(du -h "$squashfs" | cut -f1)" + +# Package list for the live medium (informational). +grep -a '^Package: ' "$rootfs/var/lib/dpkg/status" 2>/dev/null \ + | awk '{print $2}' | sort -u > "$work/filesystem.packages" || true + +# Kernel and initramfs generated inside the rootfs. +vmlinuz="$(ls -1 "$rootfs"/boot/vmlinuz-* 2>/dev/null | sort | tail -1 || true)" +initrd="$(ls -1 "$rootfs"/boot/initrd.img-* 2>/dev/null | sort | tail -1 || true)" +[[ -f "$vmlinuz" ]] || { echo "live rootfs has no vmlinuz" >&2; exit 1; } +[[ -f "$initrd" ]] || { echo "live rootfs has no initrd" >&2; exit 1; } +cp "$vmlinuz" "$work/vmlinuz" +cp "$initrd" "$work/initrd.img" + +# --------------------------------------------------------------------------- say "patch boot config for serial console" bootcfg="$work/bootcfg"; mkdir -p "$bootcfg" xorriso -osirrox on -indev "$base" \ -extract /boot/grub/grub.cfg "$bootcfg/grub.cfg" \ -extract /boot/grub/config.cfg "$bootcfg/config.cfg" >/dev/null 2>&1 chmod u+w "$bootcfg/grub.cfg" "$bootcfg/config.cfg" -sed -i 's#boot=live components quiet splash findiso=#boot=live components console=ttyS0,115200 findiso=#' "$bootcfg/grub.cfg" +sed -i 's#boot=live components quiet splash findiso=#boot=live components console=ttyS0,115200 noautologin findiso=#' "$bootcfg/grub.cfg" python3 - "$bootcfg/config.cfg" <<'PY' import sys p = sys.argv[1] @@ -117,12 +246,33 @@ t = t.replace("terminal_output gfxterm", "terminal_output gfxterm serial") open(p, "w").write(t) PY +# --------------------------------------------------------------------------- say "assemble ISO" rm -f "$out" +# Replace every kernel/initrd path the base ISO ships (both the canonical +# /live/vmlinuz and the versioned name its GRUB config may reference), plus the +# live squashfs and serial-patched GRUB config. `-boot_image any keep` preserves +# the UEFI/BIOS boot equipment. +kmap=() +while IFS= read -r path; do + [ -n "$path" ] || continue + case "$path" in + *vmlinuz*) kmap+=(-map "$work/vmlinuz" "$path") ;; + *initrd*) kmap+=(-map "$work/initrd.img" "$path") ;; + esac +done < <(xorriso -indev "$base" -find /live 2>/dev/null \ + | tr -d "'" | grep -E '^/live/(vmlinuz|initrd)' | sort -u) + xorriso -indev "$base" -outdev "$out" \ - -map "$payload" /phoebus \ + -map "$squashfs" /live/filesystem.squashfs \ + -map "$work/filesystem.packages" /live/filesystem.packages \ + "${kmap[@]}" \ -map "$bootcfg/grub.cfg" /boot/grub/grub.cfg \ -map "$bootcfg/config.cfg" /boot/grub/config.cfg \ -boot_image any keep >/dev/null + sha256sum "$out" | tee "$out.sha256" ls -lh "$out" +echo +echo "Built with Mango ${mango_version} + DankMaterialShell ${dms_version}." +echo "Live login is automatic; an installed system authenticates via greetd." diff --git a/installer/live/live-packages.list b/installer/live/live-packages.list new file mode 100644 index 0000000..583307b --- /dev/null +++ b/installer/live/live-packages.list @@ -0,0 +1,101 @@ +# Debian packages included in the Phoebus live desktop rootfs. +# +# The live medium is Debian; the installed target is Gentoo. Nothing from this +# list is installed into the Gentoo target. Versions come from the signed Debian +# `testing` archive (which provides wlroots 0.20, scenefx 0.5 and quickshell), +# and DMS is a pinned, SHA-256-verified upstream release (see build-livefs.sh). +# +# One package per line. Comments (`#`) and blank lines are ignored. + +# --- live/boot infrastructure ------------------------------------------------- +systemd +systemd-sysv +dbus +initramfs-tools +live-boot +live-config +live-config-systemd +linux-image-amd64 +sudo +ca-certificates +curl + +# --- disk / encryption tools the installer needs ------------------------------ +cryptsetup-bin +gdisk +parted +dosfstools +btrfs-progs +util-linux +e2fsprogs + +# --- login -------------------------------------------------------------------- +greetd +tuigreet + +# --- compositor / shell ------------------------------------------------------- +quickshell +qt6-wayland +qt6-qpa-plugins +qt6-declarative-dev +qml6-module-qtquick +qml6-module-qtquick-controls +qml6-module-qtquick-layouts +kitty +foot +wayland-utils +wlr-randr +wtype +xwayland + +# --- desktop integration ------------------------------------------------------ +grim +slurp +wl-clipboard +pipewire +pipewire-pulse +wireplumber +network-manager +bluez +polkitd +pkexec +xdg-desktop-portal +xdg-desktop-portal-gtk +xdg-desktop-portal-wlr +accountsservice +upower +xdg-user-dirs +pavucontrol +brightnessctl +playerctl +flatpak +fontconfig +fonts-dejavu-core +fonts-noto-core +fonts-noto-color-emoji +fonts-inter + +# --- Mango build dependencies (built from the pinned release) ----------------- +meson +ninja-build +gcc +pkg-config +libwlroots-0.20-dev +libscenefx-0.5-dev +libcjson-dev +libpcre2-dev +libpango1.0-dev +libcairo2-dev +libinput-dev +libxkbcommon-dev +libglib2.0-dev +libwayland-dev +wayland-protocols +libpixman-1-dev +libdrm-dev +libxcb1-dev +libxcb-icccm4-dev +libxcb-randr0-dev + +# --- DankMaterialShell runtime ------------------------------------------------ +jq diff --git a/installer/live/livefs-hook.sh b/installer/live/livefs-hook.sh new file mode 100644 index 0000000..6a90c39 --- /dev/null +++ b/installer/live/livefs-hook.sh @@ -0,0 +1,121 @@ +#!/bin/bash +# mmdebstrap customize hook: turn a Debian testing rootfs into the Phoebus live +# desktop (Mango + DankMaterialShell). Runs as root inside mmdebstrap's userns. +# +# Environment (set by build.sh): +# PHOEBUS_SRC directory with the verified pinned source tarballs +# PHOEBUS_RELEASE directory with the static phoebus-installer and sys +# PHOEBUS_ASSETS directory with assets emitted by `phoebus-installer --emit-asset` +# MANGO_VERSION, DMS_VERSION +set -euo pipefail + +root="$1" +: "${PHOEBUS_SRC:?}" "${PHOEBUS_RELEASE:?}" "${PHOEBUS_ASSETS:?}" +MANGO_VERSION="${MANGO_VERSION:-0.17.2}" +DMS_VERSION="${DMS_VERSION:-1.6.2}" +LIVE_USER=phoebus + +in_root() { + chroot "$root" /usr/bin/env -i \ + PATH=/usr/sbin:/usr/bin:/sbin:/bin HOME=/root TERM=linux LANG=C.UTF-8 \ + "$@" +} + +install_asset() { + local name="$1" dest="$2" mode="${3:-0644}" + local src="$PHOEBUS_ASSETS/$name" + [ -f "$src" ] || { echo "livefs-hook: missing asset $name" >&2; exit 1; } + install -D -m "$mode" "$src" "$root/$dest" +} + +say() { echo "livefs-hook: $*"; } + +say "live user" +if ! in_root id "$LIVE_USER" >/dev/null 2>&1; then + in_root useradd --create-home --shell /bin/bash \ + --groups sudo,video,render,input,audio "$LIVE_USER" +fi +install -d -m 0755 "$root/etc/sudoers.d" +printf '%s ALL=(ALL) NOPASSWD: ALL\n' "$LIVE_USER" > "$root/etc/sudoers.d/90-phoebus-live" +chmod 440 "$root/etc/sudoers.d/90-phoebus-live" +# A well-known live password so the serial/recovery console is usable; the +# graphical session still logs in automatically via greetd. This is live-only +# and is never written to an installed system. +echo "$LIVE_USER:phoebus" | chroot "$root" chpasswd +# greetd validates its default-session user at startup even when an +# initial_session is configured, so the greeter account must exist. +if ! in_root id greeter >/dev/null 2>&1; then + in_root useradd --system --no-create-home --home-dir /var/lib/greetd \ + --shell /sbin/nologin --comment "Phoebus greeter" greeter +fi + +say "installer and system broker" +install -D -m 0755 "$PHOEBUS_RELEASE/phoebus-installer" "$root/usr/local/bin/phoebus-installer" +install -D -m 0755 "$PHOEBUS_RELEASE/sys" "$root/usr/local/bin/sys" + +say "shared desktop assets" +install_asset session-mango /usr/local/bin/phoebus-session-mango 0755 +install_asset session-dwl /usr/local/bin/phoebus-session 0755 +install_asset assistant /usr/local/bin/phoebus-assistant 0755 +install_asset install /usr/local/bin/phoebus-install 0755 +install_asset menu /usr/local/bin/phoebus-menu 0755 +install_asset lock /usr/local/bin/phoebus-lock 0755 +install_asset idle /usr/local/bin/phoebus-idle 0755 +install_asset mango-config /etc/xdg/mango/config.conf +install_asset mango-session-target /usr/lib/systemd/user/mango-session.target +install_asset install-desktop /usr/share/applications/phoebus-install.desktop +install_asset wayland-session-mango /usr/share/wayland-sessions/phoebus-mango.desktop +install_asset wayland-session-dwl /usr/share/wayland-sessions/phoebus-dwl.desktop +install_asset waybar-config /etc/xdg/waybar/config +install_asset waybar-style /etc/xdg/waybar/style.css +# Live-only automatic login (never copied to an installed system). +install_asset greetd-live /etc/greetd/config.toml + +say "build Mango ${MANGO_VERSION}" +tar -xzf "$PHOEBUS_SRC/mango-${MANGO_VERSION}.tar.gz" -C "$root/tmp" +in_root sh -c "cd /tmp/mango-${MANGO_VERSION} && \ + meson setup build --prefix=/usr --buildtype=release -Dxwayland=enabled && \ + ninja -C build && ninja -C build install" +rm -rf "$root/tmp/mango-${MANGO_VERSION}" + +say "install DankMaterialShell ${DMS_VERSION}" +mkdir -p "$root/tmp/dms-full" +tar -xzf "$PHOEBUS_SRC/dms-full-amd64.tar.gz" -C "$root/tmp/dms-full" +dmsdir="$root/tmp/dms-full" +[ -x "$dmsdir/bin/dms" ] || { echo "livefs-hook: dms binary missing" >&2; exit 1; } +install -D -m 0755 "$dmsdir/bin/dms" "$root/usr/bin/dms" +install -d "$root/usr/share/quickshell" +cp -a "$dmsdir/dms" "$root/usr/share/quickshell/dms" +if [ -f "$root/usr/share/quickshell/dms/assets/systemd/dms.service" ]; then + install -D -m 0644 \ + "$root/usr/share/quickshell/dms/assets/systemd/dms.service" \ + "$root/usr/lib/systemd/user/dms.service" + install -d "$root/etc/systemd/user/mango-session.target.wants" + ln -sf /usr/lib/systemd/user/dms.service \ + "$root/etc/systemd/user/mango-session.target.wants/dms.service" +fi +for entry in "$root/usr/share/quickshell/dms/assets/"*.desktop; do + [ -f "$entry" ] || continue + install -D -m 0644 "$entry" \ + "$root/usr/share/applications/$(basename "$entry")" +done +if [ -d "$dmsdir/completions" ]; then + install -d "$root/usr/share/bash-completion/completions" + [ -f "$dmsdir/completions/completion.bash" ] && \ + install -m 0644 "$dmsdir/completions/completion.bash" \ + "$root/usr/share/bash-completion/completions/dms" +fi +rm -rf "$root/tmp/dms-full" + +say "enable services" +# Regenerate the initramfs now that live-boot/live-config and the desktop +# packages are installed, so the live boot hooks are present. +in_root update-initramfs -u -k all >/dev/null 2>&1 || \ + echo "livefs-hook: update-initramfs reported an issue" >&2 +for svc in greetd.service NetworkManager.service bluetooth.service systemd-resolved.service \ + serial-getty@ttyS0.service; do + in_root systemctl enable "$svc" >/dev/null 2>&1 \ + || echo "livefs-hook: could not enable $svc" >&2 +done + +say "desktop rootfs ready" diff --git a/installer/live/releases.sha256 b/installer/live/releases.sha256 new file mode 100644 index 0000000..f179721 --- /dev/null +++ b/installer/live/releases.sha256 @@ -0,0 +1,11 @@ +# Pinned, reviewed live-desktop sources (SHA-256). +# +# `dms-full-amd64.tar.gz` is verified against the release's own `.sha256` +# asset; the hash below matches the upstream `v1.6.2` asset. Mango publishes a +# source tarball per tag but no checksum file, so the digest below is the one +# reviewed for tag 0.17.2. +# +# Format: + +29d93a8c84843966ab20edd7c20710dfc693050388528140864c908a92877662 dms-full-amd64.tar.gz +8390a4d61a8e4c4adbe1ebf10ee98334fe54952f2c2a3669a21539d555a1bad9 mango-0.17.2.tar.gz diff --git a/installer/tests/vm/appliance-test.conf.example b/installer/tests/vm/appliance-test.conf.example index 0ee8227..6750a90 100644 --- a/installer/tests/vm/appliance-test.conf.example +++ b/installer/tests/vm/appliance-test.conf.example @@ -29,9 +29,10 @@ KEEP_KERNELS='3' PACKAGE_POLICY='balanced' FEATURES_BINPKG='yes' -# none = core system only; dwl/full add the Wayland desktop -DESKTOP_PROFILE='none' -FLATPAK='no' +# mango = default desktop. The appliance baseline harness may set `none` for a +# fast, core-only run, but the shipped default and this example are mango. +DESKTOP_PROFILE='mango' +FLATPAK='yes' NIX_ENABLED='no' diff --git a/installer/tests/vm/live-driver.py b/installer/tests/vm/live-driver.py new file mode 100644 index 0000000..568bf75 --- /dev/null +++ b/installer/tests/vm/live-driver.py @@ -0,0 +1,132 @@ +#!/usr/bin/env python3 +"""Headless driver for the Phoebus live desktop ISO. + +Boots the live ISO in a QEMU VM that still has a **graphical device** (so the +compositor gets a real DRM seat) as well as the serial console, logs in on the +serial recovery console, runs checks and captures a framebuffer screenshot via +the QEMU monitor. + + OVMF_CODE=... OVMF_VARS=... DISK=... ISO=... \ + python3 installer/tests/vm/live-driver.py live + +A serial console coexisting with graphical hardware is intentional: the checks +run over the serial line while the desktop renders on the virtual GPU. +""" +import os +import sys + +import pexpect + +QEMU = os.environ.get("QEMU_BIN", "qemu-system-x86_64") +OVMF_CODE = os.environ["OVMF_CODE"] +OVMF_VARS = os.environ["OVMF_VARS"] +ISO = os.environ["ISO"] +DISK = os.environ.get("DISK", "") +SERIAL_LOG = os.environ.get("SERIAL_LOG", "/tmp/phoebus-live-serial.log") +MONITOR = os.environ.get("MONITOR", "/tmp/phoebus-live-monitor.sock") +SHOT = os.environ.get("SHOT", "/tmp/phoebus-live-screen.ppm") +USER = os.environ.get("LIVE_USER", "phoebus") +PW = os.environ.get("LIVE_PASSWORD", "phoebus") +MEM = os.environ.get("VM_MEM", "8192") +SMP = os.environ.get("VM_SMP", "8") +BOOT_TIMEOUT = int(os.environ.get("BOOT_TIMEOUT", "600")) +CHECKS_TIMEOUT = int(os.environ.get("CHECKS_TIMEOUT", "300")) + + +def args(): + a = [ + "-machine", "q35,accel=kvm", + "-cpu", "host", "-smp", SMP, "-m", MEM, + "-drive", f"if=pflash,format=raw,readonly=on,file={OVMF_CODE}", + "-drive", f"if=pflash,format=raw,file={OVMF_VARS}", + ] + if DISK: + a += ["-drive", f"file={DISK},if=virtio,format=qcow2"] + a += [ + # A real GPU device so the compositor has a DRM node and a logind seat. + "-device", "virtio-gpu-pci", + "-netdev", "user,id=n0", "-device", "virtio-net-pci,netdev=n0,romfile=", + "-device", "virtio-rng-pci", + "-drive", f"file={ISO},media=cdrom,readonly=on", + "-boot", "order=d", + "-vga", "none", "-display", "none", + "-serial", "stdio", + "-monitor", f"unix:{MONITOR},server,nowait", + "-no-reboot", + ] + return a + + +def screendump(child): + """Ask the QEMU monitor for a framebuffer screenshot.""" + if not os.path.exists(MONITOR): + return None + import socket + import time + + s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + s.settimeout(15) + try: + s.connect(MONITOR) + time.sleep(0.5) + try: + s.recv(65536) + except socket.timeout: + pass + s.sendall(b"screendump %s\n" % SHOT.encode()) + time.sleep(2) + try: + s.recv(65536) + except socket.timeout: + pass + finally: + s.close() + return SHOT if os.path.exists(SHOT) else None + + +def main(): + log = open(SERIAL_LOG, "w") + child = pexpect.spawn(QEMU, args(), timeout=BOOT_TIMEOUT, encoding="utf-8", + codec_errors="replace", maxread=65536) + child.delaybeforesend = 0.4 + child.logfile = log + try: + # The live serial recovery console (hostname is arbitrary). + idx = child.expect([r"login:", r"[$#] $"], timeout=BOOT_TIMEOUT) + if idx == 0: + child.sendline(USER) + child.expect(r"[Pp]assword:", timeout=60) + child.sendline(PW) + child.expect(r"[$#] $", timeout=120) + + checks = os.environ.get( + "LIVE_CHECKS", + "echo ===CHECKS-$(printf START)===; " + "cat /proc/1/comm; systemctl is-system-running; " + "systemctl --failed --no-pager; " + "loginctl list-sessions --no-legend; " + "pgrep -a mango || echo NO-MANGO; " + "pgrep -a dms || echo NO-DMS; " + "pgrep -a qs || pgrep -a quickshell || echo NO-QUICKSHELL; " + "pgrep -af 'waybar|mako|swayidle|swaylock' || echo NO-DWL-HELPERS; " + "ls -l /dev/dri 2>&1; " + "sudo -n systemctl is-enabled greetd; " + "echo ===CHECKS-$(printf END)===", + ) + child.sendline(checks) + child.expect("===CHECKS-END===", timeout=CHECKS_TIMEOUT) + shot = screendump(child) + print("checks complete", flush=True) + print("screenshot", shot, flush=True) + finally: + child.close(force=True) + log.close() + + +if __name__ == "__main__": + mode = sys.argv[1] if len(sys.argv) > 1 else "" + if mode == "live": + main() + else: + print(__doc__) + sys.exit(2) diff --git a/installer/tests/vm/test.conf.example b/installer/tests/vm/test.conf.example index 30ad764..db764c7 100644 --- a/installer/tests/vm/test.conf.example +++ b/installer/tests/vm/test.conf.example @@ -27,9 +27,10 @@ KEEP_KERNELS='3' PACKAGE_POLICY='balanced' FEATURES_BINPKG='yes' -# none = core system only; dwl/full add the Wayland desktop -DESKTOP_PROFILE='none' -FLATPAK='no' +# mango = default desktop (Mango + DankMaterialShell + dwl fallback); +# none/dwl/minimal/full override it. Omitting the key selects mango. +DESKTOP_PROFILE='mango' +FLATPAK='yes' # Pinned stage3 served from the host HTTP server so the SHA-256 is verified # without a second download. Replace with a real Gentoo URL for other setups.