From edbf8d3999126e3c271a47dada54d1724f59f573 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Wed, 15 Apr 2020 16:25:12 +0100 Subject: multilib/recipes: Use new RecipePostKeyExpansion event There are issues with multilib due to the ordering of events where some functions see the remapped multilib dependencies and some do not. A significant problem is that the multilib class needs to make some changes before key expansion and some afterwards but by using existing event handlers, some code sees things in a partially translated state, leading to bugs. This patch changes things to use a new event handler from bitbake which makes the ordering of the changes explcit. The challenge in doing this is that it breaks some existing anonymous python and dyanmic assignments. In some cases these used to be translated and no longer are, meaning MLPREFIX has to be added. In some cases these are now translated and the MLPREFIX can be removed. This change does now make it very clear when MLPREFIX is required and when it is not, its just the migration path which is harder. The patch changes the small number of cases where fixes are needed. In particular, where a variable like RDEPENDS is conditionally extended (e.g. with an override), MLPREFIX is now required. This patch also reverts: base: Revert 'base.bbclass: considering multilib when setting LICENSE_EXCLUSION' This reverts 6597130256a1609c3e05ec5891aceaf549c37985 as the changes to multilib datastore handling mean its no longer necessary. (From OE-Core rev: b3fda056a674889cd9697e779de023d4f993d3ce) Signed-off-by: Richard Purdie --- meta/classes/base.bbclass | 3 +- meta/classes/fontcache.bbclass | 2 +- meta/classes/multilib.bbclass | 28 +++++++++++++---- meta/lib/oe/classextend.py | 35 ++++++++++++++++++++-- meta/recipes-core/glibc/glibc-package.inc | 2 +- .../packagegroups/packagegroup-base.bb | 8 ++--- meta/recipes-core/psplash/psplash_git.bb | 5 ++-- meta/recipes-devtools/perl/perl_5.30.2.bb | 2 +- meta/recipes-devtools/python/python3_3.8.2.bb | 14 ++++----- .../packagegroup-core-full-cmdline.bb | 10 ++++--- meta/recipes-graphics/mesa/mesa.inc | 10 ++++--- meta/recipes-multimedia/alsa/alsa-plugins_1.2.1.bb | 6 ++-- meta/recipes-support/boost/boost.inc | 10 +++++-- 13 files changed, 95 insertions(+), 40 deletions(-) (limited to 'meta') diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass index 7aa2e144eb..4c681cc870 100644 --- a/meta/classes/base.bbclass +++ b/meta/classes/base.bbclass @@ -570,8 +570,7 @@ python () { if unskipped_pkgs: for pkg in skipped_pkgs: bb.debug(1, "Skipping the package %s at do_rootfs because of incompatible license(s): %s" % (pkg, ' '.join(skipped_pkgs[pkg]))) - mlprefix = d.getVar('MLPREFIX') - d.setVar('LICENSE_EXCLUSION-' + mlprefix + pkg, ' '.join(skipped_pkgs[pkg])) + d.setVar('LICENSE_EXCLUSION-' + pkg, ' '.join(skipped_pkgs[pkg])) for pkg in unskipped_pkgs: bb.debug(1, "Including the package %s" % pkg) else: diff --git a/meta/classes/fontcache.bbclass b/meta/classes/fontcache.bbclass index 97e7f17f00..624a420a0d 100644 --- a/meta/classes/fontcache.bbclass +++ b/meta/classes/fontcache.bbclass @@ -7,7 +7,7 @@ PACKAGE_WRITE_DEPS += "qemu-native" inherit qemu FONT_PACKAGES ??= "${PN}" -FONT_EXTRA_RDEPENDS ?= "fontconfig-utils" +FONT_EXTRA_RDEPENDS ?= "${MLPREFIX}fontconfig-utils" FONTCONFIG_CACHE_DIR ?= "${localstatedir}/cache/fontconfig" FONTCONFIG_CACHE_PARAMS ?= "-v" # You can change this to e.g. FC_DEBUG=16 to debug fc-cache issues, diff --git a/meta/classes/multilib.bbclass b/meta/classes/multilib.bbclass index ee677da1e2..9f726e4537 100644 --- a/meta/classes/multilib.bbclass +++ b/meta/classes/multilib.bbclass @@ -91,13 +91,12 @@ addhandler multilib_virtclass_handler multilib_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise" python __anonymous () { - variant = d.getVar("BBEXTENDVARIANT") - - import oe.classextend + if bb.data.inherits_class('image', d): + variant = d.getVar("BBEXTENDVARIANT") + import oe.classextend - clsextend = oe.classextend.ClassExtender(variant, d) + clsextend = oe.classextend.ClassExtender(variant, d) - if bb.data.inherits_class('image', d): clsextend.map_depends_variable("PACKAGE_INSTALL") clsextend.map_depends_variable("LINGUAS_INSTALL") clsextend.map_depends_variable("RDEPENDS") @@ -109,6 +108,22 @@ python __anonymous () { bb.build.deltask('do_populate_sdk', d) bb.build.deltask('do_populate_sdk_ext', d) return +} + +python multilib_virtclass_handler_postkeyexp () { + cls = d.getVar("BBEXTENDCURR") + variant = d.getVar("BBEXTENDVARIANT") + if cls != "multilib" or not variant: + return + + variant = d.getVar("BBEXTENDVARIANT") + + import oe.classextend + + clsextend = oe.classextend.ClassExtender(variant, d) + + if bb.data.inherits_class('image', d): + return clsextend.map_depends_variable("DEPENDS") clsextend.map_variable("PROVIDES") @@ -129,6 +144,9 @@ python __anonymous () { reset_alternative_priority(d) } +addhandler multilib_virtclass_handler_postkeyexp +multilib_virtclass_handler_postkeyexp[eventmask] = "bb.event.RecipePostKeyExpansion" + def reset_alternative_priority(d): if not bb.data.inherits_class('update-alternatives', d): return diff --git a/meta/lib/oe/classextend.py b/meta/lib/oe/classextend.py index f02fbe9fba..e1049ce3e8 100644 --- a/meta/lib/oe/classextend.py +++ b/meta/lib/oe/classextend.py @@ -4,11 +4,21 @@ import collections +def get_packages(d): + pkgs = d.getVar("PACKAGES_NONML") + extcls = d.getVar("EXTENDERCLASS") + return extcls.rename_packages_internal(pkgs) + +def get_depends(varprefix, d): + extcls = d.getVar("EXTENDERCLASS") + return extcls.map_depends_variable(varprefix + "_NONML") + class ClassExtender(object): def __init__(self, extname, d): self.extname = extname self.d = d self.pkgs_mapping = [] + self.d.setVar("EXTENDERCLASS", self) def extend_name(self, name): if name.startswith("kernel-") or name == "virtual/kernel": @@ -24,7 +34,7 @@ class ClassExtender(object): if not subs.startswith(self.extname): return "virtual/" + self.extname + "-" + subs return name - if name.startswith("/"): + if name.startswith("/") or (name.startswith("${") and name.endswith("}")): return name if not name.startswith(self.extname): return self.extname + "-" + name @@ -89,8 +99,14 @@ class ClassExtender(object): for dep in deps: newdeps[self.map_depends(dep)] = deps[dep] - self.d.setVar(varname, bb.utils.join_deps(newdeps, False).replace("EXTENDPKGV", "${EXTENDPKGV}")) + if not varname.endswith("_NONML"): + #if varname == "DEPENDS": + self.d.renameVar(varname, varname + "_NONML") + self.d.setVar(varname, "${@oe.classextend.get_depends('%s', d)}" % varname) + self.d.appendVarFlag(varname, "vardeps", " " + varname + "_NONML") + ret = bb.utils.join_deps(newdeps, False).replace("EXTENDPKGV", "${EXTENDPKGV}") self.d.setVar("EXTENDPKGV", orig) + return ret def map_packagevars(self): for pkg in (self.d.getVar("PACKAGES").split() + [""]): @@ -109,10 +125,23 @@ class ClassExtender(object): continue self.pkgs_mapping.append([pkg, self.extend_name(pkg)]) - self.d.setVar("PACKAGES", " ".join([row[1] for row in self.pkgs_mapping])) + self.d.renameVar("PACKAGES", "PACKAGES_NONML") + self.d.setVar("PACKAGES", "${@oe.classextend.get_packages(d)}") + + def rename_packages_internal(self, pkgs): + self.pkgs_mapping = [] + for pkg in (self.d.expand(pkgs) or "").split(): + if pkg.startswith(self.extname): + self.pkgs_mapping.append([pkg.split(self.extname + "-")[1], pkg]) + continue + self.pkgs_mapping.append([pkg, self.extend_name(pkg)]) + + return " ".join([row[1] for row in self.pkgs_mapping]) def rename_package_variables(self, variables): for pkg_mapping in self.pkgs_mapping: + if pkg_mapping[0].startswith("${") and pkg_mapping[0].endswith("}"): + continue for subs in variables: self.d.renameVar("%s_%s" % (subs, pkg_mapping[0]), "%s_%s" % (subs, pkg_mapping[1])) diff --git a/meta/recipes-core/glibc/glibc-package.inc b/meta/recipes-core/glibc/glibc-package.inc index aa8e059216..ff25fd4187 100644 --- a/meta/recipes-core/glibc/glibc-package.inc +++ b/meta/recipes-core/glibc/glibc-package.inc @@ -24,7 +24,7 @@ libc_baselibs_append = " ${@oe.utils.conditional('ARCH_DYNAMIC_LOADER', '', '', INSANE_SKIP_${PN}_append_aarch64 = " libdir" FILES_${PN} = "${libc_baselibs} ${libexecdir}/*" -RRECOMMENDS_${PN} = "${@bb.utils.filter('DISTRO_FEATURES', 'ldconfig', d)}" +RRECOMMENDS_${PN} = "${@bb.utils.contains('DISTRO_FEATURES', 'ldconfig', '${MLPREFIX}ldconfig', '', d)}" FILES_ldconfig = "${base_sbindir}/ldconfig ${sysconfdir}/ld.so.conf" FILES_ldd = "${bindir}/ldd" FILES_libsegfault = "${base_libdir}/libSegFault*" diff --git a/meta/recipes-core/packagegroups/packagegroup-base.bb b/meta/recipes-core/packagegroups/packagegroup-base.bb index 1f802da09b..90b79adfdc 100644 --- a/meta/recipes-core/packagegroups/packagegroup-base.bb +++ b/meta/recipes-core/packagegroups/packagegroup-base.bb @@ -110,16 +110,16 @@ python __anonymous () { machine_features= set(d.getVar("MACHINE_FEATURES").split()) if "bluetooth" in distro_features and not "bluetooth" in machine_features and ("pcmcia" in machine_features or "pci" in machine_features or "usbhost" in machine_features): - d.setVar("ADD_BT", "packagegroup-base-bluetooth") + d.setVar("ADD_BT", "${MLPREFIX}packagegroup-base-bluetooth") if "wifi" in distro_features and not "wifi" in machine_features and ("pcmcia" in machine_features or "pci" in machine_features or "usbhost" in machine_features): - d.setVar("ADD_WIFI", "packagegroup-base-wifi") + d.setVar("ADD_WIFI", "${MLPREFIX}packagegroup-base-wifi") if "3g" in distro_features and not "3g" in machine_features and ("pcmcia" in machine_features or "pci" in machine_features or "usbhost" in machine_features): - d.setVar("ADD_3G", "packagegroup-base-3g") + d.setVar("ADD_3G", "${MLPREFIX}packagegroup-base-3g") if "nfc" in distro_features and not "nfc" in machine_features and ("usbhost" in machine_features): - d.setVar("ADD_NFC", "packagegroup-base-nfc") + d.setVar("ADD_NFC", "${MLPREFIX}packagegroup-base-nfc") } # diff --git a/meta/recipes-core/psplash/psplash_git.bb b/meta/recipes-core/psplash/psplash_git.bb index 22c71f099b..44f0007daf 100644 --- a/meta/recipes-core/psplash/psplash_git.bb +++ b/meta/recipes-core/psplash/psplash_git.bb @@ -22,6 +22,7 @@ SPLASH_IMAGES = "file://psplash-poky-img.h;outsuffix=default" python __anonymous() { oldpkgs = d.getVar("PACKAGES").split() splashfiles = d.getVar('SPLASH_IMAGES').split() + mlprefix = d.getVar('MLPREFIX') or '' pkgs = [] localpaths = [] for uri in splashfiles: @@ -46,9 +47,9 @@ python __anonymous() { # Set these so that we have less work to do in do_compile and do_install_append d.setVar("SPLASH_INSTALL", " ".join(pkgs)) d.setVar("SPLASH_LOCALPATHS", " ".join(localpaths)) + for p in pkgs: + d.prependVar("PACKAGES", "%s%s " % (mlprefix, p)) - d.prependVar("PACKAGES", "%s " % (" ".join(pkgs))) - mlprefix = d.getVar('MLPREFIX') or '' pn = d.getVar('PN') or '' for p in pkgs: ep = '%s%s' % (mlprefix, p) diff --git a/meta/recipes-devtools/perl/perl_5.30.2.bb b/meta/recipes-devtools/perl/perl_5.30.2.bb index 778c420b2e..26138ea9e5 100644 --- a/meta/recipes-devtools/perl/perl_5.30.2.bb +++ b/meta/recipes-devtools/perl/perl_5.30.2.bb @@ -328,7 +328,7 @@ python split_perl_packages () { python() { if d.getVar('CLASSOVERRIDE') == "class-target": - d.setVar("PACKAGES_DYNAMIC", "^perl-module-.*(?