summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2011-02-07 15:28:05 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-02-07 19:48:21 +0000
commit94faffdaf6c13ce59987aab28383d66a9a0bf100 (patch)
tree7991efbdb304abcac7fef0ce4c7c8d2405562a4a
parent37624b97450f2ba3d6fad3e1e51818486451447e (diff)
downloadpoky-94faffdaf6c13ce59987aab28383d66a9a0bf100.tar.gz
bitbake/fetch2: Update mirror processing to ensure we look for mirror tarballs
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py37
1 files changed, 21 insertions, 16 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index 9b378a85e7..dda70db489 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -168,10 +168,10 @@ def encodeurl(decoded):
168 168
169 return url 169 return url
170 170
171def uri_replace(uri, uri_find, uri_replace, d): 171def uri_replace(ud, uri_find, uri_replace, d):
172 if not uri or not uri_find or not uri_replace: 172 if not ud.url or not uri_find or not uri_replace:
173 logger.debug(1, "uri_replace: passed an undefined value, not replacing") 173 logger.debug(1, "uri_replace: passed an undefined value, not replacing")
174 uri_decoded = list(decodeurl(uri)) 174 uri_decoded = list(decodeurl(ud.url))
175 uri_find_decoded = list(decodeurl(uri_find)) 175 uri_find_decoded = list(decodeurl(uri_find))
176 uri_replace_decoded = list(decodeurl(uri_replace)) 176 uri_replace_decoded = list(decodeurl(uri_replace))
177 result_decoded = ['', '', '', '', '', {}] 177 result_decoded = ['', '', '', '', '', {}]
@@ -182,12 +182,12 @@ def uri_replace(uri, uri_find, uri_replace, d):
182 if (re.match(i, uri_decoded[loc])): 182 if (re.match(i, uri_decoded[loc])):
183 result_decoded[loc] = re.sub(i, uri_replace_decoded[loc], uri_decoded[loc]) 183 result_decoded[loc] = re.sub(i, uri_replace_decoded[loc], uri_decoded[loc])
184 if uri_find_decoded.index(i) == 2: 184 if uri_find_decoded.index(i) == 2:
185 if d: 185 if ud.mirrortarball:
186 localfn = bb.fetch2.localpath(uri, d) 186 result_decoded[loc] = os.path.join(os.path.dirname(result_decoded[loc]), os.path.basename(ud.mirrortarball))
187 if localfn: 187 elif ud.localpath:
188 result_decoded[loc] = os.path.join(os.path.dirname(result_decoded[loc]), os.path.basename(bb.fetch2.localpath(uri, d))) 188 result_decoded[loc] = os.path.join(os.path.dirname(result_decoded[loc]), os.path.basename(ud.localpath))
189 else: 189 else:
190 return uri 190 return ud.url
191 return encodeurl(result_decoded) 191 return encodeurl(result_decoded)
192 192
193methods = [] 193methods = []
@@ -392,7 +392,7 @@ def check_network_access(d, info = ""):
392 else: 392 else:
393 logger.debug(1, "Fetcher accessed the network with the command %s" % info) 393 logger.debug(1, "Fetcher accessed the network with the command %s" % info)
394 394
395def try_mirrors(d, uri, mirrors, check = False): 395def try_mirrors(d, ud, mirrors, check = False):
396 """ 396 """
397 Try to use a mirrored version of the sources. 397 Try to use a mirrored version of the sources.
398 This method will be automatically called before the fetchers go. 398 This method will be automatically called before the fetchers go.
@@ -403,8 +403,8 @@ def try_mirrors(d, uri, mirrors, check = False):
403 """ 403 """
404 ld = d.createCopy() 404 ld = d.createCopy()
405 for (find, replace) in mirrors: 405 for (find, replace) in mirrors:
406 newuri = uri_replace(uri, find, replace, ld) 406 newuri = uri_replace(ud, find, replace, ld)
407 if newuri == uri: 407 if newuri == ud.url:
408 continue 408 continue
409 try: 409 try:
410 ud = FetchData(newuri, ld) 410 ud = FetchData(newuri, ld)
@@ -423,7 +423,7 @@ def try_mirrors(d, uri, mirrors, check = False):
423 return ud.localpath 423 return ud.localpath
424 424
425 except bb.fetch2.BBFetchException: 425 except bb.fetch2.BBFetchException:
426 logger.debug(1, "Mirror fetch failure for url %s (original url: %s)" % (newuri, uri)) 426 logger.debug(1, "Mirror fetch failure for url %s (original url: %s)" % (newuri, ud.url))
427 bb.utils.remove(ud.localpath) 427 bb.utils.remove(ud.localpath)
428 continue 428 continue
429 return None 429 return None
@@ -466,6 +466,7 @@ class FetchData(object):
466 self.localfile = "" 466 self.localfile = ""
467 self.localpath = None 467 self.localpath = None
468 self.lockfile = None 468 self.lockfile = None
469 self.mirrortarball = None
469 (self.type, self.host, self.path, self.user, self.pswd, self.parm) = decodeurl(data.expand(url, d)) 470 (self.type, self.host, self.path, self.user, self.pswd, self.parm) = decodeurl(data.expand(url, d))
470 self.date = self.getSRCDate(d) 471 self.date = self.getSRCDate(d)
471 self.url = url 472 self.url = url
@@ -825,7 +826,11 @@ class Fetch(object):
825 localpath = ud.localpath 826 localpath = ud.localpath
826 elif m.try_premirror(u, ud, self.d): 827 elif m.try_premirror(u, ud, self.d):
827 mirrors = mirror_from_string(bb.data.getVar('PREMIRRORS', self.d, True)) 828 mirrors = mirror_from_string(bb.data.getVar('PREMIRRORS', self.d, True))
828 localpath = try_mirrors(self.d, u, mirrors, False) 829 mirrorpath = try_mirrors(self.d, ud, mirrors, False)
830 if mirrorpath and os.path.basename(mirrorpath) == os.path.basename(ud.localpath):
831 localpath = mirrorpath
832 elif mirrorpath and os.path.exists(mirrorpath) and not mirrorpath.startswith(self.d.getVar("DL_DIR", True)):
833 os.symlink(mirrorpath, os.path.join(self.d.getVar("DL_DIR", True), os.path.basename(mirrorpath)))
829 834
830 if bb.data.getVar("BB_FETCH_PREMIRRORONLY", self.d, True) is None: 835 if bb.data.getVar("BB_FETCH_PREMIRRORONLY", self.d, True) is None:
831 if not localpath and m.need_update(u, ud, self.d): 836 if not localpath and m.need_update(u, ud, self.d):
@@ -839,7 +844,7 @@ class Fetch(object):
839 # Remove any incomplete file 844 # Remove any incomplete file
840 bb.utils.remove(ud.localpath) 845 bb.utils.remove(ud.localpath)
841 mirrors = mirror_from_string(bb.data.getVar('MIRRORS', self.d, True)) 846 mirrors = mirror_from_string(bb.data.getVar('MIRRORS', self.d, True))
842 localpath = try_mirrors (self.d, u, mirrors) 847 localpath = try_mirrors (self.d, ud, mirrors)
843 848
844 if not localpath or not os.path.exists(localpath): 849 if not localpath or not os.path.exists(localpath):
845 raise FetchError("Unable to fetch URL %s from any source." % u, u) 850 raise FetchError("Unable to fetch URL %s from any source." % u, u)
@@ -877,7 +882,7 @@ class Fetch(object):
877 logger.debug(1, "Testing URL %s", u) 882 logger.debug(1, "Testing URL %s", u)
878 # First try checking uri, u, from PREMIRRORS 883 # First try checking uri, u, from PREMIRRORS
879 mirrors = mirror_from_string(bb.data.getVar('PREMIRRORS', self.d, True)) 884 mirrors = mirror_from_string(bb.data.getVar('PREMIRRORS', self.d, True))
880 ret = try_mirrors(self.d, u, mirrors, True) 885 ret = try_mirrors(self.d, ud, mirrors, True)
881 if not ret: 886 if not ret:
882 # Next try checking from the original uri, u 887 # Next try checking from the original uri, u
883 try: 888 try:
@@ -885,7 +890,7 @@ class Fetch(object):
885 except: 890 except:
886 # Finally, try checking uri, u, from MIRRORS 891 # Finally, try checking uri, u, from MIRRORS
887 mirrors = mirror_from_string(bb.data.getVar('MIRRORS', self.d, True)) 892 mirrors = mirror_from_string(bb.data.getVar('MIRRORS', self.d, True))
888 ret = try_mirrors (self.d, u, mirrors, True) 893 ret = try_mirrors (self.d, ud, mirrors, True)
889 894
890 if not ret: 895 if not ret:
891 raise FetchError("URL %s doesn't work" % u, u) 896 raise FetchError("URL %s doesn't work" % u, u)