summaryrefslogtreecommitdiff
path: root/classes/utils.bbclass
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-04-22 13:57:01 -0700
committerChris Larson <chris_larson@mentor.com>2010-04-22 15:52:00 -0700
commit28a068820bc4ef6bac5a4eb1b7438fd8628cdcf7 (patch)
tree76b46318ce272e8856685047e69f742c017580c0 /classes/utils.bbclass
parentaa56c494dbfefe855d28c2d62739a10dc3cd5152 (diff)
Use the python modules for checksum generation where we can
Based on df32920678d15c86897b50b752b937210a01edea. Signed-off-by: Chris Larson <chris_larson@mentor.com> Tested-by: Khem Raj <raj.khem@gmail.com> Acked-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'classes/utils.bbclass')
-rw-r--r--classes/utils.bbclass40
1 files changed, 21 insertions, 19 deletions
diff --git a/classes/utils.bbclass b/classes/utils.bbclass
index 1cc6d2b162..0252a439b0 100644
--- a/classes/utils.bbclass
+++ b/classes/utils.bbclass
@@ -84,6 +84,15 @@ def base_chk_load_parser(config_paths):
return parser
+def setup_checksum_deps(d):
+ try:
+ import hashlib
+ except ImportError:
+ if d.getVar("PN", True) != "shasum-native":
+ depends = d.getVarFlag("do_fetch", "depends") or ""
+ d.setVarFlag("do_fetch", "depends", "%s %s" %
+ (depends, "shasum-native:do_populate_staging"))
+
def base_chk_file_checksum(localpath, src_uri, expected_md5sum, expected_sha256sum, data):
strict_checking = bb.data.getVar("OE_STRICT_CHECKSUMS", data, True)
if not os.path.exists(localpath):
@@ -91,25 +100,18 @@ def base_chk_file_checksum(localpath, src_uri, expected_md5sum, expected_sha256s
bb.note("The localpath does not exist '%s'" % localpath)
raise Exception("The path does not exist '%s'" % localpath)
- try:
- md5pipe = os.popen('PATH=%s md5sum "%s"' % (bb.data.getVar('PATH', data, True), localpath))
- md5data = (md5pipe.readline().split() or [ "" ])[0]
- md5pipe.close()
- except OSError, e:
- if strict_checking:
- raise Exception("Executing md5sum failed")
- else:
- bb.note("Executing md5sum failed")
-
- try:
- shapipe = os.popen('PATH=%s oe_sha256sum "%s"' % (bb.data.getVar('PATH', data, True), localpath))
- sha256data = (shapipe.readline().split() or [ "" ])[0]
- shapipe.close()
- except OSError, e:
- if strict_checking:
- raise Exception("Executing shasum failed")
- else:
- bb.note("Executing shasum failed")
+ md5data = bb.utils.md5_file(localpath)
+ sha256data = bb.utils.sha256_file(localpath)
+ if not sha256data:
+ try:
+ shapipe = os.popen('PATH=%s oe_sha256sum "%s"' % (bb.data.getVar('PATH', data, True), localpath))
+ sha256data = (shapipe.readline().split() or [ "" ])[0]
+ shapipe.close()
+ except OSError, e:
+ if strict_checking:
+ raise Exception("Executing shasum failed")
+ else:
+ bb.note("Executing shasum failed")
if (expected_md5sum == None or expected_md5sum == None):
from string import maketrans