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() |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 14 | non_ml_recipes = d.getVar('NON_MULTILIB_RECIPES').split() |
| 15 | bpn = e.data.getVar("BPN") |
| 16 | if "virtual/kernel" in provides or \ |
| 17 | bb.data.inherits_class('module-base', e.data) or \ |
| 18 | bpn in non_ml_recipes: |
| 19 | raise bb.parse.SkipRecipe("We shouldn't have multilib variants for %s" % bpn) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 20 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 21 | save_var_name=e.data.getVar("MULTILIB_SAVE_VARNAME") or "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 22 | for name in save_var_name.split(): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 23 | val=e.data.getVar(name) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 24 | if val: |
| 25 | e.data.setVar(name + "_MULTILIB_ORIGINAL", val) |
| 26 | |
| 27 | overrides = e.data.getVar("OVERRIDES", False) |
| 28 | pn = e.data.getVar("PN", False) |
| 29 | overrides = overrides.replace("pn-${PN}", "pn-${PN}:pn-" + pn) |
| 30 | e.data.setVar("OVERRIDES", overrides) |
| 31 | |
| 32 | if bb.data.inherits_class('image', e.data): |
| 33 | e.data.setVar("MLPREFIX", variant + "-") |
| 34 | e.data.setVar("PN", variant + "-" + e.data.getVar("PN", False)) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 35 | e.data.setVar('SDKTARGETSYSROOT', e.data.getVar('SDKTARGETSYSROOT')) |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 36 | override = ":virtclass-multilib-" + variant |
| 37 | e.data.setVar("OVERRIDES", e.data.getVar("OVERRIDES", False) + override) |
Patrick Williams | 0ca19cc | 2021-08-16 14:03:13 -0500 | [diff] [blame] | 38 | target_vendor = e.data.getVar("TARGET_VENDOR:" + "virtclass-multilib-" + variant, False) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 39 | if target_vendor: |
| 40 | e.data.setVar("TARGET_VENDOR", target_vendor) |
| 41 | return |
| 42 | |
| 43 | if bb.data.inherits_class('cross-canadian', e.data): |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 44 | # Multilib cross-candian should use the same nativesdk sysroot without MLPREFIX |
| 45 | e.data.setVar("RECIPE_SYSROOT", "${WORKDIR}/recipe-sysroot") |
| 46 | e.data.setVar("STAGING_DIR_TARGET", "${WORKDIR}/recipe-sysroot") |
| 47 | e.data.setVar("STAGING_DIR_HOST", "${WORKDIR}/recipe-sysroot") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 48 | e.data.setVar("MLPREFIX", variant + "-") |
| 49 | override = ":virtclass-multilib-" + variant |
| 50 | e.data.setVar("OVERRIDES", e.data.getVar("OVERRIDES", False) + override) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 51 | return |
| 52 | |
| 53 | if bb.data.inherits_class('native', e.data): |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 54 | raise bb.parse.SkipRecipe("We can't extend native recipes") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 55 | |
| 56 | if bb.data.inherits_class('nativesdk', e.data) or bb.data.inherits_class('crosssdk', e.data): |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 57 | raise bb.parse.SkipRecipe("We can't extend nativesdk recipes") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 58 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 59 | if bb.data.inherits_class('allarch', e.data) and not d.getVar('MULTILIB_VARIANTS') \ |
| 60 | and not bb.data.inherits_class('packagegroup', e.data): |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 61 | raise bb.parse.SkipRecipe("Don't extend allarch recipes which are not packagegroups") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 62 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 63 | # 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] | 64 | 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] | 65 | |
| 66 | override = ":virtclass-multilib-" + variant |
| 67 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 68 | skip_msg = e.data.getVarFlag('SKIP_RECIPE', e.data.getVar('PN')) |
| 69 | if skip_msg: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 70 | pn_new = variant + "-" + e.data.getVar('PN') |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 71 | if not e.data.getVarFlag('SKIP_RECIPE', pn_new): |
| 72 | e.data.setVarFlag('SKIP_RECIPE', pn_new, skip_msg) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 73 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 74 | e.data.setVar("MLPREFIX", variant + "-") |
| 75 | e.data.setVar("PN", variant + "-" + e.data.getVar("PN", False)) |
| 76 | e.data.setVar("OVERRIDES", e.data.getVar("OVERRIDES", False) + override) |
| 77 | |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 78 | # Expand INCOMPATIBLE_LICENSE_EXCEPTIONS with multilib prefix |
| 79 | pkgs = e.data.getVar("INCOMPATIBLE_LICENSE_EXCEPTIONS") |
| 80 | if pkgs: |
| 81 | for pkg in pkgs.split(): |
| 82 | pkgs += " " + variant + "-" + pkg |
| 83 | e.data.setVar("INCOMPATIBLE_LICENSE_EXCEPTIONS", pkgs) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 84 | |
| 85 | # DEFAULTTUNE can change TARGET_ARCH override so expand this now before update_data |
Patrick Williams | 0ca19cc | 2021-08-16 14:03:13 -0500 | [diff] [blame] | 86 | newtune = e.data.getVar("DEFAULTTUNE:" + "virtclass-multilib-" + variant, False) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 87 | if newtune: |
| 88 | e.data.setVar("DEFAULTTUNE", newtune) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | addhandler multilib_virtclass_handler |
| 92 | multilib_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise" |
| 93 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 94 | python __anonymous () { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 95 | if bb.data.inherits_class('image', d): |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 96 | # set rpm preferred file color for 32-bit multilib image |
| 97 | if d.getVar("SITEINFO_BITS") == "32": |
| 98 | d.setVar("RPM_PREFER_ELF_ARCH", "1") |
| 99 | |
Andrew Geissler | 1e34c2d | 2020-05-29 16:02:59 -0500 | [diff] [blame] | 100 | variant = d.getVar("BBEXTENDVARIANT") |
| 101 | import oe.classextend |
| 102 | |
| 103 | clsextend = oe.classextend.ClassExtender(variant, d) |
| 104 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 105 | clsextend.map_depends_variable("PACKAGE_INSTALL") |
| 106 | clsextend.map_depends_variable("LINGUAS_INSTALL") |
| 107 | clsextend.map_depends_variable("RDEPENDS") |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 108 | pinstall = d.getVar("LINGUAS_INSTALL") + " " + d.getVar("PACKAGE_INSTALL") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 109 | d.setVar("PACKAGE_INSTALL", pinstall) |
| 110 | d.setVar("LINGUAS_INSTALL", "") |
| 111 | # FIXME, we need to map this to something, not delete it! |
| 112 | d.setVar("PACKAGE_INSTALL_ATTEMPTONLY", "") |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 113 | bb.build.deltask('do_populate_sdk_ext', d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 114 | return |
Andrew Geissler | 1e34c2d | 2020-05-29 16:02:59 -0500 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | python multilib_virtclass_handler_postkeyexp () { |
| 118 | cls = d.getVar("BBEXTENDCURR") |
| 119 | variant = d.getVar("BBEXTENDVARIANT") |
| 120 | if cls != "multilib" or not variant: |
| 121 | return |
| 122 | |
| 123 | variant = d.getVar("BBEXTENDVARIANT") |
| 124 | |
| 125 | import oe.classextend |
| 126 | |
| 127 | clsextend = oe.classextend.ClassExtender(variant, d) |
| 128 | |
| 129 | if bb.data.inherits_class('image', d): |
| 130 | return |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 131 | |
| 132 | clsextend.map_depends_variable("DEPENDS") |
| 133 | clsextend.map_variable("PROVIDES") |
| 134 | |
| 135 | if bb.data.inherits_class('cross-canadian', d): |
| 136 | return |
| 137 | |
| 138 | clsextend.rename_packages() |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 139 | clsextend.rename_package_variables((d.getVar("PACKAGEVARS") or "").split()) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 140 | |
| 141 | clsextend.map_packagevars() |
| 142 | clsextend.map_regexp_variable("PACKAGES_DYNAMIC") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 143 | clsextend.map_variable("INITSCRIPT_PACKAGES") |
| 144 | clsextend.map_variable("USERADD_PACKAGES") |
| 145 | clsextend.map_variable("SYSTEMD_PACKAGES") |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 146 | clsextend.map_variable("UPDATERCPN") |
Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame] | 147 | |
| 148 | reset_alternative_priority(d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 149 | } |
| 150 | |
Andrew Geissler | 1e34c2d | 2020-05-29 16:02:59 -0500 | [diff] [blame] | 151 | addhandler multilib_virtclass_handler_postkeyexp |
| 152 | multilib_virtclass_handler_postkeyexp[eventmask] = "bb.event.RecipePostKeyExpansion" |
| 153 | |
Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame] | 154 | def reset_alternative_priority(d): |
| 155 | if not bb.data.inherits_class('update-alternatives', d): |
| 156 | return |
| 157 | |
| 158 | # There might be multiple multilibs at the same time, e.g., lib32 and |
| 159 | # lib64, each of them should have a different priority. |
| 160 | multilib_variants = d.getVar('MULTILIB_VARIANTS') |
| 161 | bbextendvariant = d.getVar('BBEXTENDVARIANT') |
| 162 | reset_gap = multilib_variants.split().index(bbextendvariant) + 1 |
| 163 | |
| 164 | # ALTERNATIVE_PRIORITY = priority |
| 165 | alt_priority_recipe = d.getVar('ALTERNATIVE_PRIORITY') |
| 166 | # Reset ALTERNATIVE_PRIORITY when found |
| 167 | if alt_priority_recipe: |
| 168 | reset_priority = int(alt_priority_recipe) - reset_gap |
| 169 | bb.debug(1, '%s: Setting ALTERNATIVE_PRIORITY to %s' % (d.getVar('PN'), reset_priority)) |
| 170 | d.setVar('ALTERNATIVE_PRIORITY', reset_priority) |
| 171 | |
| 172 | handled_pkgs = [] |
| 173 | for pkg in (d.getVar('PACKAGES') or "").split(): |
| 174 | # ALTERNATIVE_PRIORITY_pkg = priority |
| 175 | alt_priority_pkg = d.getVar('ALTERNATIVE_PRIORITY_%s' % pkg) |
| 176 | # Reset ALTERNATIVE_PRIORITY_pkg when found |
| 177 | if alt_priority_pkg: |
| 178 | reset_priority = int(alt_priority_pkg) - reset_gap |
| 179 | if not pkg in handled_pkgs: |
| 180 | handled_pkgs.append(pkg) |
| 181 | bb.debug(1, '%s: Setting ALTERNATIVE_PRIORITY_%s to %s' % (pkg, pkg, reset_priority)) |
| 182 | d.setVar('ALTERNATIVE_PRIORITY_%s' % pkg, reset_priority) |
| 183 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 184 | for alt_name in (d.getVar('ALTERNATIVE:%s' % pkg) or "").split(): |
Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame] | 185 | # ALTERNATIVE_PRIORITY_pkg[tool] = priority |
| 186 | alt_priority_pkg_name = d.getVarFlag('ALTERNATIVE_PRIORITY_%s' % pkg, alt_name) |
| 187 | # ALTERNATIVE_PRIORITY[tool] = priority |
| 188 | alt_priority_name = d.getVarFlag('ALTERNATIVE_PRIORITY', alt_name) |
| 189 | |
| 190 | if alt_priority_pkg_name: |
| 191 | reset_priority = int(alt_priority_pkg_name) - reset_gap |
| 192 | bb.debug(1, '%s: Setting ALTERNATIVE_PRIORITY_%s[%s] to %s' % (pkg, pkg, alt_name, reset_priority)) |
| 193 | d.setVarFlag('ALTERNATIVE_PRIORITY_%s' % pkg, alt_name, reset_priority) |
| 194 | elif alt_priority_name: |
| 195 | reset_priority = int(alt_priority_name) - reset_gap |
| 196 | bb.debug(1, '%s: Setting ALTERNATIVE_PRIORITY[%s] to %s' % (pkg, alt_name, reset_priority)) |
| 197 | d.setVarFlag('ALTERNATIVE_PRIORITY', alt_name, reset_priority) |
| 198 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 199 | PACKAGEFUNCS:append = " do_package_qa_multilib" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 200 | |
| 201 | python do_package_qa_multilib() { |
| 202 | |
| 203 | def check_mlprefix(pkg, var, mlprefix): |
Andrew Geissler | 5199d83 | 2021-09-24 16:47:35 -0500 | [diff] [blame] | 204 | 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] | 205 | candidates = [] |
| 206 | for i in values: |
| 207 | if i.startswith('virtual/'): |
| 208 | i = i[len('virtual/'):] |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 209 | |
| 210 | if (not (i.startswith(mlprefix) or i.startswith("kernel-") \ |
| 211 | or ('cross-canadian' in i) or i.startswith("nativesdk-") \ |
| 212 | or i.startswith("rtld") or i.startswith("/"))): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 213 | candidates.append(i) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 214 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 215 | if len(candidates) > 0: |
| 216 | msg = "%s package %s - suspicious values '%s' in %s" \ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 217 | % (d.getVar('PN'), pkg, ' '.join(candidates), var) |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 218 | oe.qa.handle_error("multilib", msg, d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 219 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 220 | ml = d.getVar('MLPREFIX') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 221 | if not ml: |
| 222 | return |
| 223 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 224 | # exception for ${MLPREFIX}target-sdk-provides-dummy |
| 225 | if 'target-sdk-provides-dummy' in d.getVar('PN'): |
| 226 | return |
| 227 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 228 | packages = d.getVar('PACKAGES') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 229 | for pkg in packages.split(): |
| 230 | check_mlprefix(pkg, 'RDEPENDS', ml) |
| 231 | check_mlprefix(pkg, 'RPROVIDES', ml) |
| 232 | check_mlprefix(pkg, 'RRECOMMENDS', ml) |
| 233 | check_mlprefix(pkg, 'RSUGGESTS', ml) |
| 234 | check_mlprefix(pkg, 'RREPLACES', ml) |
| 235 | check_mlprefix(pkg, 'RCONFLICTS', ml) |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 236 | oe.qa.exit_if_errors(d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 237 | } |