Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/tests/sync/, pym/portage/sync/modules/rsync/, ...
Date: Tue, 21 Nov 2017 20:45:24
Message-Id: 1511296903.7d4612795d1d36d4284ad7bcbff5b88e3c74e993.zmedico@gentoo
1 commit: 7d4612795d1d36d4284ad7bcbff5b88e3c74e993
2 Author: Ilya Tumaykin <itumaykin <AT> gmail <DOT> com>
3 AuthorDate: Mon May 23 13:43:48 2016 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Tue Nov 21 20:41:43 2017 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=7d461279
7
8 Fix sync_uri parsing for paths beginning with file://
9
10 Portage allows file URLs, i.e. paths beginning with 'file://',
11 in sync_uri. According to RFC-1738 [1] a file URL must take the form
12 'file://<host>/foo/bar' or 'file:///foo/bar', when <host> is omitted
13 (in this case localhost is assumed).
14
15 Portage incorrectly parses file URLs because it leaves the second slash
16 from the 'file://' prefix as a part of the URL. Additionally test suite
17 incorrectly uses file URLs beginning with 'file:/' instead of 'file://'.
18
19 This patch adjusts string offset so that file URLs are parsed correctly:
20
21 >>> sync_uri='/foo/bar/baz'
22 >>> ('file://' + sync_uri)[6:]
23 '//foo/bar/baz'
24 >>> ('file://' + sync_uri)[6:] == sync_uri
25 False
26 >>> ('file://' + sync_uri)[7:]
27 '/foo/bar/baz'
28 >>> ('file://' + sync_uri)[7:] == sync_uri
29 True
30
31 Additionally test suite is updated to use file URLs of the form
32 'file:///foo/bar' as required by the aforementioned RFC.
33
34 [1]: https://tools.ietf.org/html/rfc1738#section-3.10
35
36 Closes: https://github.com/gentoo/portage/pull/28
37
38 pym/portage/sync/modules/git/git.py | 2 +-
39 pym/portage/sync/modules/rsync/rsync.py | 2 +-
40 pym/portage/tests/sync/test_sync_local.py | 2 +-
41 3 files changed, 3 insertions(+), 3 deletions(-)
42
43 diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
44 index 8068149c7..8b4cab273 100644
45 --- a/pym/portage/sync/modules/git/git.py
46 +++ b/pym/portage/sync/modules/git/git.py
47 @@ -47,7 +47,7 @@ class GitSync(NewBase):
48
49 sync_uri = self.repo.sync_uri
50 if sync_uri.startswith("file://"):
51 - sync_uri = sync_uri[6:]
52 + sync_uri = sync_uri[7:]
53
54 git_cmd_opts = ""
55 if self.repo.module_specific_options.get('sync-git-env'):
56
57 diff --git a/pym/portage/sync/modules/rsync/rsync.py b/pym/portage/sync/modules/rsync/rsync.py
58 index 01e4e5924..c80641ba3 100644
59 --- a/pym/portage/sync/modules/rsync/rsync.py
60 +++ b/pym/portage/sync/modules/rsync/rsync.py
61 @@ -111,7 +111,7 @@ class RsyncSync(NewBase):
62
63 if syncuri.startswith("file://"):
64 self.proto = "file"
65 - dosyncuri = syncuri[6:]
66 + dosyncuri = syncuri[7:]
67 is_synced, exitcode, updatecache_flg = self._do_rsync(
68 dosyncuri, timestamp, opts)
69 self._process_exitcode(exitcode, dosyncuri, out, 1)
70
71 diff --git a/pym/portage/tests/sync/test_sync_local.py b/pym/portage/tests/sync/test_sync_local.py
72 index 1d3856265..010c8f887 100644
73 --- a/pym/portage/tests/sync/test_sync_local.py
74 +++ b/pym/portage/tests/sync/test_sync_local.py
75 @@ -41,7 +41,7 @@ class SyncLocalTestCase(TestCase):
76 [test_repo]
77 location = %(EPREFIX)s/var/repositories/test_repo
78 sync-type = %(sync-type)s
79 - sync-uri = file:/%(EPREFIX)s/var/repositories/test_repo_sync
80 + sync-uri = file://%(EPREFIX)s/var/repositories/test_repo_sync
81 auto-sync = %(auto-sync)s
82 %(repo_extra_keys)s
83 """)