aboutsummaryrefslogtreecommitdiffstats
path: root/classes/signature.bbclass
blob: 17f7f6c59da02b7df9a18295dacd398f0d31d8f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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)
}