]> code.ossystems Code Review - openembedded-core.git/commitdiff
base.bbclass: only depend on shasum-native if we don't have hashlib
authorRoss Burton <ross@openedhand.com>
Thu, 1 May 2008 11:42:24 +0000 (11:42 +0000)
committerRoss Burton <ross@openedhand.com>
Thu, 1 May 2008 11:42:24 +0000 (11:42 +0000)
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@4389 311d38ba-8fff-0310-9ca6-ca027cbcb966

meta/classes/base.bbclass

index 0c048b997b5a717c65714258932a58dee07a68e6..d27f0d3c5dbb4488ff142f5df34c82643dd79403 100644 (file)
@@ -91,10 +91,20 @@ def base_dep_prepend(d):
        # the case where host == build == target, for now we don't work in
        # that case though.
        #
-       deps = "shasum-native "
-       if bb.data.getVar('PN', d, True) == "shasum-native":
-               deps = ""
 
+       deps = ""
+    
+       # bb.utils.sha256_file() will return None on Python 2.4 because hashlib
+       # isn't present.  In this case we use a shasum-native to checksum, so if
+       # hashlib isn't present then add shasum-native to the dependencies.
+       try:
+               import hashlib
+       except ImportError:
+               # Adding shasum-native as a dependency of shasum-native would be
+               # stupid, so don't do that.
+               if bb.data.getVar('PN', d, True) != "shasum-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
        # the application.
@@ -484,7 +494,6 @@ python base_scenefunction () {
 
 addtask fetch
 do_fetch[dirs] = "${DL_DIR}"
-do_fetch[depends] = "shasum-native:do_populate_staging"
 python base_do_fetch() {
        import sys
 
@@ -969,6 +978,15 @@ def base_after_parse(d):
         depends = depends + " git-native:do_populate_staging"
         bb.data.setVarFlag('do_fetch', 'depends', depends, d)
 
+    # bb.utils.sha256_file() will fail if hashlib isn't present, so we fallback
+    # on shasum-native.  We need to ensure that it is staged before we fetch.
+    try:
+        import hashlib
+    except ImportError:
+        depends = bb.data.getVarFlag('do_fetch', 'depends', d) or ""
+        depends = depends + " shasum-native:do_populate_staging"
+        bb.data.setVarFlag('do_fetch', 'depends', depends, d)
+
     mach_arch = bb.data.getVar('MACHINE_ARCH', d, 1)
     old_arch = bb.data.getVar('PACKAGE_ARCH', d, 1)
     if (old_arch == mach_arch):