summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2011-02-03 18:22:06 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-02-10 23:36:52 +0000
commit83f9445081595630488a5d3e170d282a13836c98 (patch)
treec08a1aaa7d1d4f27355d7b243b0e9d946cb279e3
parent2217e9af98d5cd7755b84b5961298efa845910f8 (diff)
downloadbitbake-83f9445081595630488a5d3e170d282a13836c98.tar.gz
bitbake/fetch2: Ensure that mirror fetches are symlinked from the download directory
When files are fetched from a mirror source that happens to be local, ensure links are created for the file since subsequent fetch calls can then follow the links to find files. Any other approach such as the existing manipulations of localpath internally to the fetcher are prone to errors, races and other issues. (From Poky rev: fa9fda05e1d269446b51050195b891346482e8bb) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bb/fetch2/__init__.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
index 43ba772db..2e8dab9f5 100644
--- a/lib/bb/fetch2/__init__.py
+++ b/lib/bb/fetch2/__init__.py
@@ -263,6 +263,15 @@ def subprocess_setup():
# SIGPIPE errors are known issues with gzip/bash
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
+def download_update(result, target):
+ if os.path.exists(target):
+ return
+ if not result or not os.path.exists(result):
+ return
+ if target != result:
+ os.symlink(result, target)
+ return
+
def download(d, urls = None):
"""
Fetch all urls
@@ -289,6 +298,8 @@ def download(d, urls = None):
elif os.path.exists(ud.localfile):
localpath = ud.localfile
+ download_update(localpath, ud.localpath)
+
# Need to re-test forcefetch() which will return true if our copy is too old
if m.forcefetch(u, ud, d) or not localpath:
# Next try fetching from the original uri, u
@@ -297,16 +308,19 @@ def download(d, urls = None):
if hasattr(m, "build_mirror_data"):
m.build_mirror_data(u, ud, d)
localpath = ud.localpath
+ download_update(localpath, ud.localpath)
+
except FetchError:
# Remove any incomplete file
bb.utils.remove(ud.localpath)
# Finally, try fetching uri, u, from MIRRORS
mirrors = mirror_from_string(bb.data.getVar('MIRRORS', d, True))
localpath = try_mirrors (d, u, mirrors)
- if not localpath or not os.path.exists(localpath):
- raise FetchError("Unable to fetch URL %s from any source." % u)
- ud.localpath = localpath
+ if not localpath or not os.path.exists(localpath):
+ raise FetchError("Unable to fetch URL %s from any source." % u)
+
+ download_update(localpath, ud.localpath)
if os.path.exists(ud.md5):
# Touch the md5 file to show active use of the download