Introduction
In this lab, we will explore the Flatpak package management tool for Linux. Flatpak is a modern and secure way to install and manage applications on your system, providing a consistent and isolated environment for each application. We will start by installing Flatpak and enabling the Flathub repository to access a wider range of applications. Then, we will learn how to search, install, and manage Flatpak applications on our Ubuntu 22.04 system. Finally, we will explore customizing Flatpak environments to suit our specific needs.
Introduction to Flatpak
In this step, we will explore the Flatpak package management tool for Linux. Flatpak is a modern and secure way to install and manage applications on your system, providing a consistent and isolated environment for each application.
First, let's install the Flatpak package on our Ubuntu 22.04 system:
sudo apt install -y flatpak
Example output:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
dbus-x11 flatpak-session-helper libdconf-dbus-1-0 libflatpak0 libostree-1-1 libsoup2.4-1 libsoup2.4-dev libsoup2.4-doc libsoup2.4-gir libsoup2.4-gir-dev
libsoup2.4-lang
Suggested packages:
libsoup2.4-dev
The following NEW packages will be installed:
dbus-x11 flatpak flatpak-session-helper libdconf-dbus-1-0 libflatpak0 libostree-1-1 libsoup2.4-1 libsoup2.4-dev libsoup2.4-doc libsoup2.4-gir libsoup2.4-gir-dev
libsoup2.4-lang
0 upgraded, 11 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,095 kB of archives.
After this operation, 15.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Next, let's enable the Flatpak repository to access a wider range of applications:
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
Example output:
Added remote flathub
Now, we can start exploring and installing Flatpak applications. In the next step, we will learn how to manage Flatpak applications on our system.
Installing and Managing Flatpak Applications
In this step, we will learn how to install and manage Flatpak applications on our Ubuntu 22.04 system.
First, let's search for available Flatpak applications on the Flathub repository:
flatpak search gimp
Example output:
Name Description Version Branch Remotes
org.gimp.GIMP The GNU Image Manipulation Program 2.10.30 stable flathub
To install the GIMP application as a Flatpak, we can use the following command:
sudo flatpak install flathub org.gimp.GIMP
Example output:
Looking for matches...
Found remote 'flathub'
Resolving dependencies...
Downloading metadata...
Downloading: org.gimp.GIMP/x86_64/stable (1/1)
Importing: org.gimp.GIMP/x86_64/stable (1/1)
Installation complete.
Now, let's launch the GIMP application using Flatpak:
flatpak run org.gimp.GIMP
This will start the GIMP application in a sandboxed environment provided by Flatpak.
To manage your installed Flatpak applications, you can use the following commands:
List all installed Flatpak applications:
flatpak list
Update all installed Flatpak applications:
sudo flatpak update
Remove a Flatpak application:
sudo flatpak uninstall org.gimp.GIMP
In the next step, we will explore how to customize Flatpak environments to suit your specific needs.
Customizing Flatpak Environments
In this final step, we will explore how to customize Flatpak environments to suit your specific needs.
Flatpak provides a way to create custom runtime environments for your applications. Runtimes are the underlying libraries and dependencies that an application requires to run. By using custom runtimes, you can ensure that your applications have access to the specific versions of libraries and dependencies they need, without conflicts with other applications.
Let's create a custom runtime for the GIMP application:
## Create a new Flatpak runtime
flatpak remote-add --if-not-exists flathub-beta https://flathub.org/beta-repo/flathub-beta.flatpakrepo
flatpak install flathub-beta org.gnome.Platform//43
## Create a custom GIMP runtime based on the GNOME platform
flatpak build-init gimp-runtime org.gimp.GIMP org.gnome.Platform//43
flatpak build gimp-runtime flatpak install flathub org.gimp.GIMP
flatpak build-finish gimp-runtime
flatpak build-export ~/project/gimp-runtime gimp-runtime
Now, we can install the GIMP application using our custom runtime:
flatpak install ~/project/gimp-runtime org.gimp.GIMP
flatpak run org.gimp.GIMP
This will launch the GIMP application using the custom runtime we created, ensuring that it has access to the specific libraries and dependencies it requires.
You can further customize the runtime by modifying the dependencies, environment variables, or other settings within the gimp-runtime directory.
Summary
In this lab, we first explored the Flatpak package management tool, which provides a modern and secure way to install and manage applications on Linux. We installed the Flatpak package and enabled the Flathub repository to access a wider range of applications. Next, we learned how to search for and install Flatpak applications from the Flathub repository. Finally, we discussed how to customize Flatpak environments by creating and managing Flatpak remotes and applications.



