summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2005-10-24 13:26:14 +0000
committerHolger Hans Peter Freyther <zecke@selfish.org>2005-10-24 13:26:14 +0000
commitf4aa4d1f2442e226ec4cdf23f2bf322c6fb4128c (patch)
tree6bc0b1272b415c69a154a793d0079d202f2fd024
parentc8cea831e627ca7398fba4276649097b2d18812b (diff)
downloadbitbake-f4aa4d1f2442e226ec4cdf23f2bf322c6fb4128c.tar.gz
BitBake MD5 SUM:
-Attempt at verifying the MD5 SUM after the fetch and fail if the one specified does not match the one calculated. -Simplify the code writing the md5sum
-rw-r--r--lib/bb/fetch.py29
1 files changed, 20 insertions, 9 deletions
diff --git a/lib/bb/fetch.py b/lib/bb/fetch.py
index 982ab51b7..a95c6694e 100644
--- a/lib/bb/fetch.py
+++ b/lib/bb/fetch.py
@@ -173,16 +173,26 @@ class Wget(Fetch):
def go(self, d, urls = []):
"""Fetch urls"""
- def md5_sum(basename, data):
+ def md5_sum(basename, d):
"""
Fast and incomplete OVERRIDE implementation for MD5SUM handling
MD5SUM_basename = "SUM" and fallback to MD5SUM_basename
"""
var = "MD5SUM_%s" % basename
- return getVar(var, data) or get("MD5SUM",data)
+ return data.getVar(var, d) or data.getVar("MD5SUM", d)
+ def verify_md5sum(wanted_sum, got_sum):
+ """
+ Verify the md5sum we wanted with the one we got
+ """
+ if not wanted_sum:
+ return True
+
+ return wanted_sum == got_sum
def fetch_uri(uri, basename, dl, md5, parm, d):
+ # the MD5 sum we want to verify
+ wanted_md5sum = md5_sum(basename, d)
if os.path.exists(dl):
# file exists, but we didnt complete it.. trying again..
fetchcmd = data.getVar("RESUMECOMMAND", d, 1)
@@ -212,13 +222,14 @@ class Wget(Fetch):
md5pipe.close()
except OSError:
md5data = ""
- md5out = file(md5, 'w')
- md5out.write(md5data)
- md5out.close()
- else:
- md5out = file(md5, 'w')
- md5out.write("")
- md5out.close()
+
+ # verify the md5sum
+ if not verify_md5sum(wanted_md5sum, md5data):
+ raise MD5SumError(uri)
+
+ md5out = file(md5, 'w')
+ md5out.write(md5data)
+ md5out.close()
return True
if not urls: