Record native desktop delivery, update integration and validation work in progress
This commit is contained in:
parent
d0d083098a
commit
3756d3ffeb
3 changed files with 39 additions and 18 deletions
|
|
@ -5,6 +5,9 @@ edition = "2024"
|
|||
rust-version = "1.90"
|
||||
publish = false
|
||||
|
||||
[features]
|
||||
lab-fixtures = []
|
||||
|
||||
[dependencies]
|
||||
serde_json = "1"
|
||||
archipelago-builder = { path = "../builder" }
|
||||
|
|
|
|||
31
src/main.rs
31
src/main.rs
|
|
@ -1,6 +1,7 @@
|
|||
use std::{env, process::{Command, ExitCode}};
|
||||
mod self_check;
|
||||
mod infrastructure;
|
||||
mod presentation;
|
||||
|
||||
fn run(script: &str, args: &[String]) -> Result<(), String> {
|
||||
let status = Command::new("/usr/bin/bash")
|
||||
|
|
@ -12,12 +13,17 @@ fn run(script: &str, args: &[String]) -> Result<(), String> {
|
|||
fn main() -> ExitCode {
|
||||
let args: Vec<String> = env::args().skip(1).collect();
|
||||
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; }
|
||||
["pipeline", ..] | ["release", "plan", ..] | ["release", "publish", ..] => infrastructure::dispatch(&args),
|
||||
["build", "gnome-probe", work, bootstrap] => archipelago_builder::build_gnome_probe_script()
|
||||
["build", "iso", "--purpose", "gnome", work, bootstrap] => archipelago_builder::build_gnome_probe_script()
|
||||
.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(), "gnome-probe".into()]))),
|
||||
["desktop", "reconcile"] => archipelago_system::desktop::reconcile(),
|
||||
["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)),
|
||||
["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")),
|
||||
|
|
@ -37,32 +43,21 @@ fn main() -> ExitCode {
|
|||
["boot-sync"] => run(archipelago_system::HOST, &args),
|
||||
["extension", "add", ..] => archipelago_system::extensions::add(&args[2..]),
|
||||
["update", "check"] => archipelago_system::updates::plan(false),
|
||||
["update", "check", "--json"] | ["update", "diff"] => archipelago_system::updates::plan_json(false),
|
||||
["update", "plan", "--json"] => archipelago_system::updates::plan_json(true),
|
||||
["update", "plan"] => archipelago_system::updates::plan(true),
|
||||
["update", "apply", "--plan", id] => archipelago_system::updates::apply(id),
|
||||
["overlay", "apply", "test-marker"] => {
|
||||
["overlay", "apply", "test-marker"] if cfg!(feature = "lab-fixtures") => {
|
||||
run(archipelago_system::HOST, &args)
|
||||
}
|
||||
_ => {
|
||||
eprintln!("Experimental Core profile\n\
|
||||
archipelago build iso WORKDIR BOOTSTRAP.tar.zst\n\
|
||||
archipelago build gnome-probe WORKDIR BOOTSTRAP.tar.zst (private integration probe)\n\
|
||||
archipelago registry init|verify REPOSITORY\n\
|
||||
archipelago layer validate MANIFEST.yaml\n\
|
||||
archipelago desktop reconcile|seed-flatpaks\n\
|
||||
archipelago install /dev/DEVICE --erase\n\
|
||||
archipelago firstboot | status | self-check\n\
|
||||
archipelago overlay apply test-marker\n\
|
||||
archipelago extension add PACKAGE...\n\
|
||||
archipelago update check|plan\n\
|
||||
archipelago update apply --plan PLAN_SHA256\n\
|
||||
archipelago pipeline status|logs|run --reason TEXT (configured infrastructure host)\n\
|
||||
archipelago release plan|publish CANDIDATES.json --reason TEXT (infrastructure host)\n\
|
||||
Activation happens on the next explicit reboot.");
|
||||
eprintln!("{}", if presentation::russian() { "Неизвестная команда или неверные аргументы. Справка: archipelago --help" }
|
||||
else { "Unknown command or invalid arguments. See: archipelago --help" });
|
||||
return ExitCode::from(2);
|
||||
}
|
||||
};
|
||||
match result {
|
||||
Ok(()) => ExitCode::SUCCESS,
|
||||
Err(error) => { eprintln!("archipelago: {error}"); ExitCode::FAILURE }
|
||||
Err(error) => { eprintln!("archipelago: {}: {error}", if presentation::russian() { "ошибка" } else { "error" }); ExitCode::FAILURE }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
23
src/presentation.rs
Normal file
23
src/presentation.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
//! Human-facing presentation; machine-readable keys are never translated.
|
||||
pub fn russian() -> bool {
|
||||
["LC_ALL", "LC_MESSAGES", "LANG"].iter()
|
||||
.filter_map(|key| std::env::var(key).ok())
|
||||
.find(|value| !value.is_empty())
|
||||
.is_some_and(|value| value == "ru" || value.starts_with("ru_") || value.starts_with("ru."))
|
||||
}
|
||||
|
||||
pub fn help() {
|
||||
if russian() {
|
||||
println!("Archipelago — управление системой\n\n\
|
||||
Система:\n status Состояние системы и расширений\n self-check Проверка целостности\n update check Проверить обновления\n update plan Подготовить план обновления\n update apply --plan SHA256 Применить проверенный план\n extension add ПАКЕТ... Добавить локальные расширения\n\n\
|
||||
Установка:\n install /dev/ДИСК --erase Установить систему, стерев выбранный диск\n firstboot Настройка основного пользователя\n\n\
|
||||
Сборка и инфраструктура:\n build iso [--purpose gnome] КАТАЛОГ BOOTSTRAP.tar.zst\n layer validate МАНИФЕСТ\n registry init|verify РЕПОЗИТОРИЙ\n pipeline status | logs ID | run --reason ПРИЧИНА\n release plan|publish CANDIDATES.json --reason ПРИЧИНА\n\n\
|
||||
Подготовленные изменения активируются после явной перезагрузки.");
|
||||
} else {
|
||||
println!("Archipelago — system management\n\n\
|
||||
System:\n status System and extension state\n self-check Integrity verification\n update check Check for updates\n update plan Prepare an update plan\n update apply --plan SHA256 Apply a checked plan\n extension add PACKAGE... Add local extensions\n\n\
|
||||
Installation:\n install /dev/DISK --erase Install, erasing the selected disk\n firstboot Primary-user setup\n\n\
|
||||
Build and infrastructure:\n build iso [--purpose gnome] WORKDIR BOOTSTRAP.tar.zst\n layer validate MANIFEST\n registry init|verify REPOSITORY\n pipeline status | logs ID | run --reason REASON\n release plan|publish CANDIDATES.json --reason REASON\n\n\
|
||||
Prepared changes activate after an explicit reboot.");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue