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.
diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py
index 77f633f..a2082a3 100644
--- a/pym/portage/dbapi/porttree.py
+++ b/pym/portage/dbapi/porttree.py
@@ -44,6 +44,11 @@
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 @@
# 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 162c7c2..50a1b72 100644
--- a/pym/portage/package/ebuild/fetch.py
+++ b/pym/portage/package/ebuild/fetch.py
@@ -14,6 +14,10 @@
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 @@
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 @@
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: