How to extend mender-configure Yocto recipe

Hi,

I am fruitlessly trying to modify my existing mender-configure_%.bbappend to add a custom apply-device-config script.

I have tried in many ways to extend install-scripts command, but the final image does not even contain the /usr/lib/mender-configure directory, which I guessed it should already be there regardless of my new script. I have also tried to install the directory myself, but nothing.

Here’s the actual content of my .bbappend file:

FILESEXTRAPATHS:prepend := "${THISDIR}/files:"

SRC_URI:append:mender-image:mender-systemd = " \
    file://mender-configure-data-dir.service \
"

SRC_URI:append = " \
    file://my-custom-script \
"

FILES:${PN}:append:mender-image:mender-systemd = " \
    ${systemd_unitdir}/system/mender-configure-data-dir.service \
    ${systemd_unitdir}/system/mender-configure-apply-device-config.service.wants/mender-configure-data-dir.service \
"

FILES:${PN}-scripts:append = " \
    /usr/lib/mender-configure/apply-device-config.d/my-custom-script \
"

do_install:append:class-target:mender-image:mender-systemd() {
    install -m 644 ${WORKDIR}/mender-configure-data-dir.service ${D}${systemd_unitdir}/system/mender-configure-data-dir.service
    install -d -m 755 ${D}${systemd_unitdir}/system/mender-configure-apply-device-config.service.wants
    ln -sf ../mender-configure-data-dir.service ${D}${systemd_unitdir}/system/mender-configure-apply-device-config.service.wants/mender-configure-data-dir.service
}

do_install:append() {
    install -m 755 -d ${D}/usr/lib/mender-configure/apply-device-config.d
    install -m 755 ${WORKDIR}/my-custom-script ${D}/usr/lib/mender-configure/apply-device-config.d/
}
1 Like

I have finally figured out it was merely a packaging issue: the new file was actually there when running the bitbake-ing of the single recipe, but it was finally not included in the final Mender image.

What I was missing was the specification of the class-target for the mender-image after the do_install’s append and, as a consequence, adding mender-image to SRC_URI and FILES append’s. Additionally, I have also included mender-configure-scripts package to CORE_IMAGE_EXTRA_INSTALL variable, to have the apply-device-config script dir already created, plus the out-of-the-box timezone script (which I currently do not make any use of it).

Here’s the final .bbappend:

FILESEXTRAPATHS:prepend := "${THISDIR}/files:"

SRC_URI:append:mender-image:mender-systemd = " \
    file://mender-configure-data-dir.service \
"

SRC_URI:append:mender-image = " \
    file://my-custom-script \
"

FILES:${PN}:append:mender-image:mender-systemd = " \
    ${systemd_unitdir}/system/mender-configure-data-dir.service \
    ${systemd_unitdir}/system/mender-configure-apply-device-config.service.wants/mender-configure-data-dir.service \
"

FILES:${PN}-scripts:append:mender-image = " \
    /usr/lib/mender-configure/apply-device-config.d/my-custom-script \
"

do_install:append:class-target:mender-image:mender-systemd() {
    install -m 644 ${WORKDIR}/mender-configure-data-dir.service ${D}${systemd_unitdir}/system/mender-configure-data-dir.service
    install -d -m 755 ${D}${systemd_unitdir}/system/mender-configure-apply-device-config.service.wants
    ln -sf ../mender-configure-data-dir.service ${D}${systemd_unitdir}/system/mender-configure-apply-device-config.service.wants/mender-configure-data-dir.service
}

do_install:append:class-target:mender-image() {
    install -m 755 ${WORKDIR}/my-custom-script ${D}/usr/lib/mender-configure/apply-device-config.d/
}
1 Like

Thanks for sharing the solution @wandering-tales!