| 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')) | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 36 | target_vendor = e.data.getVar("TARGET_VENDOR_" + "virtclass-multilib-" + variant, False) | 
|  | 37 | if target_vendor: | 
|  | 38 | e.data.setVar("TARGET_VENDOR", target_vendor) | 
|  | 39 | return | 
|  | 40 |  | 
|  | 41 | if bb.data.inherits_class('cross-canadian', e.data): | 
| Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 42 | # Multilib cross-candian should use the same nativesdk sysroot without MLPREFIX | 
|  | 43 | e.data.setVar("RECIPE_SYSROOT", "${WORKDIR}/recipe-sysroot") | 
|  | 44 | e.data.setVar("STAGING_DIR_TARGET", "${WORKDIR}/recipe-sysroot") | 
|  | 45 | e.data.setVar("STAGING_DIR_HOST", "${WORKDIR}/recipe-sysroot") | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 46 | e.data.setVar("MLPREFIX", variant + "-") | 
|  | 47 | override = ":virtclass-multilib-" + variant | 
|  | 48 | e.data.setVar("OVERRIDES", e.data.getVar("OVERRIDES", False) + override) | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 49 | return | 
|  | 50 |  | 
|  | 51 | if bb.data.inherits_class('native', e.data): | 
| Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 52 | raise bb.parse.SkipRecipe("We can't extend native recipes") | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 53 |  | 
|  | 54 | 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] | 55 | raise bb.parse.SkipRecipe("We can't extend nativesdk recipes") | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 56 |  | 
| Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 57 | if bb.data.inherits_class('allarch', e.data) and not d.getVar('MULTILIB_VARIANTS') \ | 
|  | 58 | and not bb.data.inherits_class('packagegroup', e.data): | 
| Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 59 | 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] | 60 |  | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 61 | # 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] | 62 | 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] | 63 |  | 
|  | 64 | override = ":virtclass-multilib-" + variant | 
|  | 65 |  | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 66 | blacklist = e.data.getVarFlag('PNBLACKLIST', e.data.getVar('PN')) | 
|  | 67 | if blacklist: | 
|  | 68 | pn_new = variant + "-" + e.data.getVar('PN') | 
|  | 69 | if not e.data.getVarFlag('PNBLACKLIST', pn_new): | 
|  | 70 | e.data.setVarFlag('PNBLACKLIST', pn_new, blacklist) | 
|  | 71 |  | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 72 | e.data.setVar("MLPREFIX", variant + "-") | 
|  | 73 | e.data.setVar("PN", variant + "-" + e.data.getVar("PN", False)) | 
|  | 74 | e.data.setVar("OVERRIDES", e.data.getVar("OVERRIDES", False) + override) | 
|  | 75 |  | 
| Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 76 | # Expand WHITELIST_GPL-3.0 with multilib prefix | 
|  | 77 | pkgs = e.data.getVar("WHITELIST_GPL-3.0") | 
|  | 78 | for pkg in pkgs.split(): | 
|  | 79 | pkgs += " " + variant + "-" + pkg | 
|  | 80 | e.data.setVar("WHITELIST_GPL-3.0", pkgs) | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 81 |  | 
|  | 82 | # DEFAULTTUNE can change TARGET_ARCH override so expand this now before update_data | 
|  | 83 | newtune = e.data.getVar("DEFAULTTUNE_" + "virtclass-multilib-" + variant, False) | 
|  | 84 | if newtune: | 
|  | 85 | e.data.setVar("DEFAULTTUNE", newtune) | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 86 | } | 
|  | 87 |  | 
|  | 88 | addhandler multilib_virtclass_handler | 
|  | 89 | multilib_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise" | 
|  | 90 |  | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 91 | python __anonymous () { | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 92 | variant = d.getVar("BBEXTENDVARIANT") | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 93 |  | 
|  | 94 | import oe.classextend | 
|  | 95 |  | 
|  | 96 | clsextend = oe.classextend.ClassExtender(variant, d) | 
|  | 97 |  | 
|  | 98 | if bb.data.inherits_class('image', d): | 
|  | 99 | clsextend.map_depends_variable("PACKAGE_INSTALL") | 
|  | 100 | clsextend.map_depends_variable("LINGUAS_INSTALL") | 
|  | 101 | clsextend.map_depends_variable("RDEPENDS") | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 102 | pinstall = d.getVar("LINGUAS_INSTALL") + " " + d.getVar("PACKAGE_INSTALL") | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 103 | d.setVar("PACKAGE_INSTALL", pinstall) | 
|  | 104 | d.setVar("LINGUAS_INSTALL", "") | 
|  | 105 | # FIXME, we need to map this to something, not delete it! | 
|  | 106 | d.setVar("PACKAGE_INSTALL_ATTEMPTONLY", "") | 
| Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 107 | bb.build.deltask('do_populate_sdk', d) | 
|  | 108 | bb.build.deltask('do_populate_sdk_ext', d) | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 109 | return | 
|  | 110 |  | 
|  | 111 | clsextend.map_depends_variable("DEPENDS") | 
|  | 112 | clsextend.map_variable("PROVIDES") | 
|  | 113 |  | 
|  | 114 | if bb.data.inherits_class('cross-canadian', d): | 
|  | 115 | return | 
|  | 116 |  | 
|  | 117 | clsextend.rename_packages() | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 118 | clsextend.rename_package_variables((d.getVar("PACKAGEVARS") or "").split()) | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 119 |  | 
|  | 120 | clsextend.map_packagevars() | 
|  | 121 | clsextend.map_regexp_variable("PACKAGES_DYNAMIC") | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 122 | clsextend.map_variable("INITSCRIPT_PACKAGES") | 
|  | 123 | clsextend.map_variable("USERADD_PACKAGES") | 
|  | 124 | clsextend.map_variable("SYSTEMD_PACKAGES") | 
| Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 125 | clsextend.map_variable("UPDATERCPN") | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 126 | } | 
|  | 127 |  | 
|  | 128 | PACKAGEFUNCS_append = " do_package_qa_multilib" | 
|  | 129 |  | 
|  | 130 | python do_package_qa_multilib() { | 
|  | 131 |  | 
|  | 132 | def check_mlprefix(pkg, var, mlprefix): | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 133 | 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] | 134 | candidates = [] | 
|  | 135 | for i in values: | 
|  | 136 | if i.startswith('virtual/'): | 
|  | 137 | i = i[len('virtual/'):] | 
|  | 138 | if (not i.startswith('kernel-module')) and (not i.startswith(mlprefix)) and \ | 
|  | 139 | (not 'cross-canadian' in i) and (not i.startswith("nativesdk-")) and \ | 
| Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 140 | (not i.startswith("rtld")) and (not i.startswith('kernel-vmlinux')) \ | 
|  | 141 | and (not i.startswith("kernel-image")): | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 142 | candidates.append(i) | 
|  | 143 | if len(candidates) > 0: | 
|  | 144 | msg = "%s package %s - suspicious values '%s' in %s" \ | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 145 | % (d.getVar('PN'), pkg, ' '.join(candidates), var) | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 146 | package_qa_handle_error("multilib", msg, d) | 
|  | 147 |  | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 148 | ml = d.getVar('MLPREFIX') | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 149 | if not ml: | 
|  | 150 | return | 
|  | 151 |  | 
| Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 152 | # exception for ${MLPREFIX}target-sdk-provides-dummy | 
|  | 153 | if 'target-sdk-provides-dummy' in d.getVar('PN'): | 
|  | 154 | return | 
|  | 155 |  | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 156 | packages = d.getVar('PACKAGES') | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 157 | for pkg in packages.split(): | 
|  | 158 | check_mlprefix(pkg, 'RDEPENDS', ml) | 
|  | 159 | check_mlprefix(pkg, 'RPROVIDES', ml) | 
|  | 160 | check_mlprefix(pkg, 'RRECOMMENDS', ml) | 
|  | 161 | check_mlprefix(pkg, 'RSUGGESTS', ml) | 
|  | 162 | check_mlprefix(pkg, 'RREPLACES', ml) | 
|  | 163 | check_mlprefix(pkg, 'RCONFLICTS', ml) | 
|  | 164 | } |