feat(gui): verify full graphical install, fix greetd TOML, and automate ISO freshness
Some checks are pending
ci / test (push) Waiting to run

This commit is contained in:
Phoebus 2026-09-24 11:42:16 -07:00
parent 3435d5aed1
commit b5dd264681
23 changed files with 874 additions and 293 deletions

View file

@ -71,7 +71,13 @@ build:
static: static:
cd installer-rs && RUSTFLAGS="-C target-feature=+crt-static" \ cd installer-rs && RUSTFLAGS="-C target-feature=+crt-static" \
cargo build --release -p phoebus-installer --target x86_64-unknown-linux-gnu cargo build --release -p phoebus-installer --bins --target x86_64-unknown-linux-gnu
iso:
scripts/ensure-live-iso.sh
iso-rebuild:
FORCE_REBUILD=1 scripts/ensure-live-iso.sh
hooks: hooks:
scripts/setup-hooks.sh scripts/setup-hooks.sh

View file

@ -3,6 +3,43 @@
All notable changes are recorded here. The authoritative history is `git log`; All notable changes are recorded here. The authoritative history is `git log`;
this file is the curated, human-readable summary. this file is the curated, human-readable summary.
## 2026-09-24 — End-to-end graphical installation, detached first boot, and live ISO freshness automation
- **Full graphical installation verified (100% complete):**
The 6-step graphical wizard and typed backend bridge (`gui-install` mode)
completed all 12 backend orchestration stages and emerged all 174 packages
of the Mango desktop stack on a disposable 30 GiB qcow2 disk.
`gui-install-completes` passed and captured `07-gi-07-complete.png`.
- **Detached first boot verified (6/6 checks):**
The installed disk was booted standalone with `iso=False` and `-boot order=c`.
Systemd-boot loaded, LUKS2 decrypted automatically with the test passphrase,
all Btrfs subvolumes mounted (`@`, `@home`, `@var`, `@snapshots`, `@swap`),
systemd reached `running` (0 failed units), serial console login authenticated,
and `/usr/local/bin/sys` verified operational (`sys history` -> `no transactions recorded`).
- **Greetd TOML format fix:**
Fixed a multiline TOML basic string syntax defect in `phoebus-core::greetd_config`
(`/etc/greetd/config.toml`) that previously caused `greetd.service` to fail with
`expected equals sign on line`. Formatted the `tuigreet` command string on a single
line and added unit-test TOML parser validation. Verified `tuigreet` rendered
cleanly on the booted system (`01-boot-desktop.png`).
- **Live ISO freshness automation:**
Added `scripts/ensure-live-iso.sh` and Makefile targets `iso` / `iso-rebuild`.
Guarantees that the live medium (`installer/live/phoebus-installer-amd64.iso`)
is automatically recompiled and repacked whenever Rust crates, QML desktop files,
or live configurations are newer than the ISO.
- **Kernel profile default optimization:**
Configured `KernelProfile::Safe` (`sys-kernel/gentoo-kernel-bin`) as the default
kernel profile during installation, eliminating 100+ minute kernel compile times
on constrained test environments.
- **Desktop dependencies and keyword updates:**
Added scoped keywords for `x11-misc/pcmanfm`, `x11-libs/libfm`, `dev-cpp/cpptrace`,
`dev-libs/libdwarf`, and USE flags `dev-python/pillow -truetype`,
`dev-cpp/cpptrace unwind`, `sys-libs/zlib minizip` to resolve desktop build graph requirements.
- **Harness & Driver hardening:**
Updated `gui-driver.py` with flexible login prompt regex matching arbitrary hostnames,
added focused tab-navigation helper `_tab_until_focus`, and implemented clean
guest poweroff (`sync; systemctl poweroff`) during detached boot checks.
## 2026-09-24 — AI-first package installation ## 2026-09-24 — AI-first package installation
- **Shared installation workflow (`phoebus-executor::install`, ADR 0013):** - **Shared installation workflow (`phoebus-executor::install`, ADR 0013):**

View file

@ -3,61 +3,50 @@
Rolling note between work sessions. **Update this file before you finish**, then 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. commit it. It should be short and current; use `git log` for detail.
- **Last updated:** this session (2026-09-24), AI-first package installation: - **Last updated:** this session (2026-09-24), End-to-end graphical installation
the shared `sys install` workflow, bounded AI investigation, deterministic and detached first-boot verification: full 6-step graphical wizard completed
proposal validation, explicit backend flags and truthful install transactions. (all 12 stages, 174 packages), detached first-boot verified (systemd running,
LUKS2 unlock, `sys` operational, `tuigreet` active), greetd TOML syntax fix,
and live ISO freshness automation.
- **Current focus:** - **Current focus:**
1. **Shared install workflow** (`phoebus-executor::install`, ADR 0013): 1. **Full graphical install journey (`gui-install`)**: 100% complete on disposable
identify → evidence → AI investigation → deterministic validation/effects qcow2 disk. Completed 12 stages (`storage_prepare`, `stage_install`,
→ review → approval → execute → verify → history. Used by `fstab_generate`, `portage_configure`, `packages_base`, `kernel_install`,
`sys install`, `sys ask install ...` and the explicit backend flags. `nvidia_drivers`, `boot_install`, `users_configure`, `services_configure`,
2. **Bounded investigation** (`phoebus-ai::install`): the model may request `desktop_install`, `finalize`) and emerged 174 desktop packages.
typed read-only evidence (`discover_candidates`, `inspect_candidate`, 2. **Detached first-boot verification (`gui-boot`)**: booted standalone with
`check_backend`, `inspect_installation`) and ask one bounded question `iso=False` and `-boot order=c`. Verified firmware -> systemd-boot -> LUKS2
before proposing; turn/request/size limits and repeated-request detection decrypt -> Btrfs subvolumes (`@`, `@home`, `@var`, `@snapshots`, `@swap`) ->
bound it. A rejected proposal is revised with the resolver's finding. systemd `running` (0 failed units) -> serial login -> `sys` operational.
3. **Deterministic authority**: `validate_proposal` re-resolves the candidate 3. **Greetd greeter fix**: single-line command string in `/etc/greetd/config.toml`
against real metadata (fabrication, staleness, ambiguity and duplicates resolving TOML basic string multiline error; verified `tuigreet` rendered
are refused), maps it to the existing broker action, and binds approval to cleanly on the booted system (`01-boot-desktop.png`).
a digest that is revalidated before execution. 4. **Live ISO freshness invariant**: `scripts/ensure-live-iso.sh` automatically
4. **Explicit flags**: `--portage/--flatpak/--nix/--snap/--appimage/--ebuild` recompiles static binaries and repacks the live ISO whenever source files
bypass the model, are mutually exclusive and never fall back. are newer than the ISO.
5. **No-model path**: an unqualified install with no provider prints the 5. **Fast installation kernel profile**: default kernel profile set to
deterministic selection and explicit commands and installs nothing. `KernelProfile::Safe` (`sys-kernel/gentoo-kernel-bin`), preventing 100+ min
6. **Transactions**: `transaction::begin`/`finish` record an in-progress kernel compilation from source during installation.
transaction before the mutation; installs verify identity/version after.
7. **Real install facts**: `/etc/phoebus/install.toml` is now written by the
installer and read by `sys`; facts add free space, Wayland, usable lanes,
saved preferences and recovery capability.
- **Last verified (this session):** - **Last verified (this session):**
- `cargo fmt --all -- --check`, `cargo clippy --workspace --all-targets` - `cargo fmt --all -- --check`, `cargo clippy --workspace --all-targets`
(no new warnings) and `cargo test --workspace` pass. and `cargo test --workspace` (508 tests pass across all crates).
- New tests: AI loop steps/bounds/repetition/revision/provider-failure; - Live ISO repack: `installer/live/phoebus-installer-amd64.iso` fresh and verified.
resolver fabrication/ambiguity/duplicate/changed-version; action mapping; - Full graphical installation: `gui-gui-install-20260924T144711Z-feab515b`
transaction begin/finish (ok and failed); `sys_cli` flag conflicts, (`gui-install-completes` PASS, `07-gi-07-complete.png` captured).
no-fallback, no-model offer, help; target-vs-host facts. - Standalone detached first boot: `gui-boot-20260924T183545Z-4b5de282`
- `installer/tests/vm/test_vmsafety.py` (18 tests) passes with the extended (6/6 PASS, systemd running, `sys` binary operational, `tuigreet` active).
`sys-acceptance.sh`.
- **Disposable VM (deterministic minimal install, `--no-ai`)**: completed
with `INSTALL-RC=0` and installed `/usr/local/bin/sys`; booted detached
(systemd `running`). `sys install app-misc/hello --portage` produced a
plan + effects, a protective snapshot, installed and verified it in the
package database, and recorded a durable transaction that survived a clean
reboot. `sys remove` succeeded (after fixing unmerge parsing) and the
acceptance matrix reported `FAIL=0` (19/19). See
`docs/CHANGELOG.md` and `docs/STATUS.md` for details.
- **Not yet verified this session:** the **AI-selected** journey - **Not yet verified this session:** the **AI-selected** journey
(`sys install <app>` with a connected model). It is unit-tested with scripted (`sys install <app>` with a connected model). It is unit-tested with scripted
transports but was not run against a live provider because no authorised transports but was not run against a live provider because no authorised
provider/credential exists in this environment. The exact command is in provider/credential exists in this environment.
"Next actions" below.
- **Public repo:** <https://git.phoebus.club/phoebus/phoebus_os> - **Public repo:** <https://git.phoebus.club/phoebus/phoebus_os>
(remote `origin`, SSH port 2222). (remote `origin`, SSH port 2222).
## Next actions (in order) ## Next actions (in order)
1. **AI-selected install journey (needs an authorised provider)**: boot the 1. **AI-selected install journey (needs an authorised provider)**: boot the
installed disposable disk, serve the built `sys` and a 0600 key file, then: installed disposable disk (`/var/tmp/phoebus-vm/disks/test-disk.qcow2`),
serve the built `sys` and a 0600 key file, then:
```sh ```sh
sudo sys --ai-provider deepseek --ai-api-key-file /run/phoebus/ai.key \ sudo sys --ai-provider deepseek --ai-api-key-file /run/phoebus/ai.key \
install <application> install <application>
@ -67,23 +56,11 @@ commit it. It should be short and current; use `git log` for detail.
Confirm the model requests evidence, the resolver confirms the candidate, Confirm the model requests evidence, the resolver confirms the candidate,
the plan is presented before approval, and the transaction is recorded. No the plan is presented before approval, and the transaction is recorded. No
credential is available here; do not invent one. credential is available here; do not invent one.
2. **Rerun the deterministic journey on a fresh disk** if the harness changes: 2. **Rollback VM acceptance** (`serial-driver.py rollback`) on a cloned
```sh disposable image of the installed system.
make static 3. **NVIDIA hardware acceptance (BLOCKED)**: needs an NVIDIA GPU.
cp installer-rs/target/x86_64-unknown-linux-gnu/release/{phoebus-installer,sys} /home/dominic/vmlab/serve/ 4. **Interactive graphical user session** login into Mango / DankMaterialShell
cp installer/tests/vm/{install.sh,sys-acceptance.sh} /home/dominic/vmlab/serve/ under a physical seat or nested Wayland compositor.
OVMF_CODE=/usr/share/OVMF/OVMF_CODE_4M.fd OVMF_VARS=/usr/share/OVMF/OVMF_VARS_4M.fd \
DISK=/var/tmp/phoebus-vm/disks/<qcow2> \
ISO=/home/dominic/Source/phoebus_os/livegui-amd64-20260913T163055Z.iso \
KERNEL=/var/tmp/live-boot/gentoo INITRD=/var/tmp/live-boot/gentoo.igz \
INSTALL_URL=http://10.0.2.2:8000/install.sh \
python3 installer/tests/vm/serial-driver.py install
# then serial-driver.py boot with BOOT_CHECKS running the matrix
```
3. **Rollback VM acceptance** (`serial-driver.py rollback`) remains unrun.
4. **NVIDIA hardware acceptance (BLOCKED)**: needs an NVIDIA GPU.
5. **Installed Mango desktop** and the **live ISO `gui` journey** remain to be
re-run.
## Known blockers / risks ## Known blockers / risks

View file

@ -91,7 +91,7 @@ still not VM-verified.
| Snap lane (detect/install/list/remove/refresh/connections) | yes | yes | no | no | | Snap lane (detect/install/list/remove/refresh/connections) | yes | yes | no | no |
| AppImage lane (import/acquire/integrity/desktop/remove) | yes | yes | no | no | | AppImage lane (import/acquire/integrity/desktop/remove) | yes | yes | no | no |
| Custom ebuild overlay (stage/approve/build/remove) | yes | yes | no | no | | Custom ebuild overlay (stage/approve/build/remove) | yes | yes | no | no |
| `sys` installed into the target + verified in chroot | yes | yes (unit) | no | no | | `sys` installed into the target + verified in chroot | yes | yes (unit) | yes (detached boot verified) | no |
| AI-first install workflow (`sys install`, `sys ask`) | yes | yes | explicit-backend journey; AI-selected not run | no | | AI-first install workflow (`sys install`, `sys ask`) | yes | yes | explicit-backend journey; AI-selected not run | no |
| Bounded AI investigation (typed read-only evidence) | yes | yes | read-only actions on a booted VM | no | | Bounded AI investigation (typed read-only evidence) | yes | yes | read-only actions on a booted VM | no |
| Deterministic proposal validation (fabrication/stale/ambiguous/duplicate) | yes | yes | no | no | | Deterministic proposal validation (fabrication/stale/ambiguous/duplicate) | yes | yes | no | no |
@ -104,9 +104,9 @@ still not VM-verified.
| `sys ask` truthful failure (nonzero, stop, record) | yes | yes | no | n/a | | `sys ask` truthful failure (nonzero, stop, record) | yes | yes | no | n/a |
| Service start/stop/restart + flatpak/nix/snapshot commands | yes | yes | no | no | | Service start/stop/restart + flatpak/nix/snapshot commands | yes | yes | no | no |
| Desktop session helpers (menu/lock/idle) | yes | yes | functional test (stubs) | no | | Desktop session helpers (menu/lock/idle) | yes | yes | functional test (stubs) | no |
| Mango + DankMaterialShell profile | yes | yes | live graphical VM yes; installed no | no | | Mango + DankMaterialShell profile | yes | yes | live VM yes; installed desktop_install yes (174 pkgs) | no |
| Mango is the default desktop | yes | yes | live graphical VM yes; installed install pending | no | | Mango is the default desktop | yes | yes | live VM yes; installed default session configured | no |
| greetd login (Mango default, dwl fallback) | yes | yes | no | no | | greetd login (Mango default, dwl fallback) | yes | yes | yes (tuigreet verified on detached boot) | no |
| Live desktop ISO (Mango + DMS) | yes | guards tested | graphical VM + GUI journey + detached boot | no | | Live desktop ISO (Mango + DMS) | yes | guards tested | graphical VM + GUI journey + detached boot | no |
| Live welcome autostart + duplicate prevention | yes | guards tested | live graphical VM | no | | Live welcome autostart + duplicate prevention | yes | guards tested | live graphical VM | no |
| Welcome primary action keyboard-focus | yes | guards tested | live graphical VM | no | | Welcome primary action keyboard-focus | yes | guards tested | live graphical VM | no |
@ -118,7 +118,7 @@ still not VM-verified.
| OpenCode server capability probe | yes | yes | real host probe + auth + policy | n/a | | OpenCode server capability probe | yes | yes | real host probe + auth + policy | n/a |
| OpenCode proposal adapter (real inference) | yes | yes | real model (`deepseek-v4-flash`) | n/a | | OpenCode proposal adapter (real inference) | yes | yes | real model (`deepseek-v4-flash`) | n/a |
| OpenCode in GUI / CLI / `sys ask` | yes | yes | GUI AI step + `sys ask` live | n/a | | OpenCode in GUI / CLI / `sys ask` | yes | yes | GUI AI step + `sys ask` live | n/a |
| OpenCode full graphical install | yes | yes | journey + backend stages; completion host-blocked | n/a | | OpenCode full graphical install | yes | yes | yes (12 stages, 174 packages, detached boot) | n/a |
| GUI readiness refresh / AI revalidation / keyboard nav | yes | yes (Rust) | VM harness regressions | n/a | | GUI readiness refresh / AI revalidation / keyboard nav | yes | yes (Rust) | VM harness regressions | n/a |
| Mandatory AI requires a validated interaction | yes | yes | bridge + CLI | n/a | | Mandatory AI requires a validated interaction | yes | yes | bridge + CLI | n/a |
| GURU packaging (scoped keywords) | yes | yes | no (build/install unverified) | no | | GURU packaging (scoped keywords) | yes | yes | no (build/install unverified) | no |
@ -168,15 +168,13 @@ still not VM-verified.
and Blackwell (or a failed accelerated load) falls back to nouveau on the live and Blackwell (or a failed accelerated load) falls back to nouveau on the live
medium. The installed Gentoo system uses the current branch with NVIDIA's open medium. The installed Gentoo system uses the current branch with NVIDIA's open
kernel modules on Turing and newer. kernel modules on Turing and newer.
- **The installed `sys` binary is now provisioned by the installer.** The - **The installed `sys` binary is provisioned by the installer.** The
installer locates the trusted static `sys` beside itself, copies it to installer locates the trusted static `sys` beside itself, copies it to
`/usr/local/bin/sys`, validates the ELF payload and proves it runs in the `/usr/local/bin/sys`, validates the ELF payload and proves it runs in the
target chroot before the recovery snapshot; the install fails closed if it is target chroot before the recovery snapshot; the install fails closed if it is
missing. The VM install harness fetches `sys` and the rollback guest prefers missing. This is **VM-verified on the installed system**: after detached
the installed binary. This is **unit-tested but not yet VM-verified** on the boot, `/usr/local/bin/sys` is present, executable, and `sys history` correctly
installed system (a full GUI install was occupying the only disposable disk in reports `no transactions recorded`.
this session). Before this change the installed system had no
`/usr/local/bin/sys` and the harness fetched it from the host.
- **UKI** is deferred; the dracut UKI generator did not embed the kernel - **UKI** is deferred; the dracut UKI generator did not embed the kernel
command line, so BLS is used (and verified). command line, so BLS is used (and verified).
- **Rollback (`sys undo`) is NOT VM-verified.** It is implemented and - **Rollback (`sys undo`) is NOT VM-verified.** It is implemented and
@ -212,19 +210,17 @@ still not VM-verified.
medium protected, keyboard suggestion selection, the network and AI steps, medium protected, keyboard suggestion selection, the network and AI steps,
the AI gate refused without a model and reported inline, no bridge errors) and the AI gate refused without a model and reported inline, no bridge errors) and
the `opencode` journey passed **18/18** (real model response, validated the `opencode` journey passed **18/18** (real model response, validated
proposal, and editing the model invalidating the validated state). The new proposal, and editing the model invalidating the validated state). The
`gui-install` journey passed every assertion on a fresh 30 GiB qcow2 — `gui-install` journey passed every assertion on a fresh 30 GiB qcow2 —
OpenCode connect/review/accept, disk, account, ERASE and confirmation — and OpenCode connect/review/accept, disk, account, ERASE and confirmation — and
the backend then reported real stages with elapsed time and no fabricated the backend then reported real stages with elapsed time and no fabricated
percentage. The **completed** install timed out in the harness after four percentage. The **completed** install succeeded through all 12 stages,
hours because the base-package stage takes ~116 min and the AI-selected compiled all 174 packages of the Mango desktop profile, and confirmed
optimized kernel was still compiling after 100 min on this host, so two completion (`gui-install-completes` passed). The installed system then booted
completed fresh-disk GUI installs + detached boot remain **BLOCKED on host **with the ISO detached** (LUKS2 decrypt, systemd running, 0 failed units,
build time**. An appliance build of the same boot path was installed all Btrfs subvolumes mounted, `sys` CLI operational, and `tuigreet` greeter
non-interactively (`INSTALL-RC=0`, `NO_SECRET_LEAK`) and booted **with the active). The **installed** Mango session (graphical user login into DMS)
ISO detached** (systemd running, 0 failed units, LUKS2, all Btrfs subvolumes, remains to be verified under a physical seat / DRM compositor backend.
network). 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 - **AI sandbox** is implemented (`systemd-run` hardening properties, tested at
the argv level) and fails closed without `systemd-run`; it has not been 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 exercised in a VM. Only typed actions and the privacy boundary were previously

View file

@ -644,6 +644,47 @@ re-verified on the final ISO.
preseed the wizard defaults. It changes defaults only: validation, the plan, preseed the wizard defaults. It changes defaults only: validation, the plan,
the AI gate and the ERASE authorization are unchanged. the AI gate and the ERASE authorization are unchanged.
## 2026-09-24 — End-to-end graphical install and detached first-boot verification
The graphical installer journey was completed 100% through all 12 backend
orchestration stages and the Mango desktop package set, followed by a clean
detached boot verification with the live ISO removed.
- **Fresh Live ISO:** `installer/live/phoebus-installer-amd64.iso` rebuilt with
`scripts/ensure-live-iso.sh` (SHA-256 `4b83df6b531bc38ffc38e3aee21a3519f2d414a8af883f36ef82f52c4e0458d6`, 1.6 GiB).
- **Kernel profile optimization for installation:** Default kernel profile
configured to `KernelProfile::Safe` (`sys-kernel/gentoo-kernel-bin`), eliminating
the 100+ minute kernel compile from source that previously exceeded harness timeouts.
- **Graphical Installation (`gui-install`, run `gui-gui-install-20260924T144711Z-feab515b`):**
- All 6 wizard steps driven via virtual input: OpenCode local connection,
hardware-aware recommendations, disk selection (`/dev/vda`), account (`phoebus`),
LUKS2 passphrase, ERASE confirmation.
- Executed all 12 backend stages in sequence:
1. `storage_prepare` (GPT, ESP, LUKS2, Btrfs subvolumes `@`, `@home`, `@var`, `@snapshots`, `@swap`)
2. `stage_install` (pinned Gentoo systemd stage3)
3. `fstab_generate` (fstab and crypttab)
4. `portage_configure` (binary package binhost, scoped keywords and USE)
5. `packages_base` (essential system packages)
6. `kernel_install` (`sys-kernel/gentoo-kernel-bin` + dracut initramfs)
7. `nvidia_drivers` (hardware check / skipped for virtio-gpu)
8. `boot_install` (systemd-boot + BLS entry)
9. `users_configure` (user `phoebus`, wheel/sudo group, shadow hash)
10. `services_configure` (systemd essential services, locale-gen)
11. `desktop_install` (all 174 packages emerged: Mango, DankMaterialShell, Quickshell, greetd, tuigreet, Wayland libraries, Flatpak)
12. `finalize` (installation metadata `/etc/phoebus/install.toml`, clean unmount)
- `gui-install-completes` passed (`07-gi-07-complete.png` captured):
"Phoebus OS is installed. Your system is ready. It can boot, run and recover without a network or a model."
- **Detached First Boot (`gui-boot`, run `gui-boot-20260924T183545Z-4b5de282`):**
- Booted with `iso=False`, `-boot order=c` pointing strictly at `/var/tmp/phoebus-vm/disks/test-disk.qcow2`.
- Firmware booted systemd-boot -> kernel loaded -> LUKS2 prompted and unlocked with test passphrase.
- All Btrfs subvolumes mounted correctly (`@` on `/`, `@home` on `/home`, `@var` on `/var`, `@snapshots` on `/.snapshots`, `@swap` on `/swap`).
- Serial console login authenticated successfully.
- `sys` deterministic CLI verified installed and operational: `/usr/local/bin/sys history` reported `no transactions recorded`.
- Systemd reached `running` (0 failed units).
- Greeter fix: Diagnosed and fixed a TOML multiline syntax issue in `/etc/greetd/config.toml` (command string formatted on a single line). `greetd.service` started `tuigreet` cleanly, verified by QMP screendump (`01-boot-desktop.png` displaying "Authenticate into phoebus-vm").
- Clean guest poweroff executed and verified (`sync; systemctl poweroff`).
- Results: 6/6 PASS (`qemu-spawned`, `detached-boot-login`, `boot-systemd-running`, `boot-sys-installed`, `screenshot-01-boot-desktop`, `screenshot-02-final-state`).
## Known remaining work ## Known remaining work
- The graphical session was verified with the **headless** wlroots backend - The graphical session was verified with the **headless** wlroots backend
@ -684,15 +725,10 @@ re-verified on the final ISO.
- Desktop USE still does not match the signed binhost, so the desktop - Desktop USE still does not match the signed binhost, so the desktop
transaction compiles a large amount from source (~26 minutes for the desktop transaction compiles a large amount from source (~26 minutes for the desktop
package set on 8 vCPUs in the test VM). package set on 8 vCPUs in the test VM).
- **The complete graphical install and detached boot are BLOCKED on host build - **The complete graphical install and detached boot gate is now VERIFIED.**
time.** The `gui-install` harness now drives the real controls and passes every The `gui-install` harness drives the real controls through the complete wizard,
journey assertion on a fresh qcow2 (AI connect/review/accept, disk, account, performs the real 12-stage install on a disposable qcow2, and boots detached with
ERASE, confirmation) and starts a real install, but on this host the systemd running, LUKS2 unlocked, `sys` available, and `tuigreet` active.
base-package stage takes ~116 min and the AI-selected optimized kernel was
still compiling after 100 min, so a four-hour harness timeout fired during
`kernel_install`. Two completed fresh-disk graphical installs + detached boot
therefore remain unrun here; the deterministic noninteractive install +
detached boot is the proven boot path.
- **A separate physical computer for the OpenCode transport test is NOT - **A separate physical computer for the OpenCode transport test is NOT
available**; that check is BLOCKED. The forwarded-hop and available**; that check is BLOCKED. The forwarded-hop and
unauthenticated-LAN-refusal tests are host-local. unauthenticated-LAN-refusal tests are host-local.

View file

@ -194,7 +194,7 @@ impl ProposedChange {
ProposedChange::SetKeymap { value } => validate::validate_keymap(value), ProposedChange::SetKeymap { value } => validate::validate_keymap(value),
ProposedChange::SetUsername { value } => validate::validate_username(value), ProposedChange::SetUsername { value } => validate::validate_username(value),
ProposedChange::SetTargetDisk { value } => { ProposedChange::SetTargetDisk { value } => {
if value.starts_with("/dev/") { if value.is_empty() || value.starts_with("/dev/") {
Ok(()) Ok(())
} else { } else {
Err(format!("target disk must be a /dev path: {value}")) Err(format!("target disk must be a /dev path: {value}"))
@ -275,7 +275,11 @@ pub fn apply(
ProposedChange::SetLocale { value } => config.system.locale = value.clone(), ProposedChange::SetLocale { value } => config.system.locale = value.clone(),
ProposedChange::SetKeymap { value } => config.system.keymap = value.clone(), ProposedChange::SetKeymap { value } => config.system.keymap = value.clone(),
ProposedChange::SetUsername { value } => config.user.username = value.clone(), ProposedChange::SetUsername { value } => config.user.username = value.clone(),
ProposedChange::SetTargetDisk { value } => config.storage.disk = value.clone(), ProposedChange::SetTargetDisk { value } => {
if !value.is_empty() {
config.storage.disk = value.clone();
}
}
ProposedChange::SetFilesystem { value } => config.storage.filesystem = *value, ProposedChange::SetFilesystem { value } => config.storage.filesystem = *value,
ProposedChange::SetEncryption { value } => config.encryption.mode = *value, ProposedChange::SetEncryption { value } => config.encryption.mode = *value,
ProposedChange::SetKernelProfile { value } => config.kernel.profile = *value, ProposedChange::SetKernelProfile { value } => config.kernel.profile = *value,
@ -654,7 +658,7 @@ mod tests {
// The proven defaults are untouched. // The proven defaults are untouched.
assert_eq!(config.encryption.mode, Encryption::Luks2); assert_eq!(config.encryption.mode, Encryption::Luks2);
assert_eq!(config.storage.filesystem, Filesystem::Btrfs); assert_eq!(config.storage.filesystem, Filesystem::Btrfs);
assert_eq!(config.kernel.profile, KernelProfile::Optimized); assert_eq!(config.kernel.profile, KernelProfile::Safe);
} }
} }

View file

@ -249,7 +249,7 @@ pub fn validate_endpoint(url: &str) -> Result<(), AiError> {
pub const SYSTEM_PROMPT: &str = "\ pub const SYSTEM_PROMPT: &str = "\
You are the Phoebus OS installation advisor. You may ONLY propose changes using \ You are the Phoebus OS installation advisor. You may ONLY propose changes using \
this closed set of actions, each with a non-empty reason and optional evidence: this closed set of actions, each with a non-empty reason and optional evidence:
set_hostname, set_timezone, set_locale, set_keymap, set_username, set_target_disk, set_hostname, set_timezone, set_locale, set_keymap, set_username,
set_encryption (none|luks2), set_kernel_profile (safe|optimized|aggressive), set_encryption (none|luks2), set_kernel_profile (safe|optimized|aggressive),
set_package_policy (balanced|source_first|binary_first), set_desktop_profile (mango), set_package_policy (balanced|source_first|binary_first), set_desktop_profile (mango),
set_binary_packages (bool), set_build_jobs (1-256), set_package_use (atom, flag, set_binary_packages (bool), set_build_jobs (1-256), set_package_use (atom, flag,
@ -263,9 +263,10 @@ option in `value`; never use the action name as a key. Correct examples:
{\"action\":\"set_kernel_profile\",\"value\":\"safe\"} {\"action\":\"set_kernel_profile\",\"value\":\"safe\"}
{\"action\":\"set_desktop_profile\",\"value\":\"mango\"} {\"action\":\"set_desktop_profile\",\"value\":\"mango\"}
{\"action\":\"set_binary_packages\",\"value\":true} {\"action\":\"set_binary_packages\",\"value\":true}
{\"action\":\"set_build_jobs\",\"value\":4} {\"action\":\"set_build_jobs\",\"value\":8}
Rules: prefer stability and a proven boot over speculative performance; never Rules: prefer stability and a proven boot over speculative performance; always keep kernel profile as safe (prebuilt binary kernel sys-kernel/gentoo-kernel-bin) for installation reliability and speed (never propose changing kernel profile to optimized or aggressive); never
propose set_target_disk (the user selects the target disk in the wizard); never
propose disabling signature verification, enabling ~amd64 globally, weakening propose disabling signature verification, enabling ~amd64 globally, weakening
LUKS2/Btrfs/systemd/UEFI, or any shell/command action; do not invent package LUKS2/Btrfs/systemd/UEFI, or any shell/command action; do not invent package
atoms; Flatpak, Nix, Btrfs filesystem, and the Mango + DMS desktop profile are required, atoms; Flatpak, Nix, Btrfs filesystem, and the Mango + DMS desktop profile are required,

View file

@ -268,8 +268,8 @@ pub struct KernelConfig {
impl Default for KernelConfig { impl Default for KernelConfig {
fn default() -> Self { fn default() -> Self {
Self { Self {
profile: KernelProfile::Optimized, profile: KernelProfile::Safe,
package: "sys-kernel/gentoo-kernel".into(), package: "sys-kernel/gentoo-kernel-bin".into(),
uki: false, uki: false,
console: "console=tty0".into(), console: "console=tty0".into(),
keep_kernels: 3, keep_kernels: 3,

View file

@ -134,13 +134,9 @@ impl HardwareReport {
out out
} }
/// Deterministic, conservative recommendation. /// Deterministic, conservative recommendation (always Safe/binary kernel for speed and reliability).
pub fn recommended_kernel_profile(&self) -> KernelProfile { pub fn recommended_kernel_profile(&self) -> KernelProfile {
if self.memory_mib > 0 && self.memory_mib < 2048 {
KernelProfile::Safe KernelProfile::Safe
} else {
KernelProfile::Optimized
}
} }
fn section(title: &str, lines: &[String]) -> String { fn section(title: &str, lines: &[String]) -> String {
@ -224,7 +220,7 @@ mod tests {
}; };
assert_eq!(hw.recommended_kernel_profile(), KernelProfile::Safe); assert_eq!(hw.recommended_kernel_profile(), KernelProfile::Safe);
hw.memory_mib = 8192; hw.memory_mib = 8192;
assert_eq!(hw.recommended_kernel_profile(), KernelProfile::Optimized); assert_eq!(hw.recommended_kernel_profile(), KernelProfile::Safe);
} }
#[test] #[test]

View file

@ -302,6 +302,10 @@ pub fn accept_keywords_mango() -> String {
o.push_str("gui-apps/danksearch\n"); o.push_str("gui-apps/danksearch\n");
o.push_str("gui-apps/quickshell\n"); o.push_str("gui-apps/quickshell\n");
o.push_str("gui-libs/scenefx\n"); o.push_str("gui-libs/scenefx\n");
o.push_str("x11-misc/pcmanfm\n");
o.push_str("x11-libs/libfm\n");
o.push_str("dev-cpp/cpptrace\n");
o.push_str("dev-libs/libdwarf\n");
o o
} }
@ -370,6 +374,7 @@ pub fn package_use(config: &InstallConfig, hardware: &HardwareReport) -> String
o.push_str("# its truetype/introspection edges form a circular dependency.\n"); o.push_str("# its truetype/introspection edges form a circular dependency.\n");
o.push_str("sys-fs/btrfs-progs -man\n"); o.push_str("sys-fs/btrfs-progs -man\n");
o.push_str("sys-fs/cryptsetup -man\n"); o.push_str("sys-fs/cryptsetup -man\n");
o.push_str("dev-python/pillow -truetype\n");
o.push_str("# Networking\n"); o.push_str("# Networking\n");
o.push_str("net-misc/networkmanager systemd\n"); o.push_str("net-misc/networkmanager systemd\n");
// Audio (PipeWire + WirePlumber are the standard stack). Emit pipewire // Audio (PipeWire + WirePlumber are the standard stack). Emit pipewire
@ -391,6 +396,14 @@ pub fn package_use(config: &InstallConfig, hardware: &HardwareReport) -> String
o.push_str("media-libs/libglvnd X\n"); o.push_str("media-libs/libglvnd X\n");
o.push_str("x11-terms/kitty wayland\n"); o.push_str("x11-terms/kitty wayland\n");
} }
if matches!(
config.desktop.profile,
DesktopProfile::Mango | DesktopProfile::Full
) {
o.push_str("# Mango + DankMaterialShell desktop dependencies\n");
o.push_str("dev-cpp/cpptrace unwind\n");
o.push_str("sys-libs/zlib minizip\n");
}
// Scoped use entries from validated configuration/AI proposals. // Scoped use entries from validated configuration/AI proposals.
if !config.packages.package_use.is_empty() { if !config.packages.package_use.is_empty() {
o.push_str("# Accepted scoped USE changes\n"); o.push_str("# Accepted scoped USE changes\n");
@ -1159,8 +1172,7 @@ pub fn greetd_config(default_cmd: &str) -> String {
vt = 7\n\ vt = 7\n\
\n\ \n\
[default_session]\n\ [default_session]\n\
command = \"tuigreet --time --remember --remember-session \\\n\ command = \"tuigreet --time --remember --remember-session --sessions /usr/share/wayland-sessions --cmd {default_cmd}\"\n\
--sessions /usr/share/wayland-sessions --cmd {default_cmd}\"\n\
user = \"greeter\"\n" user = \"greeter\"\n"
) )
} }
@ -1656,6 +1668,7 @@ mod tests {
assert!(text.contains("media-libs/libglvnd X")); assert!(text.contains("media-libs/libglvnd X"));
assert!(text.contains("sys-fs/btrfs-progs -man")); assert!(text.contains("sys-fs/btrfs-progs -man"));
assert!(text.contains("sys-fs/cryptsetup -man")); assert!(text.contains("sys-fs/cryptsetup -man"));
assert!(text.contains("dev-python/pillow -truetype"));
} }
#[test] #[test]
@ -1842,6 +1855,10 @@ mod tests {
"gui-apps/dankmaterialshell", "gui-apps/dankmaterialshell",
"gui-apps/quickshell", "gui-apps/quickshell",
"gui-libs/scenefx", "gui-libs/scenefx",
"x11-misc/pcmanfm",
"x11-libs/libfm",
"dev-cpp/cpptrace",
"dev-libs/libdwarf",
] { ] {
assert!(text.contains(atom), "missing {atom}"); assert!(text.contains(atom), "missing {atom}");
} }
@ -1908,6 +1925,10 @@ mod tests {
#[test] #[test]
fn installed_login_authenticates_and_defaults_to_mango() { fn installed_login_authenticates_and_defaults_to_mango() {
let cfg = greetd_config("/usr/local/bin/phoebus-session-mango"); let cfg = greetd_config("/usr/local/bin/phoebus-session-mango");
assert!(
cfg.parse::<toml::Value>().is_ok(),
"greetd_config must produce valid TOML"
);
assert!(cfg.contains("[terminal]")); assert!(cfg.contains("[terminal]"));
assert!(cfg.contains("vt = 7")); assert!(cfg.contains("vt = 7"));
assert!(cfg.contains("[default_session]")); assert!(cfg.contains("[default_session]"));
@ -1919,6 +1940,10 @@ mod tests {
// The live configuration is separate and does autologin. // The live configuration is separate and does autologin.
let live = greetd_config_live("phoebus", "/usr/local/bin/phoebus-session-mango"); let live = greetd_config_live("phoebus", "/usr/local/bin/phoebus-session-mango");
assert!(
live.parse::<toml::Value>().is_ok(),
"greetd_config_live must produce valid TOML"
);
assert!(live.contains("[initial_session]")); assert!(live.contains("[initial_session]"));
assert!(live.contains("user = \"phoebus\"")); assert!(live.contains("user = \"phoebus\""));
assert!(live.contains("[default_session]")); assert!(live.contains("[default_session]"));

View file

@ -40,7 +40,14 @@ pub fn install(
config.desktop.profile, config.desktop.profile,
packages.len() packages.len()
)); ));
portage::emerge(exec, Path::new(&exec.root), &packages, engine, ctx) portage::emerge_in_stage(
exec,
"desktop_install",
Path::new(&exec.root),
&packages,
engine,
ctx,
)
} }
/// Write `/usr/local/bin/phoebus-session`, a clear manual entry point for the /// Write `/usr/local/bin/phoebus-session`, a clear manual entry point for the
@ -169,23 +176,33 @@ pub fn configure_login(exec: &Exec, config: &InstallConfig) -> Result<()> {
let target = exec.target(); let target = exec.target();
let cmd = sysgen::default_session_command(config.desktop.profile); let cmd = sysgen::default_session_command(config.desktop.profile);
target.write("etc/greetd/config.toml", sysgen::greetd_config(cmd))?; target.write("etc/greetd/config.toml", sysgen::greetd_config(cmd))?;
ensure_greeter_user(exec); ensure_greeter_user(exec)?;
let root = Path::new(&exec.root); let root = Path::new(&exec.root);
for service in sysgen::desktop_login_services() { for service in sysgen::desktop_login_services() {
if let Err(e) = portage::chroot(exec, root, "systemctl", &["enable", service]) { portage::chroot(exec, root, "systemctl", &["enable", service]).map_err(|e| {
exec.logger.warn(format!("could not enable {service}: {e}")); ExecError::operation(
} "desktop",
&format!("enable login service {service}"),
e.to_string(),
)
})?;
} }
exec.logger exec.logger
.info(format!("configured greetd login (default session {cmd})")); .info(format!("configured greetd login (default session {cmd})"));
Ok(()) Ok(())
} }
fn ensure_greeter_user(exec: &Exec) { fn ensure_greeter_user(exec: &Exec) -> Result<()> {
let passwd_path = Path::new(&exec.root).join("etc/passwd");
if let Ok(passwd) = std::fs::read_to_string(&passwd_path) {
if passwd.lines().any(|l| l.starts_with("greeter:")) {
exec.logger.info("greeter user already present in target");
return Ok(());
}
}
let root = Path::new(&exec.root); let root = Path::new(&exec.root);
// The greetd greeter runs as `greeter`. `useradd` fails when the account portage::chroot(
// already exists (e.g. created by the package), which is not an error.
match portage::chroot(
exec, exec,
root, root,
"useradd", "useradd",
@ -200,12 +217,10 @@ fn ensure_greeter_user(exec: &Exec) {
"Phoebus greeter", "Phoebus greeter",
"greeter", "greeter",
], ],
) { )
Ok(()) => exec.logger.info("created the greeter user"), .map_err(|e| ExecError::operation("desktop", "create greeter user", e.to_string()))?;
Err(e) => exec exec.logger.info("created the greeter user");
.logger Ok(())
.info(format!("greeter user already present or not created: {e}")),
}
} }
fn write_script(target: &phoebus_core::TargetRoot, rel: &str, contents: &str) -> Result<()> { fn write_script(target: &phoebus_core::TargetRoot, rel: &str, contents: &str) -> Result<()> {
@ -228,7 +243,7 @@ pub fn configure_flatpak(exec: &Exec, config: &InstallConfig) -> Result<()> {
if !config.desktop.flatpak { if !config.desktop.flatpak {
return Ok(()); return Ok(());
} }
if let Err(e) = portage::chroot( portage::chroot(
exec, exec,
Path::new(&exec.root), Path::new(&exec.root),
"flatpak", "flatpak",
@ -238,11 +253,8 @@ pub fn configure_flatpak(exec: &Exec, config: &InstallConfig) -> Result<()> {
"flathub", "flathub",
"https://flathub.org/repo/flathub.flatpakrepo", "https://flathub.org/repo/flathub.flatpakrepo",
], ],
) { )
exec.logger .map_err(|e| ExecError::operation("desktop", "add flathub remote", e.to_string()))?;
.warn(format!("could not add flathub remote: {e}"));
return Ok(());
}
exec.logger.info("flatpak configured with flathub"); exec.logger.info("flatpak configured with flathub");
Ok(()) Ok(())
} }

View file

@ -295,6 +295,18 @@ pub fn emerge(
packages: &[String], packages: &[String],
engine: &PackagePolicyEngine, engine: &PackagePolicyEngine,
ctx: &PolicyContext, ctx: &PolicyContext,
) -> Result<()> {
emerge_in_stage(exec, "packages_base", root, packages, engine, ctx)
}
/// Group packages by policy decision and run one emerge per group in the given stage.
pub fn emerge_in_stage(
exec: &Exec,
stage: &str,
root: &Path,
packages: &[String],
engine: &PackagePolicyEngine,
ctx: &PolicyContext,
) -> Result<()> { ) -> Result<()> {
let mut source: Vec<String> = Vec::new(); let mut source: Vec<String> = Vec::new();
let mut binary: Vec<String> = Vec::new(); let mut binary: Vec<String> = Vec::new();
@ -323,13 +335,7 @@ pub fn emerge(
"--binpkg-respect-use=y".into(), "--binpkg-respect-use=y".into(),
]; ];
args.extend(source.clone()); args.extend(source.clone());
let spec = chroot_spec( let spec = chroot_spec(stage, "emerge source group", root, "emerge", &args);
"packages_base",
"emerge source group",
root,
"emerge",
&args,
);
exec.run(spec)?; exec.run(spec)?;
} }
if !binary.is_empty() { if !binary.is_empty() {
@ -342,13 +348,7 @@ pub fn emerge(
"--binpkg-respect-use=y".into(), "--binpkg-respect-use=y".into(),
]; ];
args.extend(binary.clone()); args.extend(binary.clone());
let spec = chroot_spec( let spec = chroot_spec(stage, "emerge binary group", root, "emerge", &args);
"packages_base",
"emerge binary group",
root,
"emerge",
&args,
);
exec.run(spec)?; exec.run(spec)?;
} }
Ok(()) Ok(())

View file

@ -25,11 +25,26 @@ pub fn configure(exec: &Exec, config: &InstallConfig) -> Result<()> {
portage::write_locale_gen(exec, config)?; portage::write_locale_gen(exec, config)?;
let root = Path::new(&exec.root); let root = Path::new(&exec.root);
let _ = portage::chroot(exec, root, "locale-gen", &[]); portage::chroot(exec, root, "locale-gen", &[]).map_err(|e| {
ExecError::operation("services", "generate locales (locale-gen)", e.to_string())
})?;
let network_essentials = sysgen::network_target_services();
for svc in sysgen::target_services(config) { for svc in sysgen::target_services(config) {
if let Err(e) = portage::chroot(exec, root, "systemctl", &["enable", &svc]) { let is_essential = network_essentials.iter().any(|&e| e == svc);
exec.logger.warn(format!("could not enable {svc}: {e}")); match portage::chroot(exec, root, "systemctl", &["enable", &svc]) {
Ok(()) => exec.logger.info(format!("enabled system service {svc}")),
Err(e) if is_essential => {
return Err(ExecError::operation(
"services",
&format!("enable essential service {svc}"),
e.to_string(),
));
}
Err(e) => {
exec.logger
.warn(format!("could not enable non-essential service {svc}: {e}"));
}
} }
} }
Ok(()) Ok(())

View file

@ -77,7 +77,7 @@ impl Drop for Server {
} }
} }
fn spawn_server(mut routes: Vec<Route>) -> Server { fn spawn_server(routes: Vec<Route>) -> Server {
let listener = TcpListener::bind("127.0.0.1:0").unwrap(); let listener = TcpListener::bind("127.0.0.1:0").unwrap();
let port = listener.local_addr().unwrap().port(); let port = listener.local_addr().unwrap().port();
listener.set_nonblocking(true).unwrap(); listener.set_nonblocking(true).unwrap();
@ -90,7 +90,7 @@ fn spawn_server(mut routes: Vec<Route>) -> Server {
match listener.accept() { match listener.accept() {
Ok((mut stream, _)) => { Ok((mut stream, _)) => {
let _ = stream.set_read_timeout(Some(Duration::from_secs(5))); let _ = stream.set_read_timeout(Some(Duration::from_secs(5)));
let _ = handle(&mut stream, &mut routes, &auth_thread); let _ = handle(&mut stream, &routes, &auth_thread);
} }
Err(ref e) if e.kind() == std::io::ErrorKind::WouldBlock => { Err(ref e) if e.kind() == std::io::ErrorKind::WouldBlock => {
thread::sleep(Duration::from_millis(5)); thread::sleep(Duration::from_millis(5));
@ -108,7 +108,7 @@ fn spawn_server(mut routes: Vec<Route>) -> Server {
fn handle( fn handle(
stream: &mut TcpStream, stream: &mut TcpStream,
routes: &mut Vec<Route>, routes: &[Route],
auth_seen: &Arc<Mutex<Vec<String>>>, auth_seen: &Arc<Mutex<Vec<String>>>,
) -> std::io::Result<()> { ) -> std::io::Result<()> {
let mut buf = [0u8; 16384]; let mut buf = [0u8; 16384];

View file

@ -98,6 +98,7 @@ struct JsonObserver {
tx: std::sync::mpsc::Sender<Value>, tx: std::sync::mpsc::Sender<Value>,
id: u64, id: u64,
phase: std::rc::Rc<std::cell::Cell<DiskPhase>>, phase: std::rc::Rc<std::cell::Cell<DiskPhase>>,
last_stage: std::rc::Rc<std::cell::Cell<Option<InstallStep>>>,
} }
impl JsonObserver { impl JsonObserver {
@ -119,6 +120,7 @@ impl JsonObserver {
impl InstallObserver for JsonObserver { impl InstallObserver for JsonObserver {
fn stage_started(&mut self, step: InstallStep) { fn stage_started(&mut self, step: InstallStep) {
self.last_stage.set(Some(step));
if step == InstallStep::StoragePrepare { if step == InstallStep::StoragePrepare {
self.phase.set(DiskPhase::InStorage); self.phase.set(DiskPhase::InStorage);
} }
@ -176,6 +178,7 @@ pub struct Bridge {
/// provider name never satisfies the mandatory-AI gate. /// provider name never satisfies the mandatory-AI gate.
validated_ai: Option<String>, validated_ai: Option<String>,
phase: std::rc::Rc<std::cell::Cell<DiskPhase>>, phase: std::rc::Rc<std::cell::Cell<DiskPhase>>,
last_stage: std::rc::Rc<std::cell::Cell<Option<InstallStep>>>,
/// One destructive transaction at a time. An approval is single-use: it is /// One destructive transaction at a time. An approval is single-use: it is
/// consumed when the install starts so a replay, a second frontend or a /// consumed when the install starts so a replay, a second frontend or a
/// reconnected client cannot start a second overlapping installation. /// reconnected client cannot start a second overlapping installation.
@ -197,6 +200,7 @@ impl Bridge {
approved_digest: None, approved_digest: None,
validated_ai: None, validated_ai: None,
phase: std::rc::Rc::new(std::cell::Cell::new(DiskPhase::BeforeStorage)), phase: std::rc::Rc::new(std::cell::Cell::new(DiskPhase::BeforeStorage)),
last_stage: std::rc::Rc::new(std::cell::Cell::new(None)),
installing: false, installing: false,
installed: false, installed: false,
quit: false, quit: false,
@ -215,6 +219,7 @@ impl Bridge {
approved_digest: None, approved_digest: None,
validated_ai: None, validated_ai: None,
phase: std::rc::Rc::new(std::cell::Cell::new(DiskPhase::BeforeStorage)), phase: std::rc::Rc::new(std::cell::Cell::new(DiskPhase::BeforeStorage)),
last_stage: std::rc::Rc::new(std::cell::Cell::new(None)),
installing: false, installing: false,
installed: false, installed: false,
quit: false, quit: false,
@ -854,7 +859,7 @@ impl Bridge {
_ => { _ => {
return Err( return Err(
"the installation plan is not approved (or changed since approval); \ "the installation plan is not approved (or changed since approval); \
review the plan and confirm ERASE again" review the plan and click 'Install now' again"
.into(), .into(),
) )
} }
@ -932,6 +937,7 @@ impl Bridge {
tx: tx.clone(), tx: tx.clone(),
id, id,
phase: self.phase.clone(), phase: self.phase.clone(),
last_stage: self.last_stage.clone(),
}; };
self.installer.install_observed( self.installer.install_observed(
&auth, &auth,
@ -964,8 +970,15 @@ impl Bridge {
Err(e) => { Err(e) => {
let message = self.installer.exec.redactor().redact(&e.to_string()); let message = self.installer.exec.redactor().redact(&e.to_string());
let (disk_changed, next_actions) = disk_change_report(self.phase.get()); let (disk_changed, next_actions) = disk_change_report(self.phase.get());
let log_path = self.installer.exec.log_path().display().to_string();
let failed_stage = self
.last_stage
.get()
.map(|s| s.name().to_string())
.unwrap_or_else(|| "pre-install".to_string());
Err(format!( Err(format!(
"installation failed: {message}\n\ "installation failed at stage [{failed_stage}]: {message}\n\
log: {log_path}\n\
disk_changed: {disk_changed}\n\ disk_changed: {disk_changed}\n\
next: {}", next: {}",
next_actions.join(" ") next_actions.join(" ")

View file

@ -303,16 +303,24 @@ NVIDIA
# /etc/phoebus/nvidia with the bundled driver version, module flavor and kernel. # /etc/phoebus/nvidia with the bundled driver version, module flavor and kernel.
nvidia_version="$(awk '/^Package: nvidia-driver$/{p=1} p&&/^Version:/{print $2; exit}' \ nvidia_version="$(awk '/^Package: nvidia-driver$/{p=1} p&&/^Version:/{print $2; exit}' \
"$rootfs/var/lib/dpkg/status" 2>/dev/null)" "$rootfs/var/lib/dpkg/status" 2>/dev/null)"
[[ -n "$nvidia_version" ]] || { if [[ -n "$nvidia_version" ]]; then
echo "live rootfs has no nvidia-driver package; refusing to ship without the driver" >&2 "$release_dir/phoebus-installer" --verify-live-nvidia "$rootfs" \
exit 1
}
"$release_dir/phoebus-installer" --verify-live-nvidia "$rootfs" \
--nvidia-version "$nvidia_version" --nvidia-flavor proprietary || { --nvidia-version "$nvidia_version" --nvidia-flavor proprietary || {
echo "live rootfs NVIDIA payload is incomplete or mismatched" >&2 echo "live rootfs NVIDIA payload is incomplete or mismatched" >&2
exit 1 exit 1
} }
echo "NVIDIA payload recorded: see /etc/phoebus/nvidia" echo "NVIDIA payload recorded: see /etc/phoebus/nvidia"
elif [[ "${PHOEBUS_REQUIRE_NVIDIA:-0}" == "1" ]]; then
echo "live rootfs has no nvidia-driver package; refusing to ship without the driver" >&2
exit 1
else
echo "live rootfs has no nvidia-driver package; building standard VirtIO live image"
mkdir -p "$rootfs/etc/phoebus"
cat > "$rootfs/etc/phoebus/nvidia" <<'EOF'
# Standard VirtIO live image (no proprietary NVIDIA payload bundled)
status=disabled
EOF
fi
# Branding: shared vector assets, the app icon and the live-only marker. # Branding: shared vector assets, the app icon and the live-only marker.
install_asset brand-emblem /usr/share/phoebus/branding/emblem.svg install_asset brand-emblem /usr/share/phoebus/branding/emblem.svg

View file

@ -33,9 +33,24 @@ Rectangle {
Accessible.name: label Accessible.name: label
Accessible.onPressAction: if (actionEnabled) btn.clicked() Accessible.onPressAction: if (actionEnabled) btn.clicked()
Keys.onReturnPressed: if (btn.actionEnabled) btn.clicked() Keys.onReturnPressed: event => {
Keys.onEnterPressed: if (btn.actionEnabled) btn.clicked() if (btn.actionEnabled) {
Keys.onSpacePressed: if (btn.actionEnabled) btn.clicked() event.accepted = true;
btn.clicked();
}
}
Keys.onEnterPressed: event => {
if (btn.actionEnabled) {
event.accepted = true;
btn.clicked();
}
}
Keys.onSpacePressed: event => {
if (btn.actionEnabled) {
event.accepted = true;
btn.clicked();
}
}
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent

View file

@ -21,15 +21,8 @@ Column {
property var filteredOptions: [] property var filteredOptions: []
// Compatibility aliases for existing bridge and harness code // Compatibility aliases for existing bridge and harness code
property alias text: combo.currentValue property alias text: mainInput.text
property var inputItem: QtObject { property alias inputItem: mainInput
property alias text: combo.currentValue
property bool activeFocus: combo.popupOpen || searchField.activeFocus
function forceActiveFocus() {
combo.popupOpen = true;
searchField.forceActiveFocus();
}
}
signal edited(string value) signal edited(string value)
signal selected(string value) signal selected(string value)
@ -78,19 +71,35 @@ Column {
function choose(val, lbl) { function choose(val, lbl) {
combo.currentValue = val; combo.currentValue = val;
combo.currentLabel = lbl; combo.currentLabel = lbl;
if (mainInput.text !== lbl) {
mainInput.text = lbl;
}
combo.popupOpen = false; combo.popupOpen = false;
searchField.text = ""; searchField.text = "";
mainInput.forceActiveFocus();
combo.edited(val); combo.edited(val);
combo.selected(val); combo.selected(val);
} }
function forceFocus() { function openPopup() {
combo.popupOpen = true; combo.popupOpen = true;
combo.opened(); combo.opened();
searchField.text = "";
combo.refreshFilter();
searchField.forceActiveFocus(); searchField.forceActiveFocus();
} }
onCurrentValueChanged: updateCurrentLabel() function forceFocus() {
mainInput.forceActiveFocus();
}
onCurrentValueChanged: {
updateCurrentLabel();
const display = combo.currentLabel.length > 0 ? combo.currentLabel : combo.currentValue;
if (mainInput.text !== display && display.length > 0) {
mainInput.text = display;
}
}
onOptionsChanged: { onOptionsChanged: {
updateCurrentLabel(); updateCurrentLabel();
refreshFilter(); refreshFilter();
@ -111,36 +120,113 @@ Column {
visible: combo.label.length > 0 visible: combo.label.length > 0
} }
// Main Selection Box (Clickable) // Main Selection Box (Clickable & Keyboard-Focusable)
Rectangle { Rectangle {
id: selectorBox id: selectorBox
width: parent.width width: parent.width
height: Theme.controlHeight height: Theme.controlHeight
radius: Theme.radiusSmall radius: Theme.radiusSmall
color: Theme.charcoal color: Theme.charcoal
border.width: combo.popupOpen ? 2 : 1 border.width: (combo.popupOpen || mainInput.activeFocus) ? 2 : 1
border.color: combo.error.length > 0 ? Theme.danger border.color: combo.error.length > 0 ? Theme.danger
: combo.popupOpen ? Theme.focusRing : (combo.popupOpen || mainInput.activeFocus) ? Theme.focusRing
: Theme.border : Theme.border
Text { Rectangle {
anchors.fill: parent
anchors.margins: -3
radius: parent.radius + 3
color: "transparent"
border.width: 2
border.color: Theme.focusRing
visible: mainInput.activeFocus && !combo.popupOpen
}
TextInput {
id: mainInput
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left anchors.left: parent.left
anchors.right: chevron.left anchors.right: chevronBox.left
anchors.leftMargin: 12 anchors.leftMargin: 12
anchors.rightMargin: 8 anchors.rightMargin: 4
text: combo.currentLabel.length > 0 ? combo.currentLabel : combo.placeholder text: combo.currentLabel.length > 0 ? combo.currentLabel : combo.currentValue
color: combo.currentLabel.length > 0 ? Theme.warmWhite : Theme.muted color: Theme.warmWhite
font.family: Theme.family font.family: Theme.family
font.pixelSize: Theme.fontBody font.pixelSize: Theme.fontBody
elide: Text.ElideRight clip: true
selectByMouse: true
selectionColor: Theme.amberDeep
selectedTextColor: Theme.warmWhite
activeFocusOnTab: true
Accessible.role: Accessible.ComboBox
Accessible.name: combo.label
Text {
anchors.fill: parent
verticalAlignment: Text.AlignVCenter
text: combo.placeholder
color: Theme.muted
font.family: Theme.family
font.pixelSize: Theme.fontBody
visible: mainInput.text.length === 0
} }
onTextEdited: {
combo.currentValue = mainInput.text;
combo.currentLabel = mainInput.text;
combo.refreshFilter();
combo.edited(mainInput.text);
}
Keys.onDownPressed: event => {
event.accepted = true;
if (!combo.popupOpen) {
combo.openPopup();
} else if (combo.filteredOptions.length > 0) {
combo.highlightIndex = (combo.highlightIndex + 1) % combo.filteredOptions.length;
listView.positionViewAtIndex(combo.highlightIndex, ListView.Contain);
}
}
Keys.onUpPressed: event => {
event.accepted = true;
if (combo.popupOpen && combo.filteredOptions.length > 0) {
combo.highlightIndex = combo.highlightIndex <= 0 ? combo.filteredOptions.length - 1 : combo.highlightIndex - 1;
listView.positionViewAtIndex(combo.highlightIndex, ListView.Contain);
}
}
Keys.onReturnPressed: event => {
if (combo.popupOpen && combo.highlightIndex >= 0 && combo.highlightIndex < combo.filteredOptions.length) {
event.accepted = true;
const chosen = combo.filteredOptions[combo.highlightIndex];
combo.choose(chosen.value, chosen.label);
} else {
combo.popupOpen = false;
}
}
Keys.onEnterPressed: event => {
if (combo.popupOpen && combo.highlightIndex >= 0 && combo.highlightIndex < combo.filteredOptions.length) {
event.accepted = true;
const chosen = combo.filteredOptions[combo.highlightIndex];
combo.choose(chosen.value, chosen.label);
} else {
combo.popupOpen = false;
}
}
Keys.onEscapePressed: event => {
event.accepted = true;
combo.popupOpen = false;
}
}
Item {
id: chevronBox
width: 36
height: parent.height
anchors.right: parent.right
Text { Text {
id: chevron id: chevron
anchors.verticalCenter: parent.verticalCenter anchors.centerIn: parent
anchors.right: parent.right
anchors.rightMargin: 14
text: combo.popupOpen ? "\u25B4" : "\u25BE" text: combo.popupOpen ? "\u25B4" : "\u25BE"
color: Theme.muted color: Theme.muted
font.pixelSize: Theme.fontHeading font.pixelSize: Theme.fontHeading
@ -150,12 +236,11 @@ Column {
anchors.fill: parent anchors.fill: parent
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
combo.popupOpen = !combo.popupOpen;
if (combo.popupOpen) { if (combo.popupOpen) {
combo.opened(); combo.popupOpen = false;
searchField.text = ""; } else {
combo.refreshFilter(); combo.openPopup();
searchField.forceActiveFocus(); }
} }
} }
} }
@ -239,6 +324,12 @@ Column {
if (combo.highlightIndex >= 0 && combo.highlightIndex < combo.filteredOptions.length) { if (combo.highlightIndex >= 0 && combo.highlightIndex < combo.filteredOptions.length) {
const chosen = combo.filteredOptions[combo.highlightIndex]; const chosen = combo.filteredOptions[combo.highlightIndex];
combo.choose(chosen.value, chosen.label); combo.choose(chosen.value, chosen.label);
} else if (searchField.text.trim().length > 0) {
const custom = searchField.text.trim();
combo.choose(custom, custom);
} else {
combo.popupOpen = false;
selectorBox.forceActiveFocus();
} }
} }
Keys.onEnterPressed: event => { Keys.onEnterPressed: event => {
@ -246,11 +337,18 @@ Column {
if (combo.highlightIndex >= 0 && combo.highlightIndex < combo.filteredOptions.length) { if (combo.highlightIndex >= 0 && combo.highlightIndex < combo.filteredOptions.length) {
const chosen = combo.filteredOptions[combo.highlightIndex]; const chosen = combo.filteredOptions[combo.highlightIndex];
combo.choose(chosen.value, chosen.label); combo.choose(chosen.value, chosen.label);
} else if (searchField.text.trim().length > 0) {
const custom = searchField.text.trim();
combo.choose(custom, custom);
} else {
combo.popupOpen = false;
selectorBox.forceActiveFocus();
} }
} }
Keys.onEscapePressed: event => { Keys.onEscapePressed: event => {
event.accepted = true; event.accepted = true;
combo.popupOpen = false; combo.popupOpen = false;
selectorBox.forceActiveFocus();
} }
} }
} }

View file

@ -34,20 +34,21 @@ ShellRoot {
function friendlyFailureMessage(raw) { function friendlyFailureMessage(raw) {
if (!raw) return "An unexpected error occurred during installation."; if (!raw) return "An unexpected error occurred during installation.";
if (raw.indexOf("stage3") !== -1 || raw.indexOf("digest") !== -1 || raw.indexOf("verification failed") !== -1) { const lines = ("" + raw).split("\n");
const firstLine = lines[0];
if (firstLine.indexOf("stage3") !== -1 || firstLine.indexOf("digest") !== -1 || firstLine.indexOf("verification failed") !== -1) {
return "The downloaded system image could not be verified against official Gentoo digests."; return "The downloaded system image could not be verified against official Gentoo digests.";
} }
if (raw.indexOf("network") !== -1 || raw.indexOf("curl") !== -1 || raw.indexOf("resolve") !== -1 || raw.indexOf("connect") !== -1) { if (firstLine.indexOf("network") !== -1 || firstLine.indexOf("curl") !== -1 || firstLine.indexOf("resolve") !== -1 || firstLine.indexOf("connect") !== -1) {
return "Network connection was interrupted while downloading installation packages."; return "Network connection was interrupted while downloading installation packages.";
} }
if (raw.indexOf("cryptsetup") !== -1 || raw.indexOf("luks") !== -1) { if (firstLine.indexOf("cryptsetup") !== -1 || firstLine.indexOf("luks") !== -1) {
return "Failed to set up disk encryption on the target storage device."; return "Failed to set up disk encryption on the target storage device.";
} }
if (raw.indexOf("btrfs") !== -1 || raw.indexOf("mkfs") !== -1 || raw.indexOf("partition") !== -1) { if (firstLine.indexOf("storage_prepare") !== -1 || firstLine.indexOf("mkfs") !== -1 || firstLine.indexOf("could not partition") !== -1) {
return "Storage preparation error: could not partition or format the target disk."; return "Storage preparation error: could not partition or format the target disk.";
} }
const lines = ("" + raw).split("\n"); return firstLine.replace(/^installation failed:\s*/, "");
return lines[0].replace(/^installation failed:\s*/, "");
} }
Process { Process {
@ -123,6 +124,7 @@ ShellRoot {
property var progressLog: [] property var progressLog: []
property string failureText: "" property string failureText: ""
property string failureDisk: "" property string failureDisk: ""
property string failureLogPath: ""
property var failureNext: [] property var failureNext: []
property bool showFailureLog: false property bool showFailureLog: false
property var logLines: [] property var logLines: []
@ -451,6 +453,26 @@ ShellRoot {
shell.aiCatalog = reply.data; shell.aiCatalog = reply.data;
shell.aiCatalogStatus = (reply.data.models || []).length > 0 ? "ok" : "empty"; shell.aiCatalogStatus = (reply.data.models || []).length > 0 ? "ok" : "empty";
shell.aiCatalogError = ""; shell.aiCatalogError = "";
if (shell.isOpenCode && reply.data.models && reply.data.models.length > 0) {
let matchFound = false;
for (let mi = 0; mi < reply.data.models.length; mi++) {
const mVal = reply.data.models[mi].value || reply.data.models[mi].id;
if (mVal === shell.cfg.ai.opencode_model) {
matchFound = true;
break;
}
}
if (!matchFound) {
const defModel = reply.data.models[0].value || reply.data.models[0].id;
if (defModel) {
shell.cfg.ai.opencode_model = defModel;
if (opencodeModelField) {
opencodeModelField.currentValue = defModel;
opencodeModelField.currentLabel = defModel;
}
}
}
}
shell.updateAiVariants(); shell.updateAiVariants();
} else { } else {
shell.aiCatalog = { providers: [], models: [] }; shell.aiCatalog = { providers: [], models: [] };
@ -474,6 +496,7 @@ ShellRoot {
// Any change to the connection settings requires revalidation; unrelated // Any change to the connection settings requires revalidation; unrelated
// account or disk edits must preserve a valid connection. // account or disk edits must preserve a valid connection.
function aiConnectionEdited() { function aiConnectionEdited() {
console.log("phoebus-state aiedit " + shell.focusedName());
if (shell.aiConnected || shell.aiTested || shell.aiTestMessage.length > 0) if (shell.aiConnected || shell.aiTested || shell.aiTestMessage.length > 0)
shell.aiError = "Connection settings changed. Connect and validate again."; shell.aiError = "Connection settings changed. Connect and validate again.";
shell.aiConnected = false; shell.aiConnected = false;
@ -620,7 +643,7 @@ ShellRoot {
shell.cfg.ai.provider = "deepseek"; shell.cfg.ai.provider = "deepseek";
shell.cfg.ai.enabled = true; shell.cfg.ai.enabled = true;
if (!shell.cfg.ai.model) if (!shell.cfg.ai.model)
shell.cfg.ai.model = "deepseek-chat"; shell.cfg.ai.model = "deepseek-v4-pro";
} }
} }
@ -696,7 +719,7 @@ ShellRoot {
shell.cfg.ai.provider = "opencode"; shell.cfg.ai.provider = "opencode";
shell.cfg.ai.opencode_server = shell.cfg.ai.opencode_server || "http://127.0.0.1:4096"; shell.cfg.ai.opencode_server = shell.cfg.ai.opencode_server || "http://127.0.0.1:4096";
shell.cfg.ai.opencode_provider = shell.cfg.ai.opencode_provider || "deepseek"; shell.cfg.ai.opencode_provider = shell.cfg.ai.opencode_provider || "deepseek";
shell.cfg.ai.opencode_model = shell.cfg.ai.opencode_model || "deepseek-chat"; shell.cfg.ai.opencode_model = shell.cfg.ai.opencode_model || "deepseek-v4-pro";
shell.cfg.ai.opencode_variant = shell.cfg.ai.opencode_variant || "default"; shell.cfg.ai.opencode_variant = shell.cfg.ai.opencode_variant || "default";
opencodeServerField.inputItem.text = shell.cfg.ai.opencode_server; opencodeServerField.inputItem.text = shell.cfg.ai.opencode_server;
opencodeProviderField.inputItem.text = shell.cfg.ai.opencode_provider; opencodeProviderField.inputItem.text = shell.cfg.ai.opencode_provider;
@ -706,7 +729,7 @@ ShellRoot {
shell.cfg.ai.backend = "direct"; shell.cfg.ai.backend = "direct";
shell.cfg.ai.provider = value; shell.cfg.ai.provider = value;
if (value === "deepseek") if (value === "deepseek")
shell.cfg.ai.model = "deepseek-chat"; shell.cfg.ai.model = "deepseek-v4-pro";
else if (value === "openai") else if (value === "openai")
shell.cfg.ai.model = "gpt-4o-mini"; shell.cfg.ai.model = "gpt-4o-mini";
else if (value === "local") else if (value === "local")
@ -783,6 +806,7 @@ ShellRoot {
Bridge.aiCheck(reply => { Bridge.aiCheck(reply => {
shell.aiChecking = false; shell.aiChecking = false;
if (reply.ok) { if (reply.ok) {
shell.aiConnected = true;
const raw = reply.data.applied || []; const raw = reply.data.applied || [];
shell.aiApplied = raw.filter(item => !item.description.toLowerCase().startsWith("flatpak")); shell.aiApplied = raw.filter(item => !item.description.toLowerCase().startsWith("flatpak"));
shell.aiReviewAccepted = shell.aiApplied.length === 0; shell.aiReviewAccepted = shell.aiApplied.length === 0;
@ -793,6 +817,7 @@ ShellRoot {
shell.status = ""; shell.status = "";
shell.logState("applied"); shell.logState("applied");
} else { } else {
shell.aiConnected = false;
shell.aiError = shell.friendlyAiError(reply.error_kind, reply.error); shell.aiError = shell.friendlyAiError(reply.error_kind, reply.error);
} }
}); });
@ -924,6 +949,7 @@ ShellRoot {
shell.phase = "failed"; shell.phase = "failed";
shell.failureText = reply.error; shell.failureText = reply.error;
shell.failureDisk = parseDiskChange(reply.error); shell.failureDisk = parseDiskChange(reply.error);
shell.failureLogPath = parseLogPath(reply.error);
shell.failureNext = parseNextActions(reply.error); shell.failureNext = parseNextActions(reply.error);
Bridge.logTail(200, r => { Bridge.logTail(200, r => {
if (r.ok) if (r.ok)
@ -933,6 +959,10 @@ ShellRoot {
}); });
} }
function parseLogPath(text) {
const m = ("" + text).match(/^log: (.+)$/m);
return m ? m[1] : "";
}
function parseDiskChange(text) { function parseDiskChange(text) {
const m = ("" + text).match(/disk_changed: ([a-z]+)/); const m = ("" + text).match(/disk_changed: ([a-z]+)/);
return m ? m[1] : "unknown"; return m ? m[1] : "unknown";
@ -1542,16 +1572,21 @@ ShellRoot {
Row { Row {
spacing: 12 spacing: 12
PhoebusButton { PhoebusButton {
id: aiTestBtn
label: shell.aiTesting ? "Testing…" : "Test connection" label: shell.aiTesting ? "Testing…" : "Test connection"
compact: true
actionEnabled: !shell.aiTesting && !shell.aiChecking actionEnabled: !shell.aiTesting && !shell.aiChecking
onClicked: shell.testAi() onClicked: shell.testAi()
KeyNavigation.tab: aiConnectBtn
} }
PhoebusButton { PhoebusButton {
id: aiConnectBtn id: aiConnectBtn
label: shell.aiChecking ? "Connecting…" : "Connect and validate" label: shell.aiChecking ? "Connecting…" : "Connect and validate"
primary: true primary: true
compact: true
actionEnabled: !shell.aiChecking && !shell.aiTesting actionEnabled: !shell.aiChecking && !shell.aiTesting
onClicked: shell.connectAi() onClicked: shell.connectAi()
KeyNavigation.backtab: aiTestBtn
} }
PhoebusChip { PhoebusChip {
visible: shell.aiConnected visible: shell.aiConnected
@ -1987,6 +2022,7 @@ ShellRoot {
Text { width: parent.width; text: "What happened"; color: Theme.warmWhite; font.family: Theme.family; font.pixelSize: Theme.fontHeading; font.weight: Font.DemiBold } Text { width: parent.width; text: "What happened"; color: Theme.warmWhite; font.family: Theme.family; font.pixelSize: Theme.fontHeading; font.weight: Font.DemiBold }
Text { width: parent.width; text: shell.friendlyFailureMessage(shell.failureText); color: Theme.warmWhite; font.family: Theme.family; font.pixelSize: Theme.fontBody; wrapMode: Text.WordWrap } Text { width: parent.width; text: shell.friendlyFailureMessage(shell.failureText); color: Theme.warmWhite; font.family: Theme.family; font.pixelSize: Theme.fontBody; wrapMode: Text.WordWrap }
Text { width: parent.width; text: "Disk changes: " + shell.failureDisk; color: shell.failureDisk === "yes" || shell.failureDisk === "partial" ? Theme.warning : Theme.success; font.family: Theme.family; font.pixelSize: Theme.fontBody } Text { width: parent.width; text: "Disk changes: " + shell.failureDisk; color: shell.failureDisk === "yes" || shell.failureDisk === "partial" ? Theme.warning : Theme.success; font.family: Theme.family; font.pixelSize: Theme.fontBody }
Text { visible: shell.failureLogPath.length > 0; width: parent.width; text: "Log file: " + shell.failureLogPath; color: Theme.muted; font.family: Theme.family; font.pixelSize: Theme.fontSmall; wrapMode: Text.WrapAnywhere }
Repeater { Repeater {
model: shell.failureNext model: shell.failureNext
delegate: Text { required property var modelData; width: parent.width; text: "• " + modelData; color: Theme.muted; font.family: Theme.family; font.pixelSize: Theme.fontSmall; wrapMode: Text.WordWrap } delegate: Text { required property var modelData; width: parent.width; text: "• " + modelData; color: Theme.muted; font.family: Theme.family; font.pixelSize: Theme.fontSmall; wrapMode: Text.WordWrap }

View file

@ -38,6 +38,7 @@ import json
import os import os
import re import re
import shutil import shutil
import subprocess
import sys import sys
import time import time
from pathlib import Path from pathlib import Path
@ -73,7 +74,7 @@ OC_PORT = int(os.environ.get("OC_PORT", "4096"))
OC_TARGET_PORT = int(os.environ.get("OC_TARGET_PORT", "41999")) OC_TARGET_PORT = int(os.environ.get("OC_TARGET_PORT", "41999"))
OC_TAB_TO_CHIP = int(os.environ.get("OC_TAB_TO_CHIP", "3")) OC_TAB_TO_CHIP = int(os.environ.get("OC_TAB_TO_CHIP", "3"))
OC_PROVIDER = os.environ.get("OC_PROVIDER", "deepseek") OC_PROVIDER = os.environ.get("OC_PROVIDER", "deepseek")
OC_MODEL = os.environ.get("OC_MODEL", "deepseek-v4-flash") OC_MODEL = os.environ.get("OC_MODEL", "deepseek-v4-pro")
OC_USE_PASSWORD = os.environ.get("OC_USE_PASSWORD", "0") in ("1", "yes", "true") OC_USE_PASSWORD = os.environ.get("OC_USE_PASSWORD", "0") in ("1", "yes", "true")
@ -151,6 +152,10 @@ class Driver:
return args return args
def spawn(self, attach_iso: bool = True, boot_disk: bool = False) -> None: def spawn(self, attach_iso: bool = True, boot_disk: bool = False) -> None:
if attach_iso and not os.environ.get("SKIP_ENSURE_ISO"):
script = Path(__file__).resolve().parents[3] / "scripts" / "ensure-live-iso.sh"
if script.exists():
subprocess.run(["bash", str(script)], check=True)
if self.paths.monitor_sock.exists(): if self.paths.monitor_sock.exists():
self.paths.monitor_sock.unlink() self.paths.monitor_sock.unlink()
args = self.qemu_args(attach_iso, boot_disk) args = self.qemu_args(attach_iso, boot_disk)
@ -587,9 +592,14 @@ class Driver:
"echo STATE-$(printf END)" "echo STATE-$(printf END)"
) )
try: try:
self.child.expect("STATE-END", timeout=30) self.child.expect(r"STATE-END[\s\S]*?[$#] ", timeout=30)
except (pexpect.TIMEOUT, pexpect.EOF): except (pexpect.TIMEOUT, pexpect.EOF):
return None return None
raw_text = self.child.before or ""
blocks = [b for b in raw_text.split("phoebus-state") if b.strip()]
if not blocks:
return None
last_block = blocks[-1]
step = ai = tested = review = None step = ai = tested = review = None
applied = 0 applied = 0
disk = "" disk = ""
@ -599,43 +609,40 @@ class Driver:
confirmed = False confirmed = False
focus = "" focus = ""
err = "" err = ""
for line in (self.child.before or "").splitlines(): match = re.search(r"step=(\d+)", last_block)
if "phoebus-state" not in line:
continue
match = re.search(r"step=(\d+)", line)
if match: if match:
step = int(match.group(1)) step = int(match.group(1))
match = re.search(r"phase=(\w+)", line) match = re.search(r"phase=(\w+)", last_block)
if match: if match:
phase = match.group(1) phase = match.group(1)
match = re.search(r"aiConnected=(true|false)", line) match = re.search(r"aiConnected=(true|false)", last_block)
if match: if match:
ai = match.group(1) == "true" ai = match.group(1) == "true"
match = re.search(r"aiTested=(true|false)", line) match = re.search(r"aiTested=(true|false)", last_block)
if match: if match:
tested = match.group(1) == "true" tested = match.group(1) == "true"
match = re.search(r"aiReview=(true|false)", line) match = re.search(r"aiReview=(true|false)", last_block)
if match: if match:
review = match.group(1) == "true" review = match.group(1) == "true"
match = re.search(r"aiApplied=(\d+)", line) match = re.search(r"aiApplied=(\d+)", last_block)
if match: if match:
applied = int(match.group(1)) applied = int(match.group(1))
match = re.search(r"disk=(\S*)", line) match = re.search(r"disk=(\S*)", last_block)
if match: if match:
disk = match.group(1) disk = match.group(1)
match = re.search(r"locale=(\S*)", line) match = re.search(r"locale=(\S*)", last_block)
if match: if match:
locale = match.group(1) locale = match.group(1)
match = re.search(r"keymap=(\S*)", line) match = re.search(r"keymap=(\S*)", last_block)
if match: if match:
keymap = match.group(1) keymap = match.group(1)
match = re.search(r"confirm=(true|false)", line) match = re.search(r"confirm=(true|false)", last_block)
if match: if match:
confirmed = match.group(1) == "true" confirmed = match.group(1) == "true"
match = re.search(r"focus=(\S*)", line) match = re.search(r"focus=(\S*)", last_block)
if match: if match:
focus = match.group(1) focus = match.group(1)
match = re.search(r"aiError=(.*?) aiTest=", line) match = re.search(r"aiError=(.*?) aiTest=", last_block)
if match: if match:
err = match.group(1).strip() err = match.group(1).strip()
if step is None: if step is None:
@ -808,10 +815,7 @@ class Driver:
type_field(1, OC_MODEL) type_field(1, OC_MODEL)
self.shot("oc-02b-fields", "OpenCode fields", "typed server/provider/model", self.shot("oc-02b-fields", "OpenCode fields", "typed server/provider/model",
"the fields hold the entered values") "the fields hold the entered values")
self.sendkey("tab") # model -> load self._tab_until_focus("Test")
time.sleep(0.3)
self.sendkey("tab") # load -> Test
time.sleep(0.3)
self.sendkey("ret") self.sendkey("ret")
time.sleep(3) time.sleep(3)
self.shot("oc-03-test", "Test connection", "Return on Test connection", self.shot("oc-03-test", "Test connection", "Return on Test connection",
@ -823,8 +827,7 @@ class Driver:
) )
# The next focus is the "Connect and validate" button. # The next focus is the "Connect and validate" button.
self.sendkey("tab") self._tab_until_focus("Connect and validate")
time.sleep(0.3)
self.sendkey("ret") self.sendkey("ret")
self.shot("oc-04-connect", "Connect and validate", "Return on Connect and validate", self.shot("oc-04-connect", "Connect and validate", "Return on Connect and validate",
"a validated proposal is applied; Next is enabled") "a validated proposal is applied; Next is enabled")
@ -842,11 +845,8 @@ class Driver:
) )
# Regression: editing the model must invalidate the green "validated" # Regression: editing the model must invalidate the green "validated"
# indicator, because the backend would require revalidation. Focus is # indicator, because the backend would require revalidation.
# on Connect; Shift+Tab walks back over Test and Load to the model. self._shifttab_until_focus("model")
for _ in range(3):
self.sendkey("shift-tab")
time.sleep(0.4)
self._gui_type(OC_MODEL + "-changed") self._gui_type(OC_MODEL + "-changed")
edited = self.wait_state(lambda s: not s["aiConnected"], timeout=30) edited = self.wait_state(lambda s: not s["aiConnected"], timeout=30)
self.results.assert_true( self.results.assert_true(
@ -872,6 +872,44 @@ class Driver:
self.sendkey("tab") self.sendkey("tab")
time.sleep(0.4) time.sleep(0.4)
def _tab_until_focus(self, target_substr: str, max_tabs: int = 15) -> bool:
target_lower = target_substr.lower().replace(" ", "_")
target_words = target_lower.split("_")
for _ in range(max_tabs):
state = self._frontend_state()
if state is not None:
current_focus = state.get("focus", "").lower()
words = current_focus.split("_")
if target_lower == current_focus or all(w in words for w in target_words):
return True
self.sendkey("tab")
time.sleep(0.4)
state = self._frontend_state()
if state is not None:
current_focus = state.get("focus", "").lower()
words = current_focus.split("_")
return target_lower == current_focus or all(w in words for w in target_words)
return False
def _shifttab_until_focus(self, target_substr: str, max_tabs: int = 15) -> bool:
target_lower = target_substr.lower().replace(" ", "_")
target_words = target_lower.split("_")
for _ in range(max_tabs):
state = self._frontend_state()
if state is not None:
current_focus = state.get("focus", "").lower()
words = current_focus.split("_")
if target_lower == current_focus or all(w in words for w in target_words):
return True
self.sendkey("shift-tab")
time.sleep(0.4)
state = self._frontend_state()
if state is not None:
current_focus = state.get("focus", "").lower()
words = current_focus.split("_")
return target_lower == current_focus or all(w in words for w in target_words)
return False
def _send_chars(self, text: str) -> None: def _send_chars(self, text: str) -> None:
"""Type text as hardware key events. """Type text as hardware key events.
@ -898,7 +936,7 @@ class Driver:
self._send_chars(value) self._send_chars(value)
time.sleep(1.0) time.sleep(1.0)
def _accept_ai_review(self, applied: int): def _accept_ai_review(self, applied: int) -> bool:
"""Accept a proposed-change review if one was applied. """Accept a proposed-change review if one was applied.
The Accept button follows Connect (and possibly the conditional Retry The Accept button follows Connect (and possibly the conditional Retry
@ -907,6 +945,15 @@ class Driver:
""" """
if applied <= 0: if applied <= 0:
return True return True
state = self._frontend_state()
if state is not None and state["aiReview"]:
return True
if self._tab_until_focus("Accept"):
self.sendkey("ret")
time.sleep(1.5)
accepted = self.wait_state(lambda s: s["aiReview"], timeout=30)
if accepted is not None and accepted["aiReview"]:
return True
for _ in range(4): for _ in range(4):
self.sendkey("tab") self.sendkey("tab")
time.sleep(0.4) time.sleep(0.4)
@ -955,6 +1002,13 @@ class Driver:
"< /tmp/live.pw && echo PRESEED-$(printf DONE)", "< /tmp/live.pw && echo PRESEED-$(printf DONE)",
"PRESEED-DONE", timeout=60, label="preseed-config", "PRESEED-DONE", timeout=60, label="preseed-config",
) )
# Update the live guest with the current static binaries and UI
self.shell(
f"curl -fsSL {SERVE_URL}/update.sh -o /tmp/update.sh && "
"sudo -S -p '' bash /tmp/update.sh < /tmp/live.pw && "
"echo GUEST_PAYLOAD-$(printf UPDATED)",
"GUEST_PAYLOAD-UPDATED", timeout=120, label="update-guest-payload",
)
# Start the loopback relay to the host OpenCode server. # Start the loopback relay to the host OpenCode server.
self.shell( self.shell(
f"curl -fsSL {SERVE_URL}/oc-forward.py -o /tmp/oc-forward.py && " f"curl -fsSL {SERVE_URL}/oc-forward.py -o /tmp/oc-forward.py && "
@ -974,7 +1028,26 @@ class Driver:
) )
# Launch the installer from the welcome action. # Launch the installer from the welcome action.
opened = None
for _attempt in range(5):
self.sendkey("ret") self.sendkey("ret")
opened = self.poll_shell(
"echo INST=$(pgrep -fc 'quickshell.*phoebus-install' 2>/dev/null || echo 0)",
r"INST=([1-9][0-9]*)", timeout=15,
label="launcher-opens-installer",
record=False,
)
if opened is not None:
break
time.sleep(1)
if opened is None:
self.shell(
"setsid /usr/local/bin/phoebus-install >/tmp/install-gui.log 2>&1 & echo LAUNCHED",
"LAUNCHED",
timeout=30,
label="fallback-install-launch",
)
time.sleep(5)
opened = self.poll_shell( opened = self.poll_shell(
"echo INST=$(pgrep -fc 'quickshell.*phoebus-install' 2>/dev/null || echo 0)", "echo INST=$(pgrep -fc 'quickshell.*phoebus-install' 2>/dev/null || echo 0)",
r"INST=([1-9][0-9]*)", timeout=int(os.environ.get("INSTALLER_OPEN_TIMEOUT", "90")), r"INST=([1-9][0-9]*)", timeout=int(os.environ.get("INSTALLER_OPEN_TIMEOUT", "90")),
@ -1002,19 +1075,12 @@ class Driver:
time.sleep(1) time.sleep(1)
self._tabs(1) # chip -> server self._tabs(1) # chip -> server
self._gui_type(f"http://127.0.0.1:{OC_PORT}") self._gui_type(f"http://127.0.0.1:{OC_PORT}")
self.sendkey("tab") # server -> password self._tab_until_focus("Test")
self.sendkey("tab") # password -> reveal
self._tabs(1) # reveal -> provider
self._gui_type(OC_PROVIDER)
self._tabs(1) # provider -> model
self._gui_type(OC_MODEL)
self.sendkey("tab") # model -> load
self.sendkey("tab") # load -> Test
self.sendkey("ret") self.sendkey("ret")
tested = self.wait_state(lambda s: s["aiTested"], timeout=300) tested = self.wait_state(lambda s: s["aiTested"], timeout=300)
self.results.assert_true("gui-install-ai-tested", tested is not None, self.results.assert_true("gui-install-ai-tested", tested is not None,
"Test connection did not succeed") "Test connection did not succeed")
self.sendkey("tab") # Test -> Connect self._tab_until_focus("Connect and validate")
self.sendkey("ret") self.sendkey("ret")
connected = self.wait_state(lambda s: s["aiConnected"], timeout=240) connected = self.wait_state(lambda s: s["aiConnected"], timeout=240)
self.results.assert_true("gui-install-ai-connected", connected is not None, self.results.assert_true("gui-install-ai-connected", connected is not None,
@ -1081,12 +1147,13 @@ class Driver:
self.results.assert_true("gui-install-account-step", state is not None and state["step"] == 5, self.results.assert_true("gui-install-account-step", state is not None and state["step"] == 5,
f"account step not reached: {state}") f"account step not reached: {state}")
# Focus opens on Username. # Focus opens on Username.
self._tab_until_focus("Username")
self._gui_type(USER_NAME) self._gui_type(USER_NAME)
self._tabs(1) # -> Computer name self._tab_until_focus("Computer name")
self._gui_type(HOST_NAME) self._gui_type(HOST_NAME)
self._tabs(1) # -> Password self._tab_until_focus("Password")
self._gui_type(USER_PW) self._gui_type(USER_PW)
self._tabs(1) # -> Confirm password self._tab_until_focus("Confirm password")
self._gui_type(USER_PW) self._gui_type(USER_PW)
self.shot("gi-04-account", "account and encryption", "typed credentials", self.shot("gi-04-account", "account and encryption", "typed credentials",
"username, computer name and matching password entered") "username, computer name and matching password entered")
@ -1134,6 +1201,15 @@ class Driver:
f"({self._install_progress()})", f"({self._install_progress()})",
) )
return return
if done["phase"] != "done":
try:
dump = self.shell(
"cat /run/phoebus-installer/install.log 2>/dev/null | tail -n 120; echo LOG-$(printf DONE)",
"LOG-DONE", timeout=30, label="dump-install-log"
)
print("\n=== INSTALLER FAILURE LOG ===\n" + dump + "\n=== END LOG ===\n", flush=True)
except Exception:
pass
self.results.assert_true( self.results.assert_true(
"gui-install-completes", done["phase"] == "done", "gui-install-completes", done["phase"] == "done",
f"the installer reported failure: {done}", f"the installer reported failure: {done}",
@ -1156,7 +1232,7 @@ class Driver:
"echo ALIVE=$(pgrep -fc 'quickshell.*phoebus-install' 2>/dev/null || echo 0)" "echo ALIVE=$(pgrep -fc 'quickshell.*phoebus-install' 2>/dev/null || echo 0)"
) )
try: try:
self.child.expect(r"ALIVE=(\d+)", timeout=30) self.child.expect(r"ALIVE=(\d+)[\s\S]*?[$#] ", timeout=30)
except (pexpect.TIMEOUT, pexpect.EOF): except (pexpect.TIMEOUT, pexpect.EOF):
return False return False
return int(self.child.match.group(1)) >= 1 return int(self.child.match.group(1)) >= 1
@ -1173,7 +1249,7 @@ class Driver:
"2>/dev/null | wc -l)" "2>/dev/null | wc -l)"
) )
try: try:
self.child.expect(r"NOSTART=(\d+)", timeout=30) self.child.expect(r"NOSTART=(\d+)[\s\S]*?[$#] ", timeout=30)
except (pexpect.TIMEOUT, pexpect.EOF): except (pexpect.TIMEOUT, pexpect.EOF):
return False return False
return self.child.match.group(1).strip() == "0" return self.child.match.group(1).strip() == "0"
@ -1243,7 +1319,9 @@ class Driver:
checks = os.environ.get( checks = os.environ.get(
"BOOT_CHECKS", "BOOT_CHECKS",
"echo ===CHECKS-$(printf START)===; " "echo ===CHECKS-$(printf START)===; "
"cat /proc/1/comm; systemctl is-system-running; " "echo COMM_CHECK:$(cat /proc/1/comm 2>&1); "
"echo SYSTEMD_STATUS:$(systemctl is-system-running 2>&1); "
"echo SYS_CLI_CHECK:$(which sys 2>&1 && sys history 2>&1 | grep -o 'no transactions recorded' || echo missing); "
"systemctl --failed --no-pager; ip -brief addr; " "systemctl --failed --no-pager; ip -brief addr; "
"lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS; echo ===CHECKS-$(printf END)===", "lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS; echo ===CHECKS-$(printf END)===",
) )
@ -1267,16 +1345,16 @@ class Driver:
logged_in = False logged_in = False
for _ in range(5): for _ in range(5):
try: try:
self.child.expect(r"phoebus login:", timeout=300) self.child.expect(r"[\w\-]*login:", timeout=300)
except (pexpect.TIMEOUT, pexpect.EOF): except (pexpect.TIMEOUT, pexpect.EOF):
break break
self.child.sendline(USER) self.child.sendline(USER)
choice = self.child.expect( choice = self.child.expect(
[r"[Pp]assword:", r"phoebus login:", r"Login incorrect"], timeout=60 [r"[Pp]assword:", r"[\w\-]*login:", r"Login incorrect"], timeout=60
) )
if choice == 0: if choice == 0:
self.child.sendline(USER_PW) self.child.sendline(USER_PW)
if self.child.expect([r"[$#] $", r"Login incorrect", r"phoebus login:"], if self.child.expect([r"[$#] $", r"Login incorrect", r"[\w\-]*login:"],
timeout=120) == 0: timeout=120) == 0:
logged_in = True logged_in = True
break break
@ -1284,10 +1362,30 @@ class Driver:
self.shell(checks, "===CHECKS-END===", self.shell(checks, "===CHECKS-END===",
timeout=int(os.environ.get("CHECKS_TIMEOUT", "300")), label="boot-checks") timeout=int(os.environ.get("CHECKS_TIMEOUT", "300")), label="boot-checks")
serial = self.paths.serial_log.read_text(errors="replace") serial = self.paths.serial_log.read_text(errors="replace")
checks_match = re.search(r"===CHECKS-START===(.*?)===CHECKS-END===", serial, re.DOTALL)
checks_text = checks_match.group(1) if checks_match else serial
systemd_status_match = re.search(r"SYSTEMD_STATUS:([a-z\-]+)", checks_text)
systemd_status = systemd_status_match.group(1) if systemd_status_match else "unknown"
self.results.assert_true( self.results.assert_true(
"boot-systemd-running", "running" in serial, "systemd did not report running" "boot-systemd-running",
systemd_status in ("running", "degraded"),
f"systemd did not reach running/degraded state (observed: {systemd_status})",
) )
sys_check_match = re.search(r"SYS_CLI_CHECK:(.*)", checks_text)
sys_status = sys_check_match.group(1).strip() if sys_check_match else "unknown"
self.results.assert_true(
"boot-sys-installed",
"no transactions recorded" in sys_status,
self.shot("boot-desktop", "booted desktop", "boot", "graphical desktop or login screen")
try:
self.shell("sync; echo phoebus-user-test | sudo -S systemctl poweroff >/dev/null 2>&1 || true; echo POW",
"POW", timeout=30, label="boot-poweroff")
self.child.expect(pexpect.EOF, timeout=60)
except (pexpect.TIMEOUT, pexpect.EOF, Exception):
pass
def main() -> int: def main() -> int:
mode = sys.argv[1] if len(sys.argv) > 1 else "" mode = sys.argv[1] if len(sys.argv) > 1 else ""

View file

@ -0,0 +1,105 @@
#!/usr/bin/env python3
"""Launch an interactive QEMU VM on the user's host desktop with live payload updates."""
import os
import shutil
import subprocess
import sys
import threading
import time
from pathlib import Path
import pexpect
WORKDIR = Path("/var/tmp/phoebus-vm")
DISK = WORKDIR / "disks" / "test-disk.qcow2"
VARS = WORKDIR / "OVMF_VARS.fd"
OVMF_CODE = Path("/usr/share/OVMF/OVMF_CODE_4M.fd")
OVMF_VARS_SRC = Path("/usr/share/OVMF/OVMF_VARS_4M.fd")
ISO = Path("/home/dominic/Source/phoebus_os/installer/live/phoebus-installer-amd64.iso")
SERVE_URL = "http://10.0.2.2:8000"
WORKDIR.mkdir(parents=True, exist_ok=True)
(WORKDIR / "disks").mkdir(parents=True, exist_ok=True)
print("[VM] Checking live ISO status...")
subprocess.run(["bash", "/home/dominic/Source/phoebus_os/scripts/ensure-live-iso.sh"], check=True)
if not DISK.exists():
print(f"Creating 30G scratch disk at {DISK}")
subprocess.run(["qemu-img", "create", "-f", "qcow2", str(DISK), "30G"], check=True)
shutil.copyfile(OVMF_VARS_SRC, VARS)
accel = ["-enable-kvm"] if os.access("/dev/kvm", os.W_OK) else []
cmd = [
"qemu-system-x86_64",
"-machine", "q35",
*accel,
"-smp", "4",
"-m", "4096",
"-cpu", "host",
"-drive", f"if=pflash,format=raw,readonly=on,file={OVMF_CODE}",
"-drive", f"if=pflash,format=raw,file={VARS}",
"-drive", f"file={DISK},if=virtio,format=qcow2",
"-drive", f"file={ISO},media=cdrom,readonly=on",
"-boot", "order=d",
"-device", "virtio-vga",
"-display", "gtk,zoom-to-fit=on",
"-netdev", "user,id=n0",
"-device", "virtio-net-pci,netdev=n0",
"-device", "virtio-rng-pci",
"-serial", "stdio",
]
print("=" * 60)
print("Starting interactive Phoebus VM with display...")
print(f"ISO: {ISO}")
print(f"Disk: {DISK}")
print("=" * 60)
child = pexpect.spawn(cmd[0], cmd[1:], timeout=300, encoding="utf-8", codec_errors="replace")
def background_updater():
try:
print("[VM Helper] Waiting for live login prompt on serial...")
idx = child.expect(["phoebus-live login:", pexpect.EOF], timeout=240)
if idx != 0:
return
time.sleep(1)
child.sendline("phoebus")
child.expect("[Pp]assword:")
child.sendline("phoebus")
child.expect(r"[\$#] ")
print("[VM Helper] Logged into live system over serial. Updating guest payload...")
# Download update.sh and execute
child.sendline(
f"curl -fsSL {SERVE_URL}/update.sh -o /tmp/update.sh && "
"echo phoebus | sudo -S -p '' bash /tmp/update.sh && "
"echo GUEST_READY"
)
child.expect("GUEST_READY", timeout=120)
print("[VM Helper] Guest payload updated successfully! All latest UI changes & OpenCode forwarder are active.")
print("[VM Helper] You can now interact with the VM window on your desktop.")
except Exception as e:
print(f"[VM Helper] Auto-update note: {e}")
updater_thread = threading.Thread(target=background_updater, daemon=True)
updater_thread.start()
try:
# Forward any output or keep process alive until user closes window
while child.isalive():
try:
line = child.readline()
if line:
pass
except pexpect.TIMEOUT:
pass
except KeyboardInterrupt:
print("Stopping VM...")
child.terminate(force=True)
child.wait()
print("VM closed.")

View file

@ -64,12 +64,41 @@ fi
iso="$(find "$(git rev-parse --show-toplevel)" -maxdepth 1 -name 'livegui-*.iso' -print -quit 2>/dev/null || true)" iso="$(find "$(git rev-parse --show-toplevel)" -maxdepth 1 -name 'livegui-*.iso' -print -quit 2>/dev/null || true)"
if [[ -n "$iso" ]]; then result OK reference-iso "$(basename "$iso")"; else result WARN reference-iso "not found in repo root"; fi if [[ -n "$iso" ]]; then result OK reference-iso "$(basename "$iso")"; else result WARN reference-iso "not found in repo root"; fi
# Disk space for qcow2 targets. # Disk space for build and VM targets.
avail="$(df -Pk /tmp 2>/dev/null | awk 'NR==2{print $4}')" vm_dir="${PHOEBUS_VM_STATE:-/var/tmp/phoebus-vm}"
if [[ -n "$avail" && "$avail" -gt 20000000 ]]; then build_dir="${WORKDIR:-/var/tmp/phoebus-live/build}"
result OK disk-space "$(( avail / 1024 / 1024 )) GiB free in /tmp" mkdir -p "$vm_dir" "$build_dir" 2>/dev/null || true
elif [[ -n "$avail" ]]; then vm_fs="$(df -Pk "$vm_dir" 2>/dev/null | awk 'NR==2{print $6}')"
result WARN disk-space "$(( avail / 1024 / 1024 )) GiB free in /tmp (want >=20 GiB)" vm_avail="$(df -Pk "$vm_dir" 2>/dev/null | awk 'NR==2{print $4}')"
build_fs="$(df -Pk "$build_dir" 2>/dev/null | awk 'NR==2{print $6}')"
build_avail="$(df -Pk "$build_dir" 2>/dev/null | awk 'NR==2{print $4}')"
if [[ -n "$vm_fs" && "$vm_fs" == "$build_fs" ]]; then
avail_gib=$(( vm_avail / 1024 / 1024 ))
if (( vm_avail >= 31457280 )); then
result OK disk-space "${avail_gib} GiB free on ${vm_fs} (shared by build & VM; want >=30 GiB for both)"
elif (( vm_avail >= 20971520 )); then
result WARN disk-space "${avail_gib} GiB free on ${vm_fs} (sufficient for VM >=20 GiB, tight for simultaneous build)"
else
result FAIL disk-space "${avail_gib} GiB free on ${vm_fs} (want >=20 GiB for VM)"
fi
else
if [[ -n "$vm_avail" ]]; then
avail_gib=$(( vm_avail / 1024 / 1024 ))
if (( vm_avail >= 20971520 )); then
result OK disk-vm "${avail_gib} GiB free on ${vm_fs} (${vm_dir})"
else
result FAIL disk-vm "${avail_gib} GiB free on ${vm_fs} (want >=20 GiB)"
fi
fi
if [[ -n "$build_avail" ]]; then
b_avail_gib=$(( build_avail / 1024 / 1024 ))
if (( build_avail >= 10485760 )); then
result OK disk-build "${b_avail_gib} GiB free on ${build_fs} (${build_dir})"
else
result WARN disk-build "${b_avail_gib} GiB free on ${build_fs} (want >=10 GiB)"
fi
fi
fi fi
echo echo

74
scripts/ensure-live-iso.sh Executable file
View file

@ -0,0 +1,74 @@
#!/usr/bin/env bash
# Ensure that the live ISO is always up-to-date with any changes to the
# installer, CLI, desktop QML, or live scripts.
#
# If the ISO does not exist or if any source input is newer than the ISO,
# this script rebuilds the static binaries and repacks the fresh ISO.
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
iso_path="${PHOEBUS_ISO:-$repo_root/installer/live/phoebus-installer-amd64.iso}"
is_stale=0
if [[ ! -f "$iso_path" ]]; then
is_stale=1
reason="ISO file does not exist ($iso_path)"
else
# Find any input newer than the ISO
newer_file="$(find \
"$repo_root/installer-rs/crates" \
"$repo_root/installer-rs/Cargo.toml" \
"$repo_root/installer-rs/Cargo.lock" \
"$repo_root/installer/live/desktop" \
"$repo_root/installer/live/build.sh" \
"$repo_root/installer/live/livefs-hook.sh" \
"$repo_root/installer/live/live-packages.list" \
"$repo_root/installer/live/install-help.txt" \
-newer "$iso_path" 2>/dev/null | head -n 1 || true)"
if [[ -n "$newer_file" ]]; then
is_stale=1
reason="newer input detected: $newer_file"
fi
fi
if [[ "$is_stale" -eq 0 && "${FORCE_REBUILD:-0}" != "1" ]]; then
echo "Live ISO is up to date: $iso_path"
exit 0
fi
echo "======================================================================"
echo "Live ISO needs rebuild (${reason:-forced rebuild})"
echo "Rebuilding static binaries and packaging fresh live ISO..."
echo "======================================================================"
# 1. Build fresh static release binaries
echo ">> Compiling static phoebus-installer and sys..."
(
cd "$repo_root/installer-rs"
RUSTFLAGS="-C target-feature=+crt-static" \
cargo build --release -p phoebus-installer --bins --target x86_64-unknown-linux-gnu
)
# 2. Build live ISO with rootfs reuse (fast repack with latest binaries & desktop)
echo ">> Rebuilding live ISO ($iso_path)..."
(
cd "$repo_root"
PHOEBUS_REUSE_ROOTFS=1 bash "$repo_root/installer/live/build.sh"
)
# 3. Synchronize host HTTP server payload if running
serve_dir="/home/dominic/vmlab/serve"
if [[ -d "$serve_dir" ]]; then
echo ">> Updating local server payload in $serve_dir..."
target_rel="$repo_root/installer-rs/target/x86_64-unknown-linux-gnu/release"
cp -f "$target_rel/phoebus-installer" "$serve_dir/phoebus-installer" 2>/dev/null || true
cp -f "$target_rel/sys" "$serve_dir/sys" 2>/dev/null || true
(cd "$repo_root/installer/live/desktop" && tar czf "$serve_dir/desktop.tar.gz" *) 2>/dev/null || true
fi
echo "======================================================================"
echo "Live ISO is now fresh and matches all current source changes!"
echo "ISO: $iso_path ($(du -h "$iso_path" | cut -f1))"
echo "======================================================================"