diff options
author | Jean-Marie LEMETAYER <jean-marie.lemetayer@savoirfairelinux.com> | 2020-01-24 18:08:09 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-01-27 16:48:10 +0000 |
commit | c37a1bc05e51abb252f36b033a1a5889a6ca9836 (patch) | |
tree | a177bd6e8460dc8c1358e7dbcc37084180ab7520 /bitbake | |
parent | 4d771e269956fafae95561ab780c1fcff9c54245 (diff) | |
download | poky-c37a1bc05e51abb252f36b033a1a5889a6ca9836.tar.gz |
bitbake: fetch2: allow fetchers to forward the done condition
This commit is necessary to introduce proxy fetchers and do not modify
the behavior of existing fetchers.
This commit allows fetchers to forwards the done condition to a
proxy fetcher.
(Bitbake rev: ee3a2545e99e6e99559a72bcda64797ae674ec71)
Signed-off-by: Jean-Marie LEMETAYER <jean-marie.lemetayer@savoirfairelinux.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/fetch2/__init__.py | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index 9a0e396fde..4fe042739d 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py | |||
@@ -1569,7 +1569,7 @@ class FetchMethod(object): | |||
1569 | """ | 1569 | """ |
1570 | Try to use a mirror | 1570 | Try to use a mirror |
1571 | """ | 1571 | """ |
1572 | return try_mirrors(fetch, d, urldata, mirrors, check) | 1572 | return bool(try_mirrors(fetch, d, urldata, mirrors, check)) |
1573 | 1573 | ||
1574 | def checkstatus(self, fetch, urldata, d): | 1574 | def checkstatus(self, fetch, urldata, d): |
1575 | """ | 1575 | """ |
@@ -1609,6 +1609,16 @@ class FetchMethod(object): | |||
1609 | """ | 1609 | """ |
1610 | return ('', '') | 1610 | return ('', '') |
1611 | 1611 | ||
1612 | def done(self, ud, d): | ||
1613 | """ | ||
1614 | Is the download done ? | ||
1615 | """ | ||
1616 | if os.path.exists(ud.localpath): | ||
1617 | return True | ||
1618 | if ud.localpath.find("*") != -1: | ||
1619 | return True | ||
1620 | return False | ||
1621 | |||
1612 | class Fetch(object): | 1622 | class Fetch(object): |
1613 | def __init__(self, urls, d, cache = True, localonly = False, connection_cache = None): | 1623 | def __init__(self, urls, d, cache = True, localonly = False, connection_cache = None): |
1614 | if localonly and cache: | 1624 | if localonly and cache: |
@@ -1672,7 +1682,7 @@ class Fetch(object): | |||
1672 | ud = self.ud[u] | 1682 | ud = self.ud[u] |
1673 | ud.setup_localpath(self.d) | 1683 | ud.setup_localpath(self.d) |
1674 | m = ud.method | 1684 | m = ud.method |
1675 | localpath = "" | 1685 | done = False |
1676 | 1686 | ||
1677 | if ud.lockfile: | 1687 | if ud.lockfile: |
1678 | lf = bb.utils.lockfile(ud.lockfile) | 1688 | lf = bb.utils.lockfile(ud.lockfile) |
@@ -1681,12 +1691,12 @@ class Fetch(object): | |||
1681 | self.d.setVar("BB_NO_NETWORK", network) | 1691 | self.d.setVar("BB_NO_NETWORK", network) |
1682 | 1692 | ||
1683 | if m.verify_donestamp(ud, self.d) and not m.need_update(ud, self.d): | 1693 | if m.verify_donestamp(ud, self.d) and not m.need_update(ud, self.d): |
1684 | localpath = ud.localpath | 1694 | done = True |
1685 | elif m.try_premirror(ud, self.d): | 1695 | elif m.try_premirror(ud, self.d): |
1686 | logger.debug(1, "Trying PREMIRRORS") | 1696 | logger.debug(1, "Trying PREMIRRORS") |
1687 | mirrors = mirror_from_string(self.d.getVar('PREMIRRORS')) | 1697 | mirrors = mirror_from_string(self.d.getVar('PREMIRRORS')) |
1688 | localpath = m.try_mirrors(self, ud, self.d, mirrors) | 1698 | done = m.try_mirrors(self, ud, self.d, mirrors) |
1689 | if localpath: | 1699 | if done: |
1690 | try: | 1700 | try: |
1691 | # early checksum verification so that if the checksum of the premirror | 1701 | # early checksum verification so that if the checksum of the premirror |
1692 | # contents mismatch the fetcher can still try upstream and mirrors | 1702 | # contents mismatch the fetcher can still try upstream and mirrors |
@@ -1694,14 +1704,14 @@ class Fetch(object): | |||
1694 | except ChecksumError as e: | 1704 | except ChecksumError as e: |
1695 | logger.warning("Checksum failure encountered with premirror download of %s - will attempt other sources." % u) | 1705 | logger.warning("Checksum failure encountered with premirror download of %s - will attempt other sources." % u) |
1696 | logger.debug(1, str(e)) | 1706 | logger.debug(1, str(e)) |
1697 | localpath = "" | 1707 | done = False |
1698 | 1708 | ||
1699 | if premirroronly: | 1709 | if premirroronly: |
1700 | self.d.setVar("BB_NO_NETWORK", "1") | 1710 | self.d.setVar("BB_NO_NETWORK", "1") |
1701 | 1711 | ||
1702 | firsterr = None | 1712 | firsterr = None |
1703 | verified_stamp = m.verify_donestamp(ud, self.d) | 1713 | verified_stamp = m.verify_donestamp(ud, self.d) |
1704 | if not localpath and (not verified_stamp or m.need_update(ud, self.d)): | 1714 | if not done and (not verified_stamp or m.need_update(ud, self.d)): |
1705 | try: | 1715 | try: |
1706 | if not trusted_network(self.d, ud.url): | 1716 | if not trusted_network(self.d, ud.url): |
1707 | raise UntrustedUrl(ud.url) | 1717 | raise UntrustedUrl(ud.url) |
@@ -1709,7 +1719,7 @@ class Fetch(object): | |||
1709 | m.download(ud, self.d) | 1719 | m.download(ud, self.d) |
1710 | if hasattr(m, "build_mirror_data"): | 1720 | if hasattr(m, "build_mirror_data"): |
1711 | m.build_mirror_data(ud, self.d) | 1721 | m.build_mirror_data(ud, self.d) |
1712 | localpath = ud.localpath | 1722 | done = True |
1713 | # early checksum verify, so that if checksum mismatched, | 1723 | # early checksum verify, so that if checksum mismatched, |
1714 | # fetcher still have chance to fetch from mirror | 1724 | # fetcher still have chance to fetch from mirror |
1715 | m.update_donestamp(ud, self.d) | 1725 | m.update_donestamp(ud, self.d) |
@@ -1734,9 +1744,9 @@ class Fetch(object): | |||
1734 | m.clean(ud, self.d) | 1744 | m.clean(ud, self.d) |
1735 | logger.debug(1, "Trying MIRRORS") | 1745 | logger.debug(1, "Trying MIRRORS") |
1736 | mirrors = mirror_from_string(self.d.getVar('MIRRORS')) | 1746 | mirrors = mirror_from_string(self.d.getVar('MIRRORS')) |
1737 | localpath = m.try_mirrors(self, ud, self.d, mirrors) | 1747 | done = m.try_mirrors(self, ud, self.d, mirrors) |
1738 | 1748 | ||
1739 | if not localpath or ((not os.path.exists(localpath)) and localpath.find("*") == -1): | 1749 | if not done or not m.done(ud, self.d): |
1740 | if firsterr: | 1750 | if firsterr: |
1741 | logger.error(str(firsterr)) | 1751 | logger.error(str(firsterr)) |
1742 | raise FetchError("Unable to fetch URL from any source.", u) | 1752 | raise FetchError("Unable to fetch URL from any source.", u) |