diff --git a/src/app/rpmostree-builtin-status.c b/src/app/rpmostree-builtin-status.c index 985abb7b2d..afe9265545 100644 --- a/src/app/rpmostree-builtin-status.c +++ b/src/app/rpmostree-builtin-status.c @@ -417,7 +417,26 @@ print_deployments (RPMOSTreeSysroot *sysroot_proxy, if (!rpmostree_refspec_classify (origin_refspec, &refspectype, &refspec_data, error)) return FALSE; g_autofree char *canonrefspec = rpmostree_refspec_to_string (refspectype, refspec_data); - g_print ("%s", canonrefspec); + switch (refspectype) + { + case RPMOSTREE_REFSPEC_TYPE_OSTREE: + { + g_print ("%s", canonrefspec); + } + break; + case RPMOSTREE_REFSPEC_TYPE_ROJIG: + { + const char *jigdo_description = NULL; + g_variant_dict_lookup (dict, "jigdo-description", "&s", &jigdo_description); + if (jigdo_description) + g_print ("%s", jigdo_description); + else + { + g_print ("%s", canonrefspec); + } + } + break; + } } else g_print ("%s", checksum); @@ -451,7 +470,15 @@ print_deployments (RPMOSTreeSysroot *sysroot_proxy, g_assert (g_variant_dict_lookup (dict, "timestamp", "t", &t)); timestamp_string = rpmostree_timestamp_str_from_unix_utc (t); - rpmostree_print_timestamp_version (version_string, timestamp_string, max_key_len); + switch (refspectype) + { + case RPMOSTREE_REFSPEC_TYPE_OSTREE: + rpmostree_print_timestamp_version (version_string, timestamp_string, max_key_len); + break; + case RPMOSTREE_REFSPEC_TYPE_ROJIG: + rpmostree_print_kv ("Timestamp", max_key_len, timestamp_string); + break; + } if (!g_variant_dict_lookup (dict, "live-inprogress", "&s", &live_inprogress)) live_inprogress = NULL; @@ -459,7 +486,9 @@ print_deployments (RPMOSTreeSysroot *sysroot_proxy, live_replaced = NULL; const gboolean have_live_changes = live_inprogress || live_replaced; - if (is_locally_assembled) + const gboolean is_ostree_or_verbose = opt_verbose || refspectype == RPMOSTREE_REFSPEC_TYPE_OSTREE; + + if (is_locally_assembled && is_ostree_or_verbose) { if (have_live_changes) rpmostree_print_kv ("BootedBaseCommit", max_key_len, base_checksum); @@ -468,7 +497,7 @@ print_deployments (RPMOSTreeSysroot *sysroot_proxy, if (opt_verbose || have_any_live_overlay) rpmostree_print_kv ("Commit", max_key_len, checksum); } - else + else if (is_ostree_or_verbose) { if (have_live_changes) rpmostree_print_kv ("BootedCommit", max_key_len, checksum); diff --git a/src/daemon/rpmostree-sysroot-upgrader.c b/src/daemon/rpmostree-sysroot-upgrader.c index b6b62690f3..edf5c79914 100644 --- a/src/daemon/rpmostree-sysroot-upgrader.c +++ b/src/daemon/rpmostree-sysroot-upgrader.c @@ -471,10 +471,14 @@ rpmostree_sysroot_upgrader_pull_base (RpmOstreeSysrootUpgrader *self, /* We're also "pure" rpm-ostree jigdo - this adds assertions that we don't depsolve for example */ if (!rpmostree_context_prepare_jigdo (ctx, cancellable, error)) return FALSE; + DnfPackage *jigdo_pkg = rpmostree_context_get_jigdo_pkg (ctx); new_base_rev = g_strdup (rpmostree_context_get_jigdo_checksum (ctx)); gboolean jigdo_changed; /* Currently unused */ if (!rpmostree_context_execute_jigdo (ctx, &jigdo_changed, cancellable, error)) return FALSE; + + if (jigdo_changed) + rpmostree_origin_set_jigdo_description (self->origin, jigdo_pkg); } } diff --git a/src/daemon/rpmostreed-deployment-utils.c b/src/daemon/rpmostreed-deployment-utils.c index 38b438f998..85e777d70f 100644 --- a/src/daemon/rpmostreed-deployment-utils.c +++ b/src/daemon/rpmostreed-deployment-utils.c @@ -301,28 +301,40 @@ rpmostreed_deployment_generate_variant (OstreeSysroot *sysroot, gboolean gpg_enabled = FALSE; g_autoptr(GVariant) sigs = NULL; - if (refspec_type == RPMOSTREE_REFSPEC_TYPE_OSTREE) + switch (refspec_type) { - if (!rpmostreed_deployment_gpg_results (repo, refspec, base_checksum, &sigs, &gpg_enabled, error)) - return NULL; + case RPMOSTREE_REFSPEC_TYPE_OSTREE: + { + if (!rpmostreed_deployment_gpg_results (repo, refspec, base_checksum, &sigs, &gpg_enabled, error)) + return NULL; - g_autofree char *pending_base_commitrev = NULL; - if (!ostree_repo_resolve_rev (repo, refspec, TRUE, - &pending_base_commitrev, error)) - return NULL; + g_autofree char *pending_base_commitrev = NULL; + if (!ostree_repo_resolve_rev (repo, refspec, TRUE, + &pending_base_commitrev, error)) + return NULL; - if (pending_base_commitrev && !g_str_equal (pending_base_commitrev, base_checksum)) - { - g_autoptr(GVariant) pending_base_commit = NULL; + if (pending_base_commitrev && !g_str_equal (pending_base_commitrev, base_checksum)) + { + g_autoptr(GVariant) pending_base_commit = NULL; - if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, - pending_base_commitrev, &pending_base_commit, - error)) - return NULL; + if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, + pending_base_commitrev, &pending_base_commit, + error)) + return NULL; - g_variant_dict_insert (&dict, "pending-base-checksum", "s", pending_base_commitrev); - variant_add_commit_details (&dict, "pending-base-", pending_base_commit); - } + g_variant_dict_insert (&dict, "pending-base-checksum", "s", pending_base_commitrev); + variant_add_commit_details (&dict, "pending-base-", pending_base_commit); + } + } + break; + case RPMOSTREE_REFSPEC_TYPE_ROJIG: + { + const char *jigdo_description = rpmostree_origin_get_jigdo_description (origin); + /* For backwards compat allow it to not exist */ + if (jigdo_description) + g_variant_dict_insert (&dict, "jigdo-description", "s", jigdo_description); + } + break; } g_autofree char *live_inprogress = NULL; diff --git a/src/libpriv/rpmostree-origin.c b/src/libpriv/rpmostree-origin.c index 764df615aa..57fd437a32 100644 --- a/src/libpriv/rpmostree-origin.c +++ b/src/libpriv/rpmostree-origin.c @@ -40,6 +40,8 @@ struct RpmOstreeOrigin { /* Version data that goes along with the refspec */ char *cached_override_commit; char *cached_jigdo_version; + /* The NEVRA of the jigdoRPM */ + char *cached_jigdo_description; char *cached_unconfigured_state; char **cached_initramfs_args; @@ -141,6 +143,7 @@ rpmostree_origin_parse_keyfile (GKeyFile *origin, ret->refspec_type = RPMOSTREE_REFSPEC_TYPE_ROJIG; ret->cached_refspec = g_steal_pointer (&jigdo_spec); ret->cached_jigdo_version = g_key_file_get_string (ret->kf, "origin", "jigdo-version", NULL); + ret->cached_jigdo_description = g_key_file_get_string (ret->kf, "origin", "jigdo-description", NULL); } if (!parse_packages_strv (ret->kf, "packages", "requested", FALSE, @@ -214,6 +217,12 @@ rpmostree_origin_get_jigdo_version (RpmOstreeOrigin *origin) return origin->cached_jigdo_version; } +const char * +rpmostree_origin_get_jigdo_description (RpmOstreeOrigin *origin) +{ + return origin->cached_jigdo_description; +} + GHashTable * rpmostree_origin_get_packages (RpmOstreeOrigin *origin) { @@ -388,6 +397,32 @@ rpmostree_origin_set_override_commit (RpmOstreeOrigin *origin, origin->cached_override_commit = g_strdup (checksum); } +/* The jigdoRPM is highly special; it doesn't live in the rpmdb for example, as + * that would be fully circular. Yet, it's of critical importance to the whole + * system; we want to render it on the client. For now, what we do is stick the + * NEVRA in the origin. That's the only data we really care about. + * + * Since the data we really want is repo + NEVRA, we parse the refspec and + * concatenate those here for convenience of callers. + * + * Perhaps down the line, what we really want to do is store the whole Header at + * least somewhere hooked off the deployment (or perhaps imported itself into + * the pkgcache)? + */ +void +rpmostree_origin_set_jigdo_description (RpmOstreeOrigin *origin, + DnfPackage *package) +{ + g_assert_cmpint (origin->refspec_type, ==, RPMOSTREE_REFSPEC_TYPE_ROJIG); + const char *colon = strchr (origin->cached_refspec, ':'); + g_assert (colon); + const char *repo = strndupa (origin->cached_refspec, colon - origin->cached_refspec); + const char *nevra = dnf_package_get_nevra (package); + g_free (origin->cached_jigdo_description); + origin->cached_jigdo_description = g_strconcat (repo, ":", nevra, NULL); + g_key_file_set_string (origin->kf, "origin", "jigdo-description", origin->cached_jigdo_description); +} + gboolean rpmostree_origin_set_rebase (RpmOstreeOrigin *origin, const char *new_refspec, diff --git a/src/libpriv/rpmostree-origin.h b/src/libpriv/rpmostree-origin.h index c09e3359da..5de33b22fb 100644 --- a/src/libpriv/rpmostree-origin.h +++ b/src/libpriv/rpmostree-origin.h @@ -67,6 +67,9 @@ rpmostree_origin_get_full_refspec (RpmOstreeOrigin *origin, const char * rpmostree_origin_get_jigdo_version (RpmOstreeOrigin *origin); +const char * +rpmostree_origin_get_jigdo_description (RpmOstreeOrigin *origin); + GHashTable * rpmostree_origin_get_packages (RpmOstreeOrigin *origin); @@ -116,6 +119,9 @@ void rpmostree_origin_set_override_commit (RpmOstreeOrigin *origin, const char *checksum, const char *version); +void +rpmostree_origin_set_jigdo_description (RpmOstreeOrigin *origin, + DnfPackage *package); gboolean rpmostree_origin_set_rebase (RpmOstreeOrigin *origin,