diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-05-15 19:49:36 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-05-20 09:24:23 +0100 |
commit | b0b9ee29a216d63387684dd6c3934b059849ab5b (patch) | |
tree | b2120b56b3619e0871931439398baa4bb6cc814e /bitbake/lib/bb/fetch2/__init__.py | |
parent | 311c68bd06a5dc2df03f689f4061a8544716c930 (diff) | |
download | poky-b0b9ee29a216d63387684dd6c3934b059849ab5b.tar.gz |
bitbake/fetch: Spell out which fetcher backends support and recommend checksums
There were some hardcoded behaviours in the system for which backends
support checksums verses which backends recommend them verses which
don't recommend them.
This moves the functionality into specific fetchers and then makes the
general code generic. This cleans up the codebase and fixes some corner
cases such as trying to checksum directories returned by the git fetcher.
(Bitbake rev: ef6d268f7b8527541a7fb044cf95a973be4097f4)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2/__init__.py')
-rw-r--r-- | bitbake/lib/bb/fetch2/__init__.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index f629c01cdb..98645956fb 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py | |||
@@ -271,10 +271,13 @@ def verify_checksum(u, ud, d): | |||
271 | matched | 271 | matched |
272 | """ | 272 | """ |
273 | 273 | ||
274 | if not ud.method.supports_checksum(ud): | ||
275 | return | ||
276 | |||
274 | md5data = bb.utils.md5_file(ud.localpath) | 277 | md5data = bb.utils.md5_file(ud.localpath) |
275 | sha256data = bb.utils.sha256_file(ud.localpath) | 278 | sha256data = bb.utils.sha256_file(ud.localpath) |
276 | 279 | ||
277 | if ud.type in ["http", "https", "ftp", "ftps"]: | 280 | if ud.method.recommends_checksum(ud): |
278 | # If strict checking enabled and neither sum defined, raise error | 281 | # If strict checking enabled and neither sum defined, raise error |
279 | strict = d.getVar("BB_STRICT_CHECKSUM", True) or None | 282 | strict = d.getVar("BB_STRICT_CHECKSUM", True) or None |
280 | if (strict and ud.md5_expected == None and ud.sha256_expected == None): | 283 | if (strict and ud.md5_expected == None and ud.sha256_expected == None): |
@@ -578,10 +581,14 @@ class FetchData(object): | |||
578 | self.sha256_name = "sha256sum" | 581 | self.sha256_name = "sha256sum" |
579 | if self.md5_name in self.parm: | 582 | if self.md5_name in self.parm: |
580 | self.md5_expected = self.parm[self.md5_name] | 583 | self.md5_expected = self.parm[self.md5_name] |
584 | elif self.type not in ["http", "https", "ftp", "ftps"]: | ||
585 | self.md5_expected = None | ||
581 | else: | 586 | else: |
582 | self.md5_expected = d.getVarFlag("SRC_URI", self.md5_name) | 587 | self.md5_expected = d.getVarFlag("SRC_URI", self.md5_name) |
583 | if self.sha256_name in self.parm: | 588 | if self.sha256_name in self.parm: |
584 | self.sha256_expected = self.parm[self.sha256_name] | 589 | self.sha256_expected = self.parm[self.sha256_name] |
590 | elif self.type not in ["http", "https", "ftp", "ftps"]: | ||
591 | self.sha256_expected = None | ||
585 | else: | 592 | else: |
586 | self.sha256_expected = d.getVarFlag("SRC_URI", self.sha256_name) | 593 | self.sha256_expected = d.getVarFlag("SRC_URI", self.sha256_name) |
587 | 594 | ||
@@ -660,6 +667,19 @@ class FetchMethod(object): | |||
660 | """ | 667 | """ |
661 | return os.path.join(data.getVar("DL_DIR", d, True), urldata.localfile) | 668 | return os.path.join(data.getVar("DL_DIR", d, True), urldata.localfile) |
662 | 669 | ||
670 | def supports_checksum(self, urldata): | ||
671 | """ | ||
672 | Is localpath something that can be represented by a checksum? | ||
673 | """ | ||
674 | return True | ||
675 | |||
676 | def recommends_checksum(self, urldata): | ||
677 | """ | ||
678 | Is the backend on where checksumming is recommended (should warnings | ||
679 | by displayed if there is no checksum)? | ||
680 | """ | ||
681 | return False | ||
682 | |||
663 | def _strip_leading_slashes(self, relpath): | 683 | def _strip_leading_slashes(self, relpath): |
664 | """ | 684 | """ |
665 | Remove leading slash as os.path.join can't cope | 685 | Remove leading slash as os.path.join can't cope |