Enable systemd services using yocto

In order to resolve this packaging error, I used the following install step

do_install() {
   install -d ${D}${bindir}
   install -m 0755 ${WORKDIR}/test_systemd.sh ${D}${bindir}
   install -d ${D}${systemd_unitdir}/system
   install -m 0644 ${WORKDIR}/test_systemd.service ${D}${systemd_unitdir}/system
}

SYSTEMD_SERVICE_${PN} += "file://test_systemd.service"

This should be:

SYSTEMD_SERVICE_${PN} = "test_systemd.service"

Other notes (unrelated to the error):

  • Installing things into /home is probably not a great idea (you could use e.g. ${libexecdir} for scripts that other scripts need.
  • there's no reason for having a do_install_append() in a bb file: you can just put everything in do_install()
  • If your Yocto is recent, using ${systemd_system_unitdir} instead of /lib/systemd/system is a good idea (in older releases ${systemd_unitdir}/system/ works)

Tags:

Bitbake

Yocto