diff options
author | Chris Larson <chris_larson@mentor.com> | 2010-04-22 13:57:01 -0700 |
---|---|---|
committer | Chris Larson <chris_larson@mentor.com> | 2010-04-22 15:52:00 -0700 |
commit | 28a068820bc4ef6bac5a4eb1b7438fd8628cdcf7 (patch) | |
tree | 76b46318ce272e8856685047e69f742c017580c0 /classes | |
parent | aa56c494dbfefe855d28c2d62739a10dc3cd5152 (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')
-rw-r--r-- | classes/base.bbclass | 10 | ||||
-rw-r--r-- | classes/utils.bbclass | 40 |
2 files changed, 26 insertions, 24 deletions
diff --git a/classes/base.bbclass b/classes/base.bbclass index d3bfa768c1..b8499b9db8 100644 --- a/classes/base.bbclass +++ b/classes/base.bbclass @@ -37,11 +37,10 @@ def base_dep_prepend(d): # the case where host == build == target, for now we don't work in # that case though. # - deps = "shasum-native coreutils-native" - if bb.data.getVar('PN', d, True) == "shasum-native" or bb.data.getVar('PN', d, True) == "stagemanager-native": + deps = "coreutils-native" + if bb.data.getVar('PN', d, True) in ("shasum-native", "stagemanager-native", + "coreutils-native"): deps = "" - if bb.data.getVar('PN', d, True) == "coreutils-native": - deps = "shasum-native" # INHIBIT_DEFAULT_DEPS doesn't apply to the patch command. Whether or not # we need that built is the responsibility of the patch function / class, not @@ -76,7 +75,6 @@ addtask setscene before do_fetch addtask fetch do_fetch[dirs] = "${DL_DIR}" -do_fetch[depends] = "shasum-native:do_populate_staging" python base_do_fetch() { import sys @@ -365,6 +363,8 @@ python () { if use_nls != None: bb.data.setVar('USE_NLS', use_nls, d) + setup_checksum_deps(d) + # Git packages should DEPEND on git-native srcuri = bb.data.getVar('SRC_URI', d, 1) if "git://" in srcuri: 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 |