summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2017-10-27 17:24:49 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2017-10-31 14:20:20 +0000
commit80ff73ba2618a1d740a92aecb15c67050d31f80e (patch)
tree42fd4fe9ba0a0b47c6eda89126edb9335a814e50
parent7f8ff5756eb7a668b3513adec8a697f203f73cb9 (diff)
downloadostree-80ff73ba2618a1d740a92aecb15c67050d31f80e.tar.gz
lib/pull: When --require-static-deltas, use them even for file:/// repos
I didn't fully spelunk this, but from what `static-delta-generate-crosscheck.sh` had, we appeared to be doing this before, and it's clearly useful for local testing rather than needing to spin up a HTTP server. Closes: #1313 Approved by: jlebon
-rw-r--r--src/libostree/ostree-repo-pull.c12
-rw-r--r--tests/pull-test.sh16
2 files changed, 24 insertions, 4 deletions
diff --git a/src/libostree/ostree-repo-pull.c b/src/libostree/ostree-repo-pull.c
index efe312d3..5588118c 100644
--- a/src/libostree/ostree-repo-pull.c
+++ b/src/libostree/ostree-repo-pull.c
@@ -1438,6 +1438,10 @@ static char *
get_real_remote_repo_collection_id (OstreeRepo *repo,
const gchar *remote_name)
{
+ /* remote_name == NULL can happen for pull-local */
+ if (!remote_name)
+ return NULL;
+
g_autofree gchar *remote_collection_id = NULL;
if (!ostree_repo_get_remote_option (repo, remote_name, "collection-id", NULL,
&remote_collection_id, NULL) ||
@@ -3544,8 +3548,12 @@ ostree_repo_pull_with_options (OstreeRepo *self,
g_autofree char *first_scheme = _ostree_fetcher_uri_get_scheme (first_uri);
/* NB: we don't support local mirrors in mirrorlists, so if this passes, it
- * means that we're not using mirrorlists (see also fetch_mirrorlist()) */
- if (g_str_equal (first_scheme, "file"))
+ * means that we're not using mirrorlists (see also fetch_mirrorlist())
+ * Also, we explicitly disable the "local repo" path if static deltas
+ * were explicitly requested to be required; this is going to happen
+ * most often for testing deltas without setting up a HTTP server.
+ */
+ if (g_str_equal (first_scheme, "file") && !pull_data->require_static_deltas)
{
g_autofree char *path = _ostree_fetcher_uri_get_path (first_uri);
g_autoptr(GFile) remote_repo_path = g_file_new_for_path (path);
diff --git a/tests/pull-test.sh b/tests/pull-test.sh
index b2613fc7..3f8030e0 100644
--- a/tests/pull-test.sh
+++ b/tests/pull-test.sh
@@ -52,7 +52,7 @@ function verify_initial_contents() {
assert_file_has_content baz/cow '^moo$'
}
-echo "1..32"
+echo "1..33"
# Try both syntaxes
repo_init --no-gpg-verify
@@ -348,12 +348,24 @@ repo_init --no-gpg-verify
${CMD_PREFIX} ostree --repo=repo pull origin main@${prev_rev}
${CMD_PREFIX} ostree --repo=repo pull --dry-run --require-static-deltas origin ${delta_target} >dry-run-pull.txt
# Compression can vary, so we support 400-699
-assert_file_has_content dry-run-pull.txt 'Delta update: 0/1 parts, 0 bytes/[456][0-9][0-9] bytes, 455 bytes total uncompressed'
+delta_dry_run_regexp='Delta update: 0/1 parts, 0 bytes/[456][0-9][0-9] bytes, 455 bytes total uncompressed'
+assert_file_has_content dry-run-pull.txt "${delta_dry_run_regexp}"
rev=$(${CMD_PREFIX} ostree --repo=repo rev-parse origin:main)
assert_streq "${prev_rev}" "${rev}"
${CMD_PREFIX} ostree --repo=repo fsck
done
+# Test pull via file:/// - this should still use the deltas path for testing
+cd ${test_tmpdir}
+repo_init --no-gpg-verify
+${CMD_PREFIX} ostree --repo=repo remote delete origin
+${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin file://$(pwd)/ostree-srv/gnomerepo
+${CMD_PREFIX} ostree --repo=repo pull origin main@${prev_rev}
+${CMD_PREFIX} ostree --repo=repo pull --dry-run --require-static-deltas origin ${delta_target} >dry-run-pull.txt
+# See above
+assert_file_has_content dry-run-pull.txt "${delta_dry_run_regexp}"
+echo "ok pull file:// + deltas required"
+
# Explicitly test delta fetches via ref name as well as commit hash
for delta_target in main ${new_rev}; do
cd ${test_tmpdir}