diff --git a/SERVICE.md b/SERVICE.md index 7131114..2541c18 100644 --- a/SERVICE.md +++ b/SERVICE.md @@ -27,12 +27,25 @@ The `archipelago` package now installs `archipelago.svg` and colored icon for the OS resource and the symbolic one for the source badge, and the GNOME/KDE finalizers refresh the hicolor cache. +Image size and licence (D-113): every image path (`build-iso.sh`, `gnome-layer.sh`, +`container-runner-layer.sh`) measures the composed tree with +`builder/adapters/image-size.py` and records `archipelago.image-size` (unique +compressed objects, i.e. the transfer upper bound) and +`archipelago.image-installed-size` (sum of checkout paths) in the published +commit. `refresh` reads them after `--commit-metadata-only`, so +`GetStatus`/`GetUpdateDetails` report `download_size`/`installed_size` before any +image bytes move. Discover shows the transfer size as the resource size and the +installed size in the description; GNOME Software sets the download size. Both +adapters declare the licence `MIT`. A target commit without the metadata keeps +an unknown size instead of a misleading zero. + Verification: the `archipelago-system` and `archipelago-builder` release test suites -pass, including new unit tests for the console parser and terminal-control -stripping, plus a real GNOME Software plugin contract test and a Discover adapter -build against the `2026-11-12` snapshot. The daemon/adapter behaviour on installed -hardware (progress animation, no reconciliation banner, icon rendering) is still -user-verified only. +pass, including new unit tests for the console parser, terminal-control stripping +and the size metadata parser, a real GNOME Software plugin contract test that now +asserts the download size and licence, and a Discover adapter build against the +`2026-11-12` snapshot. The daemon/adapter behaviour on installed +hardware (progress animation, no reconciliation banner, icon rendering, displayed +size) is still user-verified only. ## 2026-11-09 checkpoint (supersedes the historical status below) diff --git a/integrations/discover/ArchipelagoBackend.cpp b/integrations/discover/ArchipelagoBackend.cpp index 5dd3e1e..07e610c 100644 --- a/integrations/discover/ArchipelagoBackend.cpp +++ b/integrations/discover/ArchipelagoBackend.cpp @@ -20,6 +20,7 @@ #include #include #include +#include using namespace Qt::StringLiterals; @@ -149,9 +150,18 @@ public: State state() override { return record["state"_L1] == "available"_L1 ? Upgradeable : Installed; } bool hasCategory(const QString &category) const override { return category == "System"_L1; } Type type() const override { return System; } - quint64 size() override { return 0; } // The transport has not reported download size. - QString sizeDescription() override { return tr("Download size is determined by OSTree"); } - QJsonArray licenses() override { return {}; } + quint64 size() override { + // Compressed image bytes recorded by the builder in the signed target + // commit; a pull transfers at most this much. Zero means the target + // commit predates the size metadata and carries no usable value. + const auto value = record["plan"_L1].toObject()["download_size"_L1]; + return value.isDouble() ? quint64(value.toDouble()) : 0; + } + QString sizeDescription() override { + const quint64 bytes = size(); + return bytes ? KFormat().formatByteSize(bytes) : tr("Calculated after the image check"); + } + QJsonArray licenses() override { return QJsonArray{QStringLiteral("MIT")}; } QString installedVersion() const override { return record["plan"_L1].toObject()["base"_L1].toString(); } QString availableVersion() const override { return record["plan"_L1].toObject()["target"_L1].toString(); } QString origin() const override { return QStringLiteral("Archipelago"); } @@ -166,6 +176,10 @@ public: if (record["state"_L1] == "applying"_L1) text += tr("

The operating system update is being prepared. The active transaction reports its progress.

"); if (record["state"_L1] == "downloading"_L1) text += tr("

The verified operating system image is being downloaded.

"); if (record["state"_L1] == "error"_L1) text += "

"_L1 + record["error"_L1].toString().toHtmlEscaped() + "

"_L1; + const auto installed = record["plan"_L1].toObject()["installed_size"_L1]; + if (installed.isDouble() && installed.toDouble() > 0) { + text += tr("

Installed size: %1

").arg(KFormat().formatByteSize(quint64(installed.toDouble()))); + } text += "
"_L1 + record["support_description"_L1].toString().toHtmlEscaped() + "
"_L1; text += "
    "_L1; for (const auto &entry : record["plan"_L1].toObject()["package_changes"_L1].toArray()) { @@ -196,6 +210,11 @@ public: auto plan = update["details"_L1].toObject(); plan["base"_L1] = status["booted"_L1].toObject()["checksum"_L1]; plan["target"_L1] = update["target"_L1]; + // Sizes are reported by the refresh result and are also part of the + // persisted details record; prefer the fresh top-level values. + for (const auto &key : {QStringLiteral("download_size"), QStringLiteral("installed_size")}) { + if (update.contains(key)) plan.insert(key, update.value(key)); + } QString state = update["state"_L1].toString(); if (state.isEmpty()) state = QStringLiteral("current"); if (!pending["deployment_id"_L1].toString().isEmpty()) state = QStringLiteral("pending"); diff --git a/integrations/gnome-software/gs-plugin-archipelago.c b/integrations/gnome-software/gs-plugin-archipelago.c index 4891527..766d2ce 100644 --- a/integrations/gnome-software/gs-plugin-archipelago.c +++ b/integrations/gnome-software/gs-plugin-archipelago.c @@ -152,10 +152,15 @@ list_thread (GTask *task, gpointer source, gpointer task_data, GCancellable *can gs_app_add_quirk (app, GS_APP_QUIRK_NEEDS_REBOOT); gs_app_add_quirk (app, GS_APP_QUIRK_NOT_REVIEWABLE); gs_app_add_icon (app, icon); + gs_app_set_license (app, GS_APP_QUALITY_HIGHEST, "MIT"); /* Staging runs online; reboot only activates the completed deployment. */ gs_app_set_state (app, g_str_equal (state, "applying") ? GS_APP_STATE_INSTALLING : g_str_equal (state, "downloading") ? GS_APP_STATE_DOWNLOADING : GS_APP_STATE_UPDATABLE_LIVE); - gs_app_set_size_download (app, json_object_get_boolean_member_with_default (record, "downloaded", FALSE) ? GS_SIZE_TYPE_VALID : GS_SIZE_TYPE_UNKNOWN, 0); + gint64 download_size = json_object_get_int_member_with_default (plan, "download_size", 0); + if (download_size > 0) + gs_app_set_size_download (app, GS_SIZE_TYPE_VALID, (guint64) download_size); + else + gs_app_set_size_download (app, GS_SIZE_TYPE_UNKNOWN, 0); JsonArray *changes = json_object_get_array_member (plan, "package_changes"); for (guint i = 0; changes && i < json_array_get_length (changes); i++) { JsonObject *change = json_array_get_object_element (changes, i); @@ -171,7 +176,7 @@ list_thread (GTask *task, gpointer source, gpointer task_data, GCancellable *can gs_app_set_bundle_kind (package, AS_BUNDLE_KIND_PACKAGE); gs_app_set_scope (package, AS_COMPONENT_SCOPE_SYSTEM); /* Informational package diff; its bytes belong to the parent OSTree image. */ - gs_app_set_size_download (package, GS_SIZE_TYPE_VALID, 0); + gs_app_set_size_download (package, GS_SIZE_TYPE_UNKNOWN, 0); gs_app_set_version (package, old); gs_app_set_update_version (package, new ? new : (is_ru () ? "будет удалён" : "will be removed")); gs_app_add_related (app, package); @@ -198,6 +203,7 @@ list_thread (GTask *task, gpointer source, gpointer task_data, GCancellable *can gs_app_add_quirk (app, GS_APP_QUIRK_NEEDS_REBOOT); gs_app_add_quirk (app, GS_APP_QUIRK_NOT_REVIEWABLE); gs_app_add_icon (app, icon); + gs_app_set_license (app, GS_APP_QUALITY_HIGHEST, "MIT"); gs_app_set_size_download (app, GS_SIZE_TYPE_VALID, 0); gs_app_set_state (app, GS_APP_STATE_UPDATABLE); gs_app_list_add (list, app); diff --git a/integrations/gnome-software/system-bus.h b/integrations/gnome-software/system-bus.h index bdb831a..fdeb0f3 100644 --- a/integrations/gnome-software/system-bus.h +++ b/integrations/gnome-software/system-bus.h @@ -120,6 +120,15 @@ static JsonObject *bus_status(GError **error) json_object_set_string_member(plan, "base", bus_string(booted, "checksum")); json_object_set_string_member(plan, "target", bus_string(update, "target")); g_autoptr(GVariant) details = update ? g_variant_lookup_value(update, "details", G_VARIANT_TYPE_VARDICT) : NULL; + /* Image sizes are recorded in the signed target commit. Older targets + * predate them, so absence stays unknown instead of a zero-byte update. */ + const gchar *size_keys[] = {"download_size", "installed_size"}; + for (guint k = 0; k < G_N_ELEMENTS(size_keys); k++) { + guint64 bytes = 0; + if ((update && g_variant_lookup(update, size_keys[k], "t", &bytes)) || + (details && g_variant_lookup(details, size_keys[k], "t", &bytes))) + json_object_set_int_member(plan, size_keys[k], (gint64) bytes); + } g_autoptr(GVariant) changes = details ? g_variant_lookup_value(details, "package_changes", G_VARIANT_TYPE("aa{sv}")) : NULL; JsonArray *array = json_array_new(); if (changes) for (gsize i = 0; i < g_variant_n_children(changes); i++) { diff --git a/integrations/gnome-software/test-plugin.c b/integrations/gnome-software/test-plugin.c index dd76fc0..3d8eae5 100644 --- a/integrations/gnome-software/test-plugin.c +++ b/integrations/gnome-software/test-plugin.c @@ -49,6 +49,8 @@ static void method(GDBusConnection *bus, const gchar *sender, const gchar *path, g_variant_builder_add(&update, "{sv}", "details", g_variant_builder_end(&details)); g_variant_builder_add(&update, "{sv}", "state", g_variant_new_string("available")); g_variant_builder_add(&update, "{sv}", "target", g_variant_new_string(target)); + g_variant_builder_add(&update, "{sv}", "download_size", g_variant_new_uint64(1414614430)); + g_variant_builder_add(&update, "{sv}", "installed_size", g_variant_new_uint64(2092868303)); g_variant_builder_add(&status, "{sv}", "update", g_variant_builder_end(&update)); g_variant_builder_add(&status, "{sv}", "booted", map1("checksum", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")); g_dbus_method_invocation_return_value(invocation, g_variant_new("(a{sv})", &status)); @@ -142,6 +144,12 @@ int main(void) g_assert_true(gs_app_has_quirk(app, GS_APP_QUIRK_NEEDS_REBOOT)); g_assert_cmpuint(gs_app_list_length(gs_app_get_related(app)), ==, 1); g_assert_nonnull(strstr(gs_app_get_update_details_markup(app), "linux")); + /* Software centers show the image size before any download; the licence is + * static distributor metadata, not part of the transaction payload. */ + guint64 download = 0; + g_assert_cmpint(gs_app_get_size_download(app, &download), ==, GS_SIZE_TYPE_VALID); + g_assert_cmpuint(download, ==, 1414614430); + g_assert_cmpstr(gs_app_get_license(app), ==, "MIT"); app_progress = g_array_new(FALSE, FALSE, sizeof(guint)); related_progress = g_array_new(FALSE, FALSE, sizeof(guint)); g_signal_connect(app, "notify::progress", G_CALLBACK(record_progress), app_progress); diff --git a/src/service/client_output.rs b/src/service/client_output.rs index 492a01e..af98474 100644 --- a/src/service/client_output.rs +++ b/src/service/client_output.rs @@ -140,6 +140,8 @@ fn field_label(key: &str, ru: bool) -> String { "overlays" => ("Доступные оверлеи", "Available overlays"), "selection" => ("Выбранные оверлеи", "Selected overlays"), "generations" => ("История расширений", "Extension history"), "reboot_required" => ("Нужна перезагрузка", "Reboot required"), "warnings" => ("Предупреждения", "Warnings"), "message" => ("Сообщение", "Message"), + "download_size" => ("Размер загрузки (байт)", "Download size (bytes)"), + "installed_size" => ("Размер после установки (байт)", "Installed size (bytes)"), _ => return key.replace('_', " "), }; if ru { pair.0.into() } else { pair.1.into() } diff --git a/src/service/mod.rs b/src/service/mod.rs index 047b2c4..a83fa60 100644 --- a/src/service/mod.rs +++ b/src/service/mod.rs @@ -196,6 +196,13 @@ impl Manager { update.insert("details_state".into(), text("ready")); update.insert("details".into(), dictionary(wire::map(&details.result)?)); } + // Image sizes come from the signed target commit metadata, so they + // are available before any image bytes are downloaded. + for key in ["download_size", "installed_size"] { + if let Some(size) = record.result[key].as_u64() { + update.insert(key.into(), size.into()); + } + } if let Some(active) = journal.records().find(|r| !r.state.terminal() && r.target == record.target && matches!(r.binding.method, protocol::Method::Download | protocol::Method::Stage)) { update.insert("state".into(), text(if active.binding.method == protocol::Method::Download { "downloading" } else { "applying" })); diff --git a/src/updates/managed.rs b/src/updates/managed.rs index 6ae941c..6b0bf92 100644 --- a/src/updates/managed.rs +++ b/src/updates/managed.rs @@ -160,6 +160,21 @@ fn verified_path(context: &Context, target: &str) -> std::path::PathBuf { Path::new(SERVICE).join("verified-targets").join(format!("{}.json", storage::hash(format!("{}:{target}", context.trust).as_bytes()))) } +/// Parse a decimal size recorded as a commit metadata string. `ostree show +/// --print-metadata-key` quotes strings, so trim the GVariant text form. +fn recorded_size(raw: &str) -> Option { + raw.trim().trim_matches('\'').parse::().ok().filter(|size| *size > 0) +} + +/// Transfer and installed size of a published image commit. The builder records +/// both while composing the tree; clients only receive commit metadata before +/// they decide to update, so the numbers must travel inside the signed commit. +fn image_sizes(worker: &Worker, commit: &str) -> (Option, Option) { + let read = |key: &str| repo(worker, &["show", &format!("--print-metadata-key={key}"), commit], false, true) + .ok().and_then(|raw| recorded_size(&raw)); + (read("archipelago.image-size"), read("archipelago.image-installed-size")) +} + fn clean_base_from_intent(managed: &str, intent: Option<&Value>) -> Result { if !digest(managed) { return Err(fail("Invalid managed base identity")); } let Some(intent) = intent else { return Ok(managed.into()); }; @@ -206,7 +221,9 @@ fn refresh_locked(worker: &Worker, binding: &Value, context: &Context, offline: let summary = repo(worker, &["remote", "summary", REMOTE], true, false)?; let target = summary_commit(&summary, &context.track).map_err(|_| Failure::new(ErrorCode::NoTrack, "Configured signed image track is absent"))?; repo(worker, &["pull", "--commit-metadata-only", "--depth=0", REMOTE, &target], true, false)?; + let (download_size, installed_size) = image_sizes(worker, &target); let value = json!({"version":1,"context":context,"binding":binding,"target":target, + "download_size":download_size,"installed_size":installed_size, "checked_at_usec":journal::now().map_err(|_| fail("Clock unavailable"))?}); storage::directory(&Path::new(SERVICE).join("verified-targets"))?; storage::atomic(&verified_path(context, &target), &value)?; @@ -223,7 +240,8 @@ pub(crate) fn refresh(worker: &Worker, offline: bool, force: bool) -> Result Result { @@ -266,6 +284,7 @@ pub(crate) fn prepare(worker: &Worker, target: &str, offline: bool, details: boo return Err(Failure::new(ErrorCode::PlanStale, "Target is not newer than the selected managed base")); } if details { + let (download_size, installed_size) = image_sizes(worker, target); if repo(worker, &["cat", target, INVENTORY], false, true).is_err() { repo(worker, &["pull", "--depth=0", &format!("--subpath={INVENTORY}"), REMOTE, target], true, offline)?; } @@ -273,7 +292,8 @@ pub(crate) fn prepare(worker: &Worker, target: &str, offline: bool, details: boo let after = repo(worker, &["cat", target, INVENTORY], false, true)?; let changes = crate::package_diff::between(&before, &after).map_err(|_| fail("Invalid package inventory"))?; return Ok(json!({"outcome":"details-ready","changed":false,"target":target, - "booted":context.booted,"pending":context.pending.as_deref().unwrap_or(""),"package_changes":changes})); + "booted":context.booted,"pending":context.pending.as_deref().unwrap_or(""),"package_changes":changes, + "download_size":download_size,"installed_size":installed_size})); } if let Some(intent) = overlay_intent { return crate::service::overlays::prepare_update(worker, target, &context, &intent, owner_uid, offline); @@ -407,6 +427,15 @@ mod compatibility_tests { assert_eq!(clean_base_from_intent(&local, Some(&empty)).unwrap(), upstream); } + #[test] + fn recorded_commit_sizes_accept_only_positive_decimals() { + assert_eq!(recorded_size("'1414614430'\n"), Some(1414614430)); + assert_eq!(recorded_size("2092868303"), Some(2092868303)); + assert_eq!(recorded_size("'0'"), None); + assert_eq!(recorded_size("'not a size'"), None); + assert_eq!(recorded_size(""), None); + } + #[test] fn malformed_metadata_does_not_fall_back_to_a_clean_host() { for intent in [json!({"version":1,"clean_base":"a".repeat(64),"selection":[]}),