summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2011-02-08 12:46:25 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-02-08 14:02:16 +0000
commitee1a9c0476cc4b2ce9dfb0faa29a1371a8517c40 (patch)
treefdea40e8be2c895c1199d058fdc0e55ddb4283b5 /bitbake
parentc4e66a7fe0c314b843aac6340995c584ec156529 (diff)
downloadpoky-ee1a9c0476cc4b2ce9dfb0faa29a1371a8517c40.tar.gz
bitbake/fetch2: Move symlink handling into try_mirror where is belongs instead of the main download function
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py33
1 files changed, 21 insertions, 12 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index bfc0e2832f..8e35f5487e 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -421,14 +421,31 @@ def try_mirrors(d, origud, mirrors, check = False):
421 found = ud.method.checkstatus(newuri, ud, ld) 421 found = ud.method.checkstatus(newuri, ud, ld)
422 if found: 422 if found:
423 return found 423 return found
424 else: 424 continue
425 if not ud.method.need_update(newuri, ud, ld): 425
426 return ud.localpath 426 if ud.method.need_update(newuri, ud, ld):
427 ud.method.download(newuri, ud, ld) 427 ud.method.download(newuri, ud, ld)
428 if hasattr(ud.method,"build_mirror_data"): 428 if hasattr(ud.method,"build_mirror_data"):
429 ud.method.build_mirror_data(newuri, ud, ld) 429 ud.method.build_mirror_data(newuri, ud, ld)
430
431 if not ud.localpath or not os.path.exists(ud.localpath):
432 continue
433
434 if ud.localpath == origud.localpath:
430 return ud.localpath 435 return ud.localpath
431 436
437 # We may be obtaining a mirror tarball which needs further processing by the real fetcher
438 # If that tarball is a local file:// we need to provide a symlink to it
439 dldir = ld.getVar("DL_DIR", True)
440 if not ud.localpath.startswith(dldir):
441 if os.path.basename(ud.localpath) != os.path.basename(origud.localpath):
442 os.symlink(ud.localpath, os.path.join(dldir, os.path.basename(ud.localpath)))
443 return None
444 # Otherwise the result is a local file:// and we symlink to it
445 if not os.path.exists(origud.localpath):
446 os.symlink(ud.localpath, origud.localpath)
447 return ud.localpath
448
432 except bb.fetch2.BBFetchException: 449 except bb.fetch2.BBFetchException:
433 logger.debug(1, "Mirror fetch failure for url %s (original url: %s)" % (newuri, origud.url)) 450 logger.debug(1, "Mirror fetch failure for url %s (original url: %s)" % (newuri, origud.url))
434 if os.path.isfile(ud.localpath): 451 if os.path.isfile(ud.localpath):
@@ -836,11 +853,7 @@ class Fetch(object):
836 localpath = ud.localpath 853 localpath = ud.localpath
837 elif m.try_premirror(u, ud, self.d): 854 elif m.try_premirror(u, ud, self.d):
838 mirrors = mirror_from_string(bb.data.getVar('PREMIRRORS', self.d, True)) 855 mirrors = mirror_from_string(bb.data.getVar('PREMIRRORS', self.d, True))
839 mirrorpath = try_mirrors(self.d, ud, mirrors, False) 856 localpath = try_mirrors(self.d, ud, mirrors, False)
840 if mirrorpath and os.path.basename(mirrorpath) == os.path.basename(ud.localpath):
841 localpath = mirrorpath
842 elif mirrorpath and os.path.exists(mirrorpath) and not mirrorpath.startswith(self.d.getVar("DL_DIR", True)):
843 os.symlink(mirrorpath, os.path.join(self.d.getVar("DL_DIR", True), os.path.basename(mirrorpath)))
844 857
845 if bb.data.getVar("BB_FETCH_PREMIRRORONLY", self.d, True) is None: 858 if bb.data.getVar("BB_FETCH_PREMIRRORONLY", self.d, True) is None:
846 bb.data.setVar("BB_NO_NETWORK", "1", self.d) 859 bb.data.setVar("BB_NO_NETWORK", "1", self.d)
@@ -862,10 +875,6 @@ class Fetch(object):
862 if not localpath or not os.path.exists(localpath): 875 if not localpath or not os.path.exists(localpath):
863 raise FetchError("Unable to fetch URL %s from any source." % u, u) 876 raise FetchError("Unable to fetch URL %s from any source." % u, u)
864 877
865 # The local fetcher can return an alternate path so we symlink
866 if os.path.exists(localpath) and not os.path.exists(ud.localpath):
867 os.symlink(localpath, ud.localpath)
868
869 if os.path.exists(ud.donestamp): 878 if os.path.exists(ud.donestamp):
870 # Touch the done stamp file to show active use of the download 879 # Touch the done stamp file to show active use of the download
871 try: 880 try: