xref: /OK3568_Linux_fs/yocto/poky/meta/classes/image-postinst-intercepts.bbclass (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun# Gather existing and candidate postinst intercepts from BBPATH
2*4882a593SmuzhiyunPOSTINST_INTERCEPTS_DIR ?= "${COREBASE}/scripts/postinst-intercepts"
3*4882a593SmuzhiyunPOSTINST_INTERCEPTS_PATHS ?= "${@':'.join('%s/postinst-intercepts' % p for p in '${BBPATH}'.split(':'))}:${POSTINST_INTERCEPTS_DIR}"
4*4882a593Smuzhiyun
5*4882a593Smuzhiyunpython find_intercepts() {
6*4882a593Smuzhiyun    intercepts = {}
7*4882a593Smuzhiyun    search_paths = []
8*4882a593Smuzhiyun    paths = d.getVar('POSTINST_INTERCEPTS_PATHS').split(':')
9*4882a593Smuzhiyun    overrides = (':' + d.getVar('FILESOVERRIDES')).split(':') + ['']
10*4882a593Smuzhiyun    search_paths = [os.path.join(p, op) for p in paths for op in overrides]
11*4882a593Smuzhiyun    searched = oe.path.which_wild('*', ':'.join(search_paths), candidates=True)
12*4882a593Smuzhiyun    files, chksums = [], []
13*4882a593Smuzhiyun    for pathname, candidates in searched:
14*4882a593Smuzhiyun        if os.path.isfile(pathname):
15*4882a593Smuzhiyun            files.append(pathname)
16*4882a593Smuzhiyun            chksums.append('%s:True' % pathname)
17*4882a593Smuzhiyun            chksums.extend('%s:False' % c for c in candidates[:-1])
18*4882a593Smuzhiyun
19*4882a593Smuzhiyun    d.setVar('POSTINST_INTERCEPT_CHECKSUMS', ' '.join(chksums))
20*4882a593Smuzhiyun    d.setVar('POSTINST_INTERCEPTS', ' '.join(files))
21*4882a593Smuzhiyun}
22*4882a593Smuzhiyunfind_intercepts[eventmask] += "bb.event.RecipePreFinalise"
23*4882a593Smuzhiyunaddhandler find_intercepts
24