diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-06-20 12:49:39 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-06-21 13:10:33 +0100 |
commit | 20649e95ede723feb8c766bc2f76bc6ce2fd1500 (patch) | |
tree | 4485393bd9b26c7066179203d38eb6f6601ba869 /bitbake | |
parent | 3f441765a7f6c229c5f4cd4edc0d6d8a34da2d11 (diff) | |
download | poky-20649e95ede723feb8c766bc2f76bc6ce2fd1500.tar.gz |
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>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/fetch2/__init__.py | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index 737ae7ed8f..78adce2f29 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py | |||
@@ -464,6 +464,30 @@ def check_network_access(d, info = "", url = None): | |||
464 | else: | 464 | else: |
465 | logger.debug(1, "Fetcher accessed the network with the command %s" % info) | 465 | logger.debug(1, "Fetcher accessed the network with the command %s" % info) |
466 | 466 | ||
467 | def build_mirroruris(origud, mirrors, ld): | ||
468 | uris = [] | ||
469 | uds = [] | ||
470 | |||
471 | def adduri(uri, ud, uris, uds): | ||
472 | for line in mirrors: | ||
473 | try: | ||
474 | (find, replace) = line | ||
475 | except ValueError: | ||
476 | continue | ||
477 | newuri = uri_replace(ud, find, replace, ld) | ||
478 | if not newuri or newuri in uris or newuri == origud.url: | ||
479 | continue | ||
480 | uris.append(newuri) | ||
481 | newud = FetchData(newuri, ld) | ||
482 | newud.setup_localpath(ld) | ||
483 | uds.append(newud) | ||
484 | |||
485 | adduri(newuri, newud, uris, uds) | ||
486 | |||
487 | adduri(None, origud, uris, uds) | ||
488 | |||
489 | return uris, uds | ||
490 | |||
467 | def try_mirror_url(newuri, origud, ud, ld, check = False): | 491 | def try_mirror_url(newuri, origud, ud, ld, check = False): |
468 | # Return of None or a value means we're finished | 492 | # Return of None or a value means we're finished |
469 | # False means try another url | 493 | # False means try another url |
@@ -529,18 +553,11 @@ def try_mirrors(d, origud, mirrors, check = False): | |||
529 | mirrors is the list of mirrors we're going to try | 553 | mirrors is the list of mirrors we're going to try |
530 | """ | 554 | """ |
531 | ld = d.createCopy() | 555 | ld = d.createCopy() |
532 | for line in mirrors: | 556 | |
533 | try: | 557 | uris, uds = build_mirroruris(origud, mirrors, ld) |
534 | (find, replace) = line | 558 | |
535 | except ValueError: | 559 | for index, uri in enumerate(uris): |
536 | continue | 560 | ret = try_mirror_url(uri, origud, uds[index], ld, check) |
537 | newuri = uri_replace(origud, find, replace, ld) | ||
538 | if not newuri: | ||
539 | continue | ||
540 | ud = FetchData(newuri, ld) | ||
541 | ud.setup_localpath(ld) | ||
542 | |||
543 | ret = try_mirror_url(newuri, origud, ud, ld, check) | ||
544 | if ret != False: | 561 | if ret != False: |
545 | return ret | 562 | return ret |
546 | return None | 563 | return None |