diff mbox series

Fix create_merged_usr_symlinks in populate_sdk_base.bbclass and image.bbclass

Message ID 20260105025050.153889-1-yw.byun@lge.com
State Changes Requested
Headers show
Series Fix create_merged_usr_symlinks in populate_sdk_base.bbclass and image.bbclass | expand

Commit Message

Yangwoo Byun Jan. 5, 2026, 2:50 a.m. UTC
Modifying FILESYSTEM_PERMS_TABLES does not change the UID and GID of
/usr/bin.
To change the UID and GID of /usr/bin in FILESYSTEM_PERMS_TABLES to
something other than root:root, we need to modify
the create_merged_usr_symlinks function.
The ":append" method allows us to apply changes inserted in the middle
by applying the create_merged_usr_symlinks function at the end of
the execution order.

Signed-off-by: Yangwoo Byun <yw.byun@lge.com>
---
 meta/classes-recipe/image.bbclass             |  2 +-
 meta/classes-recipe/populate_sdk_base.bbclass | 48 +++++++++++++++----
 2 files changed, 40 insertions(+), 10 deletions(-)

Comments

Mathieu Dubois-Briand Jan. 7, 2026, 7:36 a.m. UTC | #1
On Mon Jan 5, 2026 at 3:50 AM CET, Yangwoo Byun via lists.openembedded.org wrote:
> Modifying FILESYSTEM_PERMS_TABLES does not change the UID and GID of
> /usr/bin.
> To change the UID and GID of /usr/bin in FILESYSTEM_PERMS_TABLES to
> something other than root:root, we need to modify
> the create_merged_usr_symlinks function.
> The ":append" method allows us to apply changes inserted in the middle
> by applying the create_merged_usr_symlinks function at the end of
> the execution order.
>
> Signed-off-by: Yangwoo Byun <yw.byun@lge.com>
> ---

Hi Yangwoo,

Thanks for your patch.

It looks like some image tests are broken by this patch. We get the
following error on the autobuilder:

RESULTS - parselogs.ParseLogsTest.test_parselogs: FAILED (9.86s)
RESULTS - systemd.SystemdBasicTests.test_systemd_failed: FAILED (3.69s)
...
Traceback (most recent call last):
  File "/srv/pokybuild/yocto-worker/qemuarm64-alt/build/layers/openembedded-core/meta/lib/oeqa/core/decorator/__init__.py", line 35, in wrapped_f
    return func(*args, **kwargs)
  File "/srv/pokybuild/yocto-worker/qemuarm64-alt/build/layers/openembedded-core/meta/lib/oeqa/runtime/cases/parselogs.py", line 185, in test_parselogs
    self.assertEqual(errcount, 0, msg=self.msg)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 6 != 0 : Log: /srv/pokybuild/yocto-worker/qemuarm64-alt/build/build/tmp/work/qemuarm64-poky-linux/core-image-full-cmdline/1.0/target_logs/dmesg_output.log
-----------------------
Central error: [    4.807586] systemd[1]: proc-fs-nfsd.mount: Failed with result 'exit-code'.
***********************
[    4.728367] EXT4-fs (vda): re-mounted 584f5c6c-2ed1-4b79-88be-411c0a82191d.
[    4.750313] systemd[1]: Mounted POSIX Message Queue File System.
[    4.757693] systemd[1]: Mounted Kernel Debug File System.
[    4.760539] systemd[1]: Mounted Kernel Trace File System.
[    4.762862] systemd[1]: Mounted Temporary Directory /tmp.
[    4.774041] systemd[1]: modprobe@configfs.service: Deactivated successfully.
[    4.788111] systemd[1]: Finished Load Kernel Module configfs.
[    4.796349] systemd[1]: modprobe@fuse.service: Deactivated successfully.
[    4.800731] systemd[1]: Finished Load Kernel Module fuse.
[    4.806094] systemd[1]: proc-fs-nfsd.mount: Mount process exited, code=exited, status=32/n/a
[    4.807586] systemd[1]: proc-fs-nfsd.mount: Failed with result 'exit-code'.
[    4.809202] systemd-journald[129]: Collecting audit messages is disabled.
[    4.811318] systemd[1]: Failed to mount NFSD configuration filesystem.
[    4.813837] systemd[1]: Dependency failed for NFS Mount Daemon.
[    4.815101] systemd[1]: Dependency failed for NFS server and services.
[    4.818094] systemd[1]: nfs-server.service: Job nfs-server.service/start failed with result 'dependency'.
[    4.819597] systemd[1]: nfs-mountd.service: Job nfs-mountd.service/start failed with result 'dependency'.
[    4.825984] systemd[1]: Finished Generate network units from Kernel command line.
[    4.834216] systemd[1]: Finished Remount Root and Kernel File Systems.
[    4.838363] systemd[1]: Finished Apply Kernel Variables.
[    4.842779] systemd[1]: Finished Load udev Rules from Credentials.
...
Traceback (most recent call last):
  File "/srv/pokybuild/yocto-worker/qemuarm64-alt/build/layers/openembedded-core/meta/lib/oeqa/core/decorator/__init__.py", line 35, in wrapped_f
    return func(*args, **kwargs)
  File "/srv/pokybuild/yocto-worker/qemuarm64-alt/build/layers/openembedded-core/meta/lib/oeqa/runtime/cases/systemd.py", line 100, in test_systemd_failed
    output += self.systemctl('status --full --failed')
              ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/pokybuild/yocto-worker/qemuarm64-alt/build/layers/openembedded-core/meta/lib/oeqa/runtime/cases/systemd.py", line 26, in systemctl
    self.assertEqual(status, expected, message)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 3 != 0 : SYSTEMD_BUS_TIMEOUT=240s systemctl status --full --failed
× proc-fs-nfsd.mount - NFSD configuration filesystem
     Loaded: loaded (/usr/lib/systemd/system/proc-fs-nfsd.mount; static)
     Active: failed (Result: exit-code) since Tue 2026-01-06 10:14:07 UTC; 1min 19s ago
 Invocation: acc2ccd9d93947c9a38972cb1cf129f8
      Where: /proc/fs/nfsd
       What: nfsd
   Mem peak: 1M
        CPU: 91ms

https://autobuilder.yoctoproject.org/valkyrie/#/builders/9/builds/2958
https://autobuilder.yoctoproject.org/valkyrie/#/builders/20/builds/2947

This can be reproduced adding `IMAGE_CLASSES += "testimage"` to your
configuration with qemux86 or qemuarm64 MACHINE and poky-altcfg DISTRO.
Then just `bitbake core-image-full-cmdline && bitbake
core-image-full-cmdline:do_testimage` should be enough.

Can you have a look at the issue?

Thanks,
Mathieu
diff mbox series

Patch

diff --git a/meta/classes-recipe/image.bbclass b/meta/classes-recipe/image.bbclass
index 53f1a9dc45b..2d90b29c8c5 100644
--- a/meta/classes-recipe/image.bbclass
+++ b/meta/classes-recipe/image.bbclass
@@ -686,7 +686,7 @@  create_merged_usr_symlinks_rootfs() {
     create_merged_usr_symlinks ${IMAGE_ROOTFS}
 }
 
-ROOTFS_PREPROCESS_COMMAND += "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', 'create_merged_usr_symlinks_rootfs', '',d)}"
+ROOTFS_POSTPROCESS_COMMAND:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', 'create_merged_usr_symlinks_rootfs', '',d)}"
 
 reproducible_final_image_task () {
     if [ "$REPRODUCIBLE_TIMESTAMP_ROOTFS" = "" ]; then
diff --git a/meta/classes-recipe/populate_sdk_base.bbclass b/meta/classes-recipe/populate_sdk_base.bbclass
index 8e671cf28fa..cafd9a5698a 100644
--- a/meta/classes-recipe/populate_sdk_base.bbclass
+++ b/meta/classes-recipe/populate_sdk_base.bbclass
@@ -186,21 +186,51 @@  POPULATE_SDK_POST_HOST_COMMAND:append:task-populate-sdk = " write_host_sdk_manif
 # Prepare the root links to point to the /usr counterparts.
 create_merged_usr_symlinks() {
     root="$1"
-    install -d $root${base_bindir} $root${base_sbindir} $root${base_libdir}
-    ln -rs $root${base_bindir} $root/bin
-    ln -rs $root${base_sbindir} $root/sbin
-    ln -rs $root${base_libdir} $root/${baselib}
+
+    if [ ! -d "$root${base_bindir}" ]; then
+        install -d "$root${base_bindir}"
+    fi
+
+    if [ ! -d "$root${base_sbindir}" ]; then
+        install -d "$root${base_sbindir}"
+    fi
+
+    if [ ! -d "$root${base_libdir}" ]; then
+        install -d "$root${base_libdir}"
+    fi
+
+    if [ ! -e "$root/bin" ]; then
+        ln -rs "$root${base_bindir}" "$root/bin"
+    fi
+
+    if [ ! -e "$root/sbin" ]; then
+        ln -rs "$root${base_sbindir}" "$root/sbin"
+    fi
+
+    if [ ! -e "$root/${baselib}" ]; then
+        ln -rs "$root${base_libdir}" "$root/${baselib}"
+    fi
 
     if [ "${nonarch_base_libdir}" != "${base_libdir}" ]; then
-       install -d $root${nonarch_base_libdir}
-       ln -rs $root${nonarch_base_libdir} $root/lib
+        if [ ! -d "$root${nonarch_base_libdir}" ]; then
+            install -d "$root${nonarch_base_libdir}"
+        fi
+
+        if [ ! -e "$root/lib" ]; then
+            ln -rs "$root${nonarch_base_libdir}" "$root/lib"
+        fi
     fi
 
     # create base links for multilibs
     multi_libdirs="${@d.getVar('MULTILIB_VARIANTS')}"
     for d in $multi_libdirs; do
-        install -d $root${exec_prefix}/$d
-        ln -rs $root${exec_prefix}/$d $root/$d
+        if [ ! -d "$root${exec_prefix}/$d" ]; then
+            install -d "$root${exec_prefix}/$d"
+        fi
+
+        if [ ! -e "$root/$d" ]; then
+            ln -rs "$root${exec_prefix}/$d" "$root/$d"
+        fi
     done
 }
 
@@ -208,7 +238,7 @@  create_merged_usr_symlinks_sdk() {
     create_merged_usr_symlinks ${SDK_OUTPUT}${SDKTARGETSYSROOT}
 }
 
-POPULATE_SDK_PRE_TARGET_COMMAND += "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', 'create_merged_usr_symlinks_sdk', '',d)}"
+POPULATE_SDK_POST_TARGET_COMMAND:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', 'create_merged_usr_symlinks_sdk', '',d)}"
 
 SDK_PACKAGING_COMMAND = "${@'${SDK_PACKAGING_FUNC}' if '${SDK_PACKAGING_FUNC}' else ''}"
 SDK_POSTPROCESS_COMMAND = "create_sdk_files check_sdk_sysroots archive_sdk ${SDK_PACKAGING_COMMAND}"