Exploring the new Flatpak and Snap package formats
YAML Files
Like Flatpak, Snap offers the ability to create a package based on a JSON file, but YAML format is standard. You can define keywords and paragraphs in the YAML file and then feed the file to Snapcraft [14], which builds a complete Snap from the information.
Snap comes with the GNU Autotools plugin, which you can use for building a program from the source code. You can use the built-in plugin interface to include functions that are missing in the Snap core. The Autotools plugin ensures that the familiar three-step process, ./configure
, make
, and make install
works when you convert source code to binary code.
The keywords, name
, version
, and summary
let the snap creator define the name of the snap, the version number, and the summary it will report. The confinement
keyword is particularly important: options include strict
(the default option) or devmode
. strict
strictly isolates the Snap from the rest of the system. For production snaps, confinement: strict
is more or less mandatory. A ready-to-use YAML file for a Hello World
snap would look like Listing 2.
Listing 2
snapcraft.yaml
If you are building snaps of more complex programs, you need to expand the parts
section. If the program requires dependencies in the form of libraries, enter them in the appropriate order in the YAML file.
To build the snap, store the YAML file as snapcraft.yaml
and run the snapcraft
command within the directory. (Be sure the snapcraft
package is installed on the system.) On Ubuntu systems, you will find snapcraft
in the official archive; for other distributions, see the instructions online [15]. Snapcraft is available for both Fedora and OpenSUSE.
Following the Snapcraft call, find a file with a .snap
file suffix in the working directory. To run the snap on a system, the system needs the Snap daemon, snapd. Once snapd is running, you can install the snap:
sudo snap install *.snap --dangerous
Concerned readers might be a little worried about the --dangerous
parameter. Don't panic! The parameter just tells Snap to skip the built-in signature validation, which ensures that only snaps from sources that the admin explicitly trusts are installed on the system.
The example shown here only scratches the surface of what is possible with Snap. The very detailed documentation, which sheds light on the possibilities and options, is available on the program website [16].
Interface System
A container app that is completely isolated from the rest of the system is of limited use. To integrate itself with the normal workflow, a container app must at least be able to access a user's personal directory. Snap solves this problem by offering standardized interfaces for different types of services [17].
For example, the home
interface gives a snap access to user folders. The dbus
interface allows access to the D-Bus on the host system. Some of the interfaces have more exotic capabilities: For example, the camera
interface lets a snap access a connected camera; tpm
lets the snap control a Trusted Platform Module (TPM) for cryptographic functions.
The Snap developers have also put some thought into the way snaps communicate with each other. An application that provides a service, can define a slot
in its YAML definition – say, a MySQL database. Another snap can define a Plug
, which then connects to the previously defined slot
(Figure 4).
The Big Difference: A Ready-Made Online Repository
The most striking difference between Flatpak and Snap is that Canonical is already running an online marketplace for ready-made snaps (Figure 5) [18]. The store offers snaps that administrators and developers have built for different use cases.
All snaps that end up in the Canonical Snap Store are digitally signed – users can therefore be sure that they are picking up the snaps from a safe source. (Flatpak is reportedly working on a similar feature.)
« Previous 1 2 3 4 Next »
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.
-
Linux Usage Increases in Two Key Areas
If market share is your thing, you'll be happy to know that Linux is on the rise in two areas that, if they keep climbing, could have serious meaning for Linux's future.
-
Vulnerability Discovered in xz Libraries
An urgent alert for Fedora 40 has been posted and users should pay attention.
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs
-
Juno Computers Launches Another Linux Laptop
If you're looking for a powerhouse laptop that runs Ubuntu, the Juno Computers Neptune 17 v6 should be on your radar.