75 lines
5 KiB
Rust
75 lines
5 KiB
Rust
//! Experimental x86_64 Core ISO profile. Native tools execute inside nspawn.
|
|
pub mod overlay;
|
|
|
|
pub fn build_iso_script() -> String {
|
|
render_iso(false)
|
|
}
|
|
|
|
fn render_iso(kde: bool) -> String {
|
|
let assets = if kde { include_str!("../adapters/kde-package.sh") } else { include_str!("../adapters/gnome-package.sh") };
|
|
let policy = if kde { include_str!("../../purposes/proposals/kde-flatpak-apps.json") } else { include_str!("../../purposes/proposals/gnome-flatpak-apps.json") };
|
|
let finalizer = if kde { include_str!("../adapters/kde-finalize.sh") } else { include_str!("../adapters/gnome-finalize.sh") };
|
|
// Render private profile path tokens before inserting assets: application IDs,
|
|
// common helpers and policy contents must never undergo variant substitution.
|
|
let profile = |text: &str| if kde { text.replace("gnome", "kde").replace("GNOME", "KDE") } else { text.to_owned() };
|
|
let gnome = assets
|
|
.replace("@@FLATPAK_POLICY@@", policy)
|
|
.replace("@@SOFTWARE_HELPER@@", include_str!("../../system/integrations/gnome-software/software-helper"))
|
|
.replace("@@SOFTWARE_POLICY@@", include_str!("../../system/integrations/gnome-software/org.archipelago.software.policy"))
|
|
.replace("@@SOFTWARE_SERVICE@@", include_str!("../../system/integrations/gnome-software/archipelago-software-refresh.service"))
|
|
.replace("@@SOFTWARE_TIMER@@", include_str!("../../system/integrations/gnome-software/archipelago-software-refresh.timer"))
|
|
.replace("@@TOOLBOX_CONFIG@@", include_str!("../../purposes/common/desktop/toolbox.conf"))
|
|
.replace("@@TOOLBOX_REGISTRIES@@", include_str!("../../purposes/common/desktop/toolbox-registries.conf"));
|
|
let package = include_str!("../adapters/package.sh")
|
|
.replace("@@PKGBUILD@@", include_str!("../../cli/packaging/PKGBUILD"))
|
|
.replace("@@SYSTEM_SERVICE@@", include_str!("../../system/integrations/dbus/archipelagod.service"))
|
|
.replace("@@SYSTEM_BUS_ACTIVATION@@", include_str!("../../system/integrations/dbus/org.archipelago.System1.service"))
|
|
.replace("@@SYSTEM_BUS_POLICY@@", include_str!("../../system/integrations/dbus/org.archipelago.System1.conf"))
|
|
.replace("@@SYSTEM_POLKIT_ACTIONS@@", include_str!("../../system/integrations/dbus/org.archipelago.system.policy"))
|
|
.replace("@@SYSTEM_POLKIT_RULES@@", include_str!("../../system/integrations/dbus/50-archipelago-system.rules"))
|
|
.replace("@@SYSTEM_BUS_XML@@", include_str!("../../contracts/dbus/org.archipelago.System1.xml"))
|
|
.replace("@@GNOME_PACKAGE@@", &gnome);
|
|
let layer = profile(include_str!("../adapters/gnome-layer.sh"))
|
|
.replace(if kde { "@@KDE_ASSETS@@" } else { "@@GNOME_ASSETS@@" }, &gnome);
|
|
profile(include_str!("../adapters/build-iso.sh")).replace("@@PACKAGE_SCRIPT@@", &package)
|
|
.replace(if kde { "@@KDE_LAYER_BUILD@@" } else { "@@GNOME_LAYER_BUILD@@" }, &layer)
|
|
.replace("@@LAYER_DELTA@@", include_str!("../../composer/layer_delta.py"))
|
|
.replace("@@UPDATE_PROFILE@@", include_str!("../defaults/update.json"))
|
|
.replace("@@UPDATE_PUBLIC_KEY@@", include_str!("../../system/archipelago-stable.asc"))
|
|
.replace("@@FLATPAK_IMPORT@@", include_str!("../../installer/adapters/flatpak-import.sh"))
|
|
.replace(if kde { "@@KDE_FINALIZE@@" } else { "@@GNOME_FINALIZE@@" }, finalizer)
|
|
}
|
|
|
|
/// KDE uses the same private composition path and the cycle's immutable Core.
|
|
pub fn build_kde_probe_script() -> Result<String, String> {
|
|
let data = archipelago_contracts::layer::validate(include_str!("../../purposes/proposals/kde.yaml"))?;
|
|
let packages = data["spec"]["packages"]["runtime"].as_array().ok_or("Missing KDE packages")?
|
|
.iter().map(|p| p["name"].as_str().ok_or("Invalid KDE package"))
|
|
.collect::<Result<Vec<_>, _>>()?.join("\n");
|
|
Ok(render_iso(true).replace("# KDE_PACKAGE_LIST", &packages))
|
|
}
|
|
|
|
/// A private integration probe, not the independent Layer v1 build pipeline.
|
|
pub fn build_gnome_probe_script() -> Result<String, String> {
|
|
let manifest = include_str!("../../purposes/proposals/gnome.yaml");
|
|
let data = archipelago_contracts::layer::validate(manifest)?;
|
|
let packages = data["spec"]["packages"]["runtime"].as_array().ok_or("Missing GNOME packages")?
|
|
.iter().map(|p| p["name"].as_str().ok_or("Invalid GNOME package"))
|
|
.collect::<Result<Vec<_>, _>>()?.join("\n");
|
|
Ok(build_iso_script().replace("# GNOME_PACKAGE_LIST", &packages))
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
use std::{io::Write, process::{Command, Stdio}};
|
|
#[test]
|
|
fn generated_profiles_are_valid_shell() {
|
|
for script in [build_iso_script(), build_gnome_probe_script().unwrap()] {
|
|
assert!(!script.contains("@@"), "unexpanded source adapter placeholder");
|
|
let mut child = Command::new("bash").arg("-n").stdin(Stdio::piped()).spawn().unwrap();
|
|
child.stdin.take().unwrap().write_all(script.as_bytes()).unwrap();
|
|
assert!(child.wait().unwrap().success());
|
|
}
|
|
}
|
|
}
|