A simple snapcraft.yaml template can be generated by running snapcraft init in a freshly created, and empty, directory. Don’t create a directory called snap in your home directory, as this will conflict with installed snaps and a directory created by snapcraft.
$ mkdir snap-test; cd snap-test
$ snapcraft init
The snapcraft.yaml template can be found within the snap/ directory, and can even be built into a snap without further modification:
Using 'snap/snapcraft.yaml': Project assets will be searched for from the 'snap' directory.
Launching a VM.
Snapping 'my-snap-name' |
For all but the simplest snaps, a final and fully functional snapcraft.yaml is the product of an iterative process. This process involves stepped revisions to tackle requirements, as outlined below:
This is the data at the top of your snapcraft.yaml. It’s typically easily to obtain, and describes your snap in general terms, including your snap’s name, version, icon location and summary.
With parts defined and configured to build and generate an executable component, the next step is to define which executable components can be run, whether they’re commands or services, and how they’re going to be run on the host system.
At this point, there should be enough metadata within snapcraft.yaml to successfully build a snap with the snapcraft command.
The resultant snap will lack important functionality, most notably interfaces, but testing a build at this point is a helpful milestone that verifies the integrity of your metadata, alongside that of your parts and build dependencies.