daemon: Add commit metadata to deployment properties

In another PR I did the manual bridging of commit metadata to deployment
property, but that's annoying. Let's just bridge all commit metadata.

Closes: #1069
Approved by: jlebon
This commit is contained in:
Colin Walters 2017-10-23 15:05:19 -04:00 committed by Atomic Bot
parent cdfba8e131
commit 9ec45d3c89
3 changed files with 22 additions and 10 deletions

View File

@ -231,28 +231,36 @@ rpmostreed_deployment_generate_variant (OstreeSysroot *sysroot,
&replaced_base_pkgs, error))
return NULL;
g_autoptr(GVariant) base_commit = NULL;
if (is_layered)
{
g_autoptr(GVariant) base_commit = NULL;
if (!ostree_repo_load_variant (repo,
OSTREE_OBJECT_TYPE_COMMIT,
base_checksum,
&base_commit,
error))
if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT,
base_checksum, &base_commit, error))
return NULL;
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);
/* 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}", layered_metadata);
}
else
{
base_commit = g_variant_ref (commit);
base_checksum = g_strdup (csum);
variant_add_metadata_attribute (&dict, OSTREE_COMMIT_META_KEY_ENDOFLIFE, "endoflife", commit);
}
/* We used to bridge individual keys, but that was annoying; just pass through all
* of the commit metadata.
*/
{ g_autoptr(GVariant) base_meta = g_variant_get_child_value (commit, 0);
g_variant_dict_insert (&dict, "base-commit-meta", "@a{sv}", base_meta);
}
sigs = rpmostreed_deployment_gpg_results (repo, refspec, base_checksum, &gpg_enabled);
variant_add_commit_details (&dict, NULL, commit);

View File

@ -31,8 +31,10 @@ vm_assert_status_jq \
'.deployments[0]["requested-packages"]' \
'.deployments[0]["requested-local-packages"]' \
'.deployments[0]["base-removals"]' \
'.deployments[0]["requested-base-removals"]'
echo "ok empty pkg arrays in status json"
'.deployments[0]["requested-base-removals"]' \
'.deployments[0]["base-commit-meta"]' \
'.deployments[0]["layered-commit-meta"]|not'
echo "ok empty pkg arrays, and commit meta correct in status json"
# Be sure an unprivileged user exists and that we can SSH into it. This is a bit
# underhanded, but we need a bona fide user session to verify non-priv status,

View File

@ -63,7 +63,9 @@ echo "ok pkg-add foo"
vm_reboot
vm_assert_status_jq \
'.deployments[0]["base-checksum"]' \
'.deployments[0]["pending-base-checksum"]|not'
'.deployments[0]["pending-base-checksum"]|not' \
'.deployments[0]["base-commit-meta"]' \
'.deployments[0]["layered-commit-meta"]["rpmostree.clientlayer_version"] == 2'
vm_assert_layered_pkg foo-1.0 present
echo "ok pkg foo added"