Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 1 | # |
| 2 | # Recipe needs to set MULTILIB_SCRIPTS in the form <pkgname>:<scriptname>, e.g. |
| 3 | # MULTILIB_SCRIPTS = "${PN}-dev:${bindir}/file1 ${PN}:${base_bindir}/file2" |
| 4 | # to indicate which script files to process from which packages. |
| 5 | # |
| 6 | |
| 7 | inherit update-alternatives |
| 8 | |
| 9 | MULTILIB_SUFFIX = "${@d.getVar('base_libdir',1).split('/')[-1]}" |
| 10 | |
| 11 | PACKAGE_PREPROCESS_FUNCS += "multilibscript_rename" |
| 12 | |
| 13 | multilibscript_rename() { |
| 14 | : |
| 15 | } |
| 16 | |
| 17 | python () { |
| 18 | # Do nothing if multilib isn't being used |
| 19 | if not d.getVar("MULTILIB_VARIANTS"): |
Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame] | 20 | return |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 21 | # Do nothing for native/cross |
| 22 | if bb.data.inherits_class('native', d) or bb.data.inherits_class('cross', d): |
Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame] | 23 | return |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 24 | |
| 25 | for entry in (d.getVar("MULTILIB_SCRIPTS", False) or "").split(): |
Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame] | 26 | pkg, script = entry.split(":") |
| 27 | epkg = d.expand(pkg) |
| 28 | scriptname = os.path.basename(script) |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 29 | d.appendVar("ALTERNATIVE:" + epkg, " " + scriptname + " ") |
Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame] | 30 | d.setVarFlag("ALTERNATIVE_LINK_NAME", scriptname, script) |
| 31 | d.setVarFlag("ALTERNATIVE_TARGET", scriptname, script + "-${MULTILIB_SUFFIX}") |
| 32 | d.appendVar("multilibscript_rename", "\n mv ${PKGD}" + script + " ${PKGD}" + script + "-${MULTILIB_SUFFIX}") |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 33 | d.appendVar("FILES:" + epkg, " " + script + "-${MULTILIB_SUFFIX}") |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 34 | } |