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 Created snap/snapcraft.yaml.
The snapcraft.yaml template can be found within the
snap/ directory, and can even be built into a snap without further modification:
$ snapcraft Using 'snap/snapcraft.yaml': Project assets will be searched for from the 'snap' directory. Launching a VM. Launched: snapcraft-my-snap-name [...] Pulling my-part Building my-part Staging my-part Priming my-part Snapping 'my-snap-name' | Snapped my-snap-name_0.1_amd64.snap
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.
For help completing these details, see Global metadata.
Choose a base
The base is the foundation layer of your snap. It provides the run-time environment for your snap, and includes basic requirements and dependencies.
To choose the best base for your project, see Base snaps.
Parts are the building blocks of your snap. They’re used to describe your application’s components, its build and run-time requirements, and those of its dependencies.
See Adding parts for further details.
Add build and staging dependencies
Many parts will require you to know specific packages to include for the part to build and run. These are your snap’s build and staging dependencies.
For help tracking them down and adding them to your parts, see Build and staging dependencies.
Expose a command to run
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.
See Defining a command for further details.
Dry-run your build
At this point, there should be enough metadata within snapcraft.yaml to successfully build a snap with the
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.
Last updated 11 months ago. Help improve this document in the forum.