mirror of
https://git.yoctoproject.org/poky
synced 2026-05-31 00:39:46 +00:00
bitbake: fetch2: Improve mirror looping to consider more cases
Currently we only consider one pass through the mirror list. This doesn't catch cases where for example you might want to setup a mirror of a mirror and allow multiple redirection. There is no reason we can't support this and the patch loops through the list recursively now. As a safeguard, it will stop if any duplicate urls are found, hence avoiding circular dependency looping. (From Poky rev: 0ec0a4412865e54495c07beea1ced8355da58073) (Bitbake rev: e585730e931e6abdb15ba8a3849c5fd22845b891) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -464,6 +464,30 @@ 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 build_mirroruris(origud, mirrors, ld):
|
||||||
|
uris = []
|
||||||
|
uds = []
|
||||||
|
|
||||||
|
def adduri(uri, ud, uris, uds):
|
||||||
|
for line in mirrors:
|
||||||
|
try:
|
||||||
|
(find, replace) = line
|
||||||
|
except ValueError:
|
||||||
|
continue
|
||||||
|
newuri = uri_replace(ud, find, replace, ld)
|
||||||
|
if not newuri or newuri in uris or newuri == origud.url:
|
||||||
|
continue
|
||||||
|
uris.append(newuri)
|
||||||
|
newud = FetchData(newuri, ld)
|
||||||
|
newud.setup_localpath(ld)
|
||||||
|
uds.append(newud)
|
||||||
|
|
||||||
|
adduri(newuri, newud, uris, uds)
|
||||||
|
|
||||||
|
adduri(None, origud, uris, uds)
|
||||||
|
|
||||||
|
return uris, uds
|
||||||
|
|
||||||
def try_mirror_url(newuri, origud, ud, ld, check = False):
|
def try_mirror_url(newuri, origud, ud, ld, check = False):
|
||||||
# Return of None or a value means we're finished
|
# Return of None or a value means we're finished
|
||||||
# False means try another url
|
# False means try another url
|
||||||
@@ -529,18 +553,11 @@ def try_mirrors(d, origud, mirrors, check = False):
|
|||||||
mirrors is the list of mirrors we're going to try
|
mirrors is the list of mirrors we're going to try
|
||||||
"""
|
"""
|
||||||
ld = d.createCopy()
|
ld = d.createCopy()
|
||||||
for line in mirrors:
|
|
||||||
try:
|
|
||||||
(find, replace) = line
|
|
||||||
except ValueError:
|
|
||||||
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)
|
uris, uds = build_mirroruris(origud, mirrors, ld)
|
||||||
|
|
||||||
|
for index, uri in enumerate(uris):
|
||||||
|
ret = try_mirror_url(uri, origud, uds[index], ld, check)
|
||||||
if ret != False:
|
if ret != False:
|
||||||
return ret
|
return ret
|
||||||
return None
|
return None
|
||||||
|
|||||||
Reference in New Issue
Block a user