1163 lines
44 KiB
Rust
1163 lines
44 KiB
Rust
//! Desktop profile installation.
|
|
//!
|
|
//! The Phoebus desktop is Mango (wlroots tiling compositor) + DarkMaterial
|
|
//! (DankMaterialShell), with PipeWire/WirePlumber audio. Flatpak is supported out of the box.
|
|
|
|
use std::path::Path;
|
|
|
|
use phoebus_core::hardware::{HardwareReport, VirtualMachine};
|
|
use phoebus_core::policy::{PackagePolicyEngine, PolicyContext};
|
|
use phoebus_core::system as sysgen;
|
|
use phoebus_core::{DesktopProfile, InstallConfig};
|
|
|
|
use crate::error::{ExecError, Result};
|
|
use crate::exec::Exec;
|
|
use crate::portage;
|
|
|
|
/// A compact, curated collection that is available offline from first login.
|
|
/// Keep the file names stable so a selected DMS wallpaper survives upgrades.
|
|
const DEFAULT_WALLPAPERS: [(&str, &[u8]); 4] = [
|
|
(
|
|
"aurora-lagoon.jpg",
|
|
include_bytes!("../../../assets/wallpapers/aurora-lagoon.jpg"),
|
|
),
|
|
(
|
|
"desert-arch.jpg",
|
|
include_bytes!("../../../assets/wallpapers/desert-arch.jpg"),
|
|
),
|
|
(
|
|
"misty-lake.jpg",
|
|
include_bytes!("../../../assets/wallpapers/misty-lake.jpg"),
|
|
),
|
|
(
|
|
"stone-strata.jpg",
|
|
include_bytes!("../../../assets/wallpapers/stone-strata.jpg"),
|
|
),
|
|
];
|
|
|
|
pub fn install(
|
|
exec: &Exec,
|
|
config: &InstallConfig,
|
|
hardware: &HardwareReport,
|
|
engine: &PackagePolicyEngine,
|
|
ctx: &PolicyContext,
|
|
) -> Result<()> {
|
|
if config.desktop.profile == DesktopProfile::None {
|
|
exec.logger.info("no desktop profile selected");
|
|
return Ok(());
|
|
}
|
|
let mut packages: Vec<String> = sysgen::desktop_packages(config.desktop.profile)
|
|
.into_iter()
|
|
.map(str::to_string)
|
|
.collect();
|
|
packages.extend(
|
|
sysgen::desktop_audio_packages()
|
|
.into_iter()
|
|
.map(str::to_string),
|
|
);
|
|
packages.extend(
|
|
sysgen::vm_guest_packages(hardware.virtual_machine)
|
|
.iter()
|
|
.map(|atom| (*atom).to_string()),
|
|
);
|
|
if config.desktop.flatpak {
|
|
packages.push("sys-apps/flatpak".to_string());
|
|
}
|
|
exec.logger.info(format!(
|
|
"installing desktop profile '{}' ({} packages)",
|
|
config.desktop.profile,
|
|
packages.len()
|
|
));
|
|
portage::emerge_in_stage(
|
|
exec,
|
|
"desktop_install",
|
|
Path::new(&exec.root),
|
|
&packages,
|
|
engine,
|
|
ctx,
|
|
)
|
|
}
|
|
|
|
/// Write `/usr/local/bin/phoebus-session-mango` and the wrapper `/usr/local/bin/phoebus-session`.
|
|
pub fn write_session_script(exec: &Exec, config: &InstallConfig) -> Result<()> {
|
|
if config.desktop.profile == DesktopProfile::None {
|
|
return Ok(());
|
|
}
|
|
let target = exec.target();
|
|
|
|
// A launcher for the installed assistant. It opens `sys ask`, which keeps
|
|
// privilege and approval in the deterministic broker.
|
|
write_script(
|
|
&target,
|
|
"usr/local/bin/phoebus-assistant",
|
|
sysgen::PHOEBUS_ASSISTANT_SCRIPT,
|
|
)?;
|
|
write_public(
|
|
&target,
|
|
"usr/share/applications/phoebus-assistant.desktop",
|
|
sysgen::PHOEBUS_ASSISTANT_DESKTOP_ENTRY,
|
|
)?;
|
|
write_public(
|
|
&target,
|
|
"usr/share/applications/phoebus-updates.desktop",
|
|
sysgen::PHOEBUS_UPDATES_DESKTOP_ENTRY,
|
|
)?;
|
|
|
|
write_script(
|
|
&target,
|
|
"usr/local/bin/phoebus-help",
|
|
sysgen::PHOEBUS_HELP_SCRIPT,
|
|
)?;
|
|
for (rel_path, content) in sysgen::desktop_help_assets() {
|
|
write_public(&target, rel_path, content)?;
|
|
}
|
|
|
|
// Provision all assistant QML assets and Polkit policy into the target.
|
|
for (rel_path, content) in sysgen::assistant_desktop_assets() {
|
|
write_public(&target, rel_path, content)?;
|
|
}
|
|
|
|
// The "Install Phoebus OS" entry point and welcome launcher are live-medium
|
|
// only: an installed system has no business offering to reinstall itself.
|
|
// They are installed by the live build, not here.
|
|
|
|
match config.desktop.profile {
|
|
DesktopProfile::Mango => {
|
|
write_mango_session(exec, &target)?;
|
|
}
|
|
DesktopProfile::None => {}
|
|
}
|
|
Ok(())
|
|
}
|
|
|
|
fn write_mango_session(exec: &Exec, target: &phoebus_core::TargetRoot) -> Result<()> {
|
|
write_script(
|
|
target,
|
|
"usr/local/bin/phoebus-session-mango",
|
|
sysgen::PHOEBUS_MANGO_SESSION_SCRIPT,
|
|
)?;
|
|
// Convenience wrapper so manual VT invocation launches the canonical session.
|
|
write_script(
|
|
target,
|
|
"usr/local/bin/phoebus-session",
|
|
"#!/bin/bash\nexec /usr/local/bin/phoebus-session-mango \"$@\"\n",
|
|
)?;
|
|
write_public(
|
|
target,
|
|
"etc/xdg/mango/config.conf",
|
|
sysgen::MANGO_CONFIG_DEFAULT,
|
|
)?;
|
|
write_public(
|
|
target,
|
|
"usr/lib/systemd/user/mango-session.target",
|
|
sysgen::MANGO_SESSION_TARGET,
|
|
)?;
|
|
// Bind dms.service to the session target when the DMS package provides it;
|
|
// the session script falls back to `dms run` otherwise.
|
|
let dms_unit = target.resolve("usr/lib/systemd/user/dms.service")?;
|
|
if dms_unit.exists() {
|
|
target.ensure_dir_mode("etc/systemd", 0o755)?;
|
|
target.ensure_dir_mode("etc/systemd/user", 0o755)?;
|
|
target.ensure_dir_mode("etc/systemd/user/mango-session.target.wants", 0o755)?;
|
|
let wants = target.resolve("etc/systemd/user/mango-session.target.wants/dms.service")?;
|
|
let _ = std::fs::remove_file(&wants);
|
|
// The link is interpreted inside the installed system. A host path
|
|
// into the staging root works during installation but breaks on boot.
|
|
std::os::unix::fs::symlink("/usr/lib/systemd/user/dms.service", &wants)
|
|
.map_err(|e| ExecError::io(wants.clone(), e))?;
|
|
}
|
|
if let Some((name, entry)) = sysgen::wayland_session_entry(DesktopProfile::Mango) {
|
|
write_public(target, &format!("usr/share/wayland-sessions/{name}"), entry)?;
|
|
}
|
|
configure_cursor_theme(target)?;
|
|
configure_nemo_default(target)?;
|
|
configure_cups_local(target)?;
|
|
exec.logger
|
|
.info("wrote /usr/local/bin/phoebus-session-mango (Mango + DMS)");
|
|
Ok(())
|
|
}
|
|
|
|
/// One consistent cursor theme + size across Mango/wlroots, XWayland, GTK,
|
|
/// Qt/Quickshell, DMS and the greeter. Ordinary, text, link, resize and
|
|
/// busy cursors all come from the complete `vanilla-dmz-xcursors` set.
|
|
fn configure_cursor_theme(target: &phoebus_core::TargetRoot) -> Result<()> {
|
|
// Mango/wlroots + XWayland session environment.
|
|
let mut env = String::new();
|
|
for (k, v) in sysgen::cursor_env_lines() {
|
|
env.push_str(&format!("export {k}={v}\n"));
|
|
}
|
|
write_public(target, "etc/xdg/mango/cursor-env.sh", env)?;
|
|
// GTK 3/4.
|
|
write_public(
|
|
target,
|
|
"etc/xdg/gtk-3.0/settings.ini",
|
|
sysgen::gtk_cursor_settings(),
|
|
)?;
|
|
// Qt/Quickshell + DMS read XCURSOR_* from the session environment;
|
|
// the greeter sources the same fragment via its shell profile.
|
|
write_public(target,
|
|
"etc/profile.d/phoebus-cursor.sh",
|
|
format!(
|
|
"# Phoebus cursor defaults (generated).\nexport XCURSOR_THEME={}\nexport XCURSOR_SIZE={}\n",
|
|
sysgen::CURSOR_THEME_NAME,
|
|
sysgen::CURSOR_THEME_SIZE
|
|
),
|
|
)?;
|
|
Ok(())
|
|
}
|
|
|
|
/// Nemo is the default graphical file manager.
|
|
fn configure_nemo_default(target: &phoebus_core::TargetRoot) -> Result<()> {
|
|
write_public(target, "etc/xdg/mimeapps.list", sysgen::nemo_mimeapps())?;
|
|
write_public(
|
|
target,
|
|
"etc/skel/.config/mimeapps.list",
|
|
sysgen::nemo_mimeapps(),
|
|
)?;
|
|
Ok(())
|
|
}
|
|
|
|
/// CUPS with local printing enabled; remote sharing/administration disabled.
|
|
fn configure_cups_local(target: &phoebus_core::TargetRoot) -> Result<()> {
|
|
write_public(target, "etc/cups/cupsd.conf", sysgen::cupsd_local_conf())?;
|
|
write_public(
|
|
target,
|
|
"etc/cups/cups-browsed.conf",
|
|
"# Phoebus: no remote printer browsing.\nBrowseRemoteProtocols none\n",
|
|
)?;
|
|
Ok(())
|
|
}
|
|
|
|
/// Configure authenticated graphical login with greetd. The installed system
|
|
/// always authenticates; only the live ISO uses automatic login.
|
|
pub fn configure_login(
|
|
exec: &Exec,
|
|
config: &InstallConfig,
|
|
hardware: &HardwareReport,
|
|
) -> Result<()> {
|
|
if !config.desktop.profile.is_desktop() {
|
|
return Ok(());
|
|
}
|
|
let target = exec.target();
|
|
let cmd = sysgen::default_session_command(config.desktop.profile);
|
|
write_public(
|
|
&target,
|
|
"etc/greetd/config.toml",
|
|
sysgen::greetd_config(cmd),
|
|
)?;
|
|
write_public(
|
|
&target,
|
|
"etc/greetd/phoebus.vtrgb",
|
|
sysgen::greetd_vt_palette(),
|
|
)?;
|
|
write_public(
|
|
&target,
|
|
"etc/systemd/system/greetd.service.d/phoebus-palette.conf",
|
|
sysgen::greetd_palette_dropin(),
|
|
)?;
|
|
ensure_greeter_user(exec)?;
|
|
let root = Path::new(&exec.root);
|
|
if let Some(service) = sysgen::vm_guest_service(hardware.virtual_machine) {
|
|
// The selected package must supply its documented systemd unit.
|
|
portage::chroot(exec, root, "systemctl", &["enable", service]).map_err(|e| {
|
|
ExecError::operation(
|
|
"desktop",
|
|
&format!("enable VM guest service {service}"),
|
|
e.to_string(),
|
|
)
|
|
})?;
|
|
exec.logger
|
|
.info(format!("enabled VM guest integration: {service}"));
|
|
}
|
|
if hardware.virtual_machine == VirtualMachine::Qemu {
|
|
let socket = target.resolve("usr/lib/systemd/system/spice-vdagentd.socket")?;
|
|
if socket.exists() {
|
|
portage::chroot(
|
|
exec,
|
|
root,
|
|
"systemctl",
|
|
&["enable", "spice-vdagentd.socket"],
|
|
)?;
|
|
}
|
|
}
|
|
if hardware.virtual_machine == VirtualMachine::Virtualbox {
|
|
portage::chroot(
|
|
exec,
|
|
root,
|
|
"usermod",
|
|
&["-aG", "vboxguest", &config.user.username],
|
|
)?;
|
|
}
|
|
for service in sysgen::desktop_login_services() {
|
|
portage::chroot(exec, root, "systemctl", &["enable", service]).map_err(|e| {
|
|
ExecError::operation(
|
|
"desktop",
|
|
&format!("enable login service {service}"),
|
|
e.to_string(),
|
|
)
|
|
})?;
|
|
}
|
|
// snapd is part of the desktop package set. Socket activation keeps the
|
|
// daemon idle until needed while making `sys find` and installs available.
|
|
portage::chroot(exec, root, "systemctl", &["enable", "snapd.socket"])
|
|
.map_err(|e| ExecError::operation("desktop", "enable snapd socket", e.to_string()))?;
|
|
// Gentoo ships these user units disabled. A graphical login must start
|
|
// PipeWire and WirePlumber without requiring a per-user manual setup.
|
|
for unit in [
|
|
"pipewire.socket",
|
|
"pipewire-pulse.socket",
|
|
"wireplumber.service",
|
|
] {
|
|
portage::chroot(exec, root, "systemctl", &["--global", "enable", unit]).map_err(|e| {
|
|
ExecError::operation(
|
|
"desktop",
|
|
&format!("enable user audio unit {unit}"),
|
|
e.to_string(),
|
|
)
|
|
})?;
|
|
}
|
|
exec.logger
|
|
.info(format!("configured greetd login (default session {cmd})"));
|
|
Ok(())
|
|
}
|
|
|
|
fn ensure_greeter_user(exec: &Exec) -> Result<()> {
|
|
let root = Path::new(&exec.root);
|
|
// The seat group may not exist yet when seatd has not been installed
|
|
// into the target (best-effort: seatd's install provides it; membership
|
|
// is what the greeter needs for libseat).
|
|
let _ = portage::chroot(exec, root, "groupadd", &["-r", "seat"]);
|
|
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");
|
|
// Still ensure seat membership on re-runs (best-effort).
|
|
let _ = portage::chroot(exec, root, "usermod", &["-a", "-G", "seat", "greeter"]);
|
|
return Ok(());
|
|
}
|
|
}
|
|
|
|
portage::chroot(
|
|
exec,
|
|
root,
|
|
"useradd",
|
|
&[
|
|
"--system",
|
|
"--no-create-home",
|
|
"--home-dir",
|
|
"/var/lib/greetd",
|
|
"--shell",
|
|
"/sbin/nologin",
|
|
"--comment",
|
|
"Phoebus greeter",
|
|
"-G",
|
|
"video,input,render,seat",
|
|
"greeter",
|
|
],
|
|
)
|
|
.map_err(|e| ExecError::operation("desktop", "create greeter user", e.to_string()))?;
|
|
exec.logger.info("created the greeter user");
|
|
Ok(())
|
|
}
|
|
|
|
fn write_script(target: &phoebus_core::TargetRoot, rel: &str, contents: &str) -> Result<()> {
|
|
use std::os::unix::fs::PermissionsExt;
|
|
let path = target.resolve(rel)?;
|
|
target.write(rel, contents)?;
|
|
std::fs::set_permissions(&path, std::fs::Permissions::from_mode(0o755))
|
|
.map_err(|e| ExecError::io(path.clone(), e))?;
|
|
if !path.is_file() {
|
|
return Err(ExecError::operation(
|
|
"desktop",
|
|
"write session helper",
|
|
format!("helper missing after write: {}", path.display()),
|
|
));
|
|
}
|
|
Ok(())
|
|
}
|
|
|
|
/// Files consumed by the greeter or an unprivileged desktop session must be
|
|
/// readable regardless of the installer's restrictive umask. Only call this
|
|
/// for public, generated configuration; credentials use `TargetRoot::write`.
|
|
fn write_public(
|
|
target: &phoebus_core::TargetRoot,
|
|
rel: &str,
|
|
contents: impl AsRef<[u8]>,
|
|
) -> Result<()> {
|
|
use std::os::unix::fs::PermissionsExt;
|
|
let path = target.write(rel, contents)?;
|
|
let mut parent = path.parent();
|
|
while let Some(dir) = parent {
|
|
if dir == target.path() {
|
|
break;
|
|
}
|
|
std::fs::set_permissions(dir, std::fs::Permissions::from_mode(0o755))
|
|
.map_err(|e| ExecError::io(dir.to_path_buf(), e))?;
|
|
parent = dir.parent();
|
|
}
|
|
std::fs::set_permissions(&path, std::fs::Permissions::from_mode(0o644))
|
|
.map_err(|e| ExecError::io(path, e))?;
|
|
Ok(())
|
|
}
|
|
|
|
pub fn configure_flatpak(exec: &Exec, config: &InstallConfig) -> Result<()> {
|
|
if !config.desktop.flatpak {
|
|
return Ok(());
|
|
}
|
|
portage::chroot(
|
|
exec,
|
|
Path::new(&exec.root),
|
|
"flatpak",
|
|
&[
|
|
"remote-add",
|
|
"--if-not-exists",
|
|
"flathub",
|
|
"https://flathub.org/repo/flathub.flatpakrepo",
|
|
],
|
|
)
|
|
.map_err(|e| ExecError::operation("desktop", "add flathub remote", e.to_string()))?;
|
|
exec.logger.info("flatpak configured with flathub");
|
|
Ok(())
|
|
}
|
|
|
|
/// Install the default Flatpaks system-wide from Flathub **in the target**
|
|
/// (never on the live host), then verify apps, launchers, icons and MIME
|
|
/// associations.
|
|
///
|
|
/// Upstream sandbox permissions are respected: no broad global override is
|
|
/// granted and no sandbox protection is disabled (see
|
|
/// `sysgen::flatpak_narrow_overrides`, which is intentionally empty).
|
|
/// Updates after reboot flow through the exact-transaction
|
|
/// `sys apply updates --flatpak` path.
|
|
pub fn install_flatpak_apps(exec: &Exec, config: &InstallConfig) -> Result<()> {
|
|
if !config.desktop.flatpak || config.desktop.profile == DesktopProfile::None {
|
|
return Ok(());
|
|
}
|
|
let ids = sysgen::fast_default_flatpak_ids();
|
|
exec.logger.info(format!(
|
|
"installing default Flatpaks in the target (system-wide): {}",
|
|
ids.join(" ")
|
|
));
|
|
let mut args: Vec<&str> = vec![
|
|
"install",
|
|
"-y",
|
|
"--system",
|
|
"--noninteractive",
|
|
"flathub",
|
|
"--",
|
|
];
|
|
args.extend(ids.iter().copied());
|
|
portage::chroot(exec, Path::new(&exec.root), "flatpak", &args)
|
|
.map_err(|e| ExecError::operation("desktop", "install default flatpaks", e.to_string()))?;
|
|
// Narrow, justified per-app overrides only (today: none).
|
|
for (app_id, override_args) in sysgen::flatpak_narrow_overrides() {
|
|
let mut oargs = vec![
|
|
"override".to_string(),
|
|
"--system".to_string(),
|
|
app_id.to_string(),
|
|
];
|
|
oargs.extend(override_args.split_whitespace().map(str::to_string));
|
|
let oargs_ref: Vec<&str> = oargs.iter().map(String::as_str).collect();
|
|
portage::chroot(exec, Path::new(&exec.root), "flatpak", &oargs_ref).map_err(|e| {
|
|
ExecError::operation("desktop", "apply flatpak override", e.to_string())
|
|
})?;
|
|
}
|
|
verify_flatpak_apps(exec, &ids)?;
|
|
Ok(())
|
|
}
|
|
|
|
/// Verify the installed Flatpaks: `flatpak list` records the app, and the
|
|
/// exported launcher, icon and MIME handler exist in the target.
|
|
fn verify_flatpak_apps(exec: &Exec, ids: &[&str]) -> Result<()> {
|
|
let owned = ["list", "--app", "--columns=application"]
|
|
.iter()
|
|
.map(|s| s.to_string())
|
|
.collect::<Vec<_>>();
|
|
let spec = portage::chroot_spec(
|
|
"desktop",
|
|
"list installed flatpaks",
|
|
Path::new(&exec.root),
|
|
"flatpak",
|
|
&owned,
|
|
);
|
|
let out = exec
|
|
.run_capture(spec)
|
|
.map_err(|e| ExecError::operation("desktop", "list installed flatpaks", e.to_string()))?;
|
|
let listed = String::from_utf8_lossy(&out.stdout).to_string();
|
|
// Record what the target contains so post-reboot verification (launchers,
|
|
// icons, MIME, `sys apply updates --flatpak`) has a baseline.
|
|
let target = exec.target();
|
|
target.write("var/lib/phoebus/flatpaks-installed", listed.clone())?;
|
|
for id in ids {
|
|
if !listed.lines().any(|l| l.trim() == *id) {
|
|
return Err(ExecError::operation(
|
|
"desktop",
|
|
"verify default flatpaks",
|
|
format!("{id} is not in `flatpak list` after installation"),
|
|
));
|
|
}
|
|
for rel in [
|
|
format!("var/lib/flatpak/exports/share/applications/{id}.desktop"),
|
|
format!("var/lib/flatpak/app/{id}"),
|
|
] {
|
|
if !target.exists(&rel) {
|
|
return Err(ExecError::operation(
|
|
"desktop",
|
|
"verify default flatpaks",
|
|
format!("{id}: expected {rel} in the target"),
|
|
));
|
|
}
|
|
}
|
|
}
|
|
// Flatseal must be present for inspection without forcing setup.
|
|
if !ids.contains(&"com.github.tchx84.Flatseal") {
|
|
return Err(ExecError::operation(
|
|
"desktop",
|
|
"verify default flatpaks",
|
|
"Flatseal is required for permission inspection",
|
|
));
|
|
}
|
|
exec.logger
|
|
.info("default Flatpaks verified (apps, launchers, exports)");
|
|
Ok(())
|
|
}
|
|
|
|
/// Provision the installed-system first-login welcome (Mango + DMS styling).
|
|
/// Live-only entries are never written here; the installed welcome runs once
|
|
/// per user, stays reopenable, and never blocks login.
|
|
pub fn provision_installed_welcome(exec: &Exec, config: &InstallConfig) -> Result<()> {
|
|
if !config.desktop.profile.is_desktop() {
|
|
return Ok(());
|
|
}
|
|
let target = exec.target();
|
|
write_script(
|
|
&target,
|
|
"usr/local/bin/phoebus-welcome",
|
|
sysgen::INSTALLED_WELCOME_SCRIPT,
|
|
)?;
|
|
for (rel_path, content) in sysgen::installed_welcome_assets() {
|
|
write_public(&target, rel_path, content)?;
|
|
}
|
|
// Keep the skeleton for future accounts. The installation user already
|
|
// exists (UsersConfigure runs before DesktopInstall), so seed that home
|
|
// as well; otherwise DMS opens its own onboarding over Phoebus welcome.
|
|
for (rel, content) in sysgen::dms_firstlaunch_seed("1.6.2") {
|
|
write_public(&target, &format!("etc/skel/{rel}"), &content)?;
|
|
let username = &config.user.username;
|
|
if !username.is_empty() && target.resolve(&format!("home/{username}"))?.is_dir() {
|
|
let user_rel = format!("home/{username}/{rel}");
|
|
if !target.resolve(&user_rel)?.exists() {
|
|
let config_rel = format!("home/{username}/.config");
|
|
let config_existed = target.resolve(&config_rel)?.exists();
|
|
target.write(&user_rel, &content)?;
|
|
let owner = format!("{username}:{username}");
|
|
let user_dir = format!("/home/{username}/.config/DankMaterialShell");
|
|
portage::chroot(exec, target.path(), "chown", &["-R", &owner, &user_dir])?;
|
|
if !config_existed {
|
|
let config_dir = format!("/home/{username}/.config");
|
|
portage::chroot(exec, target.path(), "chown", &[&owner, &config_dir])?;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
exec.logger
|
|
.info("provisioned the installed first-login welcome (once per user, reopenable)");
|
|
Ok(())
|
|
}
|
|
|
|
/// Seed the installation user's wallpaper folder and the skeleton for future
|
|
/// accounts. Existing images are never replaced, including namesakes that a
|
|
/// user has edited after installation. Give the installation user a letter
|
|
/// avatar before the first greeter login; later accounts receive one from the
|
|
/// session launcher.
|
|
pub fn provision_wallpapers(exec: &Exec, config: &InstallConfig) -> Result<()> {
|
|
use std::os::unix::fs::PermissionsExt;
|
|
|
|
if !config.desktop.profile.is_desktop() {
|
|
return Ok(());
|
|
}
|
|
let target = exec.target();
|
|
let skel = "etc/skel/Pictures/Wallpapers";
|
|
target.ensure_dir_mode(skel, 0o755)?;
|
|
for &(name, image) in &DEFAULT_WALLPAPERS {
|
|
let rel = format!("{skel}/{name}");
|
|
if !target.exists(&rel) {
|
|
target.write(&rel, image)?;
|
|
let path = target.resolve(&rel)?;
|
|
std::fs::set_permissions(&path, std::fs::Permissions::from_mode(0o644))
|
|
.map_err(|e| ExecError::io(path, e))?;
|
|
}
|
|
}
|
|
|
|
let username = &config.user.username;
|
|
let home = format!("{}/{}", config.user.home.trim_end_matches('/'), username);
|
|
let home_rel = home.trim_start_matches('/');
|
|
if username.is_empty() || !target.resolve(home_rel)?.is_dir() {
|
|
return Err(ExecError::operation(
|
|
"desktop",
|
|
"seed wallpapers",
|
|
format!("installed user's home is missing: {home}"),
|
|
));
|
|
}
|
|
let pictures = format!("{home_rel}/Pictures");
|
|
let folder = format!("{pictures}/Wallpapers");
|
|
let pictures_existed = target.exists(&pictures);
|
|
let folder_existed = target.exists(&folder);
|
|
target.ensure_dir(&folder)?;
|
|
let owner = format!("{username}:{username}");
|
|
if !pictures_existed {
|
|
portage::chroot(
|
|
exec,
|
|
target.path(),
|
|
"chown",
|
|
&[&owner, &format!("{home}/Pictures")],
|
|
)?;
|
|
}
|
|
if !folder_existed {
|
|
portage::chroot(
|
|
exec,
|
|
target.path(),
|
|
"chown",
|
|
&[&owner, &format!("{home}/Pictures/Wallpapers")],
|
|
)?;
|
|
}
|
|
for &(name, image) in &DEFAULT_WALLPAPERS {
|
|
let rel = format!("{folder}/{name}");
|
|
if target.exists(&rel) {
|
|
continue;
|
|
}
|
|
let path = target.write(&rel, image)?;
|
|
std::fs::set_permissions(&path, std::fs::Permissions::from_mode(0o644))
|
|
.map_err(|e| ExecError::io(path, e))?;
|
|
portage::chroot(
|
|
exec,
|
|
target.path(),
|
|
"chown",
|
|
&[&owner, &format!("{home}/Pictures/Wallpapers/{name}")],
|
|
)?;
|
|
}
|
|
let avatar_rel = format!("{home_rel}/.face");
|
|
if !target.exists(&avatar_rel) {
|
|
let initial = config
|
|
.user
|
|
.fullname
|
|
.trim_start()
|
|
.chars()
|
|
.next()
|
|
.filter(|letter| letter.is_alphabetic())
|
|
.or_else(|| {
|
|
username
|
|
.chars()
|
|
.next()
|
|
.filter(|letter| letter.is_alphabetic())
|
|
})
|
|
.unwrap_or('U')
|
|
.to_uppercase()
|
|
.next()
|
|
.unwrap_or('U');
|
|
let avatar = format!(
|
|
"<svg xmlns='http://www.w3.org/2000/svg' width='256' height='256' viewBox='0 0 256 256'>\n\
|
|
<defs><linearGradient id='background' x2='1' y2='1'><stop stop-color='#285965'/><stop offset='1' stop-color='#17353f'/></linearGradient></defs>\n\
|
|
<rect width='256' height='256' rx='128' fill='url(#background)'/>\n\
|
|
<circle cx='208' cy='43' r='55' fill='#9bd6cd' opacity='0.12'/>\n\
|
|
<text x='128' y='167' text-anchor='middle' font-family='DejaVu Sans,sans-serif' font-size='132' font-weight='600' fill='#f5f8f7'>{initial}</text>\n\
|
|
</svg>\n"
|
|
);
|
|
let path = target.write(&avatar_rel, &avatar)?;
|
|
std::fs::set_permissions(&path, std::fs::Permissions::from_mode(0o644))
|
|
.map_err(|e| ExecError::io(path, e))?;
|
|
portage::chroot(
|
|
exec,
|
|
target.path(),
|
|
"chown",
|
|
&[&owner, &format!("{home}/.face")],
|
|
)?;
|
|
}
|
|
exec.logger.info(format!(
|
|
"seeded {} wallpapers and an initial avatar for {username}",
|
|
DEFAULT_WALLPAPERS.len()
|
|
));
|
|
Ok(())
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
use crate::command::RecordingRunner;
|
|
use crate::log::Logger;
|
|
use phoebus_core::Redactor;
|
|
|
|
fn make_exec(runner: RecordingRunner) -> Exec {
|
|
let path = tempfile::tempdir().unwrap().keep();
|
|
let logger = Logger::open(path.join("l.log"), Redactor::new(), false);
|
|
Exec::new(Box::new(runner), logger, false, path.join("root"), path)
|
|
}
|
|
|
|
#[test]
|
|
fn no_session_script_for_none_profile() {
|
|
let runner = RecordingRunner::new();
|
|
let exec = make_exec(runner);
|
|
let mut cfg = InstallConfig::default();
|
|
cfg.desktop.profile = DesktopProfile::None;
|
|
write_session_script(&exec, &cfg).unwrap();
|
|
assert!(!exec.root.join("usr/local/bin/phoebus-session").exists());
|
|
assert!(!exec
|
|
.root
|
|
.join("usr/local/bin/phoebus-session-mango")
|
|
.exists());
|
|
// An explicit `none` also writes no assistant launcher.
|
|
assert!(!exec.root.join("usr/local/bin/phoebus-assistant").exists());
|
|
}
|
|
|
|
#[test]
|
|
fn mango_profile_installs_canonical_session_and_no_dwl_artifacts() {
|
|
use std::os::unix::fs::PermissionsExt;
|
|
let runner = RecordingRunner::new();
|
|
let exec = make_exec(runner);
|
|
let mut cfg = InstallConfig::default();
|
|
cfg.desktop.profile = DesktopProfile::Mango;
|
|
let xdg = exec.target().ensure_dir("etc/xdg").unwrap();
|
|
std::fs::set_permissions(&xdg, std::fs::Permissions::from_mode(0o700)).unwrap();
|
|
write_session_script(&exec, &cfg).unwrap();
|
|
for rel in ["etc/xdg", "etc/xdg/mango"] {
|
|
let mode = std::fs::metadata(exec.root.join(rel))
|
|
.unwrap()
|
|
.permissions()
|
|
.mode();
|
|
assert_eq!(mode & 0o777, 0o755, "{rel} must be traversable");
|
|
}
|
|
let mode = std::fs::metadata(exec.root.join("etc/xdg/mango/config.conf"))
|
|
.unwrap()
|
|
.permissions()
|
|
.mode();
|
|
assert_eq!(mode & 0o777, 0o644, "Mango config must be readable");
|
|
for rel in [
|
|
"usr/local/bin/phoebus-session-mango",
|
|
"usr/local/bin/phoebus-session",
|
|
"usr/local/bin/phoebus-assistant",
|
|
"etc/xdg/mango/config.conf",
|
|
"usr/lib/systemd/user/mango-session.target",
|
|
"usr/share/wayland-sessions/phoebus-mango.desktop",
|
|
] {
|
|
assert!(exec.root.join(rel).is_file(), "{rel} was not installed");
|
|
}
|
|
// Standalone dwl session entry and helpers must NOT be installed.
|
|
for rel in [
|
|
"usr/share/wayland-sessions/phoebus-dwl.desktop",
|
|
"usr/local/bin/phoebus-menu",
|
|
"usr/local/bin/phoebus-lock",
|
|
"usr/local/bin/phoebus-idle",
|
|
"etc/xdg/waybar/config",
|
|
"etc/xdg/waybar/style.css",
|
|
] {
|
|
assert!(!exec.root.join(rel).exists(), "{rel} must not be installed");
|
|
}
|
|
let mango =
|
|
std::fs::read_to_string(exec.root.join("usr/local/bin/phoebus-session-mango")).unwrap();
|
|
for helper in ["waybar", "mako", "swaybg", "swayidle", "swaylock"] {
|
|
assert!(
|
|
!mango.contains(helper),
|
|
"Mango session must not start {helper}"
|
|
);
|
|
}
|
|
assert!(mango.contains("dms run") || mango.contains("mango-session.target"));
|
|
let session =
|
|
std::fs::read_to_string(exec.root.join("usr/local/bin/phoebus-session")).unwrap();
|
|
assert!(
|
|
session.contains("phoebus-session-mango"),
|
|
"phoebus-session wrapper must invoke phoebus-session-mango"
|
|
);
|
|
assert!(
|
|
!session.contains("dwl &"),
|
|
"standalone dwl must not be in phoebus-session"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn mango_dms_user_unit_link_points_into_installed_system() {
|
|
use std::os::unix::fs::PermissionsExt;
|
|
let exec = make_exec(RecordingRunner::new());
|
|
let mut cfg = InstallConfig::default();
|
|
cfg.desktop.profile = DesktopProfile::Mango;
|
|
exec.target()
|
|
.write(
|
|
"usr/lib/systemd/user/dms.service",
|
|
"[Service]\nExecStart=/usr/bin/dms run\n",
|
|
)
|
|
.unwrap();
|
|
write_session_script(&exec, &cfg).unwrap();
|
|
let wants = exec
|
|
.root
|
|
.join("etc/systemd/user/mango-session.target.wants");
|
|
let link = wants.join("dms.service");
|
|
assert_eq!(
|
|
std::fs::read_link(link).unwrap(),
|
|
std::path::PathBuf::from("/usr/lib/systemd/user/dms.service")
|
|
);
|
|
assert_eq!(
|
|
std::fs::metadata(wants).unwrap().permissions().mode() & 0o777,
|
|
0o755
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn mango_profile_configures_greetd_login_and_no_install_shortcut() {
|
|
let runner = RecordingRunner::new();
|
|
let exec = make_exec(runner.clone());
|
|
let mut cfg = InstallConfig::default();
|
|
cfg.desktop.profile = DesktopProfile::Mango;
|
|
write_session_script(&exec, &cfg).unwrap();
|
|
configure_login(&exec, &cfg, &HardwareReport::default()).unwrap();
|
|
|
|
assert!(exec.root.join("etc/greetd/config.toml").is_file());
|
|
// The installer shortcut is live-medium only; an installed system must
|
|
// not advertise a reinstall entry point.
|
|
assert!(!exec.root.join("usr/local/bin/phoebus-install").exists());
|
|
assert!(!exec
|
|
.root
|
|
.join("usr/share/applications/phoebus-install.desktop")
|
|
.exists());
|
|
let login = std::fs::read_to_string(exec.root.join("etc/greetd/config.toml")).unwrap();
|
|
assert!(login.contains("phoebus-session-mango"));
|
|
assert!(login.contains("tuigreet"));
|
|
assert!(login.contains("--window-padding 2"));
|
|
assert!(login.contains("--greeting 'Welcome to Phoebus OS'"));
|
|
assert!(login.contains(";action=gray;button=gray'"));
|
|
assert_eq!(
|
|
std::fs::read_to_string(exec.root.join("etc/greetd/phoebus.vtrgb")).unwrap(),
|
|
sysgen::greetd_vt_palette()
|
|
);
|
|
assert_eq!(
|
|
std::fs::read_to_string(
|
|
exec.root
|
|
.join("etc/systemd/system/greetd.service.d/phoebus-palette.conf")
|
|
)
|
|
.unwrap(),
|
|
sysgen::greetd_palette_dropin()
|
|
);
|
|
assert!(
|
|
!login.contains("[initial_session]"),
|
|
"installed login must not autologin"
|
|
);
|
|
// greetd is enabled and the greeter account is created.
|
|
let commands: Vec<String> = runner.recorded().iter().map(|s| s.args.join(" ")).collect();
|
|
assert!(commands.iter().any(|a| a.contains("enable greetd")));
|
|
assert!(commands.iter().any(|a| a.contains("enable snapd.socket")));
|
|
assert!(commands.iter().any(|a| a.contains("useradd")));
|
|
for unit in [
|
|
"pipewire.socket",
|
|
"pipewire-pulse.socket",
|
|
"wireplumber.service",
|
|
] {
|
|
assert!(
|
|
commands
|
|
.iter()
|
|
.any(|a| a.contains(&format!("--global enable {unit}"))),
|
|
"user audio unit {unit} must be enabled"
|
|
);
|
|
}
|
|
// Seat management: seatd is enabled before the greeter, and the
|
|
// greeter joins the seat group (plus video/input/render).
|
|
let seat_pos = commands.iter().position(|a| a.contains("enable seatd"));
|
|
let greet_pos = commands.iter().position(|a| a.contains("enable greetd"));
|
|
assert!(
|
|
seat_pos.is_some() && greet_pos.is_some() && seat_pos < greet_pos,
|
|
"seatd must be enabled before greetd: {commands:?}"
|
|
);
|
|
assert!(
|
|
commands
|
|
.iter()
|
|
.any(|a| a.contains("useradd") && a.contains("seat")),
|
|
"greeter must join the seat group: {commands:?}"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn live_and_installed_welcomes_are_launched_by_the_mango_session() {
|
|
let runner = RecordingRunner::new();
|
|
let exec = make_exec(runner);
|
|
let mut cfg = InstallConfig::default();
|
|
cfg.desktop.profile = DesktopProfile::Mango;
|
|
write_session_script(&exec, &cfg).unwrap();
|
|
let mango =
|
|
std::fs::read_to_string(exec.root.join("usr/local/bin/phoebus-session-mango")).unwrap();
|
|
assert!(
|
|
mango.contains("/etc/phoebus/live"),
|
|
"the welcome autostart must be gated on the live marker"
|
|
);
|
|
assert!(mango.contains("phoebus-welcome"));
|
|
assert!(mango.contains("elif [ -x /usr/local/bin/phoebus-welcome ]"));
|
|
}
|
|
|
|
#[test]
|
|
fn explicit_none_writes_no_login_configuration() {
|
|
let runner = RecordingRunner::new();
|
|
let exec = make_exec(runner);
|
|
let mut cfg = InstallConfig::default();
|
|
cfg.desktop.profile = DesktopProfile::None;
|
|
configure_login(&exec, &cfg, &HardwareReport::default()).unwrap();
|
|
assert!(!exec.root.join("etc/greetd/config.toml").exists());
|
|
}
|
|
|
|
#[test]
|
|
fn workstation_defaults_set_cursor_nemo_and_local_cups() {
|
|
let runner = RecordingRunner::new();
|
|
let exec = make_exec(runner);
|
|
let mut cfg = InstallConfig::default();
|
|
cfg.desktop.profile = DesktopProfile::Mango;
|
|
write_session_script(&exec, &cfg).unwrap();
|
|
let cursor =
|
|
std::fs::read_to_string(exec.root.join("etc/profile.d/phoebus-cursor.sh")).unwrap();
|
|
assert!(cursor.contains("Vanilla-DMZ"));
|
|
assert!(cursor.contains("24"));
|
|
let mime = std::fs::read_to_string(exec.root.join("etc/xdg/mimeapps.list")).unwrap();
|
|
assert!(mime.contains("inode/directory=nemo.desktop"));
|
|
let cupsd = std::fs::read_to_string(exec.root.join("etc/cups/cupsd.conf")).unwrap();
|
|
assert!(cupsd.contains("Listen localhost:631"));
|
|
assert!(cupsd.contains("Browsing Off"));
|
|
assert!(!cupsd.contains("Allow all"));
|
|
}
|
|
|
|
#[test]
|
|
fn default_flatpaks_install_system_wide_in_the_target_only() {
|
|
use crate::command::CommandOutput;
|
|
let runner = RecordingRunner::new();
|
|
// `flatpak list` inside the target names every default app.
|
|
runner.set_response(
|
|
"chroot",
|
|
CommandOutput {
|
|
status: 0,
|
|
success: true,
|
|
stdout: b"com.calibre_ebook.calibre\norg.gimp.GIMP\ncom.github.tchx84.Flatseal\n"
|
|
.to_vec(),
|
|
stderr: Vec::new(),
|
|
duration: std::time::Duration::from_millis(1),
|
|
},
|
|
);
|
|
let exec = make_exec(runner.clone());
|
|
// Fixture exports: launchers and app dirs in the target.
|
|
for id in sysgen::fast_default_flatpak_ids() {
|
|
let desktop = format!("var/lib/flatpak/exports/share/applications/{id}.desktop");
|
|
let path = exec.root.join(&desktop);
|
|
std::fs::create_dir_all(path.parent().unwrap()).unwrap();
|
|
std::fs::write(&path, "[Desktop Entry]\n").unwrap();
|
|
std::fs::create_dir_all(exec.root.join(format!("var/lib/flatpak/app/{id}"))).unwrap();
|
|
}
|
|
let mut cfg = InstallConfig::default();
|
|
cfg.desktop.profile = DesktopProfile::Mango;
|
|
install_flatpak_apps(&exec, &cfg).unwrap();
|
|
// Every command ran inside the target chroot — nothing touched the
|
|
// live host directly.
|
|
for spec in runner.recorded() {
|
|
assert_eq!(spec.program, "chroot", "must not run on the host: {spec:?}");
|
|
assert_eq!(spec.args[0], exec.root.to_string_lossy().to_string());
|
|
}
|
|
let recorded = runner.recorded();
|
|
let install = recorded
|
|
.iter()
|
|
.find(|s| s.args.iter().any(|a| a == "install"))
|
|
.expect("flatpak install ran");
|
|
for flag in ["--system", "--noninteractive", "flathub"] {
|
|
assert!(install.args.iter().any(|a| a == flag), "{install:?}");
|
|
}
|
|
for id in sysgen::fast_default_flatpak_ids() {
|
|
assert!(install.args.iter().any(|a| a == id), "{install:?}");
|
|
}
|
|
// The manifest records the installed set for post-reboot checks.
|
|
let manifest =
|
|
std::fs::read_to_string(exec.root.join("var/lib/phoebus/flatpaks-installed")).unwrap();
|
|
for id in sysgen::fast_default_flatpak_ids() {
|
|
assert!(manifest.contains(id), "{manifest}");
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn flatpak_verification_fails_closed_on_a_missing_app() {
|
|
let runner = RecordingRunner::new();
|
|
let exec = make_exec(runner);
|
|
let mut cfg = InstallConfig::default();
|
|
cfg.desktop.profile = DesktopProfile::Mango;
|
|
// Default runner returns empty `flatpak list`: verification must fail
|
|
// closed instead of reporting success.
|
|
let err = install_flatpak_apps(&exec, &cfg).unwrap_err();
|
|
assert!(err.to_string().contains("not in `flatpak list`"), "{err}");
|
|
}
|
|
|
|
#[test]
|
|
fn installed_welcome_is_provisioned_once_per_user_and_reopenable() {
|
|
let runner = RecordingRunner::new();
|
|
let exec = make_exec(runner);
|
|
let mut cfg = InstallConfig::default();
|
|
cfg.desktop.profile = DesktopProfile::Mango;
|
|
provision_installed_welcome(&exec, &cfg).unwrap();
|
|
for rel in [
|
|
"usr/local/bin/phoebus-welcome",
|
|
"usr/share/applications/phoebus-welcome.desktop",
|
|
"etc/xdg/autostart/phoebus-welcome.desktop",
|
|
"etc/xdg/quickshell/phoebus-welcome-installed/shell.qml",
|
|
] {
|
|
assert!(exec.root.join(rel).is_file(), "{rel} was not installed");
|
|
}
|
|
// Launcher + autostart behaviour: reopenable, background, never a
|
|
// login gate.
|
|
let script =
|
|
std::fs::read_to_string(exec.root.join("usr/local/bin/phoebus-welcome")).unwrap();
|
|
assert!(script.contains("--reopen"));
|
|
assert!(script.contains("welcome-seen"));
|
|
let autostart =
|
|
std::fs::read_to_string(exec.root.join("etc/xdg/autostart/phoebus-welcome.desktop"))
|
|
.unwrap();
|
|
assert!(autostart.contains("X-GNOME-Autostart-enabled=true"));
|
|
assert!(autostart.contains("NoDisplay=true"));
|
|
let entry = std::fs::read_to_string(
|
|
exec.root
|
|
.join("usr/share/applications/phoebus-welcome.desktop"),
|
|
)
|
|
.unwrap();
|
|
assert!(entry.contains("--reopen"));
|
|
// QML belongs with Mango/DMS, adapts to display size, and is
|
|
// keyboard-navigable without blocking.
|
|
let qml = std::fs::read_to_string(
|
|
exec.root
|
|
.join("etc/xdg/quickshell/phoebus-welcome-installed/shell.qml"),
|
|
)
|
|
.unwrap();
|
|
assert!(qml.contains("Welcome to Phoebus OS"));
|
|
assert!(qml.contains("prebuilt"));
|
|
assert!(qml.contains("KeyNavigation.tab"));
|
|
assert!(qml.contains("Escape"));
|
|
assert!(qml.contains("Flickable"));
|
|
// Future users receive the same seed through the skeleton.
|
|
assert!(exec
|
|
.root
|
|
.join("etc/skel/.config/DankMaterialShell/.firstlaunch")
|
|
.is_file());
|
|
// The live-only installer entry is never provisioned here.
|
|
assert!(!exec
|
|
.root
|
|
.join("usr/share/applications/phoebus-install.desktop")
|
|
.exists());
|
|
}
|
|
|
|
#[test]
|
|
fn installed_welcome_seeds_the_already_created_install_user() {
|
|
let runner = RecordingRunner::new();
|
|
let exec = make_exec(runner.clone());
|
|
let mut cfg = InstallConfig::default();
|
|
cfg.desktop.profile = DesktopProfile::Mango;
|
|
cfg.user.username = "phoebus".into();
|
|
exec.target().ensure_dir("home/phoebus").unwrap();
|
|
provision_installed_welcome(&exec, &cfg).unwrap();
|
|
assert!(exec
|
|
.root
|
|
.join("home/phoebus/.config/DankMaterialShell/.firstlaunch")
|
|
.is_file());
|
|
assert!(runner.recorded().iter().any(|spec| {
|
|
spec.program == "chroot"
|
|
&& spec
|
|
.args
|
|
.iter()
|
|
.any(|arg| arg == "/home/phoebus/.config/DankMaterialShell")
|
|
}));
|
|
}
|
|
|
|
#[test]
|
|
fn wallpapers_seed_current_and_future_users_without_overwriting_edits() {
|
|
let runner = RecordingRunner::new();
|
|
let exec = make_exec(runner.clone());
|
|
let mut cfg = InstallConfig::default();
|
|
cfg.desktop.profile = DesktopProfile::Mango;
|
|
cfg.user.username = "phoebus".into();
|
|
exec.target().ensure_dir("home/phoebus").unwrap();
|
|
provision_wallpapers(&exec, &cfg).unwrap();
|
|
for (name, bytes) in DEFAULT_WALLPAPERS {
|
|
let current = exec
|
|
.root
|
|
.join(format!("home/phoebus/Pictures/Wallpapers/{name}"));
|
|
let future = exec
|
|
.root
|
|
.join(format!("etc/skel/Pictures/Wallpapers/{name}"));
|
|
assert_eq!(std::fs::read(current).unwrap(), bytes);
|
|
assert_eq!(std::fs::read(future).unwrap(), bytes);
|
|
}
|
|
let avatar = exec.root.join("home/phoebus/.face");
|
|
assert!(std::fs::read_to_string(&avatar)
|
|
.unwrap()
|
|
.contains(">P</text>"));
|
|
let custom = exec
|
|
.root
|
|
.join("home/phoebus/Pictures/Wallpapers/desert-arch.jpg");
|
|
std::fs::write(&custom, b"user's edited wallpaper").unwrap();
|
|
std::fs::write(&avatar, b"user's own profile picture").unwrap();
|
|
provision_wallpapers(&exec, &cfg).unwrap();
|
|
assert_eq!(std::fs::read(custom).unwrap(), b"user's edited wallpaper");
|
|
assert_eq!(
|
|
std::fs::read(avatar).unwrap(),
|
|
b"user's own profile picture"
|
|
);
|
|
assert!(runner.recorded().iter().any(|spec| {
|
|
spec.program == "chroot"
|
|
&& spec
|
|
.args
|
|
.iter()
|
|
.any(|arg| arg == "/home/phoebus/Pictures/Wallpapers")
|
|
}));
|
|
}
|
|
|
|
#[test]
|
|
fn no_welcome_or_flatpaks_for_headless_profile() {
|
|
let runner = RecordingRunner::new();
|
|
let exec = make_exec(runner.clone());
|
|
let mut cfg = InstallConfig::default();
|
|
cfg.desktop.profile = DesktopProfile::None;
|
|
provision_installed_welcome(&exec, &cfg).unwrap();
|
|
provision_wallpapers(&exec, &cfg).unwrap();
|
|
install_flatpak_apps(&exec, &cfg).unwrap();
|
|
assert!(!exec.root.join("usr/local/bin/phoebus-welcome").exists());
|
|
assert!(!exec.root.join("etc/skel/Pictures/Wallpapers").exists());
|
|
assert!(runner.recorded().is_empty());
|
|
}
|
|
|
|
#[test]
|
|
fn assistant_desktop_assets_are_provisioned_on_installed_target() {
|
|
let runner = RecordingRunner::new();
|
|
let exec = make_exec(runner);
|
|
let mut cfg = InstallConfig::default();
|
|
cfg.desktop.profile = DesktopProfile::Mango;
|
|
write_session_script(&exec, &cfg).unwrap();
|
|
|
|
assert!(exec.root.join("usr/local/bin/phoebus-assistant").is_file());
|
|
assert!(exec
|
|
.root
|
|
.join("usr/share/applications/phoebus-assistant.desktop")
|
|
.is_file());
|
|
assert!(exec
|
|
.root
|
|
.join("usr/share/applications/phoebus-updates.desktop")
|
|
.is_file());
|
|
assert!(exec
|
|
.root
|
|
.join("etc/xdg/quickshell/phoebus-assistant/shell.qml")
|
|
.is_file());
|
|
assert!(exec
|
|
.root
|
|
.join("etc/xdg/quickshell/phoebus-assistant/AssistantBridge.qml")
|
|
.is_file());
|
|
assert!(exec
|
|
.root
|
|
.join("etc/xdg/quickshell/phoebus-assistant/Common/qmldir")
|
|
.is_file());
|
|
assert!(exec
|
|
.root
|
|
.join("usr/share/polkit-1/actions/club.phoebus.sys.policy")
|
|
.is_file());
|
|
for path in [
|
|
"usr/local/bin/phoebus-help",
|
|
"usr/share/phoebus/help/index.html",
|
|
"usr/share/applications/phoebus-help.desktop",
|
|
"usr/share/applications/dms-welcome.desktop",
|
|
] {
|
|
assert!(exec.root.join(path).is_file(), "missing {path}");
|
|
}
|
|
}
|
|
}
|