diff --git a/integrations/gnome-software/README.md b/integrations/gnome-software/README.md index ffd2868..14d0f2b 100644 --- a/integrations/gnome-software/README.md +++ b/integrations/gnome-software/README.md @@ -1,7 +1,29 @@ # GNOME Software adapter — implementation in progress -Targets GNOME Software **51.1**, using its native plugin API. This source is not yet -installed into public images and must not be advertised as working GUI updates. +Targets GNOME Software **51.1**, using its native plugin API. The adapter is shipped +in the current GNOME images; successful end-to-end GUI OS-update acceptance is +still distinct from fresh-installation acceptance. + +## 2026-11-06 installed-host incident and fixes + +The installed 20261106 image followed a stable ref still selecting the 20261105 +image. Software showed absent target packages with empty new versions and offered +the older image as an update. The CLI now verifies signed target commit metadata +and requires its UTC commit timestamp to be strictly newer than the managed base +(equal identity is a no-op). This is checked during both planning and application, +including previously saved plans. Rollback is a separate explicit workflow. +Missing/ambiguous date formats fail closed; this is a private timestamp-based +ordering rule, not a universal release-version schema. + +Package removals now say “will be removed” / “будет удалён”. On the next CLI plan +or apply, orphaned `executing` records are marked `interrupted` while holding the +shared host-operation lock; actual deployment state remains authoritative. +Operation JSON is replaced atomically. No background job silently applies updates. + +The pipeline builds this plugin from its frozen sources on yabloko using the +GNOME Software 51.1 package headers. A failed compilation stops the cycle instead +of silently using the former precompiled plugin. Compiler package inventory and +source/binary checksums are retained with the run. - The Rust CLI produces digest-bound JSON plans and package-version differences read from signed OSTree image content. No package metadata is taken from an @@ -14,13 +36,12 @@ installed into public images and must not be advertised as working GUI updates. - The native Software plugin exposes one whole-image operation and related package changes. It conflicts with the PackageKit plugin; stock ALPM remains disabled. -Build the module inside the pinned GNOME Software 51.1 source build, adding this -directory under `plugins/` and including its `meson.build`. Keep the existing -Flatpak/fwupd plugins enabled. Never install an untested module into the user's -running desktop. +The daily pipeline compiles the module with `pkg-config gnome-software` against +the Arch 51.1 headers; an upstream source-tree build can instead include its +`meson.build` under `plugins/`. Keep existing Flatpak/fwupd plugins enabled. +Deliver changes through a new image rather than replacing the running desktop module. -Remaining before packaging: compile against the exact Arch dependencies; validate -query/schema handling, authorization and headless tests; complete pending/reboot +Remaining acceptance: validate query/schema handling and authorization; complete pending/reboot presentation and cancellation handling; run the real Software update/failure path. Download-only requests currently return unsupported rather than silently staging. The GUI must use the supported whole-image online-staging path; this needs actual diff --git a/integrations/gnome-software/gs-plugin-archipelago.c b/integrations/gnome-software/gs-plugin-archipelago.c index 29f7ae2..435453a 100644 --- a/integrations/gnome-software/gs-plugin-archipelago.c +++ b/integrations/gnome-software/gs-plugin-archipelago.c @@ -109,9 +109,11 @@ list_apps_async (GsPlugin *plugin, GsAppQuery *query, GsPluginListAppsFlags flag gs_app_set_bundle_kind (package, AS_BUNDLE_KIND_PACKAGE); gs_app_set_scope (package, AS_COMPONENT_SCOPE_SYSTEM); gs_app_set_version (package, old); - gs_app_set_update_version (package, new); + gs_app_set_update_version (package, new ? new : (is_ru () ? "будет удалён" : "will be removed")); gs_app_add_related (app, package); - g_string_append_printf (details, "%s: %s → %s\n", name, old ? old : "—", new ? new : "—"); + g_string_append_printf (details, "%s: %s → %s\n", name, + old ? old : (is_ru () ? "не установлен" : "not installed"), + new ? new : (is_ru () ? "будет удалён" : "will be removed")); } gs_app_set_update_details_text (app, details->str); gs_app_list_add (list, app); diff --git a/src/extensions.rs b/src/extensions.rs index 1e5e2b1..ad86765 100644 --- a/src/extensions.rs +++ b/src/extensions.rs @@ -167,7 +167,7 @@ fn compose(generation: &Path, id: &str, base: &str, snapshot: &str, // Native OSTree clients do not take our lock. Refuse a stale selection before // asking OSTree to atomically replace its staged deployment. if status()? != *initial { return Err("deployment selection changed during composition; retry".into()); } - run("ostree", &["admin", "deploy", "--stage", "--retain", "--os=archipelago", &commit])?; + crate::updates::stage_deployment(&commit)?; if let Err(error) = write(generation.join("staged"), b"success\n") { eprintln!("Deployment staged; could not record completion: {error}"); } diff --git a/src/updates.rs b/src/updates.rs index 959fb2a..999239a 100644 --- a/src/updates.rs +++ b/src/updates.rs @@ -7,13 +7,15 @@ const STATE: &str = "/var/lib/archipelago/updates"; const REMOTE: &str = "archipelago-hardware-test"; fn output(program: &str, args: &[&str]) -> Result { - let result = Command::new(program).args(args).env("LC_ALL", "C").output().map_err(|e| e.to_string())?; + let result = Command::new(program).args(args).env("LC_ALL", "C").env("TZ", "UTC").output().map_err(|e| e.to_string())?; if !result.status.success() { return Err(format!("{program}: {}", String::from_utf8_lossy(&result.stderr))); } String::from_utf8(result.stdout).map_err(|e| e.to_string()) } fn digest(s: &str) -> bool { s.len() == 64 && s.bytes().all(|c| c.is_ascii_digit() || (b'a'..=b'f').contains(&c)) } fn write(path: &Path, value: &Value) -> Result<(), String> { - fs::write(path, serde_json::to_vec_pretty(value).map_err(|e| e.to_string())?).map_err(|e| e.to_string()) + let temp = path.with_extension("tmp"); + fs::write(&temp, serde_json::to_vec_pretty(value).map_err(|e| e.to_string())?).map_err(|e| e.to_string())?; + fs::rename(temp, path).map_err(|e| e.to_string()) } fn repo(args: &[&str]) -> Result { let r = format!("--repo={STATE}/repo"); @@ -76,6 +78,53 @@ fn summary_commit(summary: &str, reference: &str) -> Result { fn variant() -> &'static str { if Path::new("/usr/lib/archipelago/gnome-firstboot").exists() { "gnome" } else { "core" } } +fn commit_date(repository: &str, commit: &str) -> Result { + let text = output("ostree", &[&format!("--repo={repository}"), "show", commit])?; + let date = text.lines().find_map(|line| line.strip_prefix("Date:")).ok_or("commit date missing")?.trim(); + // libostree's C-locale UTC date is fixed-width and sorts chronologically. + if date.len() != 25 || !date.ends_with(" +0000") || + !date.bytes().enumerate().all(|(i, c)| match i { + 4 | 7 => c == b'-', 10 | 19 => c == b' ', 13 | 16 => c == b':', + 20 => c == b'+', _ => c.is_ascii_digit(), + }) { + return Err("unsupported commit date format; update refused".into()); + } + Ok(date.into()) +} +fn require_newer(base: &str, target: &str) -> Result<(), String> { + if base == target { return Ok(()); } + // Metadata-only pull still verifies the target's signature before inspecting it. + repo(&["pull", "--commit-metadata-only", "--depth=0", REMOTE, target])?; + let before = commit_date("/sysroot/ostree/repo", base)?; + let after = commit_date(&format!("{STATE}/repo"), target)?; + if after <= before { + return Err(format!("Обновление отклонено: целевой образ {target} ({after}) не новее текущей базы {base} ({before}). Используйте явный rollback для отката.")); + } + Ok(()) +} +pub(crate) fn stage_deployment(commit: &str) -> Result<(), String> { + let mut args = vec!["admin", "deploy", "--stage", "--retain", "--os=archipelago"]; + if variant() == "gnome" { + args.extend(["--karg=quiet", "--karg=splash", "--karg=plymouth.ignore-serial-consoles"]); + } + args.push(commit); + output("ostree", &args).map(|_| ()) +} +fn reconcile_operations() -> Result<(), String> { + // Caller owns the shared host-operation lock: no prior CLI operation can run. + for entry in fs::read_dir(STATE).map_err(|e| e.to_string())? { + let path = entry.map_err(|e| e.to_string())?.path(); + let name = path.file_name().and_then(|s| s.to_str()).unwrap_or(""); + if !name.starts_with("operation-") || !name.ends_with(".json") { continue; } + let mut record: Value = serde_json::from_slice(&fs::read(&path).map_err(|e| e.to_string())?).map_err(|e| e.to_string())?; + if record["state"] == "executing" { + record["state"] = json!("interrupted"); + record["error"] = json!("Previous process ended without terminal status; inspect actual deployments"); + write(&path, &record)?; + } + } + Ok(()) +} fn plan_path(id: &str) -> Result { if !digest(id) { return Err("expected a 64-character plan digest".into()); } Ok(Path::new(STATE).join(format!("plan-{id}.json"))) @@ -88,6 +137,7 @@ pub fn plan_json(save: bool) -> Result<(), String> { } fn plan_output(save: bool, json_output: bool, include_diff: bool) -> Result<(), String> { let _lock = lock()?; + reconcile_operations()?; let binding = binding()?; configure(&binding)?; let state = crate::extensions::status()?; @@ -99,6 +149,7 @@ fn plan_output(save: bool, json_output: bool, include_diff: bool) -> Result<(), } let reference = binding["reference"].as_str().ok_or("missing reference")?; let target = summary_commit(&repo(&["remote", "summary", REMOTE])?, &reference)?; + require_newer(&base, &target)?; let mut plan = json!({"version":2,"binding":binding,"variant":variant(),"reference":reference, "target":target,"base":base,"requested":requested,"initial":state}); if include_diff { @@ -123,6 +174,7 @@ fn plan_output(save: bool, json_output: bool, include_diff: bool) -> Result<(), } pub fn apply(id: &str) -> Result<(), String> { let _lock = lock()?; + reconcile_operations()?; let path = plan_path(id)?; if output("sha256sum", &[path.to_str().unwrap()])?.split_whitespace().next() != Some(id) { return Err("plan integrity failure".into()); @@ -146,6 +198,7 @@ fn apply_plan(plan: &Value) -> Result<(), String> { let target = plan["target"].as_str().filter(|s| digest(s)).ok_or("invalid target")?; if plan["base"] == target { println!("Already on the selected base; no deployment created."); return Ok(()); } configure(&binding)?; + require_newer(plan["base"].as_str().filter(|s| digest(s)).ok_or("invalid base")?, target)?; // The signed summary selects the checksum during planning; exact-checksum pull // verifies its commit signature without reinterpreting old build-local ref bindings. repo(&["pull", "--depth=0", REMOTE, target])?; @@ -158,7 +211,7 @@ fn apply_plan(plan: &Value) -> Result<(), String> { let requested: BTreeSet = serde_json::from_value(plan["requested"].clone()).map_err(|e| e.to_string())?; if crate::extensions::status()? != initial { return Err("deployment state changed during download".into()); } if requested.is_empty() { - output("ostree", &["admin", "deploy", "--stage", "--retain", "--os=archipelago", target])?; + stage_deployment(target)?; } else { crate::extensions::reapply(target, &requested, &initial)?; } println!("Update prepared. Activate with an explicit reboot. Current /usr unchanged."); Ok(())