3
Snapcraft allows easy crafting of packages for Snappy Ubuntu. It makes it
4
easy to incorporate components from different sources like GitHub, Launchpad,
9
Snappy Ubuntu Core is a new rendition of Ubuntu with transactional updates — a
10
minimal server image with the same libraries as today’s Ubuntu, but
11
applications are provided through a simpler mechanism.
13
Snappy apps and Ubuntu Core itself can be upgraded atomically and rolled back
14
if needed. Apps are also strictly confined and sandboxed to safeguard your
19
A .snap package for the Ubuntu Core system contains all its
20
dependencies. This has a couple of advantages over traditional deb or
21
rpm based dependency handling, the most important being that a
22
developer can always be assured that there are no regressions triggered by
23
changes to the system underneath their app.
25
Snapcraft makes bundling these dependencies easy by allowing you to
26
specify them as “parts” in the snapcraft.yaml file.
30
A central aspect of a snapcraft recipe is a “part”. A part is a piece
31
of software or data that the snap package requires to work or to
32
build other parts. Each part is managed by a snapcraft plugin and parts
33
are usually independent of each other.
37
Snapcraft plugins are written in Python and have a yaml
38
description. A lot of default plugins are included, for example for
39
projects written in Go, Java, Python or C. It is also possible
40
to simply download binary content as part of the snapcraft recipe.
44
Each part goes through the following steps:
48
The first is that each part is pulled. This step will download
49
content, e.g. checkout a git repository or download a binary component
50
like the Java SDK. Snapcraft will create a parts/ directory with
51
sub-directories like parts/part-name/src for each part that contains
52
the downloaded content.
56
The next step is that each part is built in its parts/part-name/build
57
directory and installs itself into parts/part-name/install.
61
After the build of each part the parts are combined into a single
62
directory tree that is called the “staging area”. It can be found
63
under the ./stage directory.
65
This ./stage directory is useful for building outside code that isn’t in the
66
snapcraft.yaml recipe against the snap contents. For example, you might build a
67
local project against the libraries in ./stage by running
68
`snapcraft shell make`. Though in general, you are encouraged to add even local
69
projects to snapcraft.yaml with a local `source:` path.
73
The snap step moves the data into a ./snap directory. It contains only
74
the content that will be put into the final snap package, unlike the staging
75
area which may include some development files not destined for your package.
77
The Snappy metadata information about your project will also now be placed in
80
This ./snap directory is useful for inspecting what is going into your snap
81
and to make any final post-processing on snapcraft’s output.
85
The final step builds a snap package out of the snap directory. This .snap file
86
can be uploaded to the Ubuntu Store and published directly to Snappy users.
90
After introducing the key concept of snapcraft it is probably a good
91
time to look at the tutorial in docs/tutorial.md to see how it works
92
for an example project.