summaryrefslogtreecommitdiffstats
path: root/classes
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-04-19 11:20:37 -0700
committerChris Larson <chris_larson@mentor.com>2010-04-19 17:47:29 -0700
commit4e58c37e7d905d83140c79a83c89cad01f887ea2 (patch)
tree1847e838982d13de43092b70c77d39cba961c48d /classes
parentae8e15aedef94ba49e960f7aea10960657f3b9ae (diff)
downloadopenembedded-4e58c37e7d905d83140c79a83c89cad01f887ea2.tar.gz
Add initial signature.bbclass, which generates a hash of the recipe data
If the datastore has a 'hash' method, it will use that, otherwise it uses its own implementation. Datastore hashing will be added to bitbake master at some point, to prepare for the move away from stamps. Signed-off-by: Chris Larson <chris_larson@mentor.com>
Diffstat (limited to 'classes')
-rw-r--r--classes/signature.bbclass29
1 files changed, 29 insertions, 0 deletions
diff --git a/classes/signature.bbclass b/classes/signature.bbclass
new file mode 100644
index 0000000000..17f7f6c59d
--- /dev/null
+++ b/classes/signature.bbclass
@@ -0,0 +1,29 @@
+# Generate a signature / hash from the metadata
+#
+# Using a blacklist rather than a whitelist is safest, at least if you're
+# utilizing the signature in your pstage package filenames, as the failure
+# mode for blacklist is an unnecessary rebuild from source, whereas the
+# failure case for a whitelist is use of incorrect binaries.
+
+BB_HASH_BLACKLIST += "BUILDSTART DATE TIME DATETIME \
+ __* *DIR \
+ BB_*"
+
+def get_data_hash(d):
+ from fnmatch import fnmatchcase
+
+ try:
+ signature = d.hash()
+ except AttributeError:
+ blacklist = (d.getVar("BB_HASH_BLACKLIST", True) or "").split()
+ items = ((key, repr(d.getVar(key, False)))
+ for key in d.keys()
+ if not any(fnmatchcase(key, pattern) for pattern in blacklist))
+ signature = hash(frozenset(items))
+ return str(signature)
+
+SIGNATURE = "${@get_data_hash(d.getVar('__RECIPEDATA', False) or d)}"
+
+python () {
+ d.setVar("__RECIPEDATA", d)
+}