summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/manual/usermanual.xml2
-rw-r--r--lib/bb/fetch2/__init__.py82
-rw-r--r--lib/bb/ui/hob.py4
3 files changed, 49 insertions, 39 deletions
diff --git a/doc/manual/usermanual.xml b/doc/manual/usermanual.xml
index 3a3af6dee..687503b1c 100644
--- a/doc/manual/usermanual.xml
+++ b/doc/manual/usermanual.xml
@@ -388,7 +388,7 @@ ftp://.*/.* http://somemirror.org/sources/ \n \
http://.*/.* http://somemirror.org/sources/ \n \
https://.*/.* http://somemirror.org/sources/ \n"</screen></para>
- <para>Non-local downloaded output is placed into the directory specified by the <varname>DL_DIR</varname>. For non local downloads the code can check checksums for the download to ensure the file has been downloaded correctly. These are specified in the form <varname>SRC_URI[md5sum]</varname> for the md5 checksum and <varname>SRC_URI[sha256sum]</varname> for the sha256 checksum. If <varname>BB_STRICT_CHECKSUM</varname> is set, any download without a checksum will trigger an error message. In cases where multiple files are listed in SRC_URI, the name parameter is used assign names to the urls and these are then specified in the checksums in the form SRC_URI[name.sha256sum].</para>
+ <para>Non-local downloaded output is placed into the directory specified by the <varname>DL_DIR</varname>. For non local archive downloads the code can verify sha256 and md5 checksums for the download to ensure the file has been downloaded correctly. These may be specified either in the form <varname>SRC_URI[md5sum]</varname> for the md5 checksum and <varname>SRC_URI[sha256sum]</varname> for the sha256 checksum or as parameters on the SRC_URI such as SRC_URI="http://example.com/foobar.tar.bz2;md5sum=4a8e0f237e961fd7785d19d07fdb994d". If <varname>BB_STRICT_CHECKSUM</varname> is set, any download without a checksum will trigger an error message. In cases where multiple files are listed in SRC_URI, the name parameter is used assign names to the urls and these are then specified in the checksums in the form SRC_URI[name.sha256sum].</para>
</section>
diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
index fb6138b02..a055faaf1 100644
--- a/lib/bb/fetch2/__init__.py
+++ b/lib/bb/fetch2/__init__.py
@@ -93,28 +93,6 @@ class ParameterError(BBFetchException):
BBFetchException.__init__(self, msg)
self.args = (message, url)
-class MD5SumError(BBFetchException):
- """Exception raised when a MD5 checksum of a file does not match for a downloaded file"""
- def __init__(self, path, wanted, got, url):
- msg = "File: '%s' has md5 checksum %s when %s was expected (from URL: '%s')" % (path, got, wanted, url)
- self.url = url
- self.path = path
- self.wanted = wanted
- self.got = got
- BBFetchException.__init__(self, msg)
- self.args = (path, wanted, got, url)
-
-class SHA256SumError(MD5SumError):
- """Exception raised when a SHA256 checksum of a file does not match for a downloaded file"""
- def __init__(self, path, wanted, got, url):
- msg = "File: '%s' has sha256 checksum %s when %s was expected (from URL: '%s')" % (path, got, wanted, url)
- self.url = url
- self.path = path
- self.wanted = wanted
- self.got = got
- BBFetchException.__init__(self, msg)
- self.args = (path, wanted, got, url)
-
class NetworkAccess(BBFetchException):
"""Exception raised when network access is disabled but it is required."""
def __init__(self, url, cmd):
@@ -271,8 +249,8 @@ def verify_checksum(u, ud, d):
verify the MD5 and SHA256 checksum for downloaded src
return value:
- - True: checksum matched
- - False: checksum unmatched
+ - True: a checksum matched
+ - False: neither checksum matched
if checksum is missing in recipes file, "BB_STRICT_CHECKSUM" decide the return value.
if BB_STRICT_CHECKSUM = "1" then return false as unmatched, otherwise return true as
@@ -285,20 +263,46 @@ def verify_checksum(u, ud, d):
md5data = bb.utils.md5_file(ud.localpath)
sha256data = bb.utils.sha256_file(ud.localpath)
- if (ud.md5_expected == None or ud.sha256_expected == None):
- logger.warn('Missing SRC_URI checksum for %s, consider adding to the recipe:\n'
- '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":
- raise FetchError("No checksum specified for %s." % u, u)
- return
+ # If strict checking enabled and neither sum defined, raise error
+ strict = bb.data.getVar("BB_STRICT_CHECKSUM", d, True) or None
+ if (strict and ud.md5_expected == None and ud.sha256_expected == None):
+ raise FetchError('No checksum specified for %s, please add at least one to the recipe:\n'
+ 'SRC_URI[%s] = "%s"\nSRC_URI[%s] = "%s"', u,
+ ud.localpath, ud.md5_name, md5data,
+ ud.sha256_name, sha256data)
+
+ # Log missing sums so user can more easily add them
+ if ud.md5_expected == None:
+ logger.warn('Missing md5 SRC_URI checksum for %s, consider adding to the recipe:\n'
+ 'SRC_URI[%s] = "%s"',
+ ud.localpath, ud.md5_name, md5data)
+
+ if ud.sha256_expected == None:
+ logger.warn('Missing sha256 SRC_URI checksum for %s, consider adding to the recipe:\n'
+ 'SRC_URI[%s] = "%s"',
+ ud.localpath, ud.sha256_name, sha256data)
+
+ md5mismatch = False
+ sha256mismatch = False
if ud.md5_expected != md5data:
- raise MD5SumError(ud.localpath, ud.md5_expected, md5data, u)
+ md5mismatch = True
if ud.sha256_expected != sha256data:
- raise SHA256SumError(ud.localpath, ud.sha256_expected, sha256data, u)
+ sha256mismatch = True
+
+ # We want to alert the user if a checksum is defined in the recipe but
+ # it does not match.
+ msg = ""
+ if md5mismatch and ud.md5_expected:
+ msg = msg + "\nFile: '%s' has %s checksum %s when %s was expected (from URL: '%s')" % (ud.localpath, 'md5', md5data, ud.md5_expected, u)
+
+ if sha256mismatch and ud.sha256_expected:
+ msg = msg + "\nFile: '%s' has %s checksum %s when %s was expected (from URL: '%s')" % (ud.localpath, 'sha256', sha256data, ud.sha256_expected, u)
+
+ if len(msg):
+ raise FetchError('Checksum mismatch!%s' % msg, u)
+
def update_stamp(u, ud, d):
"""
@@ -558,8 +562,14 @@ class FetchData(object):
else:
self.md5_name = "md5sum"
self.sha256_name = "sha256sum"
- self.md5_expected = bb.data.getVarFlag("SRC_URI", self.md5_name, d)
- self.sha256_expected = bb.data.getVarFlag("SRC_URI", self.sha256_name, d)
+ if self.md5_name in self.parm:
+ self.md5_expected = self.parm[self.md5_name]
+ else:
+ self.md5_expected = bb.data.getVarFlag("SRC_URI", self.md5_name, d)
+ if self.sha256_name in self.parm:
+ self.sha256_expected = self.parm[self.sha256_name]
+ else:
+ self.sha256_expected = bb.data.getVarFlag("SRC_URI", self.sha256_name, d)
self.names = self.parm.get("name",'default').split(',')
diff --git a/lib/bb/ui/hob.py b/lib/bb/ui/hob.py
index 71ea88acd..0fcaad54a 100644
--- a/lib/bb/ui/hob.py
+++ b/lib/bb/ui/hob.py
@@ -400,9 +400,9 @@ class MainWindow (gtk.Window):
if response == gtk.RESPONSE_OK:
rep.loadRecipe(recipe)
self.save_path = recipe
+ self.model.load_image_rep(rep)
+ self.dirty = False
chooser.destroy()
- self.model.load_image_rep(rep)
- self.dirty = False
def bake_clicked_cb(self, button):
build_image = True