From e4675477d640234a26a6d7e27be99a99c71c2eed Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 19 Oct 2017 15:31:50 -0400 Subject: [PATCH] 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) --- src/app/rpmostree-builtin-status.c | 4 ++++ src/daemon/rpmostreed-deployment-utils.c | 2 ++ tests/vmcheck/overlay.sh | 10 ++++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/app/rpmostree-builtin-status.c b/src/app/rpmostree-builtin-status.c index df15da2e4a..94a6da70a7 100644 --- a/src/app/rpmostree-builtin-status.c +++ b/src/app/rpmostree-builtin-status.c @@ -301,6 +301,10 @@ status_generic (RPMOSTreeSysroot *sysroot_proxy, else g_print ("%s", checksum); g_print ("\n"); + const gchar *source_title = NULL; + g_variant_dict_lookup (dict, "source-title", "&s", &source_title); + if (source_title) + g_print (" └ %s\n", source_title); const char *base_checksum = NULL; g_variant_dict_lookup (dict, "base-checksum", "&s", &base_checksum); diff --git a/src/daemon/rpmostreed-deployment-utils.c b/src/daemon/rpmostreed-deployment-utils.c index e5d4ab86ff..5cbfc11c37 100644 --- a/src/daemon/rpmostreed-deployment-utils.c +++ b/src/daemon/rpmostreed-deployment-utils.c @@ -253,6 +253,8 @@ rpmostreed_deployment_generate_variant (OstreeSysroot *sysroot, variant_add_metadata_attribute (&dict, OSTREE_COMMIT_META_KEY_ENDOFLIFE, "endoflife", commit); } + variant_add_metadata_attribute (&dict, OSTREE_COMMIT_META_KEY_SOURCE_TITLE, "source-title", commit); + sigs = rpmostreed_deployment_gpg_results (repo, refspec, base_checksum, &gpg_enabled); variant_add_commit_details (&dict, NULL, commit); diff --git a/tests/vmcheck/overlay.sh b/tests/vmcheck/overlay.sh index 4f613fbddb..99a2724624 100755 --- a/tests/vmcheck/overlay.sh +++ b/tests/vmcheck/overlay.sh @@ -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