Skip to content

Commit

Permalink
WIP: (RFC) status: Render jigdo mode using package NEVRA
Browse files Browse the repository at this point in the history
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 ♲📦:
coreos#1081 (comment)

Basically, we can use the `NEVRA` of the jigdoRPM instead of displaying
`Version`. 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.
  • Loading branch information
cgwalters committed Feb 11, 2018
1 parent 6c933bb commit 6bc3e86
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 21 deletions.
37 changes: 33 additions & 4 deletions src/app/rpmostree-builtin-status.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -451,15 +470,25 @@ 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;
if (!g_variant_dict_lookup (dict, "live-replaced", "&s", &live_replaced))
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);
Expand All @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/daemon/rpmostree-sysroot-upgrader.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
46 changes: 29 additions & 17 deletions src/daemon/rpmostreed-deployment-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
35 changes: 35 additions & 0 deletions src/libpriv/rpmostree-origin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions src/libpriv/rpmostree-origin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 6bc3e86

Please sign in to comment.