From 186b4dee3762e69e26f8e68ef45ca7dc824114fe Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Fri, 1 Apr 2016 12:26:16 +0200 Subject: [PATCH] Add support for using a custom url whan pulling --- src/libostree/ostree-repo-pull.c | 15 +++++++++++---- src/ostree/ot-builtin-pull.c | 5 +++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/libostree/ostree-repo-pull.c b/src/libostree/ostree-repo-pull.c index e0fab5b..b83bdfb 100644 --- a/src/libostree/ostree-repo-pull.c +++ b/src/libostree/ostree-repo-pull.c @@ -1895,6 +1895,7 @@ ostree_repo_pull_with_options (OstreeRepo *self, guint64 end_time; OstreeRepoPullFlags flags = 0; const char *dir_to_pull = NULL; + const char *custom_url = NULL; char **refs_to_fetch = NULL; char **override_commit_ids = NULL; GSource *update_timeout = NULL; @@ -1909,6 +1910,7 @@ ostree_repo_pull_with_options (OstreeRepo *self, /* Reduce risk of issues if enum happens to be 64 bit for some reason */ flags = flags_i; (void) g_variant_lookup (options, "subdir", "&s", &dir_to_pull); + (void) g_variant_lookup (options, "url", "&s", &custom_url); (void) g_variant_lookup (options, "override-remote-name", "s", &pull_data->remote_name); (void) g_variant_lookup (options, "depth", "i", &pull_data->maxdepth); (void) g_variant_lookup (options, "disable-static-deltas", "b", &disable_static_deltas); @@ -1998,14 +2000,19 @@ ostree_repo_pull_with_options (OstreeRepo *self, NULL, &metalink_url_str, error)) goto out; - if (!metalink_url_str) + if (!metalink_url_str || custom_url) { g_autofree char *baseurl = NULL; - if (!ostree_repo_remote_get_url (self, remote_name_or_baseurl, &baseurl, error)) - goto out; + if (custom_url) + pull_data->base_uri = soup_uri_new (custom_url); + else + { + if (!ostree_repo_remote_get_url (self, remote_name_or_baseurl, &baseurl, error)) + goto out; - pull_data->base_uri = soup_uri_new (baseurl); + pull_data->base_uri = soup_uri_new (baseurl); + } if (!pull_data->base_uri) { diff --git a/src/ostree/ot-builtin-pull.c b/src/ostree/ot-builtin-pull.c index 8bef63a..120612c 100644 --- a/src/ostree/ot-builtin-pull.c +++ b/src/ostree/ot-builtin-pull.c @@ -35,6 +35,7 @@ static gboolean opt_disable_static_deltas; static gboolean opt_require_static_deltas; static gboolean opt_untrusted; static char* opt_subpath; +static char* opt_custom_url; static int opt_depth = 0; static GOptionEntry options[] = { @@ -44,6 +45,7 @@ static GOptionEntry options[] = { { "require-static-deltas", 0, 0, G_OPTION_ARG_NONE, &opt_require_static_deltas, "Require static deltas", NULL }, { "mirror", 0, 0, G_OPTION_ARG_NONE, &opt_mirror, "Write refs suitable for a mirror", NULL }, { "subpath", 0, 0, G_OPTION_ARG_STRING, &opt_subpath, "Only pull the provided subpath", NULL }, + { "url", 0, 0, G_OPTION_ARG_STRING, &opt_custom_url, "Pull from this url instead", NULL }, { "untrusted", 0, 0, G_OPTION_ARG_NONE, &opt_untrusted, "Do not trust (local) sources", NULL }, { "dry-run", 0, 0, G_OPTION_ARG_NONE, &opt_dry_run, "Only print information on what will be downloaded (requires static deltas)", NULL }, { "depth", 0, 0, G_OPTION_ARG_INT, &opt_depth, "Traverse DEPTH parents (-1=infinite) (default: 0)", "DEPTH" }, @@ -223,6 +225,9 @@ ostree_builtin_pull (int argc, char **argv, GCancellable *cancellable, GError ** if (opt_subpath) g_variant_builder_add (&builder, "{s v}", "subdir", g_variant_new_variant (g_variant_new_string (opt_subpath))); + if (opt_custom_url) + g_variant_builder_add (&builder, "{s v}", "url", + g_variant_new_variant (g_variant_new_string (opt_custom_url))); g_variant_builder_add (&builder, "{s v}", "flags", g_variant_new_variant (g_variant_new_int32 (pullflags))); if (refs_to_fetch) -- 2.5.5