Unix & Linux Asked by nellorocca on December 24, 2021
I’m trying to create a yocto recipe in order to add an to enable a systemd user service.
The problem is that, since the service is installed in systemd/user, with bitbake I get this error:
ERROR: mediumlevel-service-1.0-r0 do_package:
SYSTEMD_SERVICE_mediumlevel-service value mediumlevel.service does not
exist
My recipe is:
SUMMARY = "Launch mediumlevel at boot"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
inherit systemd
SRC_URI = "file://mediumlevel.service
"
S = "${WORKDIR}"
SYSTEMD_SERVICE_${PN} = "mediumlevel.service"
do_install() {
install -d ${D}${systemd_user_unitdir}
install -m 0644 ${WORKDIR}/mediumlevel.service ${D}${systemd_user_unitdir}
}
FILES_${PN} += "/usr/lib/systemd/user"
REQUESTED_DISTRO_FEATURES = "systemd"
What do you think?
Thanks!
I don't know if the answer is still relevant for you, but I wanted to drop it here anyways.
I believe your problem comes from the install step and the files for the package. I can see you tried to install the service on the folder, but that doesn't seem to work well with Yocto. You need to provide the filename together with the folder. Same on the FILE_${PN}. This recipe should work better:
SUMMARY = "Launch mediumlevel at boot"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
inherit systemd
SRC_URI = "file://mediumlevel.service
"
S = "${WORKDIR}"
SYSTEMD_SERVICE_${PN} = "mediumlevel.service"
do_install() {
install -d ${D}${systemd_user_unitdir}
install -m 0644 ${WORKDIR}/mediumlevel.service ${D}${systemd_user_unitdir}/mediumlevel.service
}
FILES_${PN} += "${systemd_user_unitdir}/mediumlevel.service"
REQUESTED_DISTRO_FEATURES = "systems"
I hope it can help you or someone else :)
Answered by Carlos Moro on December 24, 2021
systemd.bbclass takes only care for system services not user services.
I guess you have to do something like this:
Remove the SYSTEMD_SERVICE_${PN} variable
FILES_${PN} += "${systemd_user_unitdir}"
pkg_postinst_${PN} () {
#!/bin/sh -e
OPTS=""
if [ -n "$D" ]; then
OPTS="--root=$D"
fi
systemctl ${OPTS} --user enable mediumlevel.service
}
Maybe you need to remove even the inherit systemd
line, because the class sets pkg_postinst.
Answered by Markus Fuchs on December 24, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP