daemon/utils: Allow unfiltered deployment variant

For the history work, I'd like to be able to retrieve the full GVariant,
which includes the whole unfiltered layered and base commit metadata. So
let's add an argument to allow not filtering those.

Closes: #1823
Approved by: mike-nguyen
This commit is contained in:
Jonathan Lebon 2019-05-01 10:04:00 -04:00 committed by Atomic Bot
parent 0aded8a85b
commit fcd2afaade
4 changed files with 19 additions and 13 deletions

View File

@ -235,12 +235,14 @@ filter_commit_meta (GVariant *commit_meta)
return g_variant_dict_end (&dict);
}
GVariant *
rpmostreed_deployment_generate_variant (OstreeSysroot *sysroot,
GVariant*
rpmostreed_deployment_generate_variant (OstreeSysroot *sysroot,
OstreeDeployment *deployment,
const char *booted_id,
OstreeRepo *repo,
GError **error)
const char *booted_id,
OstreeRepo *repo,
gboolean filter,
GError **error)
{
const gchar *osname = ostree_deployment_get_osname (deployment);
const gchar *csum = ostree_deployment_get_csum (deployment);
@ -297,7 +299,8 @@ rpmostreed_deployment_generate_variant (OstreeSysroot *sysroot,
/* See below for base commit metadata */
g_autoptr(GVariant) layered_metadata = g_variant_get_child_value (commit, 0);
g_variant_dict_insert (&dict, "layered-commit-meta", "@a{sv}",
filter_commit_meta (layered_metadata));
filter ? filter_commit_meta (layered_metadata)
: layered_metadata);
}
else
{
@ -311,7 +314,7 @@ rpmostreed_deployment_generate_variant (OstreeSysroot *sysroot,
*/
{ g_autoptr(GVariant) base_meta = g_variant_get_child_value (base_commit, 0);
g_variant_dict_insert (&dict, "base-commit-meta", "@a{sv}",
filter_commit_meta (base_meta));
filter ? filter_commit_meta (base_meta) : base_meta);
}
variant_add_commit_details (&dict, NULL, commit);

View File

@ -39,6 +39,7 @@ GVariant * rpmostreed_deployment_generate_variant (OstreeSysroot *sysroo
OstreeDeployment *deployment,
const char *booted_id,
OstreeRepo *repo,
gboolean filter,
GError **error);
GVariant * rpmostreed_commit_generate_cached_details_variant (OstreeDeployment *deployment,

View File

@ -1715,8 +1715,9 @@ rpmostreed_os_load_internals (RpmostreedOS *self, GError **error)
if (booted_deployment && g_strcmp0 (ostree_deployment_get_osname (booted_deployment), name) == 0)
{
booted_variant =
g_variant_ref_sink (rpmostreed_deployment_generate_variant (ot_sysroot, booted_deployment, booted_id,
ot_repo, error));
g_variant_ref_sink (
rpmostreed_deployment_generate_variant (ot_sysroot, booted_deployment,
booted_id, ot_repo, TRUE, error));
if (!booted_variant)
return FALSE;
booted_id = rpmostreed_deployment_generate_id (booted_deployment);
@ -1738,7 +1739,7 @@ rpmostreed_os_load_internals (RpmostreedOS *self, GError **error)
g_variant_ref_sink (rpmostreed_deployment_generate_variant (ot_sysroot,
pending_deployment,
booted_id,
ot_repo, error));
ot_repo, TRUE, error));
if (!default_variant)
return FALSE;
}
@ -1749,8 +1750,9 @@ rpmostreed_os_load_internals (RpmostreedOS *self, GError **error)
GVariant *rollback_variant = NULL; /* Floating */
if (rollback_deployment)
{
rollback_variant = rpmostreed_deployment_generate_variant (ot_sysroot, rollback_deployment,
booted_id, ot_repo, error);
rollback_variant =
rpmostreed_deployment_generate_variant (ot_sysroot, rollback_deployment, booted_id,
ot_repo, TRUE, error);
if (!rollback_variant)
return FALSE;
}

View File

@ -324,7 +324,7 @@ sysroot_populate_deployments_unlocked (RpmostreedSysroot *self,
OstreeDeployment *deployment = deployments->pdata[i];
GVariant *variant =
rpmostreed_deployment_generate_variant (self->ot_sysroot, deployment,
booted_id, self->repo, error);
booted_id, self->repo, TRUE, error);
if (!variant)
return glnx_prefix_error (error, "Reading deployment %u", i);