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 | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 38 | target_vendor = e.data.getVar("TARGET_VENDOR_" + "virtclass-multilib-" + variant, False) |
| 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 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 68 | blacklist = e.data.getVarFlag('PNBLACKLIST', e.data.getVar('PN')) |
| 69 | if blacklist: |
| 70 | pn_new = variant + "-" + e.data.getVar('PN') |
| 71 | if not e.data.getVarFlag('PNBLACKLIST', pn_new): |
| 72 | e.data.setVarFlag('PNBLACKLIST', pn_new, blacklist) |
| 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 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 78 | # Expand WHITELIST_GPL-3.0 with multilib prefix |
| 79 | pkgs = e.data.getVar("WHITELIST_GPL-3.0") |
| 80 | for pkg in pkgs.split(): |
| 81 | pkgs += " " + variant + "-" + pkg |
| 82 | e.data.setVar("WHITELIST_GPL-3.0", pkgs) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 83 | |
| 84 | # DEFAULTTUNE can change TARGET_ARCH override so expand this now before update_data |
| 85 | newtune = e.data.getVar("DEFAULTTUNE_" + "virtclass-multilib-" + variant, False) |
| 86 | if newtune: |
| 87 | e.data.setVar("DEFAULTTUNE", newtune) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | addhandler multilib_virtclass_handler |
| 91 | multilib_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise" |
| 92 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 93 | python __anonymous () { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 94 | variant = d.getVar("BBEXTENDVARIANT") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 95 | |
| 96 | import oe.classextend |
| 97 | |
| 98 | clsextend = oe.classextend.ClassExtender(variant, d) |
| 99 | |
| 100 | if bb.data.inherits_class('image', d): |
| 101 | clsextend.map_depends_variable("PACKAGE_INSTALL") |
| 102 | clsextend.map_depends_variable("LINGUAS_INSTALL") |
| 103 | clsextend.map_depends_variable("RDEPENDS") |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 104 | pinstall = d.getVar("LINGUAS_INSTALL") + " " + d.getVar("PACKAGE_INSTALL") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 105 | d.setVar("PACKAGE_INSTALL", pinstall) |
| 106 | d.setVar("LINGUAS_INSTALL", "") |
| 107 | # FIXME, we need to map this to something, not delete it! |
| 108 | d.setVar("PACKAGE_INSTALL_ATTEMPTONLY", "") |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 109 | bb.build.deltask('do_populate_sdk', d) |
| 110 | bb.build.deltask('do_populate_sdk_ext', d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 111 | return |
| 112 | |
| 113 | clsextend.map_depends_variable("DEPENDS") |
| 114 | clsextend.map_variable("PROVIDES") |
| 115 | |
| 116 | if bb.data.inherits_class('cross-canadian', d): |
| 117 | return |
| 118 | |
| 119 | clsextend.rename_packages() |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 120 | clsextend.rename_package_variables((d.getVar("PACKAGEVARS") or "").split()) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 121 | |
| 122 | clsextend.map_packagevars() |
| 123 | clsextend.map_regexp_variable("PACKAGES_DYNAMIC") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 124 | clsextend.map_variable("INITSCRIPT_PACKAGES") |
| 125 | clsextend.map_variable("USERADD_PACKAGES") |
| 126 | clsextend.map_variable("SYSTEMD_PACKAGES") |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 127 | clsextend.map_variable("UPDATERCPN") |
Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame] | 128 | |
| 129 | reset_alternative_priority(d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 130 | } |
| 131 | |
Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame] | 132 | def reset_alternative_priority(d): |
| 133 | if not bb.data.inherits_class('update-alternatives', d): |
| 134 | return |
| 135 | |
| 136 | # There might be multiple multilibs at the same time, e.g., lib32 and |
| 137 | # lib64, each of them should have a different priority. |
| 138 | multilib_variants = d.getVar('MULTILIB_VARIANTS') |
| 139 | bbextendvariant = d.getVar('BBEXTENDVARIANT') |
| 140 | reset_gap = multilib_variants.split().index(bbextendvariant) + 1 |
| 141 | |
| 142 | # ALTERNATIVE_PRIORITY = priority |
| 143 | alt_priority_recipe = d.getVar('ALTERNATIVE_PRIORITY') |
| 144 | # Reset ALTERNATIVE_PRIORITY when found |
| 145 | if alt_priority_recipe: |
| 146 | reset_priority = int(alt_priority_recipe) - reset_gap |
| 147 | bb.debug(1, '%s: Setting ALTERNATIVE_PRIORITY to %s' % (d.getVar('PN'), reset_priority)) |
| 148 | d.setVar('ALTERNATIVE_PRIORITY', reset_priority) |
| 149 | |
| 150 | handled_pkgs = [] |
| 151 | for pkg in (d.getVar('PACKAGES') or "").split(): |
| 152 | # ALTERNATIVE_PRIORITY_pkg = priority |
| 153 | alt_priority_pkg = d.getVar('ALTERNATIVE_PRIORITY_%s' % pkg) |
| 154 | # Reset ALTERNATIVE_PRIORITY_pkg when found |
| 155 | if alt_priority_pkg: |
| 156 | reset_priority = int(alt_priority_pkg) - reset_gap |
| 157 | if not pkg in handled_pkgs: |
| 158 | handled_pkgs.append(pkg) |
| 159 | bb.debug(1, '%s: Setting ALTERNATIVE_PRIORITY_%s to %s' % (pkg, pkg, reset_priority)) |
| 160 | d.setVar('ALTERNATIVE_PRIORITY_%s' % pkg, reset_priority) |
| 161 | |
| 162 | for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg) or "").split(): |
| 163 | # ALTERNATIVE_PRIORITY_pkg[tool] = priority |
| 164 | alt_priority_pkg_name = d.getVarFlag('ALTERNATIVE_PRIORITY_%s' % pkg, alt_name) |
| 165 | # ALTERNATIVE_PRIORITY[tool] = priority |
| 166 | alt_priority_name = d.getVarFlag('ALTERNATIVE_PRIORITY', alt_name) |
| 167 | |
| 168 | if alt_priority_pkg_name: |
| 169 | reset_priority = int(alt_priority_pkg_name) - reset_gap |
| 170 | bb.debug(1, '%s: Setting ALTERNATIVE_PRIORITY_%s[%s] to %s' % (pkg, pkg, alt_name, reset_priority)) |
| 171 | d.setVarFlag('ALTERNATIVE_PRIORITY_%s' % pkg, alt_name, reset_priority) |
| 172 | elif alt_priority_name: |
| 173 | reset_priority = int(alt_priority_name) - reset_gap |
| 174 | bb.debug(1, '%s: Setting ALTERNATIVE_PRIORITY[%s] to %s' % (pkg, alt_name, reset_priority)) |
| 175 | d.setVarFlag('ALTERNATIVE_PRIORITY', alt_name, reset_priority) |
| 176 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 177 | PACKAGEFUNCS_append = " do_package_qa_multilib" |
| 178 | |
| 179 | python do_package_qa_multilib() { |
| 180 | |
| 181 | def check_mlprefix(pkg, var, mlprefix): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 182 | 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] | 183 | candidates = [] |
| 184 | for i in values: |
| 185 | if i.startswith('virtual/'): |
| 186 | i = i[len('virtual/'):] |
| 187 | if (not i.startswith('kernel-module')) and (not i.startswith(mlprefix)) and \ |
| 188 | (not 'cross-canadian' in i) and (not i.startswith("nativesdk-")) and \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 189 | (not i.startswith("rtld")) and (not i.startswith('kernel-vmlinux')) \ |
| 190 | and (not i.startswith("kernel-image")): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 191 | candidates.append(i) |
| 192 | if len(candidates) > 0: |
| 193 | msg = "%s package %s - suspicious values '%s' in %s" \ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 194 | % (d.getVar('PN'), pkg, ' '.join(candidates), var) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 195 | package_qa_handle_error("multilib", msg, d) |
| 196 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 197 | ml = d.getVar('MLPREFIX') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 198 | if not ml: |
| 199 | return |
| 200 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 201 | # exception for ${MLPREFIX}target-sdk-provides-dummy |
| 202 | if 'target-sdk-provides-dummy' in d.getVar('PN'): |
| 203 | return |
| 204 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 205 | packages = d.getVar('PACKAGES') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 206 | for pkg in packages.split(): |
| 207 | check_mlprefix(pkg, 'RDEPENDS', ml) |
| 208 | check_mlprefix(pkg, 'RPROVIDES', ml) |
| 209 | check_mlprefix(pkg, 'RRECOMMENDS', ml) |
| 210 | check_mlprefix(pkg, 'RSUGGESTS', ml) |
| 211 | check_mlprefix(pkg, 'RREPLACES', ml) |
| 212 | check_mlprefix(pkg, 'RCONFLICTS', ml) |
| 213 | } |