summaryrefslogtreecommitdiff
path: root/src/ostree/ot-builtin-summary.c
diff options
context:
space:
mode:
authorPhilip Withnall <withnall@endlessm.com>2017-05-04 11:31:50 +0100
committerAtomic Bot <atomic-devel@projectatomic.io>2017-05-08 00:55:24 +0000
commit8ea654251a61d080e8c8553c9905e02599059294 (patch)
treee7ae95f3964359a3245ce91ef6e7146eb562aabf /src/ostree/ot-builtin-summary.c
parent015ce7520b3099a0af110f7ee693ce40019c2445 (diff)
downloadostree-8ea654251a61d080e8c8553c9905e02599059294.tar.gz
ostree: Add --view mode to `ostree summary`
This allows a locally generated summary file to be viewed. It accepts the same arguments as `ostree remote summary` (i.e. --raw). Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #826 Approved by: cgwalters
Diffstat (limited to 'src/ostree/ot-builtin-summary.c')
-rw-r--r--src/ostree/ot-builtin-summary.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/ostree/ot-builtin-summary.c b/src/ostree/ot-builtin-summary.c
index fa037400..9055d972 100644
--- a/src/ostree/ot-builtin-summary.c
+++ b/src/ostree/ot-builtin-summary.c
@@ -20,17 +20,21 @@
#include "config.h"
+#include "ostree-repo-private.h"
+#include "ot-dump.h"
#include "ot-main.h"
#include "ot-builtins.h"
#include "ostree.h"
#include "otutil.h"
-static gboolean opt_update;
+static gboolean opt_update, opt_view, opt_raw;
static char **opt_key_ids;
static char *opt_gpg_homedir;
static GOptionEntry options[] = {
{ "update", 'u', 0, G_OPTION_ARG_NONE, &opt_update, "Update the summary", NULL },
+ { "view", 'v', 0, G_OPTION_ARG_NONE, &opt_view, "View the local summary file", NULL },
+ { "raw", 0, 0, G_OPTION_ARG_NONE, &opt_raw, "View the raw bytes of the summary file", NULL },
{ "gpg-sign", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_key_ids, "GPG Key ID to sign the summary with", "KEY-ID"},
{ "gpg-homedir", 0, 0, G_OPTION_ARG_FILENAME, &opt_gpg_homedir, "GPG Homedir to use when looking for keyrings", "HOMEDIR"},
{ NULL }
@@ -42,6 +46,7 @@ ostree_builtin_summary (int argc, char **argv, GCancellable *cancellable, GError
gboolean ret = FALSE;
g_autoptr(GOptionContext) context = NULL;
glnx_unref_object OstreeRepo *repo = NULL;
+ OstreeDumpFlags flags = OSTREE_DUMP_NONE;
context = g_option_context_new ("Manage summary metadata");
@@ -66,6 +71,19 @@ ostree_builtin_summary (int argc, char **argv, GCancellable *cancellable, GError
goto out;
}
}
+ else if (opt_view)
+ {
+ g_autoptr(GBytes) summary_data = NULL;
+
+ if (opt_raw)
+ flags |= OSTREE_DUMP_RAW;
+
+ summary_data = ot_file_mapat_bytes (repo->repo_dir_fd, "summary", error);
+ if (!summary_data)
+ goto out;
+
+ ot_dump_summary_bytes (summary_data, flags);
+ }
else
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,