Ubuntu-image with local snaps?

typically I would do ’ ubuntu-image snap my-model.model’ to build an image. If I have a gadget and kernel snap that I have the snaps built locally (I am testing I am not ready to push to the snap store) how do I modify the model file or change the command line syntax to pick up the local snap instead of from the store? I guess I need to overide the snap listed in the model with a local one?

If you have a locally built snap you wish to use instead you would use the --snap option to ubuntu-image to include it in the image instead.

I just can’t seem to get the syntax right. I have a local built kernel and gadget snap.

I don’t know what to put in the model file as if I leave the kernel and gadget out and only leave in the core20 and snapd it complains gadget is required in model. If I leave gadget in i do not know know what to put for id and channel as nothing is in store yet. Do you have a working example syntax?

If you want to build an image using local snaps, the model definition will need to set grade: dangerous. With that in place, you should be able to specify the snaps in the model definition without a snap ID (e.g. to build using snaps with names not registered to the store).

You can then use the --snap option to tell ubuntu-image where to find these snaps rather than downloading them from the store, as Ian outlined.

These local snaps will be installed on the system similar to how they would with snap install --dangerous. So they wouldn’t receive updates from the store after the system has been set up.

1 Like

also make sure the snap names match what you defined in your model and since nobody mentioned it, you need one --snap option per package you add … i.e.:

ubuntu-image snap mymodel.model --snap /path/to/mykernel_0.1_arm64.snap --snap /path/to/mygadget_0.1_arm64.snap

(and your model would define “mykernel” as the kernel name and “mygadget” as the gadget name)

go it working thanks

1 Like