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