From 9abb6fae60fa7700d8aa900f1cc2730581d84279 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 23 May 2013 17:06:32 -0700 Subject: [PATCH] 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. --- pym/portage/dbapi/porttree.py | 11 ++++++++++- 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: -- 2.26.2