State scrips cleanup in Yocto

Hi,
I’m developing yocto images. I need to run some state scripts based on the customer, so on some images mender needs to run script ArtifactInstall_Leave_11 while in some images it needs to run script ArtifactInstall_Leave_11 + ArtifactInstall_Leave_12 .
To do so, I’ve created two packages in the image, where package A installs ArtifactInstall_Leave_11 while package B installs ArtifactInstall_Leave_12 .

If I run the build for image with package A+B I correctly get ArtifactInstall_Leave_11 + ArtifactInstall_Leave_12 , but if then I build the image with only package A I also get ArtifactInstall_Leave_11 + ArtifactInstall_Leave_12 .
If I remove manually the file: tmp/deploy/images//mender-state-scripts/ArtifactInstall_Leave_12
then In the image I get only ArtifactInstall_Leave_11.

Do you know why this happens and how I can get rid of this behavior? is there a way to get the state scripts cleaned among builds?

Thanks!

just to be more clear, I think there is a BUG in the state scripts:
If I remove a package containing a state script this won’t be removed from a image build later on.

Filippo

Hi @filcopetti,

Thanks for the report, I’ll try to reproduce and understand the behavior. The underlying reason is probably that the state scripts are not part of the image, but just bundled into the artifact. My guess is that this causes some “interesting” effects.

Greetz,
Josef

Thanks Josef,

Only later I noted the red note here:
https://docs.mender.io/operating-system-updates-yocto-project/image-customization/state-scripts
Ok, this fixes the issue but dramatically increases the building time, I believe there are better ways to implement this feature

many thanks,
Filippo