Route installed host commands through archipelagod

This commit is contained in:
Pavel Isaev 2026-11-07 19:29:51 +03:00
parent 11223b21e4
commit 21a2e1a74c
3 changed files with 83 additions and 6 deletions

66
Cargo.lock generated
View file

@ -70,6 +70,7 @@ dependencies = [
"archipelago-contracts",
"serde",
"serde_json",
"sha2",
"zbus",
"zbus_macros",
]
@ -250,6 +251,15 @@ version = "2.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
[[package]]
name = "block-buffer"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
dependencies = [
"generic-array",
]
[[package]]
name = "blocking"
version = "1.7.0"
@ -302,12 +312,41 @@ dependencies = [
"crossbeam-utils",
]
[[package]]
name = "cpufeatures"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
dependencies = [
"libc",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6"
[[package]]
name = "crypto-common"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"
dependencies = [
"generic-array",
"typenum",
]
[[package]]
name = "digest"
version = "0.10.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
dependencies = [
"block-buffer",
"crypto-common",
]
[[package]]
name = "displaydoc"
version = "0.2.7"
@ -478,6 +517,16 @@ dependencies = [
"slab",
]
[[package]]
name = "generic-array"
version = "0.14.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
dependencies = [
"typenum",
"version_check",
]
[[package]]
name = "getrandom"
version = "0.3.4"
@ -1103,6 +1152,17 @@ dependencies = [
"syn 3.0.9",
]
[[package]]
name = "sha2"
version = "0.10.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
dependencies = [
"cfg-if",
"cpufeatures",
"digest",
]
[[package]]
name = "signal-hook-registry"
version = "1.4.8"
@ -1248,6 +1308,12 @@ dependencies = [
"once_cell",
]
[[package]]
name = "typenum"
version = "1.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
[[package]]
name = "uds_windows"
version = "1.2.1"

View file

@ -7,7 +7,7 @@ pkgdesc='Archipelago Core build, installation and deployment control'
arch=('x86_64')
depends=('bash' 'coreutils' 'util-linux' 'ostree' 'pacman' 'shadow' 'sudo'
'openssh' 'systemd' 'gptfdisk' 'parted' 'dosfstools' 'e2fsprogs'
'arch-install-scripts' 'diffutils')
'arch-install-scripts' 'diffutils' 'python-pyalpm' 'polkit')
options=('!strip' '!debug')
source=('archipelago' 'runtime.tar')
sha256sums=('@BINARY_SHA256@' '@RUNTIME_SHA256@')
@ -17,6 +17,7 @@ package() {
find "$pkgdir" -type d -exec chmod 0755 '{}' +
find "$pkgdir" -type f -exec chmod 0644 '{}' +
install -Dm0755 "$srcdir/archipelago" "$pkgdir/usr/bin/archipelago"
ln -s archipelago "$pkgdir/usr/bin/archipelagod"
chown -R 0:0 "$pkgdir"
install -d "$pkgdir/usr/share/archipelago"
# Manifest covers every packaged regular file, including itself. No setuid,

View file

@ -12,13 +12,27 @@ fn run(script: &str, args: &[String]) -> Result<(), String> {
}
fn main() -> ExitCode {
if env::args_os().next().as_deref().and_then(|path| std::path::Path::new(path).file_name()).is_some_and(|name| name == "archipelagod") {
return match archipelago_system::service::run() {
Ok(()) => ExitCode::SUCCESS,
Err(error) => { eprintln!("archipelagod: {error}"); ExitCode::FAILURE }
};
}
let args: Vec<String> = env::args().skip(1).collect();
if std::path::Path::new("/run/ostree-booted").exists() && args.first().is_some_and(|arg|
matches!(arg.as_str(), "status" | "update" | "extension" | "overlay" | "transaction" | "purpose" | "rebase" | "deployment" | "account")) {
return match archipelago_system::service::client::dispatch(&args) {
Ok(()) => ExitCode::SUCCESS,
Err(error) => { eprintln!("archipelago: {error}"); ExitCode::FAILURE }
};
}
if let Some(result) = output::transaction(&args) { return result; }
let result = match args.iter().map(String::as_str).collect::<Vec<_>>().as_slice() {
[] | ["help"] | ["--help"] | ["-h"] => { presentation::help(); return ExitCode::SUCCESS; }
["--version"] | ["version"] => { println!("archipelago {}", env!("CARGO_PKG_VERSION")); return ExitCode::SUCCESS; }
["service", "capabilities"] => archipelago_system::service::inspect(true),
["service", "status"] => archipelago_system::service::inspect(false),
["service", "host", ..] => archipelago_system::service::client::dispatch(&args[2..]),
["logs"] => output::logs(false),
["logs", "--full"] => output::logs(true),
["pipeline", ..] | ["release", "plan", ..] | ["release", "publish", ..] => infrastructure::dispatch(&args),
@ -30,11 +44,7 @@ fn main() -> ExitCode {
.and_then(|script| env::current_exe().map_err(|e| e.to_string()).and_then(|binary|
run(&script, &[work.to_string(), bootstrap.to_string(), binary.display().to_string(), "kde-probe".into()]))),
["desktop", "seed-flatpaks"] => archipelago_system::desktop::seed_flatpaks(),
["desktop", "refresh-updates"] => archipelago_system::software::refresh(),
["desktop", "software-request", "refresh"] => archipelago_system::software::request("refresh", None),
["desktop", "software-request", "apply", id] => archipelago_system::software::request("apply", Some(id)),
["desktop", "software-request", "download", id] => archipelago_system::software::request("download", Some(id)),
["desktop", "software-request", "confirm-pending", id] => archipelago_system::software::request("confirm-pending", Some(id)),
["desktop", "refresh-updates"] => archipelago_system::service::client::dispatch(&["update".into(), "check".into()]),
["layer", "validate", path] => std::fs::read_to_string(path).map_err(|e| e.to_string())
.and_then(|text| archipelago_contracts::layer::validate(&text))
.map(|_| println!("Layer v1 syntax, schema and source-local checks passed; resolution/build checks still required")),