summaryrefslogtreecommitdiff
path: root/src/ostree
diff options
context:
space:
mode:
authorMatthew Leeds <matthew.leeds@endlessm.com>2019-11-13 18:29:45 -0800
committerMatthew Leeds <matthew.leeds@endlessm.com>2020-03-28 10:35:19 -0700
commitcd37293b5ad46b6158f46537b1535ae373e10cbe (patch)
tree4071b414c54a4417706b3dda82f3a22545a9d773 /src/ostree
parent7a9592986708446cceea0d72b55f2d3219d475aa (diff)
downloadostree-cd37293b5ad46b6158f46537b1535ae373e10cbe.tar.gz
find-remotes: Add a --mirror option
This will be useful in the unit test added by the next commit. It just passes OSTREE_REPO_PULL_FLAGS_MIRROR to the call to ostree_repo_pull_from_remotes_async().
Diffstat (limited to 'src/ostree')
-rw-r--r--src/ostree/ot-builtin-find-remotes.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/ostree/ot-builtin-find-remotes.c b/src/ostree/ot-builtin-find-remotes.c
index f255501a..944533ca 100644
--- a/src/ostree/ot-builtin-find-remotes.c
+++ b/src/ostree/ot-builtin-find-remotes.c
@@ -35,6 +35,7 @@ static gchar *opt_cache_dir = NULL;
static gchar *opt_finders = NULL;
static gboolean opt_disable_fsync = FALSE;
static gboolean opt_pull = FALSE;
+static gboolean opt_mirror = FALSE;
static GOptionEntry options[] =
{
@@ -42,6 +43,7 @@ static GOptionEntry options[] =
{ "disable-fsync", 0, 0, G_OPTION_ARG_NONE, &opt_disable_fsync, "Do not invoke fsync()", NULL },
{ "finders", 0, 0, G_OPTION_ARG_STRING, &opt_finders, "Use the specified comma separated list of finders (e.g. config,lan,mount)", "FINDERS" },
{ "pull", 0, 0, G_OPTION_ARG_NONE, &opt_pull, "Pull the updates after finding them", NULL },
+ { "mirror", 0, 0, G_OPTION_ARG_NONE, &opt_mirror, "Do a mirror pull (see ostree pull --mirror)", NULL},
{ NULL }
};
@@ -188,6 +190,7 @@ ostree_builtin_find_remotes (int argc,
g_auto(OstreeRepoFinderResultv) results = NULL;
g_auto(GLnxConsoleRef) console = { 0, };
g_autoptr(GHashTable) refs_found = NULL; /* set (element-type OstreeCollectionRef) */
+ g_autoptr(GVariant) pull_options = NULL;
context = g_option_context_new ("COLLECTION-ID REF [COLLECTION-ID REF...]");
@@ -210,6 +213,12 @@ ostree_builtin_find_remotes (int argc,
return FALSE;
}
+ if (opt_mirror && !opt_pull)
+ {
+ ot_util_usage_error (context, "When --mirror is specified, --pull must also be", error);
+ return FALSE;
+ }
+
if (opt_disable_fsync)
ostree_repo_set_disable_fsync (repo, TRUE);
@@ -359,13 +368,24 @@ ostree_builtin_find_remotes (int argc,
if (!opt_pull)
return TRUE;
+ {
+ GVariantBuilder builder;
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
+
+ if (opt_mirror)
+ g_variant_builder_add (&builder, "{s@v}", "flags",
+ g_variant_new_variant (g_variant_new_int32 (OSTREE_REPO_PULL_FLAGS_MIRROR)));
+
+ pull_options = g_variant_ref_sink (g_variant_builder_end (&builder));
+ }
+
/* Run the pull operation. */
if (console.is_tty)
progress = ostree_async_progress_new_and_connect (ostree_repo_pull_default_console_progress_changed, &console);
ostree_repo_pull_from_remotes_async (repo,
(const OstreeRepoFinderResult * const *) results,
- NULL, /* no options */
+ pull_options,
progress, cancellable,
get_result_cb, &pull_result);