summaryrefslogtreecommitdiff
path: root/bitbake/lib
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/lib
parentc4e66a7fe0c314b843aac6340995c584ec156529 (diff)
downloadopenembedded-core-ee1a9c0476cc4b2ce9dfb0faa29a1371a8517c40.tar.gz
openembedded-core-ee1a9c0476cc4b2ce9dfb0faa29a1371a8517c40.tar.bz2
openembedded-core-ee1a9c0476cc4b2ce9dfb0faa29a1371a8517c40.tar.xz
openembedded-core-ee1a9c0476cc4b2ce9dfb0faa29a1371a8517c40.zip
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/lib')
-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 bfc0e2832..8e35f5487 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):
found = ud.method.checkstatus(newuri, ud, ld)
if found:
return found
- else:
- if not ud.method.need_update(newuri, ud, ld):
- return ud.localpath
+ continue
+
+ if ud.method.need_update(newuri, ud, ld):
ud.method.download(newuri, ud, ld)
if hasattr(ud.method,"build_mirror_data"):
ud.method.build_mirror_data(newuri, ud, ld)
+
+ if not ud.localpath or not os.path.exists(ud.localpath):
+ continue
+
+ if ud.localpath == origud.localpath:
return ud.localpath
+ # We may be obtaining a mirror tarball which needs further processing by the real fetcher
+ # If that tarball is a local file:// we need to provide a symlink to it
+ dldir = ld.getVar("DL_DIR", True)
+ if not ud.localpath.startswith(dldir):
+ if os.path.basename(ud.localpath) != os.path.basename(origud.localpath):
+ os.symlink(ud.localpath, os.path.join(dldir, os.path.basename(ud.localpath)))
+ return None
+ # Otherwise the result is a local file:// and we symlink to it
+ if not os.path.exists(origud.localpath):
+ os.symlink(ud.localpath, origud.localpath)
+ return ud.localpath
+
except bb.fetch2.BBFetchException:
logger.debug(1, "Mirror fetch failure for url %s (original url: %s)" % (newuri, origud.url))
if os.path.isfile(ud.localpath):
@@ -836,11 +853,7 @@ class Fetch(object):
localpath = ud.localpath
elif m.try_premirror(u, ud, self.d):
mirrors = mirror_from_string(bb.data.getVar('PREMIRRORS', self.d, True))
- mirrorpath = try_mirrors(self.d, ud, mirrors, False)
- if mirrorpath and os.path.basename(mirrorpath) == os.path.basename(ud.localpath):
- localpath = mirrorpath
- elif mirrorpath and os.path.exists(mirrorpath) and not mirrorpath.startswith(self.d.getVar("DL_DIR", True)):
- os.symlink(mirrorpath, os.path.join(self.d.getVar("DL_DIR", True), os.path.basename(mirrorpath)))
+ localpath = try_mirrors(self.d, ud, mirrors, False)
if bb.data.getVar("BB_FETCH_PREMIRRORONLY", self.d, True) is None:
bb.data.setVar("BB_NO_NETWORK", "1", self.d)
@@ -862,10 +875,6 @@ class Fetch(object):
if not localpath or not os.path.exists(localpath):
raise FetchError("Unable to fetch URL %s from any source." % u, u)
- # The local fetcher can return an alternate path so we symlink
- if os.path.exists(localpath) and not os.path.exists(ud.localpath):
- os.symlink(localpath, ud.localpath)
-
if os.path.exists(ud.donestamp):
# Touch the done stamp file to show active use of the download
try: