Skip to content

Commit

Permalink
Deployment: add endoflife
Browse files Browse the repository at this point in the history
When commit metadata contains ostree.endoflife attribute,
its information will be added to the deployment Variant,
which will later be shown as a red & bold message when
'rpm-ostree status' command is called.
  • Loading branch information
peterbaouoft committed Jul 26, 2017
1 parent 5763027 commit cc63bcb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/app/rpmostree-builtin-status.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,16 @@ 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 endoflife attribute in the deployment */
g_variant_dict_lookup (dict, "endoflife", "&s", &end_of_life_string);

if (end_of_life_string)
{
g_print ("%s%s", red_prefix, bold_prefix);
print_kv ("EndOfLife", max_key_len, end_of_life_string);
g_print ("%s%s", bold_suffix, red_suffix);
}
}

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

static void
variant_add_metadata_attribute (GVariantDict *dict,
const gchar *attribute,
const gchar *new_attribute,
GVariant *commit)
{
g_autofree gchar *attribute_string_value = NULL;
g_autoptr(GVariant) 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)
g_variant_dict_insert (dict, new_attribute ?: attribute, "s", attribute_string_value);
}
}

static void
variant_add_commit_details (GVariantDict *dict,
const char *prefix,
Expand Down Expand Up @@ -227,9 +244,14 @@ rpmostreed_deployment_generate_variant (OstreeSysroot *sysroot,

g_variant_dict_insert (&dict, "base-checksum", "s", base_checksum);
variant_add_commit_details (&dict, "base-", base_commit);
/* for layered commits, check if their base commit has end of life attribute */
variant_add_metadata_attribute (&dict, OSTREE_COMMIT_META_KEY_ENDOFLIFE, "endoflife", base_commit);
}
else
base_checksum = g_strdup (csum);
{
base_checksum = g_strdup (csum);
variant_add_metadata_attribute (&dict, OSTREE_COMMIT_META_KEY_ENDOFLIFE, "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 cc63bcb

Please sign in to comment.