blob: 4a3e582816d5c8a3886fd136ae4cc269316b1e24 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001python multilib_virtclass_handler () {
Brad Bishop6e60e8b2018-02-01 10:27:11 -05002 cls = e.data.getVar("BBEXTENDCURR")
3 variant = e.data.getVar("BBEXTENDVARIANT")
Patrick Williamsc124f4f2015-09-15 14:41:29 -05004 if cls != "multilib" or not variant:
5 return
6
Brad Bishopd7bf8c12018-02-25 22:55:05 -05007 localdata = bb.data.createCopy(e.data)
8 localdata.delVar('TMPDIR')
9 e.data.setVar('STAGING_KERNEL_DIR', localdata.getVar('STAGING_KERNEL_DIR'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050010
11 # There should only be one kernel in multilib configs
12 # We also skip multilib setup for module packages.
Brad Bishop6e60e8b2018-02-01 10:27:11 -050013 provides = (e.data.getVar("PROVIDES") or "").split()
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080014 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 Williamsc124f4f2015-09-15 14:41:29 -050020
Brad Bishop6e60e8b2018-02-01 10:27:11 -050021 save_var_name=e.data.getVar("MULTILIB_SAVE_VARNAME") or ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -050022 for name in save_var_name.split():
Brad Bishop6e60e8b2018-02-01 10:27:11 -050023 val=e.data.getVar(name)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050024 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 Bishop6e60e8b2018-02-01 10:27:11 -050035 e.data.setVar('SDKTARGETSYSROOT', e.data.getVar('SDKTARGETSYSROOT'))
Brad Bishop15ae2502019-06-18 21:44:24 -040036 override = ":virtclass-multilib-" + variant
37 e.data.setVar("OVERRIDES", e.data.getVar("OVERRIDES", False) + override)
Patrick Williams0ca19cc2021-08-16 14:03:13 -050038 target_vendor = e.data.getVar("TARGET_VENDOR:" + "virtclass-multilib-" + variant, False)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050039 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 Bishop1a4b7ee2018-12-16 17:11:34 -080044 # 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 Williamsc124f4f2015-09-15 14:41:29 -050048 e.data.setVar("MLPREFIX", variant + "-")
49 override = ":virtclass-multilib-" + variant
50 e.data.setVar("OVERRIDES", e.data.getVar("OVERRIDES", False) + override)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050051 return
52
53 if bb.data.inherits_class('native', e.data):
Brad Bishop316dfdd2018-06-25 12:45:53 -040054 raise bb.parse.SkipRecipe("We can't extend native recipes")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050055
56 if bb.data.inherits_class('nativesdk', e.data) or bb.data.inherits_class('crosssdk', e.data):
Brad Bishop316dfdd2018-06-25 12:45:53 -040057 raise bb.parse.SkipRecipe("We can't extend nativesdk recipes")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050058
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080059 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 Bishop316dfdd2018-06-25 12:45:53 -040061 raise bb.parse.SkipRecipe("Don't extend allarch recipes which are not packagegroups")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050062
Patrick Williamsc124f4f2015-09-15 14:41:29 -050063 # Expand this since this won't work correctly once we set a multilib into place
Brad Bishop6e60e8b2018-02-01 10:27:11 -050064 e.data.setVar("ALL_MULTILIB_PACKAGE_ARCHS", e.data.getVar("ALL_MULTILIB_PACKAGE_ARCHS"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050065
66 override = ":virtclass-multilib-" + variant
67
Brad Bishop6e60e8b2018-02-01 10:27:11 -050068 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 Williamsc124f4f2015-09-15 14:41:29 -050074 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 Bishop1a4b7ee2018-12-16 17:11:34 -080078 # 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 Williamsc124f4f2015-09-15 14:41:29 -050083
84 # DEFAULTTUNE can change TARGET_ARCH override so expand this now before update_data
Patrick Williams0ca19cc2021-08-16 14:03:13 -050085 newtune = e.data.getVar("DEFAULTTUNE:" + "virtclass-multilib-" + variant, False)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050086 if newtune:
87 e.data.setVar("DEFAULTTUNE", newtune)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050088}
89
90addhandler multilib_virtclass_handler
91multilib_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise"
92
Patrick Williamsc124f4f2015-09-15 14:41:29 -050093python __anonymous () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -050094 if bb.data.inherits_class('image', d):
Andrew Geissler595f6302022-01-24 19:11:47 +000095 # set rpm preferred file color for 32-bit multilib image
96 if d.getVar("SITEINFO_BITS") == "32":
97 d.setVar("RPM_PREFER_ELF_ARCH", "1")
98
Andrew Geissler1e34c2d2020-05-29 16:02:59 -050099 variant = d.getVar("BBEXTENDVARIANT")
100 import oe.classextend
101
102 clsextend = oe.classextend.ClassExtender(variant, d)
103
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500104 clsextend.map_depends_variable("PACKAGE_INSTALL")
105 clsextend.map_depends_variable("LINGUAS_INSTALL")
106 clsextend.map_depends_variable("RDEPENDS")
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500107 pinstall = d.getVar("LINGUAS_INSTALL") + " " + d.getVar("PACKAGE_INSTALL")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500108 d.setVar("PACKAGE_INSTALL", pinstall)
109 d.setVar("LINGUAS_INSTALL", "")
110 # FIXME, we need to map this to something, not delete it!
111 d.setVar("PACKAGE_INSTALL_ATTEMPTONLY", "")
Brad Bishop316dfdd2018-06-25 12:45:53 -0400112 bb.build.deltask('do_populate_sdk_ext', d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500113 return
Andrew Geissler1e34c2d2020-05-29 16:02:59 -0500114}
115
116python multilib_virtclass_handler_postkeyexp () {
117 cls = d.getVar("BBEXTENDCURR")
118 variant = d.getVar("BBEXTENDVARIANT")
119 if cls != "multilib" or not variant:
120 return
121
122 variant = d.getVar("BBEXTENDVARIANT")
123
124 import oe.classextend
125
126 clsextend = oe.classextend.ClassExtender(variant, d)
127
128 if bb.data.inherits_class('image', d):
129 return
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500130
131 clsextend.map_depends_variable("DEPENDS")
132 clsextend.map_variable("PROVIDES")
133
134 if bb.data.inherits_class('cross-canadian', d):
135 return
136
137 clsextend.rename_packages()
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500138 clsextend.rename_package_variables((d.getVar("PACKAGEVARS") or "").split())
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500139
140 clsextend.map_packagevars()
141 clsextend.map_regexp_variable("PACKAGES_DYNAMIC")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500142 clsextend.map_variable("INITSCRIPT_PACKAGES")
143 clsextend.map_variable("USERADD_PACKAGES")
144 clsextend.map_variable("SYSTEMD_PACKAGES")
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800145 clsextend.map_variable("UPDATERCPN")
Brad Bishop96ff1982019-08-19 13:50:42 -0400146
147 reset_alternative_priority(d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500148}
149
Andrew Geissler1e34c2d2020-05-29 16:02:59 -0500150addhandler multilib_virtclass_handler_postkeyexp
151multilib_virtclass_handler_postkeyexp[eventmask] = "bb.event.RecipePostKeyExpansion"
152
Brad Bishop96ff1982019-08-19 13:50:42 -0400153def reset_alternative_priority(d):
154 if not bb.data.inherits_class('update-alternatives', d):
155 return
156
157 # There might be multiple multilibs at the same time, e.g., lib32 and
158 # lib64, each of them should have a different priority.
159 multilib_variants = d.getVar('MULTILIB_VARIANTS')
160 bbextendvariant = d.getVar('BBEXTENDVARIANT')
161 reset_gap = multilib_variants.split().index(bbextendvariant) + 1
162
163 # ALTERNATIVE_PRIORITY = priority
164 alt_priority_recipe = d.getVar('ALTERNATIVE_PRIORITY')
165 # Reset ALTERNATIVE_PRIORITY when found
166 if alt_priority_recipe:
167 reset_priority = int(alt_priority_recipe) - reset_gap
168 bb.debug(1, '%s: Setting ALTERNATIVE_PRIORITY to %s' % (d.getVar('PN'), reset_priority))
169 d.setVar('ALTERNATIVE_PRIORITY', reset_priority)
170
171 handled_pkgs = []
172 for pkg in (d.getVar('PACKAGES') or "").split():
173 # ALTERNATIVE_PRIORITY_pkg = priority
174 alt_priority_pkg = d.getVar('ALTERNATIVE_PRIORITY_%s' % pkg)
175 # Reset ALTERNATIVE_PRIORITY_pkg when found
176 if alt_priority_pkg:
177 reset_priority = int(alt_priority_pkg) - reset_gap
178 if not pkg in handled_pkgs:
179 handled_pkgs.append(pkg)
180 bb.debug(1, '%s: Setting ALTERNATIVE_PRIORITY_%s to %s' % (pkg, pkg, reset_priority))
181 d.setVar('ALTERNATIVE_PRIORITY_%s' % pkg, reset_priority)
182
Patrick Williams213cb262021-08-07 19:21:33 -0500183 for alt_name in (d.getVar('ALTERNATIVE:%s' % pkg) or "").split():
Brad Bishop96ff1982019-08-19 13:50:42 -0400184 # ALTERNATIVE_PRIORITY_pkg[tool] = priority
185 alt_priority_pkg_name = d.getVarFlag('ALTERNATIVE_PRIORITY_%s' % pkg, alt_name)
186 # ALTERNATIVE_PRIORITY[tool] = priority
187 alt_priority_name = d.getVarFlag('ALTERNATIVE_PRIORITY', alt_name)
188
189 if alt_priority_pkg_name:
190 reset_priority = int(alt_priority_pkg_name) - reset_gap
191 bb.debug(1, '%s: Setting ALTERNATIVE_PRIORITY_%s[%s] to %s' % (pkg, pkg, alt_name, reset_priority))
192 d.setVarFlag('ALTERNATIVE_PRIORITY_%s' % pkg, alt_name, reset_priority)
193 elif alt_priority_name:
194 reset_priority = int(alt_priority_name) - reset_gap
195 bb.debug(1, '%s: Setting ALTERNATIVE_PRIORITY[%s] to %s' % (pkg, alt_name, reset_priority))
196 d.setVarFlag('ALTERNATIVE_PRIORITY', alt_name, reset_priority)
197
Patrick Williams213cb262021-08-07 19:21:33 -0500198PACKAGEFUNCS:append = " do_package_qa_multilib"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500199
200python do_package_qa_multilib() {
201
202 def check_mlprefix(pkg, var, mlprefix):
Andrew Geissler5199d832021-09-24 16:47:35 -0500203 values = bb.utils.explode_deps(d.getVar('%s:%s' % (var, pkg)) or d.getVar(var) or "")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500204 candidates = []
205 for i in values:
206 if i.startswith('virtual/'):
207 i = i[len('virtual/'):]
Andrew Geissler82c905d2020-04-13 13:39:40 -0500208
209 if (not (i.startswith(mlprefix) or i.startswith("kernel-") \
210 or ('cross-canadian' in i) or i.startswith("nativesdk-") \
211 or i.startswith("rtld") or i.startswith("/"))):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500212 candidates.append(i)
Andrew Geissler82c905d2020-04-13 13:39:40 -0500213
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500214 if len(candidates) > 0:
215 msg = "%s package %s - suspicious values '%s' in %s" \
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500216 % (d.getVar('PN'), pkg, ' '.join(candidates), var)
Andrew Geisslereff27472021-10-29 15:35:00 -0500217 oe.qa.handle_error("multilib", msg, d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500218
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500219 ml = d.getVar('MLPREFIX')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500220 if not ml:
221 return
222
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800223 # exception for ${MLPREFIX}target-sdk-provides-dummy
224 if 'target-sdk-provides-dummy' in d.getVar('PN'):
225 return
226
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500227 packages = d.getVar('PACKAGES')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500228 for pkg in packages.split():
229 check_mlprefix(pkg, 'RDEPENDS', ml)
230 check_mlprefix(pkg, 'RPROVIDES', ml)
231 check_mlprefix(pkg, 'RRECOMMENDS', ml)
232 check_mlprefix(pkg, 'RSUGGESTS', ml)
233 check_mlprefix(pkg, 'RREPLACES', ml)
234 check_mlprefix(pkg, 'RCONFLICTS', ml)
Andrew Geisslereff27472021-10-29 15:35:00 -0500235 oe.qa.exit_if_errors(d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500236}