summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py13
-rw-r--r--bitbake/lib/bb/tests/fetch.py14
2 files changed, 22 insertions, 5 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index 88c92c0b03..844f24aa5e 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -182,7 +182,7 @@ def encodeurl(decoded):
182 182
183 return url 183 return url
184 184
185def uri_replace(ud, uri_find, uri_replace, d): 185def uri_replace(ud, uri_find, uri_replace, replacements, d):
186 if not ud.url or not uri_find or not uri_replace: 186 if not ud.url or not uri_find or not uri_replace:
187 logger.error("uri_replace: passed an undefined value, not replacing") 187 logger.error("uri_replace: passed an undefined value, not replacing")
188 return None 188 return None
@@ -213,6 +213,8 @@ def uri_replace(ud, uri_find, uri_replace, d):
213 if not uri_replace_decoded[loc]: 213 if not uri_replace_decoded[loc]:
214 result_decoded[loc] = "" 214 result_decoded[loc] = ""
215 else: 215 else:
216 for k in replacements:
217 uri_replace_decoded[loc] = uri_replace_decoded[loc].replace(k, replacements[k])
216 #bb.note("%s %s %s" % (i, uri_replace_decoded[loc], uri_decoded[loc])) 218 #bb.note("%s %s %s" % (i, uri_replace_decoded[loc], uri_decoded[loc]))
217 result_decoded[loc] = re.sub(i, uri_replace_decoded[loc], uri_decoded[loc]) 219 result_decoded[loc] = re.sub(i, uri_replace_decoded[loc], uri_decoded[loc])
218 if loc == 2: 220 if loc == 2:
@@ -485,13 +487,20 @@ def build_mirroruris(origud, mirrors, ld):
485 uris = [] 487 uris = []
486 uds = [] 488 uds = []
487 489
490 replacements = {}
491 replacements["TYPE"] = origud.type
492 replacements["HOST"] = origud.host
493 replacements["PATH"] = origud.path
494 replacements["BASENAME"] = origud.path.split("/")[-1]
495 replacements["MIRRORNAME"] = origud.host.replace(':','.') + origud.path.replace('/', '.')
496
488 def adduri(uri, ud, uris, uds): 497 def adduri(uri, ud, uris, uds):
489 for line in mirrors: 498 for line in mirrors:
490 try: 499 try:
491 (find, replace) = line 500 (find, replace) = line
492 except ValueError: 501 except ValueError:
493 continue 502 continue
494 newuri = uri_replace(ud, find, replace, ld) 503 newuri = uri_replace(ud, find, replace, replacements, ld)
495 if not newuri or newuri in uris or newuri == origud.url: 504 if not newuri or newuri in uris or newuri == origud.url:
496 continue 505 continue
497 try: 506 try:
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index 9961343d76..1477fab0e7 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -48,7 +48,14 @@ class FetcherTest(unittest.TestCase):
48 ("http://www.apache.org/dist/subversion/subversion-1.7.1.tar.bz2", "http://www.apache.org/dist", "http://archive.apache.org/dist") 48 ("http://www.apache.org/dist/subversion/subversion-1.7.1.tar.bz2", "http://www.apache.org/dist", "http://archive.apache.org/dist")
49 : "http://archive.apache.org/dist/subversion/subversion-1.7.1.tar.bz2", 49 : "http://archive.apache.org/dist/subversion/subversion-1.7.1.tar.bz2",
50 ("http://www.apache.org/dist/subversion/subversion-1.7.1.tar.bz2", "http://.*/.*", "file:///somepath/downloads/") 50 ("http://www.apache.org/dist/subversion/subversion-1.7.1.tar.bz2", "http://.*/.*", "file:///somepath/downloads/")
51 : "file:///somepath/downloads/subversion-1.7.1.tar.bz2" 51 : "file:///somepath/downloads/subversion-1.7.1.tar.bz2",
52 ("git://git.invalid.infradead.org/mtd-utils.git;tag=1234567890123456789012345678901234567890", "git://.*/.*", "git://somewhere.org/somedir/BASENAME;protocol=http")
53 : "git://somewhere.org/somedir/mtd-utils.git;tag=1234567890123456789012345678901234567890;protocol=http",
54 ("git://git.invalid.infradead.org/foo/mtd-utils.git;tag=1234567890123456789012345678901234567890", "git://.*/.*", "git://somewhere.org/somedir/BASENAME;protocol=http")
55 : "git://somewhere.org/somedir/mtd-utils.git;tag=1234567890123456789012345678901234567890;protocol=http",
56 ("git://git.invalid.infradead.org/foo/mtd-utils.git;tag=1234567890123456789012345678901234567890", "git://.*/.*", "git://somewhere.org/somedir/MIRRORNAME;protocol=http")
57 : "git://somewhere.org/somedir/git.invalid.infradead.org.foo.mtd-utils.git;tag=1234567890123456789012345678901234567890;protocol=http",
58
52 #Renaming files doesn't work 59 #Renaming files doesn't work
53 #("http://somewhere.org/somedir1/somefile_1.2.3.tar.gz", "http://somewhere.org/somedir1/somefile_1.2.3.tar.gz", "http://somewhere2.org/somedir3/somefile_2.3.4.tar.gz") : "http://somewhere2.org/somedir3/somefile_2.3.4.tar.gz" 60 #("http://somewhere.org/somedir1/somefile_1.2.3.tar.gz", "http://somewhere.org/somedir1/somefile_1.2.3.tar.gz", "http://somewhere2.org/somedir3/somefile_2.3.4.tar.gz") : "http://somewhere2.org/somedir3/somefile_2.3.4.tar.gz"
54 #("file://sstate-xyz.tgz", "file://.*/.*", "file:///somewhere/1234/sstate-cache") : "file:///somewhere/1234/sstate-cache/sstate-xyz.tgz", 61 #("file://sstate-xyz.tgz", "file://.*/.*", "file:///somewhere/1234/sstate-cache") : "file:///somewhere/1234/sstate-cache/sstate-xyz.tgz",
@@ -143,8 +150,9 @@ class FetcherTest(unittest.TestCase):
143 for k, v in self.replaceuris.items(): 150 for k, v in self.replaceuris.items():
144 ud = bb.fetch.FetchData(k[0], self.d) 151 ud = bb.fetch.FetchData(k[0], self.d)
145 ud.setup_localpath(self.d) 152 ud.setup_localpath(self.d)
146 newuris = bb.fetch2.uri_replace(ud, k[1], k[2], self.d) 153 mirrors = bb.fetch2.mirror_from_string("%s %s" % (k[1], k[2]))
147 self.assertEqual(newuris, v) 154 newuris, uds = bb.fetch2.build_mirroruris(ud, mirrors, self.d)
155 self.assertEqual(newuris, [v])
148 156
149 def test_urilist1(self): 157 def test_urilist1(self):
150 fetcher = bb.fetch.FetchData("http://downloads.yoctoproject.org/releases/bitbake/bitbake-1.0.tar.gz", self.d) 158 fetcher = bb.fetch.FetchData("http://downloads.yoctoproject.org/releases/bitbake/bitbake-1.0.tar.gz", self.d)