What's the recommended mechanism for installing a custom mender-device-identity script in Yocto?

I’m using the Raspberry Pi 0 Wifi board integration with Yocto.

https://docs.mender.io/2.0/client-configuration/identity#implementing-a-device-identity-executable describes how to write a mender-device-identity script.

I wrote a Yocto recipe which installs my custom script to /usr/share/mender/identity/mender-device-identity, however it conflicts with the mender recipe which also installs /usr/share/mender/identity/mender-device-identity.

Error: Transaction check error:
  file /usr/share/mender/identity/mender-device-identity conflicts between attempted installs of mender-device-identity-1.0-r0.arm1176jzfshf_vfp and mender-1.7.0-r0.arm1176jzfshf_vfp

What’s the recommend method for installing a custom mender-device-identity script when using Mender with Yocto?

I just bbappend the mender recipe rather than creating a separate one.

1 Like

I did that too, I created a mender_%.bbappend file which installs the script without conflict.

I have been struggling with this problem. I am not a Yocto expert, but I followed the instructions to install a custom mender.conf file by putting it in the recipes-mender/mender/files directory and also creating the mender_%.bbappend file with the contents. I tried doing the same with the mender-device-identity script, but to no avail.

I put both mender.conf and mender-device-identity in the mender/files directory. Here’s the current contents of mender_%.bbappend.

SRC_URI_append = " file://mender.conf"
FILESEXTRAPATHS_prepend := “${THISDIR}/files:”

SRC_URI_append = " file://mender.conf"
SRC_URI_append = " file://mender-device-identity"

After I build, I see that my custom mender.conf is located in /etc/mender but my custom identity script does not show up in /usr/share/mender/identity, only the default script…

You probably need to add something like this in your mender_%.bbappend

do_install_append() {
     install -t ${D}/${datadir}/mender/identity -m 0755 \
            ${WORKDIR}/mender-device-identity
}

For your custom file to be installed.

1 Like

OK, that seems to work. Thanks!

I also noticed that the custom mender.conf file I provided is changed before it makes it to /etc/mender/mender.conf in the rootfs. The file I provide is:

{
    "InventoryPollIntervalSeconds": 1800,
    "RetryPollIntervalSeconds": 300,
    "ServerURL": "https://admin.zbapp.com:9010/",
    "ServerCertificate": "/opt/hydroid/gateway/scripts/mender.crt",
    "UpdatePollIntervalSeconds": 30
}

The mender.conf that ends up in rootfs contains:

{
    "InventoryPollIntervalSeconds": 1800,
    "RetryPollIntervalSeconds": 300,
    "RootfsPartA": "/dev/mmcblk0p2",
    "RootfsPartB": "/dev/mmcblk0p3",
    "ServerCertificate": "/opt/hydroid/gateway/scripts/mender.crt",
    "ServerURL": "https://docker.mender.io",
    "TenantToken": "dummy",
    "UpdatePollIntervalSeconds": 1800
}

So my UpdatePollIntervalSeconds and ServerURL were switched back to default values, but my ServerCertificate is correct. What do I need to do to prevent switching back to default values?

Thanks
-Zac

Edit: @mirzak: Apply syntax highlight

Hm, which Yocto version are you using and which client version are you building?

I am using client v.1.3.0 and Yocto on an orange pi PC plus.

I found I can get the right mender.conf generated if I delete the URL line in my custom file and instead add the MENDER_SERVER_URL to the local.conf. That way it picks up both the cert and the URL.

I have had some more difficulty with mender-device-identity, though. I have suddenly begun seeing the following error:

| install: cannot stat '/home/zac/gateway_yoctodev/yocto/build-h2o/tmp-glibc/work/cortexa7hf-neon-vfpv4-oe-linux-gnueabi/mender/1.3.0-r0/mender-device-identity': No such file or directory
| WARNING: exit code 1 from a shell command.
| ERROR: Function failed: do_install (log file is located at /home/zac/gateway_yoctodev/yocto/build-h2o/tmp-glibc/work/cortexa7hf-neon-vfpv4-oe-linux-gnueabi/mender/1.3.0-r0/temp/log.do_install.4998)
ERROR: Task (/home/zac/gateway_yoctodev/yocto/meta-mender/meta-mender-core/recipes-mender/mender/mender_1.3.0.bb:do_install) failed with exit code '1'

I suggest a “bitbake -c cleansstate mender”. It looks like something may be out of sync in your build.

Additionally, Mender v1.3 is quite old and no longer supported. Is there a reason you are sticking with that version?