# State scripts not integrating with Yocto

**URL:** https://hub.mender.io/t/state-scripts-not-integrating-with-yocto/2083
**Category:** General Discussions
**Tags:** yocto, x86, warrior
**Created:** [June 20, 2020, 8:55am UTC](https://hub.mender.io/t/state-scripts-not-integrating-with-yocto/2083 "2020-06-20T08:55:15Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![fnx\_qt](https://avatars.discourse-cdn.com/v4/letter/f/b4bc9f/32.png) [@fnx\_qt](https://hub.mender.io/u/fnx_qt)
#### Post date: [June 20, 2020, 8:55am UTC](https://hub.mender.io/t/state-scripts-not-integrating-with-yocto/2083/1 "2020-06-20T08:55:15Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![oleorhagen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/oleorhagen/32/297_2.png) [@oleorhagen](https://hub.mender.io/u/oleorhagen)
#### Post date: [June 22, 2020, 8:07am UTC](https://hub.mender.io/t/state-scripts-not-integrating-with-yocto/2083/2 "2020-06-22T08:07:10Z")

</div>

Hi @fnx_qt

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

See [this](https://docs.mender.io/2.3/artifacts/yocto-project/variables#mender_state_scripts_dir).

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](https://github.com/mendersoftware/meta-mender/blob/master/meta-mender-core/classes/mender-state-scripts.bbclass) For how this is done 🙂

---

<div class="post-metadata">

### Author: ![fnx\_qt](https://avatars.discourse-cdn.com/v4/letter/f/b4bc9f/32.png) [@fnx\_qt](https://hub.mender.io/u/fnx_qt)
#### Post date: [June 22, 2020, 10:58am UTC](https://hub.mender.io/t/state-scripts-not-integrating-with-yocto/2083/3 "2020-06-22T10:58:14Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![oleorhagen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/oleorhagen/32/297_2.png) [@oleorhagen](https://hub.mender.io/u/oleorhagen)
#### Post date: [June 22, 2020, 12:00pm UTC](https://hub.mender.io/t/state-scripts-not-integrating-with-yocto/2083/4 "2020-06-22T12:00:30Z")

</div>

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

Add:

```auto
IMAGE_INSTALL_append = " state-scripts"

```

preferably to your `local.conf` for now.

[See doc](https://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html#var-IMAGE_INSTALL)

To make sure that the recipe actually gets executed 🙂

---

<div class="post-metadata">

### Author: ![fnx\_qt](https://avatars.discourse-cdn.com/v4/letter/f/b4bc9f/32.png) [@fnx\_qt](https://hub.mender.io/u/fnx_qt)
#### Post date: [June 22, 2020, 12:16pm UTC](https://hub.mender.io/t/state-scripts-not-integrating-with-yocto/2083/5 "2020-06-22T12:16:33Z")

</div>

That was it, thank you!
