diff --git a/src/app/rpmostree-builtin-status.c b/src/app/rpmostree-builtin-status.c index 3ec588d534..eaf6bfabe4 100644 --- a/src/app/rpmostree-builtin-status.c +++ b/src/app/rpmostree-builtin-status.c @@ -469,7 +469,40 @@ 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: + { + g_autoptr(GVariant) jigdo_description = NULL; + g_variant_dict_lookup (dict, "jigdo-description", "@a{sv}", &jigdo_description); + if (jigdo_description) + { + g_autoptr(GVariantDict) dict = g_variant_dict_new (jigdo_description); + const char *repo = NULL; + g_variant_dict_lookup (dict, "repo", "&s", &repo); + const char *name = NULL; + g_variant_dict_lookup (dict, "name", "&s", &name); + const char *evr = NULL; + g_variant_dict_lookup (dict, "evr", "&s", &evr); + const char *arch = NULL; + g_variant_dict_lookup (dict, "arch", "&s", &arch); + g_assert (repo && name); + g_print ("%s:%s", repo, name); + if (evr && arch) + g_print ("-%s.%s", evr, arch); + } + else + { + g_print ("%s", canonrefspec); + } + } + break; + } } else g_print ("%s", checksum); @@ -511,7 +544,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); @@ -520,7 +555,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 f5972bec48..025a9246de 100644 --- a/src/daemon/rpmostree-sysroot-upgrader.c +++ b/src/daemon/rpmostree-sysroot-upgrader.c @@ -472,10 +472,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 327efb4bb2..a144906c23 100644 --- a/src/daemon/rpmostreed-deployment-utils.c +++ b/src/daemon/rpmostreed-deployment-utils.c @@ -301,28 +301,38 @@ 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: + { + g_variant_dict_insert (&dict, "jigdo-description", "@a{sv}", + rpmostree_origin_get_jigdo_description (origin)); + } + break; } g_autofree char *live_inprogress = NULL; diff --git a/src/libpriv/rpmostree-origin.c b/src/libpriv/rpmostree-origin.c index f10a4c54b7..1553b26671 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, @@ -221,6 +224,31 @@ rpmostree_origin_get_jigdo_version (RpmOstreeOrigin *origin) return origin->cached_jigdo_version; } +/* Returns a new (floating) variant of type a{sv} with fields: + * - s: repo + * - s: name + * - s: evr + * - s: arch + * Note this type is exposed as DBus API. + */ +GVariant * +rpmostree_origin_get_jigdo_description (RpmOstreeOrigin *origin) +{ + const char *colon = strchr (origin->cached_refspec, ':'); + g_assert (colon); + const char *repo = strndupa (origin->cached_refspec, colon - origin->cached_refspec); + g_autofree char *jigdo_evr = g_key_file_get_string (origin->kf, "origin", "jigdo-evr", NULL); + g_autofree char *jigdo_arch = g_key_file_get_string (origin->kf, "origin", "jigdo-arch", NULL); + g_autoptr(GVariantBuilder) builder = g_variant_builder_new (G_VARIANT_TYPE_VARDICT); + g_variant_builder_add (builder, "{sv}", "repo", g_variant_new_string (repo)); + g_variant_builder_add (builder, "{sv}", "name", g_variant_new_string (colon + 1)); + if (jigdo_evr) + g_variant_builder_add (builder, "{sv}", "evr", g_variant_new_string (jigdo_evr)); + if (jigdo_arch) + g_variant_builder_add (builder, "{sv}", "arch", g_variant_new_string (jigdo_arch)); + return g_variant_builder_end (builder); +} + GHashTable * rpmostree_origin_get_packages (RpmOstreeOrigin *origin) { @@ -407,6 +435,24 @@ rpmostree_origin_set_jigdo_version (RpmOstreeOrigin *origin, origin->cached_jigdo_version = g_strdup (version); } +/* 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 + * EVR+A in the origin. That's the only data we really care about. + * + * 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); + g_key_file_set_string (origin->kf, "origin", "jigdo-evr", dnf_package_get_evr (package)); + g_key_file_set_string (origin->kf, "origin", "jigdo-arch", dnf_package_get_arch (package)); +} + 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 969fb54f0c..06cdf666cb 100644 --- a/src/libpriv/rpmostree-origin.h +++ b/src/libpriv/rpmostree-origin.h @@ -69,6 +69,9 @@ gboolean rpmostree_origin_is_rojig (RpmOstreeOrigin *origin); const char * rpmostree_origin_get_jigdo_version (RpmOstreeOrigin *origin); +GVariant * +rpmostree_origin_get_jigdo_description (RpmOstreeOrigin *origin); + GHashTable * rpmostree_origin_get_packages (RpmOstreeOrigin *origin); @@ -118,6 +121,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); void rpmostree_origin_set_jigdo_version (RpmOstreeOrigin *origin, diff --git a/tests/vmcheck/test-jigdo-client.sh b/tests/vmcheck/test-jigdo-client.sh index db4ce7a0d5..015b1e6b31 100755 --- a/tests/vmcheck/test-jigdo-client.sh +++ b/tests/vmcheck/test-jigdo-client.sh @@ -53,3 +53,8 @@ vm_assert_status_jq '.deployments[0].origin|startswith("rojig://fahc:fedora-atom '.deployments[0].version == "'${prev_version}'"' echo "ok jigdo client deploy" + +vm_cmd rpm-ostree status > status.txt +assert_file_has_content_literal status.txt 'fahc:fedora-atomic-host-'${prev_version}'-1.fc27.x86_64' + +echo "ok jigdo status"