angstrom: prefer the git version of tslib
[openembedded.git] / classes / signature.bbclass
blob17f7f6c59da02b7df9a18295dacd398f0d31d8f5
1 # Generate a signature / hash from the metadata
3 # Using a blacklist rather than a whitelist is safest, at least if you're
4 # utilizing the signature in your pstage package filenames, as the failure
5 # mode for blacklist is an unnecessary rebuild from source, whereas the
6 # failure case for a whitelist is use of incorrect binaries.
8 BB_HASH_BLACKLIST += "BUILDSTART DATE TIME DATETIME \
9                       __* *DIR \
10                       BB_*"
12 def get_data_hash(d):
13     from fnmatch import fnmatchcase
15     try:
16         signature = d.hash()
17     except AttributeError:
18         blacklist = (d.getVar("BB_HASH_BLACKLIST", True) or "").split()
19         items = ((key, repr(d.getVar(key, False)))
20                  for key in d.keys()
21                  if not any(fnmatchcase(key, pattern) for pattern in blacklist))
22         signature = hash(frozenset(items))
23     return str(signature)
25 SIGNATURE = "${@get_data_hash(d.getVar('__RECIPEDATA', False) or d)}"
27 python () {
28     d.setVar("__RECIPEDATA", d)