Base snaps


#1

A base snap is a special kind of snap that provides a run-time environment with a minimal set of libraries that are common to most applications. They’re transparent to users, but they need to be considered, and specified, when building a snap.

Bases are defined by adding the base: keyword to a snap’s snapcraft.yaml followed by the base name.

There are currently two supported bases:

For example, to specify core 18, use the following:

base: core18

To specify core 16, use the following

base: core

The base snap mounts itself as the root filesystem within your snap such that when your application runs, the base’s library paths are searched directly after the paths for your specific snap.

:warning: When building your snap with no specified base, Snapcraft will operate in legacy mode. This is essentially a prior (2.43-era) version of Snapcraft, and will lose the functionalities and bug fixes introduced in the new version.

Building a base snap

While it is possible to build your own base snap, its publisher needs to take responsibility for its maintenance and updates. In particular:

  • bases need to be built from stable packages
  • ABI compatibility cannot broken (ie. never replace symbols or libraries, and be strict)
  • security updates must be pro-active

Base snaps can be either bootable or non-bootable. The former needs to include systemd while the latter can be leaner.

build-base

The base keyword on its own does not not take into account the creation of bases. Instead, with older versions of snapcraft, the name keyword was arbitrarily used to determine the build environment:

name: core18
type: base
# base: is not set elsewhere 

The above example uses name to specify the creation of an Ubuntu 18.04 (core18) based build environment.

But the above fails if a base has yet to be bootstrapped, or is otherwise unavailable. For example, the following will currently generate a `launch failed: Unable to find an image matching “core20” error:

name: core20
type: base
# base: is not set elsewhere 

In cases like the above, where the base has not yet been bootstrapped, the build-base keyword should be used to explicitly define the base to use for the build environment.

To solve the above issue, for example, use the following:

name: core20
type: base
build-base: core18
# base: is not set elsewhere 

Snapcraft top-level metadata
Snapcraft.yaml reference
Snap layouts
Release notes: Snapcraft 3.8
Release notes: Snapcraft 3.0
List and table presentation ideas
Snapcraft build, debug and publishing docs roadmap (page breakdown)
Adding global metadata
Creating snapcraft.yaml
Upgrading snapcraft
Creating docker images for snapcraft
Build on Docker
Using parts
Snap documentation
#2

Should this be 2.43-era ?


#3

thanks! I’ll update the version in the doc.