Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | python multilib_virtclass_handler () { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 2 | cls = e.data.getVar("BBEXTENDCURR") |
| 3 | variant = e.data.getVar("BBEXTENDVARIANT") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4 | if cls != "multilib" or not variant: |
| 5 | return |
| 6 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7 | localdata = bb.data.createCopy(e.data) |
| 8 | localdata.delVar('TMPDIR') |
| 9 | e.data.setVar('STAGING_KERNEL_DIR', localdata.getVar('STAGING_KERNEL_DIR')) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10 | |
| 11 | # There should only be one kernel in multilib configs |
| 12 | # We also skip multilib setup for module packages. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 13 | provides = (e.data.getVar("PROVIDES") or "").split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14 | if "virtual/kernel" in provides or bb.data.inherits_class('module-base', e.data): |
| 15 | raise bb.parse.SkipPackage("We shouldn't have multilib variants for the kernel") |
| 16 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 17 | save_var_name=e.data.getVar("MULTILIB_SAVE_VARNAME") or "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 18 | for name in save_var_name.split(): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 19 | val=e.data.getVar(name) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 20 | if val: |
| 21 | e.data.setVar(name + "_MULTILIB_ORIGINAL", val) |
| 22 | |
| 23 | overrides = e.data.getVar("OVERRIDES", False) |
| 24 | pn = e.data.getVar("PN", False) |
| 25 | overrides = overrides.replace("pn-${PN}", "pn-${PN}:pn-" + pn) |
| 26 | e.data.setVar("OVERRIDES", overrides) |
| 27 | |
| 28 | if bb.data.inherits_class('image', e.data): |
| 29 | e.data.setVar("MLPREFIX", variant + "-") |
| 30 | e.data.setVar("PN", variant + "-" + e.data.getVar("PN", False)) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 31 | e.data.setVar('SDKTARGETSYSROOT', e.data.getVar('SDKTARGETSYSROOT')) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 32 | target_vendor = e.data.getVar("TARGET_VENDOR_" + "virtclass-multilib-" + variant, False) |
| 33 | if target_vendor: |
| 34 | e.data.setVar("TARGET_VENDOR", target_vendor) |
| 35 | return |
| 36 | |
| 37 | if bb.data.inherits_class('cross-canadian', e.data): |
| 38 | e.data.setVar("MLPREFIX", variant + "-") |
| 39 | override = ":virtclass-multilib-" + variant |
| 40 | e.data.setVar("OVERRIDES", e.data.getVar("OVERRIDES", False) + override) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 41 | return |
| 42 | |
| 43 | if bb.data.inherits_class('native', e.data): |
| 44 | raise bb.parse.SkipPackage("We can't extend native recipes") |
| 45 | |
| 46 | if bb.data.inherits_class('nativesdk', e.data) or bb.data.inherits_class('crosssdk', e.data): |
| 47 | raise bb.parse.SkipPackage("We can't extend nativesdk recipes") |
| 48 | |
| 49 | if bb.data.inherits_class('allarch', e.data) and not bb.data.inherits_class('packagegroup', e.data): |
| 50 | raise bb.parse.SkipPackage("Don't extend allarch recipes which are not packagegroups") |
| 51 | |
| 52 | |
| 53 | # Expand this since this won't work correctly once we set a multilib into place |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 54 | e.data.setVar("ALL_MULTILIB_PACKAGE_ARCHS", e.data.getVar("ALL_MULTILIB_PACKAGE_ARCHS")) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 55 | |
| 56 | override = ":virtclass-multilib-" + variant |
| 57 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 58 | blacklist = e.data.getVarFlag('PNBLACKLIST', e.data.getVar('PN')) |
| 59 | if blacklist: |
| 60 | pn_new = variant + "-" + e.data.getVar('PN') |
| 61 | if not e.data.getVarFlag('PNBLACKLIST', pn_new): |
| 62 | e.data.setVarFlag('PNBLACKLIST', pn_new, blacklist) |
| 63 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 64 | e.data.setVar("MLPREFIX", variant + "-") |
| 65 | e.data.setVar("PN", variant + "-" + e.data.getVar("PN", False)) |
| 66 | e.data.setVar("OVERRIDES", e.data.getVar("OVERRIDES", False) + override) |
| 67 | |
| 68 | # Expand the WHITELISTs with multilib prefix |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 69 | for whitelist in ["WHITELIST_GPL-3.0", "LGPLv2_WHITELIST_GPL-3.0"]: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 70 | pkgs = e.data.getVar(whitelist) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 71 | for pkg in pkgs.split(): |
| 72 | pkgs += " " + variant + "-" + pkg |
| 73 | e.data.setVar(whitelist, pkgs) |
| 74 | |
| 75 | # DEFAULTTUNE can change TARGET_ARCH override so expand this now before update_data |
| 76 | newtune = e.data.getVar("DEFAULTTUNE_" + "virtclass-multilib-" + variant, False) |
| 77 | if newtune: |
| 78 | e.data.setVar("DEFAULTTUNE", newtune) |
| 79 | e.data.setVar('DEFAULTTUNE_ML_%s' % variant, newtune) |
| 80 | } |
| 81 | |
| 82 | addhandler multilib_virtclass_handler |
| 83 | multilib_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise" |
| 84 | |
| 85 | STAGINGCC_prepend = "${BBEXTENDVARIANT}-" |
| 86 | |
| 87 | python __anonymous () { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 88 | variant = d.getVar("BBEXTENDVARIANT") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 89 | |
| 90 | import oe.classextend |
| 91 | |
| 92 | clsextend = oe.classextend.ClassExtender(variant, d) |
| 93 | |
| 94 | if bb.data.inherits_class('image', d): |
| 95 | clsextend.map_depends_variable("PACKAGE_INSTALL") |
| 96 | clsextend.map_depends_variable("LINGUAS_INSTALL") |
| 97 | clsextend.map_depends_variable("RDEPENDS") |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 98 | pinstall = d.getVar("LINGUAS_INSTALL") + " " + d.getVar("PACKAGE_INSTALL") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 99 | d.setVar("PACKAGE_INSTALL", pinstall) |
| 100 | d.setVar("LINGUAS_INSTALL", "") |
| 101 | # FIXME, we need to map this to something, not delete it! |
| 102 | d.setVar("PACKAGE_INSTALL_ATTEMPTONLY", "") |
| 103 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 104 | if bb.data.inherits_class('image', d): |
| 105 | return |
| 106 | |
| 107 | clsextend.map_depends_variable("DEPENDS") |
| 108 | clsextend.map_variable("PROVIDES") |
| 109 | |
| 110 | if bb.data.inherits_class('cross-canadian', d): |
| 111 | return |
| 112 | |
| 113 | clsextend.rename_packages() |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 114 | clsextend.rename_package_variables((d.getVar("PACKAGEVARS") or "").split()) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 115 | |
| 116 | clsextend.map_packagevars() |
| 117 | clsextend.map_regexp_variable("PACKAGES_DYNAMIC") |
| 118 | clsextend.map_variable("PACKAGE_INSTALL") |
| 119 | clsextend.map_variable("INITSCRIPT_PACKAGES") |
| 120 | clsextend.map_variable("USERADD_PACKAGES") |
| 121 | clsextend.map_variable("SYSTEMD_PACKAGES") |
| 122 | } |
| 123 | |
| 124 | PACKAGEFUNCS_append = " do_package_qa_multilib" |
| 125 | |
| 126 | python do_package_qa_multilib() { |
| 127 | |
| 128 | def check_mlprefix(pkg, var, mlprefix): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 129 | values = bb.utils.explode_deps(d.getVar('%s_%s' % (var, pkg)) or d.getVar(var) or "") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 130 | candidates = [] |
| 131 | for i in values: |
| 132 | if i.startswith('virtual/'): |
| 133 | i = i[len('virtual/'):] |
| 134 | if (not i.startswith('kernel-module')) and (not i.startswith(mlprefix)) and \ |
| 135 | (not 'cross-canadian' in i) and (not i.startswith("nativesdk-")) and \ |
| 136 | (not i.startswith("rtld")) and (not i.startswith('kernel-vmlinux')): |
| 137 | candidates.append(i) |
| 138 | if len(candidates) > 0: |
| 139 | msg = "%s package %s - suspicious values '%s' in %s" \ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 140 | % (d.getVar('PN'), pkg, ' '.join(candidates), var) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 141 | package_qa_handle_error("multilib", msg, d) |
| 142 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 143 | ml = d.getVar('MLPREFIX') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 144 | if not ml: |
| 145 | return |
| 146 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 147 | packages = d.getVar('PACKAGES') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 148 | for pkg in packages.split(): |
| 149 | check_mlprefix(pkg, 'RDEPENDS', ml) |
| 150 | check_mlprefix(pkg, 'RPROVIDES', ml) |
| 151 | check_mlprefix(pkg, 'RRECOMMENDS', ml) |
| 152 | check_mlprefix(pkg, 'RSUGGESTS', ml) |
| 153 | check_mlprefix(pkg, 'RREPLACES', ml) |
| 154 | check_mlprefix(pkg, 'RCONFLICTS', ml) |
| 155 | } |