State scripts not integrating with Yocto

Hello,

I’m using Yocto to create a custom image for an x86-64 embedded system. The image is working fine and Mender too. However, I’m having trouble adding state scripts to the artifact.
I use the following recipes in a custom layer:

recipes-mender
├── hello-mender
│   └── hello-mender.bb
├── mender-client
│   ├── files
│   │   ├── artifact-verify-key.pem
│   │   └── private.key
│   └── mender_%.bbappend
└── state-scripts
    ├── files
    │   ├── ArtifactCommit_Enter_00.sh
    │   └── LICENSE
    └── state-scripts_1.0.bb 

The recipe state-scripts_1.0.bb is not adding the ArtifactCommit_Enter scripts in the mender artifact after the generation. The script is copied from the examples you provide in the demo layer:

FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI = "file://ArtifactCommit_Enter_00.sh;subdir=${PN}-${PV} \
          file://LICENSE;subdir=${PN}-${PV} \
          "

LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e"

inherit mender-state-scripts

do_compile() {
    install -m 755 ${DEV}../scripts/* ${MENDER_STATE_SCRIPTS_DIR}
    cp ArtifactCommit_Enter_00.sh ${MENDER_STATE_SCRIPTS_DIR}/ArtifactCommit_Enter_00.sh
}

When I read the content of the artifact, the script is not appearing:

Mender artifact:
  Name: release-1.0.0
  Format: mender
  Version: 3
  Signature: no signature
  Compatible devices: '[up-squared]'
  Provides group:
  Depends on one of artifact(s): []
  Depends on one of group(s): []
  State scripts:

Updates:
    0:
    Type:   rootfs-image

All other recipes work normally. Does someone have an idea ? Thanks.

Hi @fnx_qt

When inheriting the mender-state-scripts, you don’t necessarily have to create your own install function.

See this.

This means that you should only have to list the directory where your scripts are located, and the mender-state-scripts class will install them for you.

See mender-state-scripts.bbclass For how this is done :slight_smile:

Hi,

Thank you but I don’t understand what I need to do. I tried removing all instructions and just “listing” the files:

FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI = "file://ArtifactCommit_Enter_00.sh;subdir=${PN}-${PV} \
          file://LICENSE;subdir=${PN}-${PV} \
          "

LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e"

inherit mender-state-scripts

It didn’t work. After that I tried adding the following line, as shown in the meta-mender-demo layer:

do_compile() {
    cp ArtifactCommit_Enter_00.sh ${MENDER_STATE_SCRIPTS_DIR}/ArtifactCommit_Enter_00.sh
}

However both methods don’t work. I read the mender-state-scripts.bbclass but it doesn’t help. I also tried creating a mender-state-scripts folder and put my script in it but it didn’t work either.
Do you have an idea on what I’m doing wrong?

Ahh, I think I got it. The recipe for installing the scripts is actually never run.

Add:

IMAGE_INSTALL_append = " state-scripts"

preferably to your local.conf for now.

See doc

To make sure that the recipe actually gets executed :slight_smile:

1 Like

That was it, thank you!

1 Like