status: Render jigdo mode using package NEVRA

What's happened up till now is supporting `rojig://` in the same way as
`ostree://`.  However, part of the high level goal here is to reduce
the need for system administrators to understand ostree.

This patch set starts to introduce some of the ideas for client-side
changes as part of jigdo ♲📦:
https://github.com/projectatomic/rpm-ostree/issues/1081#issuecomment-348540604

Concretely, we start using `${repo}:${nevra}` instead of `rojig://`.

(v2): Keep `Version` (plus timestamp) as a split out field for maximum visual aid.

Also, let's be opinionated here and entirely drop the `Commit` checksum by
default. I believe the Cockpit guys were right here - versions are for humans.
The fact that we have a checksum is powerful; and we still show it with `status
-v`. The way I think of it is: the checksum shows we're really an image system.
But we don't need to show it by default.

Closes: #1240
Approved by: jlebon
This commit is contained in:
Colin Walters 2018-02-11 12:52:16 -05:00 committed by Atomic Bot
parent 0729487ae5
commit a0b6d241d2
6 changed files with 128 additions and 20 deletions

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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-imported-evr", NULL);
g_autofree char *jigdo_arch = g_key_file_get_string (origin->kf, "origin", "jigdo-imported-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-imported-evr", dnf_package_get_evr (package));
g_key_file_set_string (origin->kf, "origin", "jigdo-imported-arch", dnf_package_get_arch (package));
}
gboolean
rpmostree_origin_set_rebase (RpmOstreeOrigin *origin,
const char *new_refspec,
@ -429,6 +475,8 @@ rpmostree_origin_set_rebase (RpmOstreeOrigin *origin,
case RPMOSTREE_REFSPEC_TYPE_OSTREE:
{
g_key_file_remove_key (origin->kf, "origin", "rojig", NULL);
g_key_file_remove_key (origin->kf, "origin", "jigdo-imported-evr", NULL);
g_key_file_remove_key (origin->kf, "origin", "jigdo-imported-arch", NULL);
const char *refspec_key =
g_key_file_has_key (origin->kf, "origin", "baserefspec", NULL) ?
"baserefspec" : "refspec";

View File

@ -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,

View File

@ -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"