aboutsummaryrefslogtreecommitdiffstats
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-10 23:37:18 +0000
commit25204a6a816a6c8c4cbe2debea5f669d09f82af3 (patch)
tree110c73dc67a1465d63eb9914abadc2428fb5c754
parent76e999c59875214e6eca4a57b5d34b983821aef8 (diff)
downloadbitbake-25204a6a816a6c8c4cbe2debea5f669d09f82af3.tar.gz
bitbake-25204a6a816a6c8c4cbe2debea5f669d09f82af3.tar.bz2
bitbake-25204a6a816a6c8c4cbe2debea5f669d09f82af3.zip
bitbake/fetch2: Move symlink handling into try_mirror where is belongs instead of the main download function
(From Poky rev: ee1a9c0476cc4b2ce9dfb0faa29a1371a8517c40) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bb/fetch2/__init__.py33
1 files changed, 21 insertions, 12 deletions
diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
index bfc0e283..8e35f548 100644
--- a/lib/bb/fetch2/__init__.py
+++ b/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: