TheMeaningfulEngineer
TheMeaningfulEngineer

Reputation: 16349

systemd yocto recipe for an existing executable

I'm looking for a template recipe for enabling a systemd recipe in yocto. The executable is already installed by a recipe provided by yocto. The goal of this recipe is to provide make /usr/bin/btattach be run at startup.

As a start I created the following structure in my layer in the appropriate recipe directory:

btattach-systemd/
|-- files
|   `-- btattach.service
`-- btattach-systemd.bb

The content of the recipe

SUMMARY = "Writes patterns to the fb device"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

inherit systemd

REQUIRED_DISTRO_FEATURES= "systemd"

SRC_URI = "file://btattach.service"
S = "${WORKDIR}"

do_install () {    
    install -m 0644 ${WORKDIR}/btattach.service.service ${D}${sysconfdir}/systemd/system
 }

SYSTEMD_SERVICE_${PN} = "btattach.service"

Besides that, the IMAGE_INSTALL in the image recipe has been correctly extended with btattach-systemd.

bitbake btattach-systemd runns ok but when trying to build the complete image the at do_rootfs step for the whole image. with the error:

 * opkg_solver_install: Cannot install package btattach-systemd.                                    

Ideas on where the bug is?

Upvotes: 0

Views: 1893

Answers (3)

Brendan
Brendan

Reputation: 978

Assuming that the .service file is correct, my take on the Yocto recipe and why it might be failing is because that the btattach.service file isn't included with the installation which is what the final line does below.

Have you ensured that you do a bitbake btattach.systemd -c cleanall and bitbake btattach.systemd -c cleanstate beforehand as well, as I noticed you had a typo in the Yocto recipe as btattach.service.service.

SUMMARY = "Writes patterns to the fb device"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

inherit systemd

REQUIRED_DISTRO_FEATURES= "systemd"

SRC_URI = "file://btattach.service"
S = "${WORKDIR}"

do_install () {    
    install -m 0644 ${WORKDIR}/btattach.service ${D}${sysconfdir}/systemd/system
}

SYSTEMD_SERVICE_${PN} = "btattach.service"

FILES_${PN} += "/lib/systemd/system/btattach.service"

Upvotes: 1

vbarboza
vbarboza

Reputation: 165

I am sorry for not commenting your question as I have no reputation for that. Also, LetoThe2nd answer is more complete than mine, but here follows a possible quick fix:

It seems to me you are installing 'btattach.service.service' instead of 'btattach.service'.

Upvotes: 1

LetoThe2nd
LetoThe2nd

Reputation: 1326

I think the recipe should look like this (leaving out summary, license, license checksum, and assuming that the binary package is called "btattach"):

SRC_URI = "file://btattach.service"
SYSTEMD_SERVICE_${PN} = "btattach.service"

inherit systemd

do_install_append() {
    install -d ${D}${systemd_unitdir}/system
    for service in ${SYSTEMD_SERVICE_${PN}}; do
        install -m 0644 ${WORKDIR}/${service} ${D}${systemd_unitdir}/system/

        sed -i -e 's,@BINDIR@,${bindir},g' ${D}${systemd_unitdir}/system/${service}
    done
}

RDEPENDS_${PN} = "btattach"

Upvotes: 1

Related Questions