Bug 15710 - systemd.bbclass does not handle presets for user services properly
Summary: systemd.bbclass does not handle presets for user services properly
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: configuration (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Medium+ normal
Target Milestone: 5.2 M2
Assignee: Artur Kowalski
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2025-01-08 16:14 UTC by Artur Kowalski
Modified: 2025-01-23 16:32 UTC (History)
2 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Don't know


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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!