diff options
author | Joshua Lock <josh@linux.intel.com> | 2010-02-05 12:08:15 +0000 |
---|---|---|
committer | Joshua Lock <josh@linux.intel.com> | 2010-02-05 12:19:05 +0000 |
commit | ec92133d6fc049b4b666d670d3ac263de5a1d103 (patch) | |
tree | 54cfa7e1cb4b0f5e5e752dff80a33b080dec749b /bitbake | |
parent | b5965307e9659ed8ac8796c25fc4f0e7e95e8f1c (diff) | |
download | openembedded-core-ec92133d6fc049b4b666d670d3ac263de5a1d103.tar.gz openembedded-core-ec92133d6fc049b4b666d670d3ac263de5a1d103.tar.bz2 openembedded-core-ec92133d6fc049b4b666d670d3ac263de5a1d103.tar.xz openembedded-core-ec92133d6fc049b4b666d670d3ac263de5a1d103.zip |
bitbake: Test premirrors and mirrors in checkstatus()
checkstatus() is used to ensure we can fetch a copy of each file, so it makes
sense to also test PREMIRRORS and MIRRORS in the method.
This patch adds calls to try_mirrors() to the Fetch.checkstatus() method and
changes the try_mirrors() method to take a check argument, which is False by
default. When check is True try_mirrors() will call a fetchers checkstatus()
with the replaced uri.
Signed-off-by: Joshua Lock <josh@linux.intel.com>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/fetch/__init__.py | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/bitbake/lib/bb/fetch/__init__.py b/bitbake/lib/bb/fetch/__init__.py index 58fa41b4d..4b1203d60 100644 --- a/bitbake/lib/bb/fetch/__init__.py +++ b/bitbake/lib/bb/fetch/__init__.py @@ -219,7 +219,18 @@ def checkstatus(d): ud = urldata[u] m = ud.method bb.msg.note(1, bb.msg.domain.Fetcher, "Testing URL %s" % u) - ret = m.checkstatus(u, ud, d) + # First try checking uri, u, from PREMIRRORS + mirrors = [ i.split() for i in (bb.data.getVar('PREMIRRORS', d, 1) or "").split('\n') if i ] + ret = try_mirrors(d, u, mirrors, True) + if not ret: + # Next try checking from the original uri, u + try: + ret = m.checkstatus(u, ud, d) + except: + # Finally, try checking uri, u, from MIRRORS + mirrors = [ i.split() for i in (bb.data.getVar('MIRRORS', d, 1) or "").split('\n') if i ] + ret = try_mirrors (d, u, mirrors, True) + if not ret: bb.msg.fatal(bb.msg.domain.Fetcher, "URL %s doesn't work" % u) @@ -348,7 +359,7 @@ def runfetchcmd(cmd, d, quiet = False): return output -def try_mirrors(d, uri, mirrors): +def try_mirrors(d, uri, mirrors, check = False): """ Try to use a mirrored version of the sources. This method will be automatically called before the fetchers go. @@ -358,7 +369,7 @@ def try_mirrors(d, uri, mirrors): mirrors is the list of mirrors we're going to try """ fpath = os.path.join(data.getVar("DL_DIR", d, 1), os.path.basename(uri)) - if os.access(fpath, os.R_OK): + if not check and os.access.path(fpath, os.R_OK): bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists, skipping checkout." % fpath) return fpath @@ -375,7 +386,10 @@ def try_mirrors(d, uri, mirrors): ud.setup_localpath(ld) try: - ud.method.go(newuri, ud, ld) + if check: + ud.method.go(newuri, ud, ld) + else: + ud.method.checkstatus(newuri, ud, ld) return ud.localpath except (bb.fetch.MissingParameterError, bb.fetch.FetchError, |