aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Tumaykin <itumaykin@gmail.com>2016-05-23 16:43:48 +0300
committerZac Medico <zmedico@gentoo.org>2017-11-21 12:41:43 -0800
commit7d4612795d1d36d4284ad7bcbff5b88e3c74e993 (patch)
tree20c1d71968da03df37b7f716e9649012a40ece72
parentemaint binhost: use _populate_local return value when appropriate (diff)
downloadportage-7d461279.tar.gz
portage-7d461279.tar.bz2
portage-7d461279.zip
Fix sync_uri parsing for paths beginning with file://
Portage allows file URLs, i.e. paths beginning with 'file://', in sync_uri. According to RFC-1738 [1] a file URL must take the form 'file://<host>/foo/bar' or 'file:///foo/bar', when <host> is omitted (in this case localhost is assumed). Portage incorrectly parses file URLs because it leaves the second slash from the 'file://' prefix as a part of the URL. Additionally test suite incorrectly uses file URLs beginning with 'file:/' instead of 'file://'. This patch adjusts string offset so that file URLs are parsed correctly: >>> sync_uri='/foo/bar/baz' >>> ('file://' + sync_uri)[6:] '//foo/bar/baz' >>> ('file://' + sync_uri)[6:] == sync_uri False >>> ('file://' + sync_uri)[7:] '/foo/bar/baz' >>> ('file://' + sync_uri)[7:] == sync_uri True Additionally test suite is updated to use file URLs of the form 'file:///foo/bar' as required by the aforementioned RFC. [1]: https://tools.ietf.org/html/rfc1738#section-3.10 Closes: https://github.com/gentoo/portage/pull/28
-rw-r--r--pym/portage/sync/modules/git/git.py2
-rw-r--r--pym/portage/sync/modules/rsync/rsync.py2
-rw-r--r--pym/portage/tests/sync/test_sync_local.py2
3 files changed, 3 insertions, 3 deletions
diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
index 8068149c7..8b4cab273 100644
--- a/pym/portage/sync/modules/git/git.py
+++ b/pym/portage/sync/modules/git/git.py
@@ -47,7 +47,7 @@ class GitSync(NewBase):
sync_uri = self.repo.sync_uri
if sync_uri.startswith("file://"):
- sync_uri = sync_uri[6:]
+ sync_uri = sync_uri[7:]
git_cmd_opts = ""
if self.repo.module_specific_options.get('sync-git-env'):
diff --git a/pym/portage/sync/modules/rsync/rsync.py b/pym/portage/sync/modules/rsync/rsync.py
index 01e4e5924..c80641ba3 100644
--- a/pym/portage/sync/modules/rsync/rsync.py
+++ b/pym/portage/sync/modules/rsync/rsync.py
@@ -111,7 +111,7 @@ class RsyncSync(NewBase):
if syncuri.startswith("file://"):
self.proto = "file"
- dosyncuri = syncuri[6:]
+ dosyncuri = syncuri[7:]
is_synced, exitcode, updatecache_flg = self._do_rsync(
dosyncuri, timestamp, opts)
self._process_exitcode(exitcode, dosyncuri, out, 1)
diff --git a/pym/portage/tests/sync/test_sync_local.py b/pym/portage/tests/sync/test_sync_local.py
index 1d3856265..010c8f887 100644
--- a/pym/portage/tests/sync/test_sync_local.py
+++ b/pym/portage/tests/sync/test_sync_local.py
@@ -41,7 +41,7 @@ class SyncLocalTestCase(TestCase):
[test_repo]
location = %(EPREFIX)s/var/repositories/test_repo
sync-type = %(sync-type)s
- sync-uri = file:/%(EPREFIX)s/var/repositories/test_repo_sync
+ sync-uri = file://%(EPREFIX)s/var/repositories/test_repo_sync
auto-sync = %(auto-sync)s
%(repo_extra_keys)s
""")