summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2010-10-07 15:42:15 +0100
committerRichard Purdie <rpurdie@linux.intel.com>2010-10-07 15:42:15 +0100
commit24ad63979f08c13867a5d7fd489ba8368dd9ee60 (patch)
tree526b3b8047e4c8d577a42377734d2f22428a4a76 /bitbake/lib/bb
parent0e0fadb400b4656c4b15ae4120aa39ff8ed72985 (diff)
downloadpoky-24ad63979f08c13867a5d7fd489ba8368dd9ee60.tar.gz
bitbake/fetch/__init__.py: Abstract mirror variable handling and enhance to accept \n delimitation in variables
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r--bitbake/lib/bb/fetch/__init__.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/bitbake/lib/bb/fetch/__init__.py b/bitbake/lib/bb/fetch/__init__.py
index c678e6185c..156b815569 100644
--- a/bitbake/lib/bb/fetch/__init__.py
+++ b/bitbake/lib/bb/fetch/__init__.py
@@ -222,6 +222,9 @@ def init(urls, d, setup = True):
222 urldata_cache[fn] = urldata 222 urldata_cache[fn] = urldata
223 return urldata 223 return urldata
224 224
225def mirror_from_string(data):
226 return [ i.split() for i in (data or "").replace('\\n','\n').split('\n') if i ]
227
225def go(d, urls = None): 228def go(d, urls = None):
226 """ 229 """
227 Fetch all urls 230 Fetch all urls
@@ -261,7 +264,7 @@ def go(d, urls = None):
261 264
262 if premirror_fetch: 265 if premirror_fetch:
263 # First try fetching uri, u, from PREMIRRORS 266 # First try fetching uri, u, from PREMIRRORS
264 mirrors = [ i.split() for i in (bb.data.getVar('PREMIRRORS', d, 1) or "").split('\n') if i ] 267 mirrors = mirror_from_string(bb.data.getVar('PREMIRRORS', d, True))
265 localpath = try_mirrors(d, u, mirrors, False, m.forcefetch(u, ud, d)) 268 localpath = try_mirrors(d, u, mirrors, False, m.forcefetch(u, ud, d))
266 elif os.path.exists(ud.localfile): 269 elif os.path.exists(ud.localfile):
267 localpath = ud.localfile 270 localpath = ud.localfile
@@ -274,7 +277,7 @@ def go(d, urls = None):
274 localpath = ud.localpath 277 localpath = ud.localpath
275 except FetchError: 278 except FetchError:
276 # Finally, try fetching uri, u, from MIRRORS 279 # Finally, try fetching uri, u, from MIRRORS
277 mirrors = [ i.split() for i in (bb.data.getVar('MIRRORS', d, 1) or "").split('\n') if i ] 280 mirrors = mirror_from_string(bb.data.getVar('MIRRORS', d, True))
278 localpath = try_mirrors (d, u, mirrors) 281 localpath = try_mirrors (d, u, mirrors)
279 if not localpath or not os.path.exists(localpath): 282 if not localpath or not os.path.exists(localpath):
280 raise FetchError("Unable to fetch URL %s from any source." % u) 283 raise FetchError("Unable to fetch URL %s from any source." % u)
@@ -300,7 +303,7 @@ def checkstatus(d):
300 m = ud.method 303 m = ud.method
301 bb.msg.note(1, bb.msg.domain.Fetcher, "Testing URL %s" % u) 304 bb.msg.note(1, bb.msg.domain.Fetcher, "Testing URL %s" % u)
302 # First try checking uri, u, from PREMIRRORS 305 # First try checking uri, u, from PREMIRRORS
303 mirrors = [ i.split() for i in (bb.data.getVar('PREMIRRORS', d, 1) or "").split('\n') if i ] 306 mirrors = mirror_from_string(bb.data.getVar('PREMIRRORS', d, True))
304 ret = try_mirrors(d, u, mirrors, True) 307 ret = try_mirrors(d, u, mirrors, True)
305 if not ret: 308 if not ret:
306 # Next try checking from the original uri, u 309 # Next try checking from the original uri, u
@@ -308,7 +311,7 @@ def checkstatus(d):
308 ret = m.checkstatus(u, ud, d) 311 ret = m.checkstatus(u, ud, d)
309 except: 312 except:
310 # Finally, try checking uri, u, from MIRRORS 313 # Finally, try checking uri, u, from MIRRORS
311 mirrors = [ i.split() for i in (bb.data.getVar('MIRRORS', d, 1) or "").split('\n') if i ] 314 mirrors = mirror_from_string(bb.data.getVar('MIRRORS', d, True))
312 ret = try_mirrors (d, u, mirrors, True) 315 ret = try_mirrors (d, u, mirrors, True)
313 316
314 if not ret: 317 if not ret:
@@ -516,7 +519,7 @@ class FetchData(object):
516 local = "" 519 local = ""
517 if premirrors and self.url: 520 if premirrors and self.url:
518 aurl = self.url.split(";")[0] 521 aurl = self.url.split(";")[0]
519 mirrors = [ i.split() for i in (premirrors or "").split('\n') if i ] 522 mirrors = mirror_from_string(premirrors)
520 for (find, replace) in mirrors: 523 for (find, replace) in mirrors:
521 if replace.startswith("file://"): 524 if replace.startswith("file://"):
522 path = aurl.split("://")[1] 525 path = aurl.split("://")[1]