diff mbox series

[1/2] classes/recipes: remove unnecessary qemu inherit and qemu-native dependency

Message ID 20250410040825.1283228-1-Qi.Chen@windriver.com
State New
Headers show
Series [1/2] classes/recipes: remove unnecessary qemu inherit and qemu-native dependency | expand

Commit Message

Chen, Qi April 10, 2025, 4:08 a.m. UTC
From: Chen Qi <Qi.Chen@windriver.com>

Some classes/recipes inherit qemu.bbclass but does not actually use anything
from it. Besides, putting qemu-native in PACKAGE_WRITE_DEPS is not needed because
the process of generating package does not need qemu-native.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/classes-recipe/fontcache.bbclass           | 3 ---
 meta/classes-recipe/gio-module-cache.bbclass    | 3 ---
 meta/classes-recipe/gtk-immodules-cache.bbclass | 4 ----
 meta/classes-recipe/manpages.bbclass            | 2 --
 meta/classes-recipe/pixbufcache.bbclass         | 5 +----
 meta/recipes-core/systemd/systemd_257.4.bb      | 3 +--
 meta/recipes-core/udev/eudev_3.2.14.bb          | 2 +-
 7 files changed, 3 insertions(+), 19 deletions(-)

Comments

Richard Purdie April 10, 2025, 6:15 a.m. UTC | #1
On Wed, 2025-04-09 at 21:08 -0700, Chen Qi via lists.openembedded.org wrote:
> From: Chen Qi <Qi.Chen@windriver.com>
> 
> Some classes/recipes inherit qemu.bbclass but does not actually use anything
> from it. Besides, putting qemu-native in PACKAGE_WRITE_DEPS is not needed because
> the process of generating package does not need qemu-native.
> 
> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
> ---
>  meta/classes-recipe/fontcache.bbclass           | 3 ---
>  meta/classes-recipe/gio-module-cache.bbclass    | 3 ---
>  meta/classes-recipe/gtk-immodules-cache.bbclass | 4 ----
>  meta/classes-recipe/manpages.bbclass            | 2 --
>  meta/classes-recipe/pixbufcache.bbclass         | 5 +----
>  meta/recipes-core/systemd/systemd_257.4.bb      | 3 +--
>  meta/recipes-core/udev/eudev_3.2.14.bb          | 2 +-
>  7 files changed, 3 insertions(+), 19 deletions(-)
> 
> diff --git a/meta/classes-recipe/fontcache.bbclass b/meta/classes-recipe/fontcache.bbclass
> index 6f4978369d..6082af08f3 100644
> --- a/meta/classes-recipe/fontcache.bbclass
> +++ b/meta/classes-recipe/fontcache.bbclass
> @@ -9,9 +9,6 @@
>  # packages.
>  #
>  
> -PACKAGE_WRITE_DEPS += "qemu-native"
> -inherit qemu
> -
>  FONT_PACKAGES ??= "${PN}"
>  FONT_PACKAGES:class-native = ""
>  FONT_EXTRA_RDEPENDS ?= "${MLPREFIX}fontconfig-utils"

I picked one of these to validate this as I didn't quite believe we didn't use qemu there.
fontconfig.bbclass has:

fontcache_common() {
if [ -n "$D" ] ; then
	$INTERCEPT_DIR/postinst_intercept update_font_cache ${PKG} mlprefix=${MLPREFIX} binprefix=${MLPREFIX} \

in it's postinstall script. Then in scripts/postinst-
intercepts/update_font_cache we have:

PSEUDO_UNLOAD=1 ${binprefix}qemuwrapper -L $D -E ${fontconfigcacheenv} $D${libexecdir}/${binprefix}fc-cache --sysroot=$D --system-only ${fontconfigcacheparams}

so I'm afraid it does use qemu and you can't simply drop the class
inherit or dependency as it is used.

Cheers,

Richard
Chen, Qi April 10, 2025, 6:31 a.m. UTC | #2
Hi Richard,

The postinst uses qemuwrapper which in turns uses qemu-native. But the postinst runs at do_rootfs time. And this dependency is ensured by the following line:
meta/classes-recipe/image.bbclass:DEPENDS += "${@' '.join(["%s-qemuwrapper-cross" % m for m in d.getVar("MULTILIB_VARIANTS").split()])} qemuwrapper-cross depmodwrapper-cross cross-localedef-native"

PACKAGE_WRITE_DEPS  is for do_package_write_rpm/deb/ipk. These tasks do not run postinst and thus not using qemu-native. So 'qemu-native' can be removed from PACKAGE_WRITE_DEPS safely.

For the removal of qemu.bbclass inherit, these classes/recipes do not really use any function from this qemu.bbclass. So we can safely remove 'inherit qemu' for them.

My test for this patch 1/2 is: qemux86-64 + systemd + bitbake core-image-sato. There's no error.

Regards,
Qi



-----Original Message-----
From: Richard Purdie <richard.purdie@linuxfoundation.org> 
Sent: Thursday, April 10, 2025 2:15 PM
To: Chen, Qi <Qi.Chen@windriver.com>; openembedded-core@lists.openembedded.org
Subject: Re: [OE-core][PATCH 1/2] classes/recipes: remove unnecessary qemu inherit and qemu-native dependency

On Wed, 2025-04-09 at 21:08 -0700, Chen Qi via lists.openembedded.org wrote:
> From: Chen Qi <Qi.Chen@windriver.com>
> 
> Some classes/recipes inherit qemu.bbclass but does not actually use 
> anything from it. Besides, putting qemu-native in PACKAGE_WRITE_DEPS 
> is not needed because the process of generating package does not need qemu-native.
> 
> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
> ---
>  meta/classes-recipe/fontcache.bbclass           | 3 ---
>  meta/classes-recipe/gio-module-cache.bbclass    | 3 ---
>  meta/classes-recipe/gtk-immodules-cache.bbclass | 4 ----
>  meta/classes-recipe/manpages.bbclass            | 2 --
>  meta/classes-recipe/pixbufcache.bbclass         | 5 +----
>  meta/recipes-core/systemd/systemd_257.4.bb      | 3 +--
>  meta/recipes-core/udev/eudev_3.2.14.bb          | 2 +-
>  7 files changed, 3 insertions(+), 19 deletions(-)
> 
> diff --git a/meta/classes-recipe/fontcache.bbclass 
> b/meta/classes-recipe/fontcache.bbclass
> index 6f4978369d..6082af08f3 100644
> --- a/meta/classes-recipe/fontcache.bbclass
> +++ b/meta/classes-recipe/fontcache.bbclass
> @@ -9,9 +9,6 @@
>  # packages.
>  #
>  
> -PACKAGE_WRITE_DEPS += "qemu-native"
> -inherit qemu
> -
>  FONT_PACKAGES ??= "${PN}"
>  FONT_PACKAGES:class-native = ""
>  FONT_EXTRA_RDEPENDS ?= "${MLPREFIX}fontconfig-utils"

I picked one of these to validate this as I didn't quite believe we didn't use qemu there.
fontconfig.bbclass has:

fontcache_common() {
if [ -n "$D" ] ; then
	$INTERCEPT_DIR/postinst_intercept update_font_cache ${PKG} mlprefix=${MLPREFIX} binprefix=${MLPREFIX} \

in it's postinstall script. Then in scripts/postinst- intercepts/update_font_cache we have:

PSEUDO_UNLOAD=1 ${binprefix}qemuwrapper -L $D -E ${fontconfigcacheenv} $D${libexecdir}/${binprefix}fc-cache --sysroot=$D --system-only ${fontconfigcacheparams}

so I'm afraid it does use qemu and you can't simply drop the class inherit or dependency as it is used.

Cheers,

Richard
Richard Purdie April 10, 2025, 6:42 a.m. UTC | #3
On Thu, 2025-04-10 at 06:31 +0000, Chen, Qi wrote:
> The postinst uses qemuwrapper which in turns uses qemu-native. But
> the postinst runs at do_rootfs time. And this dependency is ensured
> by the following line:
> meta/classes-recipe/image.bbclass:DEPENDS += "${@' '.join(["%s-
> qemuwrapper-cross" % m for m in
> d.getVar("MULTILIB_VARIANTS").split()])} qemuwrapper-cross
> depmodwrapper-cross cross-localedef-native"
> 
> PACKAGE_WRITE_DEPS  is for do_package_write_rpm/deb/ipk. These tasks
> do not run postinst and thus not using qemu-native. So 'qemu-native'
> can be removed from PACKAGE_WRITE_DEPS safely.
> 
> For the removal of qemu.bbclass inherit, these classes/recipes do not
> really use any function from this qemu.bbclass. So we can safely
> remove 'inherit qemu' for them.
> 
> My test for this patch 1/2 is: qemux86-64 + systemd + bitbake core-
> image-sato. There's no error.

Something needs to trigger the system to have qemu-native available at
do_rootfs time since these recipes write a postinstall which can use
qemu. That is what PACKAGE_WRITE_DEPS is for. I suspect you're pulling
in qemu through other dependencies but that doesn't mean this one is
unneeded.

package.bbclass has a comment about this:

# If your postinstall can execute at rootfs creation time rather than on
# target but depends on a native/cross tool in order to execute, you need to
# list that tool in PACKAGE_WRITE_DEPS. Target package dependencies belong
# in the package dependencies as normal, this is just for native/cross support
# tools at rootfs build time.
PACKAGE_WRITE_DEPS ??= ""

As for the qemu class inherit, the code used to write the qemu binary
call into the postinst but it uses qemuwrapper now which comes from
qemuwrapper-cross. I suspect you're right that it means the qemu
inherit is no longer needed however we should probably change the
inherit qemu for a PACKAGE_WRITE_DEPS += "qemuwrapper-cross"?

(and see if we could remove the dependency in image.bbclass?)

Cheers,

Richard
Chen, Qi April 10, 2025, 6:45 a.m. UTC | #4
Got it. Thanks for the detailed explanation.
I'll check and send out V2.

Regards,
Qi

-----Original Message-----
From: Richard Purdie <richard.purdie@linuxfoundation.org> 
Sent: Thursday, April 10, 2025 2:42 PM
To: Chen, Qi <Qi.Chen@windriver.com>; openembedded-core@lists.openembedded.org
Subject: Re: [OE-core][PATCH 1/2] classes/recipes: remove unnecessary qemu inherit and qemu-native dependency

On Thu, 2025-04-10 at 06:31 +0000, Chen, Qi wrote:
> The postinst uses qemuwrapper which in turns uses qemu-native. But the 
> postinst runs at do_rootfs time. And this dependency is ensured by the 
> following line:
> meta/classes-recipe/image.bbclass:DEPENDS += "${@' '.join(["%s- 
> qemuwrapper-cross" % m for m in 
> d.getVar("MULTILIB_VARIANTS").split()])} qemuwrapper-cross 
> depmodwrapper-cross cross-localedef-native"
> 
> PACKAGE_WRITE_DEPS  is for do_package_write_rpm/deb/ipk. These tasks 
> do not run postinst and thus not using qemu-native. So 'qemu-native'
> can be removed from PACKAGE_WRITE_DEPS safely.
> 
> For the removal of qemu.bbclass inherit, these classes/recipes do not 
> really use any function from this qemu.bbclass. So we can safely 
> remove 'inherit qemu' for them.
> 
> My test for this patch 1/2 is: qemux86-64 + systemd + bitbake core- 
> image-sato. There's no error.

Something needs to trigger the system to have qemu-native available at do_rootfs time since these recipes write a postinstall which can use qemu. That is what PACKAGE_WRITE_DEPS is for. I suspect you're pulling in qemu through other dependencies but that doesn't mean this one is unneeded.

package.bbclass has a comment about this:

# If your postinstall can execute at rootfs creation time rather than on # target but depends on a native/cross tool in order to execute, you need to # list that tool in PACKAGE_WRITE_DEPS. Target package dependencies belong # in the package dependencies as normal, this is just for native/cross support # tools at rootfs build time.
PACKAGE_WRITE_DEPS ??= ""

As for the qemu class inherit, the code used to write the qemu binary call into the postinst but it uses qemuwrapper now which comes from qemuwrapper-cross. I suspect you're right that it means the qemu inherit is no longer needed however we should probably change the inherit qemu for a PACKAGE_WRITE_DEPS += "qemuwrapper-cross"?

(and see if we could remove the dependency in image.bbclass?)

Cheers,

Richard
Richard Purdie April 10, 2025, 7:27 a.m. UTC | #5
> As for the qemu class inherit, the code used to write the qemu binary
> call into the postinst but it uses qemuwrapper now which comes from
> qemuwrapper-cross. I suspect you're right that it means the qemu
> inherit is no longer needed however we should probably change the
> inherit qemu for a PACKAGE_WRITE_DEPS += "qemuwrapper-cross"?
> 
> (and see if we could remove the dependency in image.bbclass?)

I was thinking about this further and I think we could replace the
qemu-native dependency for a qemuwrapper-cross dependency since that
has the correct qemu-native dependency.

Cheers,

Richard
diff mbox series

Patch

diff --git a/meta/classes-recipe/fontcache.bbclass b/meta/classes-recipe/fontcache.bbclass
index 6f4978369d..6082af08f3 100644
--- a/meta/classes-recipe/fontcache.bbclass
+++ b/meta/classes-recipe/fontcache.bbclass
@@ -9,9 +9,6 @@ 
 # packages.
 #
 
-PACKAGE_WRITE_DEPS += "qemu-native"
-inherit qemu
-
 FONT_PACKAGES ??= "${PN}"
 FONT_PACKAGES:class-native = ""
 FONT_EXTRA_RDEPENDS ?= "${MLPREFIX}fontconfig-utils"
diff --git a/meta/classes-recipe/gio-module-cache.bbclass b/meta/classes-recipe/gio-module-cache.bbclass
index d12e03c4a0..4340715b01 100644
--- a/meta/classes-recipe/gio-module-cache.bbclass
+++ b/meta/classes-recipe/gio-module-cache.bbclass
@@ -4,9 +4,6 @@ 
 # SPDX-License-Identifier: MIT
 #
 
-PACKAGE_WRITE_DEPS += "qemu-native"
-inherit qemu
-
 GIO_MODULE_PACKAGES ??= "${PN}"
 
 gio_module_cache_common() {
diff --git a/meta/classes-recipe/gtk-immodules-cache.bbclass b/meta/classes-recipe/gtk-immodules-cache.bbclass
index 8fbe1dd1fb..83deb2d48a 100644
--- a/meta/classes-recipe/gtk-immodules-cache.bbclass
+++ b/meta/classes-recipe/gtk-immodules-cache.bbclass
@@ -8,10 +8,6 @@ 
 #
 # Usage: Set GTKIMMODULES_PACKAGES to the packages that needs to update the inputmethod modules
 
-PACKAGE_WRITE_DEPS += "qemu-native"
-
-inherit qemu
-
 GTKIMMODULES_PACKAGES ?= "${PN}"
 
 gtk_immodule_cache_postinst() {
diff --git a/meta/classes-recipe/manpages.bbclass b/meta/classes-recipe/manpages.bbclass
index e9ca2f895b..bdd91b8564 100644
--- a/meta/classes-recipe/manpages.bbclass
+++ b/meta/classes-recipe/manpages.bbclass
@@ -10,8 +10,6 @@ 
 # by default.
 PACKAGECONFIG:append:class-target = " ${@bb.utils.contains('DISTRO_FEATURES', 'api-documentation', 'manpages', '', d)}"
 
-inherit qemu
-
 # usually manual files are packaged to ${PN}-doc except man-pages
 MAN_PKG ?= "${PN}-doc"
 
diff --git a/meta/classes-recipe/pixbufcache.bbclass b/meta/classes-recipe/pixbufcache.bbclass
index 107e38885e..66ac4ed23c 100644
--- a/meta/classes-recipe/pixbufcache.bbclass
+++ b/meta/classes-recipe/pixbufcache.bbclass
@@ -9,12 +9,9 @@ 
 # packages.
 #
 
-DEPENDS:append:class-target = " qemu-native"
-inherit qemu
-
 PIXBUF_PACKAGES ??= "${PN}"
 
-PACKAGE_WRITE_DEPS += "qemu-native gdk-pixbuf-native"
+PACKAGE_WRITE_DEPS += "gdk-pixbuf-native"
 
 pixbufcache_common() {
 if [ "x$D" != "x" ]; then
diff --git a/meta/recipes-core/systemd/systemd_257.4.bb b/meta/recipes-core/systemd/systemd_257.4.bb
index 24aad11c0a..4066509f7d 100644
--- a/meta/recipes-core/systemd/systemd_257.4.bb
+++ b/meta/recipes-core/systemd/systemd_257.4.bb
@@ -8,7 +8,7 @@  DEPENDS = "gperf-native libcap util-linux python3-jinja2-native"
 
 SECTION = "base/shell"
 
-inherit useradd pkgconfig meson perlnative update-rc.d update-alternatives qemu systemd gettext bash-completion manpages features_check mime
+inherit useradd pkgconfig meson perlnative update-rc.d update-alternatives systemd gettext bash-completion manpages features_check mime
 
 # unmerged-usr support is deprecated upstream, taints the system and will be
 # removed in the near future. Fail the build if it is not enabled.
@@ -932,7 +932,6 @@  pkg_prerm:${PN}:libc-glibc () {
 	fi
 }
 
-PACKAGE_WRITE_DEPS += "qemu-native"
 pkg_postinst:udev-hwdb () {
 	if test -n "$D"; then
 		$INTERCEPT_DIR/postinst_intercept update_udev_hwdb ${PKG} mlprefix=${MLPREFIX} binprefix=${MLPREFIX} \
diff --git a/meta/recipes-core/udev/eudev_3.2.14.bb b/meta/recipes-core/udev/eudev_3.2.14.bb
index b3e7d092c5..24551a3fc5 100644
--- a/meta/recipes-core/udev/eudev_3.2.14.bb
+++ b/meta/recipes-core/udev/eudev_3.2.14.bb
@@ -20,7 +20,7 @@  SRC_URI[sha256sum] = "8da4319102f24abbf7fff5ce9c416af848df163b29590e666d334cc192
 
 GITHUB_BASE_URI = "https://github.com/eudev-project/eudev/releases"
 
-inherit autotools update-rc.d qemu pkgconfig features_check manpages github-releases
+inherit autotools update-rc.d pkgconfig features_check manpages github-releases
 
 CONFLICT_DISTRO_FEATURES = "systemd"