summaryrefslogtreecommitdiff
path: root/src/ostree/ot-builtin-pull-local.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ostree/ot-builtin-pull-local.c')
-rw-r--r--src/ostree/ot-builtin-pull-local.c118
1 files changed, 66 insertions, 52 deletions
diff --git a/src/ostree/ot-builtin-pull-local.c b/src/ostree/ot-builtin-pull-local.c
index a49445da..6ea8da05 100644
--- a/src/ostree/ot-builtin-pull-local.c
+++ b/src/ostree/ot-builtin-pull-local.c
@@ -21,12 +21,12 @@
#include "config.h"
-#include <unistd.h>
#include <stdlib.h>
+#include <unistd.h>
-#include "ot-main.h"
-#include "ot-builtins.h"
#include "ostree.h"
+#include "ot-builtins.h"
+#include "ot-main.h"
#include "otutil.h"
static char *opt_remote;
@@ -46,45 +46,55 @@ static int opt_depth = 0;
* man page (man/ostree-pull-local.xml) when changing the option list.
*/
-static GOptionEntry options[] = {
- { "commit-metadata-only", 0, 0, G_OPTION_ARG_NONE, &opt_commit_only, "Fetch only the commit metadata", NULL },
- { "remote", 0, 0, G_OPTION_ARG_STRING, &opt_remote, "Add REMOTE to refspec", "REMOTE" },
- { "disable-fsync", 0, 0, G_OPTION_ARG_NONE, &opt_disable_fsync, "Do not invoke fsync()", NULL },
- { "per-object-fsync", 0, 0, G_OPTION_ARG_NONE, &opt_per_object_fsync, "Perform writes in such a way that avoids stalling concurrent processes", NULL },
- { "untrusted", 0, 0, G_OPTION_ARG_NONE, &opt_untrusted, "Verify checksums of local sources (always enabled for HTTP pulls)", NULL },
- { "bareuseronly-files", 0, 0, G_OPTION_ARG_NONE, &opt_bareuseronly_files, "Reject regular files with mode outside of 0775 (world writable, suid, etc.)", NULL },
- { "require-static-deltas", 0, 0, G_OPTION_ARG_NONE, &opt_require_static_deltas, "Require static deltas", NULL },
- { "gpg-verify", 0, 0, G_OPTION_ARG_NONE, &opt_gpg_verify, "GPG verify commits (must specify --remote)", NULL },
- { "gpg-verify-summary", 0, 0, G_OPTION_ARG_NONE, &opt_gpg_verify_summary, "GPG verify summary (must specify --remote)", NULL },
- { "disable-verify-bindings", 0, 0, G_OPTION_ARG_NONE, &opt_disable_verify_bindings, "Do not verify commit bindings", NULL },
- { "depth", 0, 0, G_OPTION_ARG_INT, &opt_depth, "Traverse DEPTH parents (-1=infinite) (default: 0)", "DEPTH" },
- { NULL }
-};
+static GOptionEntry options[]
+ = { { "commit-metadata-only", 0, 0, G_OPTION_ARG_NONE, &opt_commit_only,
+ "Fetch only the commit metadata", NULL },
+ { "remote", 0, 0, G_OPTION_ARG_STRING, &opt_remote, "Add REMOTE to refspec", "REMOTE" },
+ { "disable-fsync", 0, 0, G_OPTION_ARG_NONE, &opt_disable_fsync, "Do not invoke fsync()",
+ NULL },
+ { "per-object-fsync", 0, 0, G_OPTION_ARG_NONE, &opt_per_object_fsync,
+ "Perform writes in such a way that avoids stalling concurrent processes", NULL },
+ { "untrusted", 0, 0, G_OPTION_ARG_NONE, &opt_untrusted,
+ "Verify checksums of local sources (always enabled for HTTP pulls)", NULL },
+ { "bareuseronly-files", 0, 0, G_OPTION_ARG_NONE, &opt_bareuseronly_files,
+ "Reject regular files with mode outside of 0775 (world writable, suid, etc.)", NULL },
+ { "require-static-deltas", 0, 0, G_OPTION_ARG_NONE, &opt_require_static_deltas,
+ "Require static deltas", NULL },
+ { "gpg-verify", 0, 0, G_OPTION_ARG_NONE, &opt_gpg_verify,
+ "GPG verify commits (must specify --remote)", NULL },
+ { "gpg-verify-summary", 0, 0, G_OPTION_ARG_NONE, &opt_gpg_verify_summary,
+ "GPG verify summary (must specify --remote)", NULL },
+ { "disable-verify-bindings", 0, 0, G_OPTION_ARG_NONE, &opt_disable_verify_bindings,
+ "Do not verify commit bindings", NULL },
+ { "depth", 0, 0, G_OPTION_ARG_INT, &opt_depth,
+ "Traverse DEPTH parents (-1=infinite) (default: 0)", "DEPTH" },
+ { NULL } };
/* See canonical version of this in ot-builtin-pull.c */
static void
-noninteractive_console_progress_changed (OstreeAsyncProgress *progress,
- gpointer user_data)
+noninteractive_console_progress_changed (OstreeAsyncProgress *progress, gpointer user_data)
{
/* We do nothing here - we just want the final status */
}
gboolean
-ostree_builtin_pull_local (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ostree_builtin_pull_local (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
gboolean ret = FALSE;
- g_autoptr(GOptionContext) context = NULL;
- g_autoptr(OstreeRepo) repo = NULL;
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (OstreeRepo) repo = NULL;
int i;
const char *src_repo_arg;
g_autofree char *src_repo_uri = NULL;
- g_autoptr(OstreeAsyncProgress) progress = NULL;
- g_autoptr(GPtrArray) refs_to_fetch = NULL;
+ g_autoptr (OstreeAsyncProgress) progress = NULL;
+ g_autoptr (GPtrArray) refs_to_fetch = NULL;
OstreeRepoPullFlags pullflags = 0;
context = g_option_context_new ("SRC_REPO [REFS...]");
- if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
+ if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable,
+ error))
goto out;
if (!ostree_ensure_repo_writable (repo, error))
@@ -95,8 +105,7 @@ ostree_builtin_pull_local (int argc, char **argv, OstreeCommandInvocation *invoc
gchar *help = g_option_context_get_help (context, TRUE, NULL);
g_printerr ("%s\n", help);
g_free (help);
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "DESTINATION must be specified");
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "DESTINATION must be specified");
goto out;
}
@@ -122,9 +131,9 @@ ostree_builtin_pull_local (int argc, char **argv, OstreeCommandInvocation *invoc
if (argc == 2)
{
- g_autoptr(GFile) src_repo_path = g_file_new_for_path (src_repo_arg);
- g_autoptr(OstreeRepo) src_repo = ostree_repo_new (src_repo_path);
- g_autoptr(GHashTable) refs_to_clone = NULL;
+ g_autoptr (GFile) src_repo_path = g_file_new_for_path (src_repo_arg);
+ g_autoptr (OstreeRepo) src_repo = ostree_repo_new (src_repo_path);
+ g_autoptr (GHashTable) refs_to_clone = NULL;
refs_to_fetch = g_ptr_array_new_with_free_func (g_free);
@@ -133,11 +142,11 @@ ostree_builtin_pull_local (int argc, char **argv, OstreeCommandInvocation *invoc
/* FIXME: This should grow support for pulling refs from refs/mirrors on
* a local repository, using ostree_repo_list_collection_refs(). */
- if (!ostree_repo_list_refs (src_repo, NULL, &refs_to_clone,
- cancellable, error))
+ if (!ostree_repo_list_refs (src_repo, NULL, &refs_to_clone, cancellable, error))
goto out;
- { GHashTableIter hashiter;
+ {
+ GHashTableIter hashiter;
gpointer hkey, hvalue;
g_hash_table_iter_init (&hashiter, refs_to_clone);
@@ -153,14 +162,17 @@ ostree_builtin_pull_local (int argc, char **argv, OstreeCommandInvocation *invoc
{
const char *ref = argv[i];
- g_ptr_array_add (refs_to_fetch, (char*)ref);
+ g_ptr_array_add (refs_to_fetch, (char *)ref);
}
g_ptr_array_add (refs_to_fetch, NULL);
}
- { GVariantBuilder builder;
- g_autoptr(GVariant) opts = NULL;
- g_auto(GLnxConsoleRef) console = { 0, };
+ {
+ GVariantBuilder builder;
+ g_autoptr (GVariant) opts = NULL;
+ g_auto (GLnxConsoleRef) console = {
+ 0,
+ };
glnx_console_lock (&console);
@@ -168,21 +180,24 @@ ostree_builtin_pull_local (int argc, char **argv, OstreeCommandInvocation *invoc
g_variant_builder_add (&builder, "{s@v}", "flags",
g_variant_new_variant (g_variant_new_int32 (pullflags)));
- g_variant_builder_add (&builder, "{s@v}", "refs",
- g_variant_new_variant (g_variant_new_strv ((const char *const*) refs_to_fetch->pdata, -1)));
+ g_variant_builder_add (
+ &builder, "{s@v}", "refs",
+ g_variant_new_variant (g_variant_new_strv ((const char *const *)refs_to_fetch->pdata, -1)));
if (opt_remote)
g_variant_builder_add (&builder, "{s@v}", "override-remote-name",
g_variant_new_variant (g_variant_new_string (opt_remote)));
- g_variant_builder_add (&builder, "{s@v}", "require-static-deltas",
- g_variant_new_variant (g_variant_new_boolean (opt_require_static_deltas)));
+ g_variant_builder_add (
+ &builder, "{s@v}", "require-static-deltas",
+ g_variant_new_variant (g_variant_new_boolean (opt_require_static_deltas)));
if (opt_gpg_verify)
g_variant_builder_add (&builder, "{s@v}", "gpg-verify",
g_variant_new_variant (g_variant_new_boolean (TRUE)));
if (opt_gpg_verify_summary)
g_variant_builder_add (&builder, "{s@v}", "gpg-verify-summary",
g_variant_new_variant (g_variant_new_boolean (TRUE)));
- g_variant_builder_add (&builder, "{s@v}", "disable-verify-bindings",
- g_variant_new_variant (g_variant_new_boolean (opt_disable_verify_bindings)));
+ g_variant_builder_add (
+ &builder, "{s@v}", "disable-verify-bindings",
+ g_variant_new_variant (g_variant_new_boolean (opt_disable_verify_bindings)));
g_variant_builder_add (&builder, "{s@v}", "depth",
g_variant_new_variant (g_variant_new_int32 (opt_depth)));
/* local pulls always disable signapi verification. If you don't want this, use
@@ -193,19 +208,18 @@ ostree_builtin_pull_local (int argc, char **argv, OstreeCommandInvocation *invoc
g_variant_builder_add (&builder, "{s@v}", "disable-sign-verify-summary",
g_variant_new_variant (g_variant_new_boolean (TRUE)));
if (opt_per_object_fsync)
- g_variant_builder_add (&builder, "{s@v}", "per-object-fsync",
- g_variant_new_variant (g_variant_new_boolean (TRUE)));
+ g_variant_builder_add (&builder, "{s@v}", "per-object-fsync",
+ g_variant_new_variant (g_variant_new_boolean (TRUE)));
if (console.is_tty)
- progress = ostree_async_progress_new_and_connect (ostree_repo_pull_default_console_progress_changed, &console);
+ progress = ostree_async_progress_new_and_connect (
+ ostree_repo_pull_default_console_progress_changed, &console);
else
- progress = ostree_async_progress_new_and_connect (noninteractive_console_progress_changed, &console);
+ progress = ostree_async_progress_new_and_connect (noninteractive_console_progress_changed,
+ &console);
opts = g_variant_ref_sink (g_variant_builder_end (&builder));
- if (!ostree_repo_pull_with_options (repo, src_repo_uri,
- opts,
- progress,
- cancellable, error))
+ if (!ostree_repo_pull_with_options (repo, src_repo_uri, opts, progress, cancellable, error))
goto out;
if (!console.is_tty)
@@ -219,7 +233,7 @@ ostree_builtin_pull_local (int argc, char **argv, OstreeCommandInvocation *invoc
}
ret = TRUE;
- out:
+out:
if (repo)
ostree_repo_abort_transaction (repo, cancellable, NULL);
return ret;