Skip to content

Packaging with Snapcraft

Michael R Sweet edited this page Mar 17, 2020 · 2 revisions

The following comes from Till Kamppeter (OpenPrinting and Canonical)

The Basics

Snapcraft is a software distribution and containment solution, primarily for Linux. See the example snapcraft.yaml file from the GSoC 2019 OpenPrinting printer application project.

In order for the Printer Application to be started automatically, it must be declared as a daemon using the "daemon" directive:

apps:
  run-server:
    command: bin/server
    daemon: simple
    plugs: [ avahi-control, home, network-bind, network-observe, ... ]

The Printer Application specifies any of several interfaces using the "plugs" directive:

  • "avahi-control" to register DNS-SD services
  • "avahi-observe" to discover DNS-SD services
  • "hardware-observe" to be notified via UDEV when printers are connected and disconnected
  • "hardware-random-observe" to have access to entropy data (for TLS and other cryptographic needs)
  • "home" to access the home directory
  • "network" to access network services/devices
  • "network-bind" to listen for network connections
  • "network-observed" to monitor for network configuration changes
  • "raw-usb" to access USB printers via libusb
  • "serial-port" to access serial ports

Avahi 0.8.0 or later is needed for localhost support.

Security

Snaps run with some level of confinement on the system. Snap servers run as the root user within the confined environment, but can drop privileges if desired, e.g., to the "lp" user.

Clone this wiki locally