summaryrefslogtreecommitdiffstats
path: root/meta/classes-recipe/multilib_script.bbclass
blob: a7a08930b7e3ae1441c58a76735d3a15407055e5 (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
30
31
32
33
34
35
36
37
38
39
#
# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: MIT
#

#
# Recipe needs to set MULTILIB_SCRIPTS in the form <pkgname>:<scriptname>, e.g.
# MULTILIB_SCRIPTS = "${PN}-dev:${bindir}/file1 ${PN}:${base_bindir}/file2"
# to indicate which script files to process from which packages.
#

inherit update-alternatives

MULTILIB_SUFFIX = "${@d.getVar('base_libdir',1).split('/')[-1]}"

PACKAGE_PREPROCESS_FUNCS += "multilibscript_rename"

multilibscript_rename() {
	:
}

python () {
    # Do nothing if multilib isn't being used
    if not d.getVar("MULTILIB_VARIANTS"):
        return
    # Do nothing for native/cross
    if bb.data.inherits_class('native', d) or bb.data.inherits_class('cross', d):
        return

    for entry in (d.getVar("MULTILIB_SCRIPTS") or "").split():
        pkg, script = entry.split(":", 1)
        scriptname = os.path.basename(script)
        d.appendVar("ALTERNATIVE:" + pkg, " " + scriptname + " ")
        d.setVarFlag("ALTERNATIVE_LINK_NAME", scriptname, script)
        d.setVarFlag("ALTERNATIVE_TARGET", scriptname, script + "-${MULTILIB_SUFFIX}")
        d.appendVar("multilibscript_rename",  "\n	mv ${PKGD}" + script + " ${PKGD}" + script + "-${MULTILIB_SUFFIX}")
        d.appendVar("FILES:" + pkg, " " + script + "-${MULTILIB_SUFFIX}")
}