diff options
author | Richard Purdie <rpurdie@linux.intel.com> | 2010-12-20 16:04:51 +0000 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2010-12-20 16:04:51 +0000 |
commit | 7abdf3e5c36197c5518edf53acb98611559dadec (patch) | |
tree | 5532da2d46e90f46087572630015386754cbdd57 | |
parent | cf410542f9e0eed5b01ab36fb47f1ce78bd4bb9b (diff) | |
download | poky-7abdf3e5c36197c5518edf53acb98611559dadec.tar.gz |
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>
-rw-r--r-- | bitbake/lib/bb/fetch/__init__.py | 18 |
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): | |||
231 | except: | 231 | except: |
232 | pass | 232 | pass |
233 | 233 | ||
234 | def verify_checksum(d, ud): | 234 | def verify_checksum(u, ud, d): |
235 | """ | 235 | """ |
236 | verify the MD5 and SHA256 checksum for downloaded src | 236 | verify the MD5 and SHA256 checksum for downloaded src |
237 | 237 | ||
@@ -245,7 +245,7 @@ def verify_checksum(d, ud): | |||
245 | """ | 245 | """ |
246 | 246 | ||
247 | if not ud.type in ["http", "https", "ftp", "ftps"]: | 247 | if not ud.type in ["http", "https", "ftp", "ftps"]: |
248 | return True | 248 | return |
249 | 249 | ||
250 | md5data = bb.utils.md5_file(ud.localpath) | 250 | md5data = bb.utils.md5_file(ud.localpath) |
251 | sha256data = bb.utils.sha256_file(ud.localpath) | 251 | sha256data = bb.utils.sha256_file(ud.localpath) |
@@ -255,17 +255,13 @@ def verify_checksum(d, ud): | |||
255 | "SRC_URI[%s] = \"%s\"\nSRC_URI[%s] = \"%s\"" \ | 255 | "SRC_URI[%s] = \"%s\"\nSRC_URI[%s] = \"%s\"" \ |
256 | % (ud.localpath, ud.md5_name, md5data, ud.sha256_name, sha256data)) | 256 | % (ud.localpath, ud.md5_name, md5data, ud.sha256_name, sha256data)) |
257 | if bb.data.getVar("BB_STRICT_CHECKSUM", d, True) == "1": | 257 | if bb.data.getVar("BB_STRICT_CHECKSUM", d, True) == "1": |
258 | return False | 258 | raise FetchError("No checksum specified for %s." % u) |
259 | else: | ||
260 | return True | ||
261 | 259 | ||
262 | if (ud.md5_expected != md5data or ud.sha256_expected != sha256data): | 260 | if (ud.md5_expected != md5data or ud.sha256_expected != sha256data): |
263 | bb.error("The checksums for '%s' did not match." % ud.localpath) | 261 | bb.error("The checksums for '%s' did not match." % ud.localpath) |
264 | bb.error("Expected MD5: '%s' and Got: '%s'" % (ud.md5_expected, md5data)) | 262 | bb.error("Expected MD5: '%s' and Got: '%s'" % (ud.md5_expected, md5data)) |
265 | bb.error("Expected SHA256: '%s' and Got: '%s'" % (ud.sha256_expected, sha256data)) | 263 | bb.error("Expected SHA256: '%s' and Got: '%s'" % (ud.sha256_expected, sha256data)) |
266 | return False | 264 | raise FetchError("%s checksum mismatch." % u) |
267 | |||
268 | return True | ||
269 | 265 | ||
270 | def go(d, urls = None): | 266 | def go(d, urls = None): |
271 | """ | 267 | """ |
@@ -309,6 +305,9 @@ def go(d, urls = None): | |||
309 | raise FetchError("Unable to fetch URL %s from any source." % u) | 305 | raise FetchError("Unable to fetch URL %s from any source." % u) |
310 | 306 | ||
311 | ud.localpath = localpath | 307 | ud.localpath = localpath |
308 | |||
309 | verify_checksum(u, ud, d) | ||
310 | |||
312 | if os.path.exists(ud.md5): | 311 | if os.path.exists(ud.md5): |
313 | # Touch the md5 file to show active use of the download | 312 | # Touch the md5 file to show active use of the download |
314 | try: | 313 | try: |
@@ -319,9 +318,6 @@ def go(d, urls = None): | |||
319 | else: | 318 | else: |
320 | Fetch.write_md5sum(u, ud, d) | 319 | Fetch.write_md5sum(u, ud, d) |
321 | 320 | ||
322 | if not verify_checksum(d, ud): | ||
323 | raise FetchError("%s checksum mismatch." % u) | ||
324 | |||
325 | bb.utils.unlockfile(lf) | 321 | bb.utils.unlockfile(lf) |
326 | 322 | ||
327 | def checkstatus(d, urls = None): | 323 | def checkstatus(d, urls = None): |