summaryrefslogtreecommitdiffstats
path: root/lib/bb/fetch/__init__.py
diff options
context:
space:
mode:
authorJoshua Lock <josh@linux.intel.com>2010-02-05 12:08:15 +0000
committerRichard Purdie <rpurdie@linux.intel.com>2010-02-15 17:18:44 +0000
commitf084f2aaea012ffddba924610d0954f743993c17 (patch)
tree3fe33dc9b594de387621e01b4401d97883d6a687 /lib/bb/fetch/__init__.py
parent1d65af155751885cf2a84df586b8a28e21cd9078 (diff)
downloadbitbake-f084f2aaea012ffddba924610d0954f743993c17.tar.gz
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. (From Poky rev: ec92133d6fc049b4b666d670d3ac263de5a1d103) Signed-off-by: Joshua Lock <josh@linux.intel.com> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'lib/bb/fetch/__init__.py')
-rw-r--r--lib/bb/fetch/__init__.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/bb/fetch/__init__.py b/lib/bb/fetch/__init__.py
index 58fa41b4d..4b1203d60 100644
--- a/lib/bb/fetch/__init__.py
+++ b/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,