status: Render ostree metadata source-title key

Depends: https://github.com/ostreedev/ostree/pull/1296

As I mention in the commit there, I see two uses for this in rpm-ostree; first
in our test suite, and second for OCI-built image imports.

I also took a step further here and inject an `original-origin` metadata
key, though we aren't actually using that yet.  The problem I'm trying
to solve there is that repeated `make vmoverlay` starts chaining things up,
but that gets very confusing.  I think we should always have `vmoverlay` unwind
back to the base ref.  (Or at least do that by default)

Closes: #1069
Approved by: jlebon
This commit is contained in:
Colin Walters 2017-10-19 15:31:50 -04:00 committed by Atomic Bot
parent 9ec45d3c89
commit 1f31cbb99a
3 changed files with 28 additions and 3 deletions

View File

@ -216,6 +216,8 @@ status_generic (RPMOSTreeSysroot *sysroot_proxy,
{
g_autoptr(GVariant) child = g_variant_iter_next_value (&iter);
g_autoptr(GVariantDict) dict = NULL;
g_autoptr(GVariantDict) commit_meta_dict = NULL;
g_autoptr(GVariantDict) layered_commit_meta_dict = NULL;
gboolean is_locally_assembled = FALSE;
g_autofree const gchar **origin_packages = NULL;
g_autofree const gchar **origin_requested_packages = NULL;
@ -307,6 +309,23 @@ status_generic (RPMOSTreeSysroot *sysroot_proxy,
if (base_checksum != NULL)
is_locally_assembled = TRUE;
/* Load the commit metadata into a dict */
{ g_autoptr(GVariant) commit_meta_v = NULL;
g_assert (g_variant_dict_lookup (dict, "base-commit-meta", "@a{sv}", &commit_meta_v));
commit_meta_dict = g_variant_dict_new (commit_meta_v);
}
if (is_locally_assembled)
{
g_autoptr(GVariant) layered_commit_meta_v = NULL;
g_assert (g_variant_dict_lookup (dict, "layered-commit-meta", "@a{sv}", &layered_commit_meta_v));
layered_commit_meta_dict = g_variant_dict_new (layered_commit_meta_v);
}
const gchar *source_title = NULL;
g_variant_dict_lookup (commit_meta_dict, OSTREE_COMMIT_META_KEY_SOURCE_TITLE, "&s", &source_title);
if (source_title)
g_print (" %s %s\n", libsd_special_glyph (TREE_RIGHT), source_title);
if (is_locally_assembled)
g_assert (g_variant_dict_lookup (dict, "base-timestamp", "t", &t));
else

View File

@ -21,13 +21,19 @@ set -x
# And then this code path in the VM
# get csum of current default deployment
# get csum and origin of current default deployment
commit=$(rpm-ostree status --json | \
python -c '
import sys, json;
deployment = json.load(sys.stdin)["deployments"][0]
print deployment["checksum"]
exit()')
origin=$(rpm-ostree status --json | \
python -c '
import sys, json;
deployment = json.load(sys.stdin)["deployments"][0]
print deployment["origin"]
exit()')
if [[ -z $commit ]] || ! ostree rev-parse $commit; then
echo "Error while determining current commit" >&2
@ -59,6 +65,6 @@ fi
rm -vrf vmcheck/usr/etc/selinux/targeted/semanage.*.LOCK
# ✀✀✀ END tmp hack
ostree commit --parent=none -b vmcheck --link-checkout-speedup \
ostree commit --parent=none -b vmcheck --add-metadata-string=ostree.source-title="Dev overlay on ${origin}" --add-metadata-string=rpmostree.original-origin=${origin} --link-checkout-speedup \
--selinux-policy=vmcheck --tree=dir=vmcheck
ostree admin deploy vmcheck

View File

@ -32,7 +32,7 @@ vm_assert_status_jq \
'.deployments[0]["requested-local-packages"]' \
'.deployments[0]["base-removals"]' \
'.deployments[0]["requested-base-removals"]' \
'.deployments[0]["base-commit-meta"]' \
'.deployments[0]["base-commit-meta"]["ostree.source-title"]|contains("overlay")' \
'.deployments[0]["layered-commit-meta"]|not'
echo "ok empty pkg arrays, and commit meta correct in status json"