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
-
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.
-
ZorinOS 17.1 Released, Includes Improved Windows App Support
If you need or desire to run Windows applications on Linux, there's one distribution intent on making that easier for you and its new release further improves that feature.
-
Linux Market Share Surpasses 4% for the First Time
Look out Windows and macOS, Linux is on the rise and has even topped ChromeOS to become the fourth most widely used OS around the globe.
-
KDE’s Plasma 6 Officially Available
KDE’s Plasma 6.0 "Megarelease" has happened, and it's brimming with new features, polish, and performance.
-
Latest Version of Tails Unleashed
Tails 6.0 is based on Debian 12 and includes GNOME 43.
-
KDE Announces New Slimbook V with Plenty of Power and KDE’s Plasma 6
If you're a fan of KDE Plasma, you'll be thrilled to hear they've announced a new Slimbook with an AMD CPU and the latest version of KDE Plasma desktop.
-
Monthly Sponsorship Includes Early Access to elementary OS 8
If you want to get a glimpse of what's in the pipeline for elementary OS 8, just set up a monthly sponsorship to help fund its continued existence.