1 |
commit: 9abb6fae60fa7700d8aa900f1cc2730581d84279 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri May 24 00:06:32 2013 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri May 24 00:06:32 2013 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=9abb6fae |
7 |
|
8 |
fetch: correctly handle file name without scheme |
9 |
|
10 |
Before, the file name would be passed directly to FETCHCOMMAND as |
11 |
though it were a valid URI. Now, FETCHCOMMAND will only be called when |
12 |
there is a valid URI or a mirror to try. |
13 |
|
14 |
--- |
15 |
pym/portage/dbapi/porttree.py | 11 ++++++++++- |
16 |
pym/portage/package/ebuild/fetch.py | 13 ++++++++++++- |
17 |
2 files changed, 22 insertions(+), 2 deletions(-) |
18 |
|
19 |
diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py |
20 |
index 77f633f..a2082a3 100644 |
21 |
--- a/pym/portage/dbapi/porttree.py |
22 |
+++ b/pym/portage/dbapi/porttree.py |
23 |
@@ -44,6 +44,11 @@ import sys |
24 |
import traceback |
25 |
import warnings |
26 |
|
27 |
+try: |
28 |
+ from urllib.parse import urlparse |
29 |
+except ImportError: |
30 |
+ from urlparse import urlparse |
31 |
+ |
32 |
if sys.hexversion >= 0x3000000: |
33 |
basestring = str |
34 |
long = int |
35 |
@@ -1164,7 +1169,11 @@ def _parse_uri_map(cpv, metadata, use=None): |
36 |
# while ensuring uniqueness. |
37 |
uri_set = OrderedDict() |
38 |
uri_map[distfile] = uri_set |
39 |
- uri_set[uri] = True |
40 |
+ |
41 |
+ # SRC_URI may contain a file name with no scheme, and in |
42 |
+ # this case it does not belong in uri_set. |
43 |
+ if urlparse(uri).scheme: |
44 |
+ uri_set[uri] = True |
45 |
|
46 |
# Convert OrderedDicts to tuples. |
47 |
for k, v in uri_map.items(): |
48 |
|
49 |
diff --git a/pym/portage/package/ebuild/fetch.py b/pym/portage/package/ebuild/fetch.py |
50 |
index 162c7c2..50a1b72 100644 |
51 |
--- a/pym/portage/package/ebuild/fetch.py |
52 |
+++ b/pym/portage/package/ebuild/fetch.py |
53 |
@@ -14,6 +14,10 @@ import stat |
54 |
import sys |
55 |
import tempfile |
56 |
|
57 |
+try: |
58 |
+ from urllib.parse import urlparse |
59 |
+except ImportError: |
60 |
+ from urlparse import urlparse |
61 |
|
62 |
import portage |
63 |
portage.proxy.lazyimport.lazyimport(globals(), |
64 |
@@ -402,9 +406,14 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, |
65 |
for myfile, uri_set in myuris.items(): |
66 |
for myuri in uri_set: |
67 |
file_uri_tuples.append((myfile, myuri)) |
68 |
+ if not uri_set: |
69 |
+ file_uri_tuples.append((myfile, None)) |
70 |
else: |
71 |
for myuri in myuris: |
72 |
- file_uri_tuples.append((os.path.basename(myuri), myuri)) |
73 |
+ if urlparse(myuri).scheme: |
74 |
+ file_uri_tuples.append((os.path.basename(myuri), myuri)) |
75 |
+ else: |
76 |
+ file_uri_tuples.append((os.path.basename(myuri), None)) |
77 |
|
78 |
filedict = OrderedDict() |
79 |
primaryuri_dict = {} |
80 |
@@ -414,6 +423,8 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, |
81 |
filedict[myfile]=[] |
82 |
for y in range(0,len(locations)): |
83 |
filedict[myfile].append(locations[y]+"/distfiles/"+myfile) |
84 |
+ if myuri is None: |
85 |
+ continue |
86 |
if myuri[:9]=="mirror://": |
87 |
eidx = myuri.find("/", 9) |
88 |
if eidx != -1: |