blob: 8f61d8d41a414052aef977755e0cd2ece8031f85 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001python multilib_virtclass_handler () {
2 cls = e.data.getVar("BBEXTENDCURR", True)
3 variant = e.data.getVar("BBEXTENDVARIANT", True)
4 if cls != "multilib" or not variant:
5 return
6
7 e.data.setVar('STAGING_KERNEL_DIR', e.data.getVar('STAGING_KERNEL_DIR', True))
8
9 # There should only be one kernel in multilib configs
10 # We also skip multilib setup for module packages.
11 provides = (e.data.getVar("PROVIDES", True) or "").split()
12 if "virtual/kernel" in provides or bb.data.inherits_class('module-base', e.data):
13 raise bb.parse.SkipPackage("We shouldn't have multilib variants for the kernel")
14
15 save_var_name=e.data.getVar("MULTILIB_SAVE_VARNAME", True) or ""
16 for name in save_var_name.split():
17 val=e.data.getVar(name, True)
18 if val:
19 e.data.setVar(name + "_MULTILIB_ORIGINAL", val)
20
21 overrides = e.data.getVar("OVERRIDES", False)
22 pn = e.data.getVar("PN", False)
23 overrides = overrides.replace("pn-${PN}", "pn-${PN}:pn-" + pn)
24 e.data.setVar("OVERRIDES", overrides)
25
26 if bb.data.inherits_class('image', e.data):
27 e.data.setVar("MLPREFIX", variant + "-")
28 e.data.setVar("PN", variant + "-" + e.data.getVar("PN", False))
29 target_vendor = e.data.getVar("TARGET_VENDOR_" + "virtclass-multilib-" + variant, False)
30 if target_vendor:
31 e.data.setVar("TARGET_VENDOR", target_vendor)
32 return
33
34 if bb.data.inherits_class('cross-canadian', e.data):
35 e.data.setVar("MLPREFIX", variant + "-")
36 override = ":virtclass-multilib-" + variant
37 e.data.setVar("OVERRIDES", e.data.getVar("OVERRIDES", False) + override)
38 bb.data.update_data(e.data)
39 return
40
41 if bb.data.inherits_class('native', e.data):
42 raise bb.parse.SkipPackage("We can't extend native recipes")
43
44 if bb.data.inherits_class('nativesdk', e.data) or bb.data.inherits_class('crosssdk', e.data):
45 raise bb.parse.SkipPackage("We can't extend nativesdk recipes")
46
47 if bb.data.inherits_class('allarch', e.data) and not bb.data.inherits_class('packagegroup', e.data):
48 raise bb.parse.SkipPackage("Don't extend allarch recipes which are not packagegroups")
49
50
51 # Expand this since this won't work correctly once we set a multilib into place
52 e.data.setVar("ALL_MULTILIB_PACKAGE_ARCHS", e.data.getVar("ALL_MULTILIB_PACKAGE_ARCHS", True))
53
54 override = ":virtclass-multilib-" + variant
55
56 e.data.setVar("MLPREFIX", variant + "-")
57 e.data.setVar("PN", variant + "-" + e.data.getVar("PN", False))
58 e.data.setVar("OVERRIDES", e.data.getVar("OVERRIDES", False) + override)
59
60 # Expand the WHITELISTs with multilib prefix
61 for whitelist in ["HOSTTOOLS_WHITELIST_GPL-3.0", "WHITELIST_GPL-3.0", "LGPLv2_WHITELIST_GPL-3.0"]:
62 pkgs = e.data.getVar(whitelist, True)
63 for pkg in pkgs.split():
64 pkgs += " " + variant + "-" + pkg
65 e.data.setVar(whitelist, pkgs)
66
67 # DEFAULTTUNE can change TARGET_ARCH override so expand this now before update_data
68 newtune = e.data.getVar("DEFAULTTUNE_" + "virtclass-multilib-" + variant, False)
69 if newtune:
70 e.data.setVar("DEFAULTTUNE", newtune)
71 e.data.setVar('DEFAULTTUNE_ML_%s' % variant, newtune)
72}
73
74addhandler multilib_virtclass_handler
75multilib_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise"
76
77STAGINGCC_prepend = "${BBEXTENDVARIANT}-"
78
79python __anonymous () {
80 variant = d.getVar("BBEXTENDVARIANT", True)
81
82 import oe.classextend
83
84 clsextend = oe.classextend.ClassExtender(variant, d)
85
86 if bb.data.inherits_class('image', d):
87 clsextend.map_depends_variable("PACKAGE_INSTALL")
88 clsextend.map_depends_variable("LINGUAS_INSTALL")
89 clsextend.map_depends_variable("RDEPENDS")
90 pinstall = d.getVar("LINGUAS_INSTALL", True) + " " + d.getVar("PACKAGE_INSTALL", True)
91 d.setVar("PACKAGE_INSTALL", pinstall)
92 d.setVar("LINGUAS_INSTALL", "")
93 # FIXME, we need to map this to something, not delete it!
94 d.setVar("PACKAGE_INSTALL_ATTEMPTONLY", "")
95
96 if bb.data.inherits_class('populate_sdk_base', d):
97 clsextend.map_depends_variable("TOOLCHAIN_TARGET_TASK")
98 clsextend.map_depends_variable("TOOLCHAIN_TARGET_TASK_ATTEMPTONLY")
99
100 if bb.data.inherits_class('image', d):
101 return
102
103 clsextend.map_depends_variable("DEPENDS")
104 clsextend.map_variable("PROVIDES")
105
106 if bb.data.inherits_class('cross-canadian', d):
107 return
108
109 clsextend.rename_packages()
110 clsextend.rename_package_variables((d.getVar("PACKAGEVARS", True) or "").split())
111
112 clsextend.map_packagevars()
113 clsextend.map_regexp_variable("PACKAGES_DYNAMIC")
114 clsextend.map_variable("PACKAGE_INSTALL")
115 clsextend.map_variable("INITSCRIPT_PACKAGES")
116 clsextend.map_variable("USERADD_PACKAGES")
117 clsextend.map_variable("SYSTEMD_PACKAGES")
118}
119
120PACKAGEFUNCS_append = " do_package_qa_multilib"
121
122python do_package_qa_multilib() {
123
124 def check_mlprefix(pkg, var, mlprefix):
125 values = bb.utils.explode_deps(d.getVar('%s_%s' % (var, pkg), True) or d.getVar(var, True) or "")
126 candidates = []
127 for i in values:
128 if i.startswith('virtual/'):
129 i = i[len('virtual/'):]
130 if (not i.startswith('kernel-module')) and (not i.startswith(mlprefix)) and \
131 (not 'cross-canadian' in i) and (not i.startswith("nativesdk-")) and \
132 (not i.startswith("rtld")) and (not i.startswith('kernel-vmlinux')):
133 candidates.append(i)
134 if len(candidates) > 0:
135 msg = "%s package %s - suspicious values '%s' in %s" \
136 % (d.getVar('PN', True), pkg, ' '.join(candidates), var)
137 package_qa_handle_error("multilib", msg, d)
138
139 ml = d.getVar('MLPREFIX', True)
140 if not ml:
141 return
142
143 packages = d.getVar('PACKAGES', True)
144 for pkg in packages.split():
145 check_mlprefix(pkg, 'RDEPENDS', ml)
146 check_mlprefix(pkg, 'RPROVIDES', ml)
147 check_mlprefix(pkg, 'RRECOMMENDS', ml)
148 check_mlprefix(pkg, 'RSUGGESTS', ml)
149 check_mlprefix(pkg, 'RREPLACES', ml)
150 check_mlprefix(pkg, 'RCONFLICTS', ml)
151}