blob: d80a34cf27fcf697045b28cc0ba333a5535819d9 [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
Patrick Williamsc124f4f2015-09-15 14:41:29 -05007python multilib_virtclass_handler () {
Brad Bishop6e60e8b2018-02-01 10:27:11 -05008 cls = e.data.getVar("BBEXTENDCURR")
9 variant = e.data.getVar("BBEXTENDVARIANT")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050010 if cls != "multilib" or not variant:
11 return
12
Brad Bishopd7bf8c12018-02-25 22:55:05 -050013 localdata = bb.data.createCopy(e.data)
14 localdata.delVar('TMPDIR')
15 e.data.setVar('STAGING_KERNEL_DIR', localdata.getVar('STAGING_KERNEL_DIR'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050016
17 # There should only be one kernel in multilib configs
18 # We also skip multilib setup for module packages.
Brad Bishop6e60e8b2018-02-01 10:27:11 -050019 provides = (e.data.getVar("PROVIDES") or "").split()
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080020 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 Williamsc124f4f2015-09-15 14:41:29 -050026
Brad Bishop6e60e8b2018-02-01 10:27:11 -050027 save_var_name=e.data.getVar("MULTILIB_SAVE_VARNAME") or ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -050028 for name in save_var_name.split():
Brad Bishop6e60e8b2018-02-01 10:27:11 -050029 val=e.data.getVar(name)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050030 if val:
31 e.data.setVar(name + "_MULTILIB_ORIGINAL", val)
32
Andrew Geissler220dafd2023-10-04 10:18:08 -050033 # We nearly don't need this but dependencies on NON_MULTILIB_RECIPES don't work without it
34 d.setVar("SSTATE_ARCHS_TUNEPKG", "${@all_multilib_tune_values(d, 'TUNE_PKGARCH')}")
35
Patrick Williamsc124f4f2015-09-15 14:41:29 -050036 overrides = e.data.getVar("OVERRIDES", False)
37 pn = e.data.getVar("PN", False)
38 overrides = overrides.replace("pn-${PN}", "pn-${PN}:pn-" + pn)
39 e.data.setVar("OVERRIDES", overrides)
40
41 if bb.data.inherits_class('image', e.data):
42 e.data.setVar("MLPREFIX", variant + "-")
43 e.data.setVar("PN", variant + "-" + e.data.getVar("PN", False))
Brad Bishop6e60e8b2018-02-01 10:27:11 -050044 e.data.setVar('SDKTARGETSYSROOT', e.data.getVar('SDKTARGETSYSROOT'))
Brad Bishop15ae2502019-06-18 21:44:24 -040045 override = ":virtclass-multilib-" + variant
46 e.data.setVar("OVERRIDES", e.data.getVar("OVERRIDES", False) + override)
Patrick Williams0ca19cc2021-08-16 14:03:13 -050047 target_vendor = e.data.getVar("TARGET_VENDOR:" + "virtclass-multilib-" + variant, False)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050048 if target_vendor:
49 e.data.setVar("TARGET_VENDOR", target_vendor)
50 return
51
52 if bb.data.inherits_class('cross-canadian', e.data):
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080053 # Multilib cross-candian should use the same nativesdk sysroot without MLPREFIX
54 e.data.setVar("RECIPE_SYSROOT", "${WORKDIR}/recipe-sysroot")
55 e.data.setVar("STAGING_DIR_TARGET", "${WORKDIR}/recipe-sysroot")
56 e.data.setVar("STAGING_DIR_HOST", "${WORKDIR}/recipe-sysroot")
Andrew Geisslerfc113ea2023-03-31 09:59:46 -050057 e.data.setVar("RECIPE_SYSROOT_MANIFEST_SUBDIR", "nativesdk-" + variant)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050058 e.data.setVar("MLPREFIX", variant + "-")
59 override = ":virtclass-multilib-" + variant
60 e.data.setVar("OVERRIDES", e.data.getVar("OVERRIDES", False) + override)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050061 return
62
63 if bb.data.inherits_class('native', e.data):
Brad Bishop316dfdd2018-06-25 12:45:53 -040064 raise bb.parse.SkipRecipe("We can't extend native recipes")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050065
66 if bb.data.inherits_class('nativesdk', e.data) or bb.data.inherits_class('crosssdk', e.data):
Brad Bishop316dfdd2018-06-25 12:45:53 -040067 raise bb.parse.SkipRecipe("We can't extend nativesdk recipes")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050068
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080069 if bb.data.inherits_class('allarch', e.data) and not d.getVar('MULTILIB_VARIANTS') \
70 and not bb.data.inherits_class('packagegroup', e.data):
Brad Bishop316dfdd2018-06-25 12:45:53 -040071 raise bb.parse.SkipRecipe("Don't extend allarch recipes which are not packagegroups")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050072
Patrick Williamsc124f4f2015-09-15 14:41:29 -050073 # Expand this since this won't work correctly once we set a multilib into place
Brad Bishop6e60e8b2018-02-01 10:27:11 -050074 e.data.setVar("ALL_MULTILIB_PACKAGE_ARCHS", e.data.getVar("ALL_MULTILIB_PACKAGE_ARCHS"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050075
76 override = ":virtclass-multilib-" + variant
77
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000078 skip_msg = e.data.getVarFlag('SKIP_RECIPE', e.data.getVar('PN'))
79 if skip_msg:
Brad Bishop6e60e8b2018-02-01 10:27:11 -050080 pn_new = variant + "-" + e.data.getVar('PN')
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000081 if not e.data.getVarFlag('SKIP_RECIPE', pn_new):
82 e.data.setVarFlag('SKIP_RECIPE', pn_new, skip_msg)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050083
Patrick Williamsc124f4f2015-09-15 14:41:29 -050084 e.data.setVar("MLPREFIX", variant + "-")
85 e.data.setVar("PN", variant + "-" + e.data.getVar("PN", False))
86 e.data.setVar("OVERRIDES", e.data.getVar("OVERRIDES", False) + override)
87
Andrew Geissler9aee5002022-03-30 16:27:02 +000088 # Expand INCOMPATIBLE_LICENSE_EXCEPTIONS with multilib prefix
89 pkgs = e.data.getVar("INCOMPATIBLE_LICENSE_EXCEPTIONS")
90 if pkgs:
91 for pkg in pkgs.split():
92 pkgs += " " + variant + "-" + pkg
93 e.data.setVar("INCOMPATIBLE_LICENSE_EXCEPTIONS", pkgs)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050094
95 # DEFAULTTUNE can change TARGET_ARCH override so expand this now before update_data
Patrick Williams0ca19cc2021-08-16 14:03:13 -050096 newtune = e.data.getVar("DEFAULTTUNE:" + "virtclass-multilib-" + variant, False)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050097 if newtune:
98 e.data.setVar("DEFAULTTUNE", newtune)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050099}
100
101addhandler multilib_virtclass_handler
102multilib_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise"
103
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500104python __anonymous () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500105 if bb.data.inherits_class('image', d):
Andrew Geissler595f6302022-01-24 19:11:47 +0000106 # set rpm preferred file color for 32-bit multilib image
107 if d.getVar("SITEINFO_BITS") == "32":
108 d.setVar("RPM_PREFER_ELF_ARCH", "1")
109
Andrew Geissler1e34c2d2020-05-29 16:02:59 -0500110 variant = d.getVar("BBEXTENDVARIANT")
111 import oe.classextend
112
113 clsextend = oe.classextend.ClassExtender(variant, d)
114
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500115 clsextend.map_depends_variable("PACKAGE_INSTALL")
116 clsextend.map_depends_variable("LINGUAS_INSTALL")
117 clsextend.map_depends_variable("RDEPENDS")
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500118 pinstall = d.getVar("LINGUAS_INSTALL") + " " + d.getVar("PACKAGE_INSTALL")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500119 d.setVar("PACKAGE_INSTALL", pinstall)
120 d.setVar("LINGUAS_INSTALL", "")
121 # FIXME, we need to map this to something, not delete it!
122 d.setVar("PACKAGE_INSTALL_ATTEMPTONLY", "")
Brad Bishop316dfdd2018-06-25 12:45:53 -0400123 bb.build.deltask('do_populate_sdk_ext', d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500124 return
Andrew Geissler1e34c2d2020-05-29 16:02:59 -0500125}
126
127python multilib_virtclass_handler_postkeyexp () {
128 cls = d.getVar("BBEXTENDCURR")
129 variant = d.getVar("BBEXTENDVARIANT")
130 if cls != "multilib" or not variant:
131 return
132
133 variant = d.getVar("BBEXTENDVARIANT")
134
135 import oe.classextend
136
137 clsextend = oe.classextend.ClassExtender(variant, d)
138
139 if bb.data.inherits_class('image', d):
140 return
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500141
142 clsextend.map_depends_variable("DEPENDS")
143 clsextend.map_variable("PROVIDES")
144
145 if bb.data.inherits_class('cross-canadian', d):
146 return
147
148 clsextend.rename_packages()
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500149 clsextend.rename_package_variables((d.getVar("PACKAGEVARS") or "").split())
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500150
151 clsextend.map_packagevars()
152 clsextend.map_regexp_variable("PACKAGES_DYNAMIC")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500153 clsextend.map_variable("INITSCRIPT_PACKAGES")
154 clsextend.map_variable("USERADD_PACKAGES")
155 clsextend.map_variable("SYSTEMD_PACKAGES")
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800156 clsextend.map_variable("UPDATERCPN")
Brad Bishop96ff1982019-08-19 13:50:42 -0400157
158 reset_alternative_priority(d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500159}
160
Andrew Geissler1e34c2d2020-05-29 16:02:59 -0500161addhandler multilib_virtclass_handler_postkeyexp
162multilib_virtclass_handler_postkeyexp[eventmask] = "bb.event.RecipePostKeyExpansion"
163
Brad Bishop96ff1982019-08-19 13:50:42 -0400164def reset_alternative_priority(d):
165 if not bb.data.inherits_class('update-alternatives', d):
166 return
167
168 # There might be multiple multilibs at the same time, e.g., lib32 and
169 # lib64, each of them should have a different priority.
170 multilib_variants = d.getVar('MULTILIB_VARIANTS')
171 bbextendvariant = d.getVar('BBEXTENDVARIANT')
172 reset_gap = multilib_variants.split().index(bbextendvariant) + 1
173
174 # ALTERNATIVE_PRIORITY = priority
175 alt_priority_recipe = d.getVar('ALTERNATIVE_PRIORITY')
176 # Reset ALTERNATIVE_PRIORITY when found
177 if alt_priority_recipe:
178 reset_priority = int(alt_priority_recipe) - reset_gap
179 bb.debug(1, '%s: Setting ALTERNATIVE_PRIORITY to %s' % (d.getVar('PN'), reset_priority))
180 d.setVar('ALTERNATIVE_PRIORITY', reset_priority)
181
182 handled_pkgs = []
183 for pkg in (d.getVar('PACKAGES') or "").split():
184 # ALTERNATIVE_PRIORITY_pkg = priority
185 alt_priority_pkg = d.getVar('ALTERNATIVE_PRIORITY_%s' % pkg)
186 # Reset ALTERNATIVE_PRIORITY_pkg when found
187 if alt_priority_pkg:
188 reset_priority = int(alt_priority_pkg) - reset_gap
189 if not pkg in handled_pkgs:
190 handled_pkgs.append(pkg)
191 bb.debug(1, '%s: Setting ALTERNATIVE_PRIORITY_%s to %s' % (pkg, pkg, reset_priority))
192 d.setVar('ALTERNATIVE_PRIORITY_%s' % pkg, reset_priority)
193
Patrick Williams213cb262021-08-07 19:21:33 -0500194 for alt_name in (d.getVar('ALTERNATIVE:%s' % pkg) or "").split():
Brad Bishop96ff1982019-08-19 13:50:42 -0400195 # ALTERNATIVE_PRIORITY_pkg[tool] = priority
196 alt_priority_pkg_name = d.getVarFlag('ALTERNATIVE_PRIORITY_%s' % pkg, alt_name)
197 # ALTERNATIVE_PRIORITY[tool] = priority
198 alt_priority_name = d.getVarFlag('ALTERNATIVE_PRIORITY', alt_name)
199
200 if alt_priority_pkg_name:
201 reset_priority = int(alt_priority_pkg_name) - reset_gap
202 bb.debug(1, '%s: Setting ALTERNATIVE_PRIORITY_%s[%s] to %s' % (pkg, pkg, alt_name, reset_priority))
203 d.setVarFlag('ALTERNATIVE_PRIORITY_%s' % pkg, alt_name, reset_priority)
204 elif alt_priority_name:
205 reset_priority = int(alt_priority_name) - reset_gap
206 bb.debug(1, '%s: Setting ALTERNATIVE_PRIORITY[%s] to %s' % (pkg, alt_name, reset_priority))
207 d.setVarFlag('ALTERNATIVE_PRIORITY', alt_name, reset_priority)
208
Patrick Williams213cb262021-08-07 19:21:33 -0500209PACKAGEFUNCS:append = " do_package_qa_multilib"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500210
211python do_package_qa_multilib() {
212
213 def check_mlprefix(pkg, var, mlprefix):
Andrew Geissler5199d832021-09-24 16:47:35 -0500214 values = bb.utils.explode_deps(d.getVar('%s:%s' % (var, pkg)) or d.getVar(var) or "")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500215 candidates = []
216 for i in values:
217 if i.startswith('virtual/'):
218 i = i[len('virtual/'):]
Andrew Geissler82c905d2020-04-13 13:39:40 -0500219
220 if (not (i.startswith(mlprefix) or i.startswith("kernel-") \
221 or ('cross-canadian' in i) or i.startswith("nativesdk-") \
222 or i.startswith("rtld") or i.startswith("/"))):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500223 candidates.append(i)
Andrew Geissler82c905d2020-04-13 13:39:40 -0500224
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500225 if len(candidates) > 0:
226 msg = "%s package %s - suspicious values '%s' in %s" \
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500227 % (d.getVar('PN'), pkg, ' '.join(candidates), var)
Andrew Geisslereff27472021-10-29 15:35:00 -0500228 oe.qa.handle_error("multilib", msg, d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500229
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500230 ml = d.getVar('MLPREFIX')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500231 if not ml:
232 return
233
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800234 # exception for ${MLPREFIX}target-sdk-provides-dummy
235 if 'target-sdk-provides-dummy' in d.getVar('PN'):
236 return
237
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500238 packages = d.getVar('PACKAGES')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500239 for pkg in packages.split():
240 check_mlprefix(pkg, 'RDEPENDS', ml)
241 check_mlprefix(pkg, 'RPROVIDES', ml)
242 check_mlprefix(pkg, 'RRECOMMENDS', ml)
243 check_mlprefix(pkg, 'RSUGGESTS', ml)
244 check_mlprefix(pkg, 'RREPLACES', ml)
245 check_mlprefix(pkg, 'RCONFLICTS', ml)
Andrew Geisslereff27472021-10-29 15:35:00 -0500246 oe.qa.exit_if_errors(d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500247}