Sideload snaps during a custom Ubuntu Core image build

Is there a way to sideload snaps (i.e. snaps that have not been published in the snap store) when building a custom Ubuntu Core image?

Further reading, for anyone else interested in this:

Official docs for building a custom Ubuntu Core image: https://core.docs.ubuntu.com/en/guides/build-device/image-building

Great blog from @ogra with more detail on building an ‘appliance’ image: https://ograblog.wordpress.com/2019/01/07/291/

the --extra-snaps option mentioned in your first link has been replaced with the --snap option, this should allow you to sideload local snaps at image build time … (see ubuntu-image snap --help) … note that for UC20 your model assertion needs to be marked “dangerous” to actually allow this …

Ah, perfect - missed that the first time around! Thanks

Is there any way to set up default/automatic snap connections when sideloading snaps into a custom image in this way? (for example using a forked pi3 gadget snap, as referenced in your blog, which seems to require the “snap ID” to set up connections)

no, the gadget connections require a snap ID, there is no way around this currently … you need to have the gadget uploaded to your brand store to have this work …

Hi, just a note that with grade: signed or grade: secured images, you can still use the --snap option to ubuntu-image, but you can only use snap files that are asserted from the store with this option. You cannot use a locally built snap file that has not been uploaded to the store with this option. Also note that since this confusion has popped up elsewhere, you only need the .snap file you do not also need the .assert file that is generated when you run snap download. Snapd will calculate a hash of the .snap file provided via --snap, and if this hash has an associated snap-revision assertion from the store, then snapd will allow including this file in the image even with grade: signed|secured, but if there is not a hash matching the snap file (because i.e. you built it yourself locally and have not yet uploaded it to the store), then snapd will not allow including it into grade: signed|secured images.

Hope this helps

1 Like