summaryrefslogtreecommitdiffstats
path: root/meta/classes-recipe/image-postinst-intercepts.bbclass
blob: fc15926384507c0bb7fc8c6bee6e5f4f93c47356 (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
#
# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: MIT
#

# Gather existing and candidate postinst intercepts from BBPATH
POSTINST_INTERCEPTS_DIR ?= "${COREBASE}/scripts/postinst-intercepts"
POSTINST_INTERCEPTS_PATHS ?= "${@':'.join('%s/postinst-intercepts' % p for p in '${BBPATH}'.split(':'))}:${POSTINST_INTERCEPTS_DIR}"

python find_intercepts() {
    intercepts = {}
    search_paths = []
    paths = d.getVar('POSTINST_INTERCEPTS_PATHS').split(':')
    overrides = (':' + d.getVar('FILESOVERRIDES')).split(':') + ['']
    search_paths = [os.path.join(p, op) for p in paths for op in overrides]
    searched = oe.path.which_wild('*', ':'.join(search_paths), candidates=True)
    files, chksums = [], []
    for pathname, candidates in searched:
        if os.path.isfile(pathname):
            files.append(pathname)
            chksums.append('%s:True' % pathname)
            chksums.extend('%s:False' % c for c in candidates[:-1])

    d.setVar('POSTINST_INTERCEPT_CHECKSUMS', ' '.join(chksums))
    d.setVar('POSTINST_INTERCEPTS', ' '.join(files))
}
find_intercepts[eventmask] += "bb.event.RecipePreFinalise"
addhandler find_intercepts