Kubefeeds Team A dedicated and highly skilled team at Kubefeeds, driven by a passion for Kubernetes and Cloud-Native technologies, delivering innovative solutions with expertise and enthusiasm.

Linux: An Intro to the Flatpak Universal Package Manager

4 min read

Once upon a time, installing applications on the Linux operating system was challenging. When I first started using Linux back in 1997, all applications had to be installed via source, which could lead to an infinite loop of dependency hell. To install A, you had to install B, but to install B, you had to install C, and to install C, you had to install D.

And on and on and on.

There were times when I’d give up trying to install a piece of software because I couldn’t figure out how to put that dependency puzzle together.

And then came dpkg and rpm, which made it slightly easier to install applications via binary files. The real change, however, came with the creation of apt and yum. Those package managers were able to handle dependency resolution with ease. Apt even had the ability to fix broken installations (with the apt-get install -f command).

Those package managers helped to elevate the Linux experience into new realms of user-friendliness and it no longer required a degree in computer science to use the open-source operating system.

Linux users were content with apt and yum (which was eventually replaced by dnf) but there was another issue — compatibility.

Here’s the problem: When a developer begins a project for the Linux operating system, they have to decide if they’re going to release the software for all Linux distributions, all desktop environments, and all window managers.

Or, do they only release their software for specific distributions, specific desktop environments, and specific window managers. Do they go with Ubuntu and its default desktop, or Fedora with KDE Plasma. Maybe a developer prefers the Budgie desktop and the Debian distribution?

The combinations can become endless and it’s often why a piece of software might be available for one distribution and not all of them. Imagine the time it would take to develop an application for every single combination found in Linux land.

That’s why universal package managers were created.

A universal package is an application bundled with all necessary dependencies and doesn’t interact with the hosting platform’s libraries. In some cases, Universal packages also automatically update and are more secure than applications installed via the standard means.

There are two main universal package managers, Snap and Flatpak. We’ve already discussed Snap, so this time around, we’re going to dive into Flatpak.

What Is Flatpak?

Flatpak is an open source framework for developing and distributing applications across multiple Linux distributions. Flatpak enables developers to package their applications such that they are portable, easy to install, and secure.

The benefits of Flatpak include:

  • Containerized applications — which means they contain everything necessary to install and run.
  • Sandboxed — Flatpak applications are isolated from the rest of the system.
  • Cross-distro compatible — Flatpak apps can be installed on any supporting distribution, regardless of the desktop environment.
  • Simplified updates — no matter how many Flatpak apps you have installed, you can update them all with the command sudo flatpak update. You can also update individual packages with sudo flatpak update PACKAGE (Where PACKAGE is the name of the package to be updated). Flatpak apps are also automatically updated 10 minutes after each boot.
  • Consistency — Flatpak ensures apps run in a consistent environment, regardless of the underlying system.
  • Third-party apps — you’ll find tons of third-party apps (even proprietary apps like Slack and Spotify) that can be installed via Flatpak.
  • GUIs — some distributions bake Flatpak support into their GUI app stores (such as GNOME software).

In the end, Flatpak is a simplified means of installing and managing applications on a Linux distribution.

Using Flatpak

Although many Linux distributions ship with Flatpak pre-installed (moreso than Snap), let’s assume your distribution of choice doesn’t include Flatpak out of the box. If that’s the case, here’s how to install it. I’ll demonstrate on both Ubuntu and Fedora.

On Ubuntu, the Flatpak installation goes like this:

sudo apt-get install flatpak -y

Once installed, you then have to enable the official Flathub repo with the command:

flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

If you do not run the above command, you’ll not be able to install any apps from Flathub because Flatpak will not know how to reach it.

After taking care of that, reboot your computer.

If your distribution makes use of GNOME software, install the required plugin to add Flatpak support with the command:

sudo apt-get install gnome-software-plugin-flatpak gnome-software -y

If you use Fedora, chances are pretty good that Flatpak is already installed. If, however, you find it’s not, you can take care of that with the command:

sudo dnf install flatpak -y

After doing that, you must enable Flathub with:

flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

Reboot and enjoy.

How To Install an App With Flatpak

The first thing you’ll want to do is visit Flathub, which is the official repository for Flatpak packages. From that site, you can search for and find any applications you might want to install. As well, when you click on a Flathub entry, you’ll be given the command to install the app in question.

For example, if you want to install Spotify via Flatpak, the command would be:

sudo flatpak install spotify

You’ll be asked to verify the package to be installed by either typing Y and hitting Enter or simply hitting Enter for the default (which is Yes). You then have to verify the installation by typing Y and then typing it again to proceed with the installation.

After the installation, if you don’t find the new app in your desktop menu, log out and log back in and it will appear.

If you want to remove a Flapak application, the command is:

sudo flatpak uninstall NAME

Where NAME is the name of the package to be removed.

You can list all installed Flatpak apps with the command:

flatpak list

From that list, you can then decide if there’s a particular package you want to update.

As I mentioned earlier, some distributions bake Flatpak into their app stores. For example, Fedora includes Flatpak in GNOME Software. If you find an app you want to install via GNOME Software, you should see a drop-down under the Install button, where you can select how the app is to be installed. In some cases (such as with Slack), Flatpak is the only option (Figure 1).

Screenshot

Figure 1: Installing Slack on Fedora with Flatpak in GNOME Software.

There you go; you should now know how to use Flatpak to install applications on any Linux distribution that supports the universal package manager.

The post Linux: An Intro to the Flatpak Universal Package Manager appeared first on The New Stack.

Kubefeeds Team A dedicated and highly skilled team at Kubefeeds, driven by a passion for Kubernetes and Cloud-Native technologies, delivering innovative solutions with expertise and enthusiasm.

Leave a Reply