user2477865
user2477865

Reputation: 301

ERROR: hellosystemd-1.00-r0 do_package: Didn't find service unit 'hello.service', specified in SYSTEMD_SERVICE:hellosystemd

I need to install a systemd service into my own image, but it is failing with following errors:

*ERROR: hellosystemd-1.00-r0 do_package: Didn't find service unit 'hello.service', specified in SYSTEMD_SERVICE:hellosystemd. 
ERROR: Logfile of failure stored in: /home/milaap/WORKSPACE/yocto-kirkstone/build-qemux86-64/tmp/work/core2-64-poky-linux/hellosystemd/1.00-r0/temp/log.do_package.1304921
ERROR: Task (/home/milaap/WORKSPACE/yocto-kirkstone/layers/meta-test/recipes-example/systemd/hellosystemd_1.00.bb:do_package) failed with exit code '1'*

I have configured all DISTRO_FEATURES which is needed. But, unable to resolve. Find the below code:

local.conf

# set machine 
MACHINE = "qemux86-64"

# enable some features for the distro
DISTRO_FEATURES:append = " systemd"
DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"
INIT_MANAGER = "systemd"
VIRTUAL-RUNTIME:init_manager = "systemd"
VIRTUAL-RUNTIME:initscripts = ""

hellosystemd.bb

SUMMARY = "Systemd Example Recipe"
DESCRIPTION = "Run hellosystemd script"
LICENSE = "CLOSED"

SRC_URI = "file://hello.service"

DEPENDS += "systemd"
RDEPENDS:${PN} += "systemd"

S = "${WORKDIR}"

inherit pkgconfig systemd

SYSTEMD_AUTO_ENABLE = "enable"
SYSTEMD_SERVICE:${PN} = " hello.service"

FILES:${PN} += "/system/hello.service"

hello.service is getting copied to below location:

./tmp/work/core2-64-poky-linux/systemd/1_250.5-r0/git/test/units/hello.service
./tmp/work/core2-64-poky-linux/hellosystemd/1.00-r0/hello.service

Please provide the solution.

Upvotes: -1

Views: 52

Answers (1)

PierreOlivier
PierreOlivier

Reputation: 1556

I see a main issue, you are not installing the file in a do_install task.

do_install() {
    install -d ${D}/${systemd_system_unitdir}
    install -m 0644 ${S}/hello.service ${D}/${systemd_system_unitdir}/
}

Your FILES:{PN} needs to be set accordingly (setting the directory is enough):

FILES:${PN} += "${systemd_system_unitdir}"

And two remarks:

  • I don't think RDEPENDS on systemd do something (if you want to use systemd, use INIT_MANAGER in a .conf file)
  • SYSTEMD_AUTO_ENABLE is not needed, as the service is enabled by default
  • pkgconfig don't needs to be inherited here

You final recipe should look like:

SUMMARY = "Systemd Example Recipe"
DESCRIPTION = "Run hellosystemd script"
LICENSE = "CLOSED"

SRC_URI = "file://hello.service"

S = "${WORKDIR}"

inherit systemd

SYSTEMD_SERVICE:${PN} = " hello.service"

do_install() {
    install -d ${D}/${systemd_system_unitdir}
    install -m 0644 ${S}/hello.service ${D}/${systemd_system_unitdir}/
}

FILES:${PN} += "${systemd_system_unitdir}"

Upvotes: 1

Related Questions