diff mbox series

multilib.bbclass: Filter ROOTFS_RO_UNNEEDED to fix uninstallation

Message ID 20251020160353.413127-1-mac@mcrowe.com
State Accepted, archived
Commit 77c35362fb13c75145f9f999216b3d879ab18b77
Headers show
Series multilib.bbclass: Filter ROOTFS_RO_UNNEEDED to fix uninstallation | expand

Commit Message

mac@mcrowe.com Oct. 20, 2025, 4:03 p.m. UTC
From: Mike Crowe <mac@mcrowe.com>

When building an entire multilib image (e.g. lib32-core-image-minimal)
we need to ensure that the unneeded packages in ROOTFS_RO_UNNEEDED get
the multilib prefix applied before they are compared against the list of
installed packages inside Rootfs._uninstall_unneeded() to decide whether
they need to be installed.

Before this change with local.conf containing:

 MACHINE = qemuarm64
 require conf/multilib.conf
 MULTILIBS = "multilib:lib32"
 DEFAULTTUNE:virtclass-multilib-lib32 = "armv7at-neon"
 IMAGE_FEATURES = "read-only-rootfs"

running:
 bitbake lib32-core-image-minimal
 tar tavf tmp/deploy/images/qemuarm64/lib32-core-image-minimal-qemuarm64.rootfs.tar.zst|grep postinst

shows three files:
 -rwxr-xr-x 0/0              25 2018-03-09 12:34 ./etc/init.d/run-postinsts
 lrwxrwxrwx 0/0               0 2018-03-09 12:34 ./etc/rcS.d/S99run-postinsts -> ../init.d/run-postinsts
 -rwxr-xr-x 0/0            2153 2018-03-09 12:34 ./usr/sbin/run-postinsts

whereas with this change there are no matching files.

Signed-off-by: Mike Crowe <mac@mcrowe.com>
---
 meta/classes/multilib.bbclass | 1 +
 1 file changed, 1 insertion(+)

Rootfs._uninstall_unneeded can also try to uninstall run-postinsts
without using the multilib prefix right at the top. I could fix that
with d.expand("${MLPREFIX}run-postinsts") it feels wrong to sully the
generic code with something multilib specific. Advice welcome.

Comments

Ross Burton Oct. 29, 2025, 4:12 p.m. UTC | #1
Hi Mike,

> On 20 Oct 2025, at 17:03, Mike Crowe via lists.openembedded.org <mac=mcrowe.com@lists.openembedded.org> wrote:
> 
> From: Mike Crowe <mac@mcrowe.com>
> 
> When building an entire multilib image (e.g. lib32-core-image-minimal)
> we need to ensure that the unneeded packages in ROOTFS_RO_UNNEEDED get
> the multilib prefix applied before they are compared against the list of
> installed packages inside Rootfs._uninstall_unneeded() to decide whether
> they need to be installed.

Would you be able to make a test case in oeqa to verify that this behaviour works as expected in the future, and doesn’t regress?

Thanks,
Ross
mac@mcrowe.com Oct. 31, 2025, 1:45 p.m. UTC | #2
Hi Ross,

On Wednesday 29 October 2025 at 16:12:06 +0000, Ross Burton wrote:
>> On 20 Oct 2025, at 17:03, Mike Crowe via lists.openembedded.org <mac=mcrowe.com@lists.openembedded.org> wrote:
>>> When building an entire multilib image (e.g. lib32-core-image-minimal)
>>> we need to ensure that the unneeded packages in ROOTFS_RO_UNNEEDED get
>>> the multilib prefix applied before they are compared against the list of
>>> installed packages inside Rootfs._uninstall_unneeded() to decide whether
>>> they need to be installed.
> 
> Would you be able to make a test case in oeqa to verify that this
> behaviour works as expected in the future, and doesn’t regress?

I've never written one before and I wasn't sure whether it should fit
inside one of the existing case files, but is this the sort of thing you
mean?

Subject: [PATCH] oe-selftest: Add test of read-only multilib image

This test confirms that the fix for ROOTFS_RO_UNNEEDED with multilib
images in 77c35362fb13c75145f9f999216b3d879ab18b77 don't regress.

diff --git a/meta/lib/oeqa/selftest/cases/multilib.py b/meta/lib/oeqa/selftest/cases/multilib.py
new file mode 100644
index 0000000000..67bfb37967
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/multilib.py
@@ -0,0 +1,32 @@
+#
+# Copyright OpenEmbedded Contributors
+#
+# SPDX-License-Identifier: MIT
+#
+
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import get_bb_var, bitbake, runCmd
+
+class MultiLib(OESelftestTestCase):
+
+    def test_read_only_multilib_image_lacks_run_postinsts(self):
+        """
+        Check that a read-only multilib image can be built and that image has had
+        ${MLPREFIX}run-postinsts correctly uninstalled.
+        """
+
+        config = """
+MACHINE = "qemuarm64"
+require conf/multilib.conf
+MULTILIBS = "multilib:lib32"
+DEFAULTTUNE:virtclass-multilib-lib32 = "armv7at-neon"
+IMAGE_FEATURES = "read-only-rootfs"
+"""
+        self.write_config(config)
+        bitbake('lib32-core-image-minimal')
+        deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE')
+        manifest_lines = open(deploy_dir_image + "/lib32-core-image-minimal-qemuarm64.rootfs.manifest").readlines()
+
+        # lib32-run-postinsts should have been uninstalled since
+        # run-postinsts is in ROOTFS_RO_UNNEEDED.
+        self.assertEqual(list(filter(lambda l: "run-postinsts" in l, manifest_lines)), [])
--
2.39.5

Thanks.

Mike.
diff mbox series

Patch

diff --git a/meta/classes/multilib.bbclass b/meta/classes/multilib.bbclass
index 677dbc854a..15056dac4d 100644
--- a/meta/classes/multilib.bbclass
+++ b/meta/classes/multilib.bbclass
@@ -116,6 +116,7 @@  python __anonymous () {
         clsextend = oe.classextend.ClassExtender(variant, prefixes, d)
         clsextend.set_filter("PACKAGE_INSTALL", deps=False)
         clsextend.set_filter("LINGUAS_INSTALL", deps=False)
+        clsextend.set_filter("ROOTFS_RO_UNNEEDED", deps=False)
         clsextend.set_filter("RDEPENDS", deps=True)
         pinstall = d.getVar("LINGUAS_INSTALL") + " " + d.getVar("PACKAGE_INSTALL")
         d.setVar("PACKAGE_INSTALL", pinstall)