summaryrefslogtreecommitdiff
path: root/src/ostree
diff options
context:
space:
mode:
authorPhilip Withnall <withnall@endlessm.com>2017-06-07 14:53:58 +0100
committerAtomic Bot <atomic-devel@projectatomic.io>2017-06-26 15:56:07 +0000
commit18456d25fb1071909b83e203c16ad898cd651f7b (patch)
tree13624e53882f83e25c03161f15abb9d97386e602 /src/ostree
parentb7b79fa78d34a34cb75aeca4d0b041586ed74224 (diff)
downloadostree-18456d25fb1071909b83e203c16ad898cd651f7b.tar.gz
ostree/dump: Include collection IDs and mirrored refs in summary dumps
If a repository’s summary file includes a collection ID, output that. If it includes refs from other collections (in the ‘collection map’), output those and include the same metadata detail as for refs in the summary file’s main refs map. If collection IDs are specified in the summary file, this changes the output format from `ostree summary -v` to use (collection ID, ref name) tuples. Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #924 Approved by: cgwalters
Diffstat (limited to 'src/ostree')
-rw-r--r--src/ostree/ot-dump.c84
1 files changed, 63 insertions, 21 deletions
diff --git a/src/ostree/ot-dump.c b/src/ostree/ot-dump.c
index e6b8859b..83eb307f 100644
--- a/src/ostree/ot-dump.c
+++ b/src/ostree/ot-dump.c
@@ -176,7 +176,8 @@ ot_dump_object (OstreeObjectType objtype,
}
static void
-dump_summary_ref (const char *ref_name,
+dump_summary_ref (const char *collection_id,
+ const char *ref_name,
guint64 commit_size,
GVariant *csum_v,
GVariantIter *metadata)
@@ -187,7 +188,10 @@ dump_summary_ref (const char *ref_name,
GVariant *value;
char *key;
- g_print ("* %s\n", ref_name);
+ if (collection_id == NULL)
+ g_print ("* %s\n", ref_name);
+ else
+ g_print ("* (%s, %s)\n", collection_id, ref_name);
size = g_format_size (commit_size);
g_print (" Latest Commit (%s):\n", size);
@@ -229,6 +233,39 @@ dump_summary_ref (const char *ref_name,
}
}
+static void
+dump_summary_refs (const gchar *collection_id,
+ GVariant *refs)
+{
+ GVariantIter iter;
+ GVariant *value;
+
+ g_variant_iter_init (&iter, refs);
+
+ while ((value = g_variant_iter_next_value (&iter)) != NULL)
+ {
+ const char *ref_name = NULL;
+
+ g_variant_get_child (value, 0, "&s", &ref_name);
+
+ if (ref_name != NULL)
+ {
+ g_autoptr(GVariant) csum_v = NULL;
+ g_autoptr(GVariantIter) metadata = NULL;
+ guint64 commit_size;
+
+ g_variant_get_child (value, 1, "(t@aya{sv})",
+ &commit_size, &csum_v, &metadata);
+
+ dump_summary_ref (collection_id, ref_name, commit_size, csum_v, metadata);
+
+ g_print ("\n");
+ }
+
+ g_variant_unref (value);
+ }
+}
+
void
ot_dump_summary_bytes (GBytes *summary_bytes,
OstreeDumpFlags flags)
@@ -254,31 +291,26 @@ ot_dump_summary_bytes (GBytes *summary_bytes,
refs = g_variant_get_child_value (summary, 0);
exts = g_variant_get_child_value (summary, 1);
- g_variant_iter_init (&iter, refs);
+ /* Print the refs, including those with a collection ID specified. */
+ const gchar *main_collection_id;
+ g_autoptr(GVariant) collection_map = NULL;
+ const gchar *collection_id;
- while ((value = g_variant_iter_next_value (&iter)) != NULL)
- {
- const char *ref_name = NULL;
+ if (!g_variant_lookup (exts, OSTREE_SUMMARY_COLLECTION_ID, "&s", &main_collection_id))
+ main_collection_id = NULL;
- g_variant_get_child (value, 0, "&s", &ref_name);
+ dump_summary_refs (main_collection_id, refs);
- if (ref_name != NULL)
- {
- g_autoptr(GVariant) csum_v = NULL;
- g_autoptr(GVariantIter) metadata = NULL;
- guint64 commit_size;
-
- g_variant_get_child (value, 1, "(t@aya{sv})",
- &commit_size, &csum_v, &metadata);
-
- dump_summary_ref (ref_name, commit_size, csum_v, metadata);
-
- g_print ("\n");
- }
+ collection_map = g_variant_lookup_value (exts, OSTREE_SUMMARY_COLLECTION_MAP, G_VARIANT_TYPE ("a{sa(s(taya{sv}))}"));
+ if (collection_map != NULL)
+ {
+ g_variant_iter_init (&iter, collection_map);
- g_variant_unref (value);
+ while (g_variant_iter_loop (&iter, "{&s@a(s(taya{sv}))}", &collection_id, &refs))
+ dump_summary_refs (collection_id, refs);
}
+ /* Print out the additional metadata. */
g_variant_iter_init (&iter, exts);
while (g_variant_iter_loop (&iter, "{sv}", &key, &value))
@@ -301,6 +333,16 @@ ot_dump_summary_bytes (GBytes *summary_bytes,
pretty_key = "Expires";
value_str = uint64_secs_to_iso8601 (GUINT64_FROM_BE (g_variant_get_uint64 (value)));
}
+ else if (g_strcmp0 (key, OSTREE_SUMMARY_COLLECTION_ID) == 0)
+ {
+ pretty_key = "Collection ID";
+ value_str = g_variant_dup_string (value, NULL);
+ }
+ else if (g_strcmp0 (key, OSTREE_SUMMARY_COLLECTION_MAP) == 0)
+ {
+ pretty_key = "Collection Map";
+ value_str = g_strdup ("(printed above)");
+ }
else
{
value_str = g_variant_print (value, FALSE);