Skip to content

Commit

Permalink
Deployment: add ostree.endoflife
Browse files Browse the repository at this point in the history
When metadata contains ostree.endoflife attribute,
its information will be added to the deployment Variant,
which will later be shown with rpm-ostree status command
  • Loading branch information
peterbaouoft committed Jul 24, 2017
1 parent 5763027 commit b91ad0c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/app/rpmostree-builtin-status.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,12 @@ status_generic (RPMOSTreeSysroot *sysroot_proxy,
print_kv ("Unlocked", max_key_len, unlocked);
g_print ("%s%s", bold_suffix, red_suffix);
}
const char *end_of_life_string = NULL;
/* look for ostree.endoflife attribute in the deployment */
g_variant_dict_lookup (dict, "endoflife", "&s", &end_of_life_string);

if (end_of_life_string)
g_print ("\n end-of-life: %s", end_of_life_string);
}

return TRUE;
Expand Down
34 changes: 33 additions & 1 deletion src/daemon/rpmostreed-deployment-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,34 @@ rpmostreed_deployment_generate_blank_variant (void)
return g_variant_dict_end (&dict);
}

static void
variant_add_metadata_attribute (GVariantDict *dict,
const gchar *attribute,
GVariant *commit)
{
g_autoptr(GVariant) metadata = NULL;
g_autofree gchar *attribute_string_value = NULL;

metadata = g_variant_get_child_value (commit, 0);

if (metadata != NULL)
{
g_variant_lookup (metadata, attribute, "s", &attribute_string_value);
if (attribute_string_value != NULL)
{
/* for attributes starting with ostree., remove the prefix */
if(g_str_has_prefix (attribute, "ostree."))
{
const char *new_string = strchr (attribute, '.');
const char *new_attribute = new_string + 1;
g_variant_dict_insert (dict, new_attribute, "s", attribute_string_value);
}
else
g_variant_dict_insert (dict, attribute, "s", attribute_string_value);
}
}
}

static void
variant_add_commit_details (GVariantDict *dict,
const char *prefix,
Expand Down Expand Up @@ -229,7 +257,11 @@ rpmostreed_deployment_generate_variant (OstreeSysroot *sysroot,
variant_add_commit_details (&dict, "base-", base_commit);
}
else
base_checksum = g_strdup (csum);
{
base_checksum = g_strdup (csum);
/* we would not consider endoflife attribute for layered commits */
variant_add_metadata_attribute (&dict, "ostree.endoflife", commit);
}

sigs = rpmostreed_deployment_gpg_results (repo, refspec, base_checksum, &gpg_enabled);
variant_add_commit_details (&dict, NULL, commit);
Expand Down

0 comments on commit b91ad0c

Please sign in to comment.