Skip to content

canonical/meta-snapd

Repository files navigation

Community maintained OpenEmbedded/Yocto layer for snap support

==================================================

This meta layer adds support for snapd and snaps for all OpenEmbedded/Yocto based devices.

This meta layer mainly contains the following components which are required for supporting snaps in your system:

  • snapd

The layer follows Yocto master branch.

The following layers are required:

  • meta-openembedded/meta-oe
  • meta-openembedded/meta-networking
  • meta-openembedded/meta-perl
  • meta-openembedded/meta-pythoin
  • meta-openembedded/meta-filesystems
  • meta-security

Try it!

  1. Follow the Yocto Quickstart guide to get your build host properly setup: https://www.yoctoproject.org/docs/latest/yocto-project-qs/yocto-project-qs.html

  2. Download latest yocto release

 $ git clone git://git.yoctoproject.org/poky
 $ cd poky
  1. Fetch meta-openembedded layer:
 $ git clone git://git.openembedded.org/meta-openembedded
  1. Fetch meta-security layer:
 $ git clone git://git.yoctoproject.org/meta-security
  1. Fetch meta-snapd layer
 $ git clone https://github.com/snapcore/meta-snapd.git
  1. Prepare the build environment
 $ source oe-init-build-env

Now add meta-snapd to your conf/bblayers.conf so that it looks similar to this

 BBLAYERS ?= " \
   ...
   /tmp/poky/meta-snapd \
   /tmp/meta-openembedded/meta-oe \
   /tmp/meta-openembedded/meta-networking \
   /tmp/meta-openembedded/meta-perl \
   /tmp/meta-openembedded/meta-python \
   /tmp/meta-openembedded/meta-filesystems \
   /tmp/meta-openembedded/meta-security \
  "
  1. Modify your conf/local.conf

Enable support for systemd which is mandatory for snapd. See https://www.yoctoproject.org/docs/latest/dev-manual/dev-manual.html#using-systemd-exclusively for more details.

cat <<EOF >> conf/local.conf
DISTRO_FEATURES:append = " systemd security"
INIT_MANAGER = "systemd"
EOF

Optionally enable AppArmor support:

cat <<EOF >> conf/local.conf
DISTRO_FEATURES:append = " apparmor"
EOF

The snap-confine tool assumes that the home directory of root is /root. Make sure we do not break this assumption, otherwise snaps mount namespace setup will fail early in the process. To use /root', set ROOT_HOME like this:

cat <<EOF >> conf/local.conf
ROOT_HOME = "/root"
EOF

(Optional) The build can take up a huge amount of disk space, inheriting rm_work class will help deal with that (see https://www.yoctoproject.org/docs/latest/ref-manual/ref-manual.html#ref-classes-rm-work for details):

INHERIT += "rm_work"
# exclude snapd in case you want to develop snapd recipes
RM_WORK_EXCLUDE += "snapd"
  1. Finally you can now build the demo image via
 $ bitbake snapd-demo-image

Depending on your host system the build will take a while.

The snapd-demo-image set IMAGE_ROOTFS_SIZE ?= "819200", this the resulting image is > 800MB in size. When building custom images make sure to add room for storing snaps by either setting IMAGE_ROOTFS_EXTRA_SPACE or tuning IMAGE_ROOTFS_SIZE

  1. Once the build is done you can boot the image with QEMU with the following command:
 $ runqemu qemux86-64 nographic slirp stdioserial
  1. When the system has fully booted login with root and no password. Afterwards you can use the the snap system as normal.
 $ snap install hello-world
 $ /snap/bin/hello-world.shell
 # path to /snap/bin is automatically addded to user's environment
 $ hello-world

Contributions & support

Please submit any issues or pull requests on out github project at http://github.com/snapcore/meta-snapd

Head out to https://forum.snapcraft.io/ for support and questions about snapd.