Bug 15627

Summary: PermissionError in systemd_preset_all when using systemd
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Christian Charreyre <christian.charreyre>
Component: coreAssignee: Ross Burton <ross.burton>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: Medium+ CC: christian.charreyre, meta.mr.watcher, meta.watcher, randy.macleod
Version: 5.0.4   
Target Milestone: 5.2 M3   
Hardware: All   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know
Attachments:
Description Flags
Log of do_image step for core-image-minimal none

Description Christian Charreyre 2024-10-17 12:40:14 UTC
Created attachment 5076 [details]
Log of do_image step for core-image-minimal

When DISTRO_FEATURES contains systemd, systemd_preset_all is added to IMAGE_PREPROCESS_COMMAND.

This function uses recipe-sysroot-native/usr/bin/systemctl to create links in etc/systemd/system/, but in the rootfs of the image the processed files can point on nothing (depending on the host distro, mine is Ubunut 20.04). In fact it points to a file in /usr/lib/, that will be OK on the target but can not exist on the dev environment.

In my case /dd/test-scarthgap-bug/build/tmp/work/qemux86_64-poky-linux/core-image-minimal/1.0/rootfs/etc/systemd/system/default.target -> /usr/lib/systemd/system/multi-user.target, which triggers the error.

This leads to an error in path.is_dir() test of systemctl, due to self.stat() test in python3.12 pathlib.py :

    def stat(self, *, follow_symlinks=True):
        """
        Return the result of the stat() system call on this path, like
        os.stat() does.
        """
        return os.stat(self, follow_symlinks=follow_symlinks)

Same image with dunfell, using python3.8, worked fine, with different code in pathlib.py :

    def stat(self):
        """
        Return the result of the stat() system call on this path, like
        os.stat() does.
        """
        return self._accessor.stat(self)


Tests conditions: build core-image-minimal with just poky layer activated.
Comment 1 Ross Burton 2025-02-12 18:15:24 UTC
We're potentially going to remove the systemctl reimplmentation shortly which hopefully will fix this.
Comment 2 Ross Burton 2025-02-20 15:20:56 UTC
I've verified that the proper systemctl does the right thing, and that is queued for master.
Comment 3 Ross Burton 2025-03-25 20:25:44 UTC
This should be fixed in oe-core 7a580800db391891a3a0f838c4ae6e1513c710a2.