Bug 15710

Summary: systemd.bbclass does not handle presets for user services properly
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Artur Kowalski <arturkow2000>
Component: configurationAssignee: Artur Kowalski <arturkow2000>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium+ CC: pavel, randy.macleod
Version: unspecified   
Target Milestone: 5.2 M2   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

Description Artur Kowalski 2025-01-08 16:14:13 UTC
systemd.bbclass creates all presets in ${systemd_unitdir}/system-preset where presets for user services should be created in ${systemd_unitdir}/user-preset instead.

An example recipe

SUMMARY = "Bug reproduction"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

do_configure[noexec] = "1"
do_compile[noexec] = "1"

inherit allarch systemd

SYSTEMD_PACKAGES = "${PN}"
SYSTEMD_SERVICE:${PN} = "test-service.service"

do_install() {
    install -d ${D}${systemd_user_unitdir}
    cat <<EOF > ${D}${systemd_user_unitdir}/test-service.service
[Unit]
Description=Test
[Service]
ExecStart=${bindir}/true
EOF
}

Results in

./usr
./usr/lib
./usr/lib/systemd
./usr/lib/systemd/user
./usr/lib/systemd/user/test-service.service
./usr/lib/systemd/system-preset
./usr/lib/systemd/system-preset/98-do-something.preset


In effect, this causes image build to fail if broken package is included:

ERROR: core-image-minimal-1.0-r0 do_rootfs: Error: Systemctl main enable issue in test-service.service (test-service.service)
Comment 1 Randy MacLeod 2025-01-09 15:53:00 UTC
Artur, are you willing and able to send a patch?
Even adding a readable error message would help.
Comment 2 Artur Kowalski 2025-01-09 18:57:35 UTC
Fix is underway, I will provide patches in a day or two.
Comment 3 Artur Kowalski 2025-01-12 14:44:35 UTC
Patches sent: https://patchwork.yoctoproject.org/project/oe-core/list/?series=30672
Comment 4 Randy MacLeod 2025-01-23 16:32:53 UTC
Merged 8 commits, the most recent of which was:

https://git.openembedded.org/openembedded-core/commit/?id=ce62b88d8f71368e356b6409ada46a34a6017ddf

Thanks Artur!