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>
This commit is contained in:
parent
b5965307e9
commit
ec92133d6f
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue