Model.assertion format


#1

Hi,

I’m trying to add a gadget-snap into an Ubuntu 18.04 desktop image. For this I use the command: sudo snap prepare-image --classic --snap [my_build_gadget_file.snap] model.assertion /mnt/. The model.assertion I got from my device by using: sudo snap known serial.

Sadly it fails with this message: assertion body length and declared body-length don’t match: 728 != 0. This is because it wants a body that matches the current body-length (which I haven’t defined because I don’t have a body yet). If I do change the body length to 728 it will say that my signature is empty. The problem is that because I don’t have I body it will see my signature as the body and think that the signature field is left empty.

According to https://docs.ubuntu.com/core/en/reference/assertions I don’t need a body, but still the message implies I do. What could I put in the body or is there some way to separate the two (body and signature).


#2

Gadget snaps aren’t part of classic Ubuntu installs: instead, they are one of the components of an Ubuntu Core device. So what exactly are you trying to do?

If you are trying to build an Ubuntu Core image though, this describes how to create a model assertion:

https://docs.ubuntu.com/core/en/guides/build-device/board-enablement#the-model-assertion

In short, you create a file describing what should be in the image (the kernel, gadget snap, base snap to use as root file system, any required application snaps), then sign it with a key associated with your account.

To actually build the file system image, you are better off using the ubuntu-image command rather than trying to drive snap prepare-image directly. This is also covered in the above documentation.


#3

snap prepare-image --classic didn’t support desktop image, even if using ubuntu-image classic is impossible. For ubuntu-image classic command, it purposes to build an preinstalled image based on given PROJECT arugment, for example, PROJECT=ubuntu-cpc, now ubuntu-cpc is set by default.