diff options
author | Zac Medico <zmedico@gentoo.org> | 2013-05-23 17:06:32 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2013-05-23 17:06:32 -0700 |
commit | 9abb6fae60fa7700d8aa900f1cc2730581d84279 (patch) | |
tree | 31ca5c728981adca5d219223c824b3ecd1d4c633 | |
parent | ecompressdir: indirect symlinks, bug #470916 (diff) | |
download | portage-9abb6fae60fa7700d8aa900f1cc2730581d84279.tar.gz portage-9abb6fae60fa7700d8aa900f1cc2730581d84279.tar.bz2 portage-9abb6fae60fa7700d8aa900f1cc2730581d84279.zip |
fetch: correctly handle file name without scheme
Before, the file name would be passed directly to FETCHCOMMAND as
though it were a valid URI. Now, FETCHCOMMAND will only be called when
there is a valid URI or a mirror to try.
-rw-r--r-- | pym/portage/dbapi/porttree.py | 11 | ||||
-rw-r--r-- | pym/portage/package/ebuild/fetch.py | 13 |
2 files changed, 22 insertions, 2 deletions
diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index 77f633f75..a2082a372 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -44,6 +44,11 @@ import sys import traceback import warnings +try: + from urllib.parse import urlparse +except ImportError: + from urlparse import urlparse + if sys.hexversion >= 0x3000000: basestring = str long = int @@ -1164,7 +1169,11 @@ def _parse_uri_map(cpv, metadata, use=None): # while ensuring uniqueness. uri_set = OrderedDict() uri_map[distfile] = uri_set - uri_set[uri] = True + + # SRC_URI may contain a file name with no scheme, and in + # this case it does not belong in uri_set. + if urlparse(uri).scheme: + uri_set[uri] = True # Convert OrderedDicts to tuples. for k, v in uri_map.items(): diff --git a/pym/portage/package/ebuild/fetch.py b/pym/portage/package/ebuild/fetch.py index 162c7c274..50a1b7216 100644 --- a/pym/portage/package/ebuild/fetch.py +++ b/pym/portage/package/ebuild/fetch.py @@ -14,6 +14,10 @@ import stat import sys import tempfile +try: + from urllib.parse import urlparse +except ImportError: + from urlparse import urlparse import portage portage.proxy.lazyimport.lazyimport(globals(), @@ -402,9 +406,14 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, for myfile, uri_set in myuris.items(): for myuri in uri_set: file_uri_tuples.append((myfile, myuri)) + if not uri_set: + file_uri_tuples.append((myfile, None)) else: for myuri in myuris: - file_uri_tuples.append((os.path.basename(myuri), myuri)) + if urlparse(myuri).scheme: + file_uri_tuples.append((os.path.basename(myuri), myuri)) + else: + file_uri_tuples.append((os.path.basename(myuri), None)) filedict = OrderedDict() primaryuri_dict = {} @@ -414,6 +423,8 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, filedict[myfile]=[] for y in range(0,len(locations)): filedict[myfile].append(locations[y]+"/distfiles/"+myfile) + if myuri is None: + continue if myuri[:9]=="mirror://": eidx = myuri.find("/", 9) if eidx != -1: |