Application Snaps are expected to contain both applications, and the necessary libraries needed for the applications to function correctly. The developer specifies at build time what libraries to include. Libraries may be included as individual parts or can be included as stage-packages
in the application part.
Compiling the libraries from source, or dumping individual pre-built libraries allows the snap developer to have fine-grained control over which versions of libraries are included in the snap. Developers can include libraries theyâve already built elsewhere in the build-chain, inside the snap. Placing libraries in the /lib
directory within the snap will ensure theyâre found in the library path at runtime.
In this snippet libraries are in the libs/ path of their project directory. At build time snapcraft
will incorporate the libraries into the snap.
parts:
libraries:
plugin: dump
source: ./libs
organize:
"*.so": /lib/
Using stage-packages
can be considered a convenience, saving the developer the time and effort of compiling each one from source. When building snaps to run with an Ubuntu 16 Core (base), the specified stage-packages
will come from the Ubuntu 16.04 (Xenial) repository. The libraries are included at build-time, and will pull whatever the current version in the Ubuntu repository is.
In this snippet, some libraries are listed in the application part. Those (and in turn their dependencies) will be incorporated into the snap at build time.
parts:
game:
plugin: make
source: ./sourcefiles
stage-packages:
- libgl1-mesa-dri
- libgl1-mesa-glx
The Snap Store will send automated emails to developers using stage-packages
when a security update occurs, recommending the affected snap(s) are rebuilt and published.