Re: [OE-core] [PATCH RFC 2/2] conf/recipes: Replace VIRTUAL-RUNTIME with PACKAGE_GLOBAL_RENAMES
On 11/04/2021 07:05 PM, Richard Purdie wrote: I don't think anyone has ever liked VIRTUAL-RUNTIME as a solution. This patch replaces it with PACKAGE_GLOBAL_RENAME. There are two types of VIRTUAL-RUNTIME. Direct package replacements like getopt or keymaps and "namespaces" for things like "device-manager" or "login-manager". The later are different in that one recipe may provide several but they need to be configured individually. If they were all "systemd", we couldn't replace the correct ones. As such this patch introduces the "virtual-XXX" namespace where the system is expected to resolve these into final values as per the configuration. The advantage of this approach is that we no longer need to have specific VIRTUAL-RUNTIME parameterisation for a user to change a particular dependency, they can just do things like: PACKAGE_GLOBAL_RENAME[keymaps] = "mykeymaps" or simply: PACKAGE_GLOBAL_RENAME[keymaps] = "" to remove it. You can see examples of the virtual-* mappings in the init manager includes. This patch uses the PACKAGE_GLOBAL_RENAMES variable and mechanism from the previous patch to function but to be clear, this only works at package creation time, not at build time. As such we have to inject the virtual namespace into RPROVIDES. Filtering all package variables at parse time isn't really viable at present (the multilib classes show the work involved). Known issues: a) The changes apply at final image build time which means that the original provider would be built and the alternate only swapped in at do_rootfs. b) The patch throwns build-rdeps QA warnings (probably as a result of a). c) As a result of b) there are probably missing build dependencies d) The tests are unconverted. Hi Richard, I think this is a very good solution. From my point of view, it solves the problem that VIRTUAL-RUNTIME solution will never scale and is always tending to expand. I tried out these two patches a little bit, made a few local changes and core-image-minimal built successfully without warning. There are mainly two changes: 1) make recipe build if required e.g. PACKAGE_GLOBAL_RENAMES[A] = C, and B rdepends on A. We need to make sure C is built when building A. I order to do this, I tweaked the rpovides injection logic a little bit, making it apply to all PACKAGE_GLOBAL_RENAMES items. 2) make sure pkgdata is written out correctly As yocto uses pkgdata as the key database when creating packages and performing some package QA checks, we need to make sure the database is correct. In order to do this, I tweaked the write_if_exists() function a little bit, considering PACKAGE_GLOBAL_RENAMES, RPROVIDES, RRECOMMENDS and RDEPENDS. Attached is the patch. Regards, Qi As such I suspect this patch won't quite work but I want to share it and see what people think and if a better solution could rise from this as a result. Adding "filter" support to variables as JPEW and I once discussed may be a different way of handling this which would also handle some multilib issues. Signed-off-by: Richard Purdie --- meta/classes/base.bbclass | 6 + meta/classes/image.bbclass| 3 ++- meta/classes/multilib_global.bbclass | 5 + meta/classes/package.bbclass | 4 +++- meta/classes/packagegroup.bbclass | 4 ++-- meta/classes/update-alternatives.bbclass | 5 + .../conf/distro/include/default-providers.inc | 13 +-- .../include/init-manager-mdev-busybox.inc | 9 .../conf/distro/include/init-manager-none.inc | 7 +++--- .../distro/include/init-manager-systemd.inc | 9 .../distro/include/init-manager-sysvinit.inc | 7 +++--- meta/conf/layer.conf | 2 +- meta/lib/oe/rootfs.py | 2 +- meta/recipes-core/busybox/busybox.inc | 4 ++-- meta/recipes-core/busybox/busybox_1.34.1.bb | 6 ++--- .../images/core-image-minimal-initramfs.bb| 2 +- .../images/core-image-tiny-initramfs.bb | 4 +--- .../initrdscripts/initramfs-framework_1.0.bb | 4 ++-- .../initramfs-live-install-efi_1.0.bb | 4 ++-- .../initramfs-live-install_1.0.bb | 4 ++-- .../initramfs-module-install-efi_1.0.bb | 4 ++-- .../initramfs-module-install_1.0.bb | 4 ++-- .../packagegroups/packagegroup-base.bb| 9 +++- .../packagegroups/packagegroup-core-boot.bb | 22 --- meta/recipes-devtools/dpkg/dpkg.inc | 2 +- meta/recipes-devtools/opkg/opkg_0.4.5.bb | 2 +- meta/recipes-extended/lsb/lsb-release_1.4.bb | 2 +- .../packagegroup-core-base-utils.bb | 4 +--- .../packagegroup-core-full-cmdline.bb | 9 .../packagegroups/packagegroup-core-weston.bb | 2 +- .../packagegroups/packagegroup-core-x11.bb| 9 +--- meta/recipes-graphics/wayland/weston-init.bb | 6 ++---
[OE-core] [PATCH RFC 2/2] conf/recipes: Replace VIRTUAL-RUNTIME with PACKAGE_GLOBAL_RENAMES
I don't think anyone has ever liked VIRTUAL-RUNTIME as a solution. This patch replaces it with PACKAGE_GLOBAL_RENAME. There are two types of VIRTUAL-RUNTIME. Direct package replacements like getopt or keymaps and "namespaces" for things like "device-manager" or "login-manager". The later are different in that one recipe may provide several but they need to be configured individually. If they were all "systemd", we couldn't replace the correct ones. As such this patch introduces the "virtual-XXX" namespace where the system is expected to resolve these into final values as per the configuration. The advantage of this approach is that we no longer need to have specific VIRTUAL-RUNTIME parameterisation for a user to change a particular dependency, they can just do things like: PACKAGE_GLOBAL_RENAME[keymaps] = "mykeymaps" or simply: PACKAGE_GLOBAL_RENAME[keymaps] = "" to remove it. You can see examples of the virtual-* mappings in the init manager includes. This patch uses the PACKAGE_GLOBAL_RENAMES variable and mechanism from the previous patch to function but to be clear, this only works at package creation time, not at build time. As such we have to inject the virtual namespace into RPROVIDES. Filtering all package variables at parse time isn't really viable at present (the multilib classes show the work involved). Known issues: a) The changes apply at final image build time which means that the original provider would be built and the alternate only swapped in at do_rootfs. b) The patch throwns build-rdeps QA warnings (probably as a result of a). c) As a result of b) there are probably missing build dependencies d) The tests are unconverted. As such I suspect this patch won't quite work but I want to share it and see what people think and if a better solution could rise from this as a result. Adding "filter" support to variables as JPEW and I once discussed may be a different way of handling this which would also handle some multilib issues. Signed-off-by: Richard Purdie --- meta/classes/base.bbclass | 6 + meta/classes/image.bbclass| 3 ++- meta/classes/multilib_global.bbclass | 5 + meta/classes/package.bbclass | 4 +++- meta/classes/packagegroup.bbclass | 4 ++-- meta/classes/update-alternatives.bbclass | 5 + .../conf/distro/include/default-providers.inc | 13 +-- .../include/init-manager-mdev-busybox.inc | 9 .../conf/distro/include/init-manager-none.inc | 7 +++--- .../distro/include/init-manager-systemd.inc | 9 .../distro/include/init-manager-sysvinit.inc | 7 +++--- meta/conf/layer.conf | 2 +- meta/lib/oe/rootfs.py | 2 +- meta/recipes-core/busybox/busybox.inc | 4 ++-- meta/recipes-core/busybox/busybox_1.34.1.bb | 6 ++--- .../images/core-image-minimal-initramfs.bb| 2 +- .../images/core-image-tiny-initramfs.bb | 4 +--- .../initrdscripts/initramfs-framework_1.0.bb | 4 ++-- .../initramfs-live-install-efi_1.0.bb | 4 ++-- .../initramfs-live-install_1.0.bb | 4 ++-- .../initramfs-module-install-efi_1.0.bb | 4 ++-- .../initramfs-module-install_1.0.bb | 4 ++-- .../packagegroups/packagegroup-base.bb| 9 +++- .../packagegroups/packagegroup-core-boot.bb | 22 --- meta/recipes-devtools/dpkg/dpkg.inc | 2 +- meta/recipes-devtools/opkg/opkg_0.4.5.bb | 2 +- meta/recipes-extended/lsb/lsb-release_1.4.bb | 2 +- .../packagegroup-core-base-utils.bb | 4 +--- .../packagegroup-core-full-cmdline.bb | 9 .../packagegroups/packagegroup-core-weston.bb | 2 +- .../packagegroups/packagegroup-core-x11.bb| 9 +--- meta/recipes-graphics/wayland/weston-init.bb | 6 ++--- meta/recipes-graphics/wayland/weston_9.0.0.bb | 2 +- .../gstreamer/gstreamer1.0-omx_1.18.5.bb | 3 +-- 34 files changed, 88 insertions(+), 96 deletions(-) diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass index a65fcc6c1db..1395df4a02c 100644 --- a/meta/classes/base.bbclass +++ b/meta/classes/base.bbclass @@ -334,6 +334,12 @@ python base_eventhandler() { profprov = d.getVar("PREFERRED_PROVIDER_" + p) if profprov and pn != profprov: raise bb.parse.SkipRecipe("PREFERRED_PROVIDER_%s set to %s, not %s" % (p, profprov, pn)) + + +remaps = d.getVarFlags("PACKAGE_GLOBAL_RENAMES") +for m in remaps: +if m.startswith("virtual-"): +d.setVar("RPROVIDES:" + remaps[m] + ":append", " " + m) } CONFIGURESTAMPFILE = "${WORKDIR}/configure.sstate" diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass index b3f5421697d..605dcc9eee2 100644 --- a/meta/classes/image.bbclass +++ b/meta/classes/image.bbclass @@ -43,7 +43,7 @@ IMAGE_INSTALL_DEBUGFS ?= "" # These