summaryrefslogtreecommitdiff
path: root/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2010-12-20 16:04:51 +0000
committerRichard Purdie <rpurdie@linux.intel.com>2010-12-20 16:04:51 +0000
commit7abdf3e5c36197c5518edf53acb98611559dadec (patch)
tree5532da2d46e90f46087572630015386754cbdd57 /bitbake
parentcf410542f9e0eed5b01ab36fb47f1ce78bd4bb9b (diff)
downloadopenembedded-core-7abdf3e5c36197c5518edf53acb98611559dadec.tar.gz
openembedded-core-7abdf3e5c36197c5518edf53acb98611559dadec.tar.bz2
openembedded-core-7abdf3e5c36197c5518edf53acb98611559dadec.zip
bitbake/fetch: Checksum validity fixes
If the checksum check failed, the .md5 stamp file would still have been created meaning subsequent builds would proceed with the corrupt file. Reorder the calls to avoid this. Also raise a specific error for the checksum not specified error case. Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/fetch/__init__.py18
1 files changed, 7 insertions, 11 deletions
diff --git a/bitbake/lib/bb/fetch/__init__.py b/bitbake/lib/bb/fetch/__init__.py
index 387de669e1..708e397264 100644
--- a/bitbake/lib/bb/fetch/__init__.py
+++ b/bitbake/lib/bb/fetch/__init__.py
@@ -231,7 +231,7 @@ def removefile(f):
except:
pass
-def verify_checksum(d, ud):
+def verify_checksum(u, ud, d):
"""
verify the MD5 and SHA256 checksum for downloaded src
@@ -245,7 +245,7 @@ def verify_checksum(d, ud):
"""
if not ud.type in ["http", "https", "ftp", "ftps"]:
- return True
+ return
md5data = bb.utils.md5_file(ud.localpath)
sha256data = bb.utils.sha256_file(ud.localpath)
@@ -255,17 +255,13 @@ def verify_checksum(d, ud):
"SRC_URI[%s] = \"%s\"\nSRC_URI[%s] = \"%s\"" \
% (ud.localpath, ud.md5_name, md5data, ud.sha256_name, sha256data))
if bb.data.getVar("BB_STRICT_CHECKSUM", d, True) == "1":
- return False
- else:
- return True
+ raise FetchError("No checksum specified for %s." % u)
if (ud.md5_expected != md5data or ud.sha256_expected != sha256data):
bb.error("The checksums for '%s' did not match." % ud.localpath)
bb.error("Expected MD5: '%s' and Got: '%s'" % (ud.md5_expected, md5data))
bb.error("Expected SHA256: '%s' and Got: '%s'" % (ud.sha256_expected, sha256data))
- return False
-
- return True
+ raise FetchError("%s checksum mismatch." % u)
def go(d, urls = None):
"""
@@ -309,6 +305,9 @@ def go(d, urls = None):
raise FetchError("Unable to fetch URL %s from any source." % u)
ud.localpath = localpath
+
+ verify_checksum(u, ud, d)
+
if os.path.exists(ud.md5):
# Touch the md5 file to show active use of the download
try:
@@ -319,9 +318,6 @@ def go(d, urls = None):
else:
Fetch.write_md5sum(u, ud, d)
- if not verify_checksum(d, ud):
- raise FetchError("%s checksum mismatch." % u)
-
bb.utils.unlockfile(lf)
def checkstatus(d, urls = None):