Flatpak

From LinuxReviews
Jump to navigationJump to search
Flatpak
Flatpak.png
Original author(s)Alex Larsson
Developer(s)Alex Larsson and 140 minor contributors
Initial releaseSeptember 2015; 6 years ago (2015-09)
Stable release
1.8.2 / August 21, 2020; 16 months ago (2020-08-21)
Repositorygithub.com /flatpak/flatpak
Written inC
Operating systemLinux only
LicenseGNU LGPL
Flatpak.png

Flatpak is a distribution-independent package management tool for Linux from Sweden which can be used in addition or as a substitute for Linux-distribution specific package managers like apt or rpm. It was created by Swedish developer Alex Larsson using the C programming language in 2015.

Flatpak is popular among developers because it allows them to deploy packages that can be used on most Linux distributions from a central point they control.

Advantages For Developers[edit]

Linux distributions have their own maintainers who package software and make it available in whatever package format a Linux distribution happens to use. Individual software authors can make packages for Ubuntu, Debian, Fedora, Linux Mint and other distributions and make them available on their own. Doing so is a lot of work compared to making a single package available at flathub.org.

Developers can control and update the versions available at Flathub, or another site of their choosing, themselves. They have little or no say in what packages are and are not made available in the official repositories for Gentoo or Debian, making it hard to ensure that they carry the latest version.

Flatpak packages are mostly distributed through flathub.org. That puts the administrators of that site in the same kind of potential gate-keeper position Google and Apple are in with regards to their "Play" and "App" stores. Developers have the option of hosting their Flatpak packages using their own repositories if package censorship on Flathub becomes an issue.

Advantages For End-Users[edit]

The Flatpak packages on flathub.org can be, and sometimes are, more up-to-date than what the various Linux-distributions offer in their own repositories.

There is a lot of software available through flatpak that is not, and never will be, in many Linux distributions repositories. The most widely used Flathub repository Flathub has packages for a lot of non-free proprietary software like Spotify and Basemark GPU. Most Linux distributions do not allow evil binary blobs to be in their repositories for good reason. Flatpak/Flathub provides a way to easily install proprietary software and other software not in regular distribution repositories.

Disadvantages[edit]

Many Flatpak packages have dependencies and they tend to be gigantic. Flatpak dependencies tend to be "foundation libraries" which are, in practice, collections of lots and lots of different libraries that a package may or may use some of. These collections tend to be very huge terms of both download and install size.

Flatpak packages will download and use special Flatpak editions of common libraries even if newer and less buggy versions are installed as part of the regular system. This has some performance-implications and stability-implications. If you, as an example, download Basemark GPU from Flathub you'll end up benchmarking using an ancient version of the Mesa graphics library.

This really is a major disadvantage to using Flatpak which nobody seems to be willing to talk about.

Here is a concrete example of what happens if you enable the Flathub repository and try to install the Krita paint program from there:

flatpak remote-add flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak install flathub org.kde.krita

The "install" command will prompt Flatpak to ask the "simple" question:

Looking for matches…
Required runtime for org.kde.krita/x86_64/stable (runtime/org.kde.Platform/x86_64/5.14) found in remote flathub
Do you want to install it? [Y/n]:

Answering Yes to that question reveals the horrible truth behind that innocent-sounding statement:

Required runtime for org.kde.krita/x86_64/stable (runtime/org.kde.Platform/x86_64/5.14) found in remote flathub
Do you want to install it? [Y/n]: y

org.kde.krita permissions:
    ipc network pulseaudio x11 dri file access [1] dbus access [2] system dbus access [3]

    [1] host, xdg-config/kdeglobals:ro, xdg-run/gvfs
    [2] com.canonical.AppMenu.Registrar
    [3] org.freedesktop.ColorManager

     ID                                   Branch   Op  Remote    Download
 1.  org.freedesktop.Platform.GL.default  19.08    i   flathub   < 89.1 MB
 2.  org.freedesktop.Platform.openh264    2.0      i   flathub   < 1.5 MB
 3.  org.kde.Platform.Locale              5.14     i   flathub   < 337.6 MB (partial)
 4.  org.kde.Platform                     5.14     i   flathub   < 362.5 MB
 5.  org.kde.krita.Locale                 stable   i   flathub   < 5.0 MB (partial)
 6.  org.kde.krita                        stable   i   flathub   < 120.4 MB

Proceed with these changes to the system installation? [Y/n]:

The machine the above command was executed on already had Qt 5.14 and KDE Frameworks version 5.73.0 installed. This is where Flatpak has a clear inefficiency-problem: You will get many sometimes identical and sometimes older versions of libraries that are already installed by a distributions regular package management system.

Installing the Krita 4.3.0 Flatpak, and the required dependencies, results in a 1.6 GiB large /var/lib/flatpak/ directory. That's 6.7 times more than the AppImage and magnitudes more than the distributions native Krita package.

As a point of reference: the current Krita 5.0 pre-alpha AppImage, available from krita.org /en/download/krita-desktop/, is 239 MiB.

The "platform" dependencies consisting of large bundles like "org.kde.Platform" do have one advantage to them, they are not just pure piles of mostly bloat. Installing additional packages made for that specific version of "org.kde.Platform" would re-use the "org.kde.Platform" bundle. But it's not always that simple. Installing a simple program for KDE or GNOME frameworks may make Flatpak decide to not re-use an already installed framework bundle if the specific package you are trying to install wants version X.Y.1 and you have bundles of X.Y.3 installed. Installing just a hand-full of different GNOME and KDE programs using Flatpak can easily result in a 10+ GiB /var/lib/flatpak/. That may be a non-issue, and it probably is if your / is on a 2 TiB NVMe drive. It may be a problem if all you have is a 120 GiB SSD.

Usage[edit]

Flatpak packages can be installed or eradicated from graphical package management tools like KDE Plasma Discover.

The command-line flatpak, usually installable with dnf install flatpak or apt install flatpak, can be used to manage flatpak repositories, install packages and run software.

Managing repositories
Option Example Function
remote-add flatpak remote-add flathub https://flathub.org/repo/flathub.flatpakrepo Adds a Flatpak repository
remote-delete flatpak remote-delete flathub Removes a Flatpak repository
Managing packages
Option Example(s) Function
install flatpak install flathub org.mozilla.firefox Acquires and installs software. Flatpak will show what dependencies are required and prompt you to install those as well.
flatpak install flathub net.supertuxkart.SuperTuxKart
uninstall flatpak uninstall org.mozilla.firefox Eradicates software
list flatpak list Shows all the packages, and the "platform" libraries, installed by Flatpak
run flatpak run org.mozilla.firefox Launches software. Do packages tend to provide a .desktop file so they show up in your desktop environments menu so you rarely have to use the run option.
flatpak run net.supertuxkart.SuperTuxKart
update flatpak update Updates installed packages. You can use package names as arguments but you don't need to, running "flatpak update" will update whatever package you want a newer version of anyway.

For Developers[edit]

The KDE project has a useful page with documentation titled Distributing KDE Software as Flatpak at develop.kde.org.

Beneath The Hood[edit]

flatpak packages are, in their entirety, installed to subfolders in /var/lib/flatpak/. You will have a problem if your /var is on a separate partition with limited storage capacity. This is not a default on any GNU/Linux distribution but it may be an issue if you installed something like Gentoo Linux or Arch yourself.

"Home" Folders[edit]

flatpak sets $XDG_DATA_HOME, $XDG_CONFIG_HOME and $XDG_CACHE_HOME to a special $HOME/.var/app directory. This means that if an application like Mozilla Firefox stores settings in $HOME/.mozila/firefox then the Flatpak edition will store settings in $HOME/.var/app/org.mozilla.firefox/.mozilla/firefox and other data created by Firefox would be stored in $HOME/.var/app/org.mozilla.firefox/.

If an application running under Flatpak tells you that your settings are in $HOME/.somewhere then they are likely in reality in $HOME/.var/app/appname/.somewhere.

HOWTO Make GTK Flatpak Programs Use A Sane GTK theme[edit]

Flatpak runs in it's own little Sandbox. The system color theme and icons theme settings are not honored within that sandbox.

One solution to making GTK Flatpak applications use the same theme as your system theme is to install and use pakitheme from github.com/refi64/pakitheme.

There is no similar sane solution for the icons; though you can check if the icon theme you are using is available as a Flatpak and install it again.

Links[edit]

The repository for the Flatpak tool is at github.com/flatpak/flatpak.

flathub.org is the largest and in practice the de-facto Flatpak repository. It is run by people who call software "apps". It seems like a fine service even though it's clearly maintained by teenagers who are more familiar with smartphones than they are with desktop and laptop computers.


Add your comment
LinuxReviews welcomes all comments. If you do not want to be anonymous, register or log in. It is free.