mirror of
https://git.yoctoproject.org/poky
synced 2026-05-30 00:20:08 +00:00
bitbake: fetch2: Split try_mirrors into two parts
There are no functionality changes in this change (From Poky rev: d222ebb7c75d74fde4fd04ea6feb27e10a862bae) (Bitbake rev: db62e109cc36380ff8b8918628c9dea14ac9afbc) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -464,6 +464,60 @@ def check_network_access(d, info = "", url = None):
|
|||||||
else:
|
else:
|
||||||
logger.debug(1, "Fetcher accessed the network with the command %s" % info)
|
logger.debug(1, "Fetcher accessed the network with the command %s" % info)
|
||||||
|
|
||||||
|
def try_mirror_url(newuri, origud, ud, ld, check = False):
|
||||||
|
# Return of None or a value means we're finished
|
||||||
|
# False means try another url
|
||||||
|
try:
|
||||||
|
if check:
|
||||||
|
found = ud.method.checkstatus(newuri, ud, ld)
|
||||||
|
if found:
|
||||||
|
return found
|
||||||
|
return False
|
||||||
|
|
||||||
|
os.chdir(ld.getVar("DL_DIR", True))
|
||||||
|
|
||||||
|
if not os.path.exists(ud.donestamp) or 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):
|
||||||
|
return False
|
||||||
|
|
||||||
|
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 os.path.basename(ud.localpath) != os.path.basename(origud.localpath):
|
||||||
|
open(ud.donestamp, 'w').close()
|
||||||
|
dest = os.path.join(dldir, os.path.basename(ud.localpath))
|
||||||
|
if not os.path.exists(dest):
|
||||||
|
os.symlink(ud.localpath, dest)
|
||||||
|
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)
|
||||||
|
update_stamp(newuri, origud, ld)
|
||||||
|
return ud.localpath
|
||||||
|
|
||||||
|
except bb.fetch2.NetworkAccess:
|
||||||
|
raise
|
||||||
|
|
||||||
|
except bb.fetch2.BBFetchException as e:
|
||||||
|
if isinstance(e, ChecksumError):
|
||||||
|
logger.warn("Mirror checksum failure for url %s (original url: %s)\nCleaning and trying again." % (newuri, origud.url))
|
||||||
|
logger.warn(str(e))
|
||||||
|
else:
|
||||||
|
logger.debug(1, "Mirror fetch failure for url %s (original url: %s)" % (newuri, origud.url))
|
||||||
|
logger.debug(1, str(e))
|
||||||
|
try:
|
||||||
|
ud.method.clean(ud, ld)
|
||||||
|
except UnboundLocalError:
|
||||||
|
pass
|
||||||
|
return False
|
||||||
|
|
||||||
def try_mirrors(d, origud, mirrors, check = False):
|
def try_mirrors(d, origud, mirrors, check = False):
|
||||||
"""
|
"""
|
||||||
Try to use a mirrored version of the sources.
|
Try to use a mirrored version of the sources.
|
||||||
@@ -482,59 +536,12 @@ def try_mirrors(d, origud, mirrors, check = False):
|
|||||||
newuri = uri_replace(origud, find, replace, ld)
|
newuri = uri_replace(origud, find, replace, ld)
|
||||||
if not newuri:
|
if not newuri:
|
||||||
continue
|
continue
|
||||||
try:
|
ud = FetchData(newuri, ld)
|
||||||
ud = FetchData(newuri, ld)
|
ud.setup_localpath(ld)
|
||||||
ud.setup_localpath(ld)
|
|
||||||
|
|
||||||
os.chdir(ld.getVar("DL_DIR", True))
|
ret = try_mirror_url(newuri, origud, ud, ld, check)
|
||||||
|
if ret != False:
|
||||||
if check:
|
return ret
|
||||||
found = ud.method.checkstatus(newuri, ud, ld)
|
|
||||||
if found:
|
|
||||||
return found
|
|
||||||
continue
|
|
||||||
|
|
||||||
if not os.path.exists(ud.donestamp) or 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 os.path.basename(ud.localpath) != os.path.basename(origud.localpath):
|
|
||||||
open(ud.donestamp, 'w').close()
|
|
||||||
dest = os.path.join(dldir, os.path.basename(ud.localpath))
|
|
||||||
if not os.path.exists(dest):
|
|
||||||
os.symlink(ud.localpath, dest)
|
|
||||||
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)
|
|
||||||
update_stamp(newuri, origud, ld)
|
|
||||||
return ud.localpath
|
|
||||||
|
|
||||||
except bb.fetch2.NetworkAccess:
|
|
||||||
raise
|
|
||||||
|
|
||||||
except bb.fetch2.BBFetchException as e:
|
|
||||||
if isinstance(e, ChecksumError):
|
|
||||||
logger.warn("Mirror checksum failure for url %s (original url: %s)\nCleaning and trying again." % (newuri, origud.url))
|
|
||||||
logger.warn(str(e))
|
|
||||||
else:
|
|
||||||
logger.debug(1, "Mirror fetch failure for url %s (original url: %s)" % (newuri, origud.url))
|
|
||||||
logger.debug(1, str(e))
|
|
||||||
try:
|
|
||||||
ud.method.clean(ud, ld)
|
|
||||||
except UnboundLocalError:
|
|
||||||
pass
|
|
||||||
continue
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def srcrev_internal_helper(ud, d, name):
|
def srcrev_internal_helper(ud, d, name):
|
||||||
|
|||||||
Reference in New Issue
Block a user