1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-01 13:09:50 +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:
Richard Purdie
2012-06-20 12:46:32 +00:00
parent 927565c3b1
commit f3fb4dc40f
+32 -25
View File
@@ -464,35 +464,17 @@ 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_mirrors(d, origud, mirrors, check = False): def try_mirror_url(newuri, origud, ud, ld, check = False):
""" # Return of None or a value means we're finished
Try to use a mirrored version of the sources. # False means try another url
This method will be automatically called before the fetchers go.
d Is a bb.data instance
uri is the original uri we're trying to download
mirrors is the list of mirrors we're going to try
"""
ld = d.createCopy()
for line in mirrors:
try: try:
(find, replace) = line
except ValueError:
continue
newuri = uri_replace(origud, find, replace, ld)
if not newuri:
continue
try:
ud = FetchData(newuri, ld)
ud.setup_localpath(ld)
os.chdir(ld.getVar("DL_DIR", True))
if check: if check:
found = ud.method.checkstatus(newuri, ud, ld) found = ud.method.checkstatus(newuri, ud, ld)
if found: if found:
return found return found
continue return False
os.chdir(ld.getVar("DL_DIR", True))
if not os.path.exists(ud.donestamp) or ud.method.need_update(newuri, ud, ld): if not os.path.exists(ud.donestamp) or ud.method.need_update(newuri, ud, ld):
ud.method.download(newuri, ud, ld) ud.method.download(newuri, ud, ld)
@@ -500,7 +482,7 @@ def try_mirrors(d, origud, mirrors, check = False):
ud.method.build_mirror_data(newuri, ud, ld) ud.method.build_mirror_data(newuri, ud, ld)
if not ud.localpath or not os.path.exists(ud.localpath): if not ud.localpath or not os.path.exists(ud.localpath):
continue return False
if ud.localpath == origud.localpath: if ud.localpath == origud.localpath:
return ud.localpath return ud.localpath
@@ -534,7 +516,32 @@ def try_mirrors(d, origud, mirrors, check = False):
ud.method.clean(ud, ld) ud.method.clean(ud, ld)
except UnboundLocalError: except UnboundLocalError:
pass pass
return False
def try_mirrors(d, origud, mirrors, check = False):
"""
Try to use a mirrored version of the sources.
This method will be automatically called before the fetchers go.
d Is a bb.data instance
uri is the original uri we're trying to download
mirrors is the list of mirrors we're going to try
"""
ld = d.createCopy()
for line in mirrors:
try:
(find, replace) = line
except ValueError:
continue continue
newuri = uri_replace(origud, find, replace, ld)
if not newuri:
continue
ud = FetchData(newuri, ld)
ud.setup_localpath(ld)
ret = try_mirror_url(newuri, origud, ud, ld, check)
if ret != False:
return ret
return None return None
def srcrev_internal_helper(ud, d, name): def srcrev_internal_helper(ud, d, name):