Skip to content

Commit

Permalink
status: Render ostree metadata source-title key
Browse files Browse the repository at this point in the history
Depends: ostreedev/ostree#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
  • Loading branch information
cgwalters authored and rh-atomic-bot committed Oct 25, 2017
1 parent 9ec45d3 commit 1f31cbb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
19 changes: 19 additions & 0 deletions src/app/rpmostree-builtin-status.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions tests/vmcheck/overlay.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/vmcheck/test-basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit 1f31cbb

Please sign in to comment.