Flatpak offline repository usage

There may be a case where you need to use Flatpak offline, such as in a secure environment that has computers which are restricted from accessing remote Flatpak repositories such as FlatHub. In such a case, it is possible to create your own offline Flatpak repo, load it with the software you choose, and then allow other computers to download software from it. In this tutorial, you will learn how to create an offline Flatpak repository that you can install Flatpak applications from on a Linux system.

In this tutorial you will learn:

  • How to create an offline Flatpak repository
  • How to install applications from an offline Flatpak repository
Flatpak offline repository usage
Flatpak offline repository usage
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software Flatpak package manager
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Flatpak offline repository usage – step by step instructions

In the steps below, we will create an offline Flatpak repository and put one application (gedit) inside of it. Afterwards, you can transport this offline repository to another system (via USB drive, for example) or share it out over the local network, and then install applications from the offline Flatpak repo.

  1. First, we are assuming that you already have a Flatpak application installed which you want to include in your new offline repository. As an example, we have installed gedit (GNOME text editor) from FlatHub, and plan to include it in an offline Flatpak repo. Start by identifying the application ID with the following command:
    $ flatpak list --app

    In our case, the application ID is org.gnome.gedit. Take note of this for later.

  2. The other thing you will need to know is the origin of the application. In other words, from which remote it was installed. You can see this information by executing:
    $ flatpak info -o org.gnome.gedit

    As you can see from our output, the org.gnome.gedit application was installed via flathub. Again, keep your results in mind for later.

  3. The original remote will need to have a collection ID configured. You can see if yours does by executing the following command and checking the “collection ID” column:
    $ flatpak remotes -d

    If not, execute the following command to configure a collection ID (substitute your own values where appropriate):

    $ sudo flatpak remote-modify --collection-id=org.flathub.Stable flathub

  4. Next, we will use the flatpak create-usb command to create an offline Flatpak repo. This command is intended to turn your USB drive into an offline Flatpak remote, but keep in mind that you can just use it on a normal directory if you do not want to load the remote onto a flash drive. It is up to you. Let’s put our gedit application into the following directory:
    $ flatpak create-usb /home/linuxconfig/offline-repo org.gnome.gedit
    The flatpak create-usb command has finished copying over all the necessary files for gedit
    The flatpak create-usb command has finished copying over all the necessary files for gedit
  5. Once that command finishes running and copying all of the necessary files over, we are ready to install gedit on some other computer by using this offline repo. You can either put the files onto a flash drive or share them out over your local network. Then, on the PC which you want to install the application, execute:
    $ sudo flatpak install --sideload-repo=/home/linuxconfig/offline-repo/.ostree/repo flathub org.gnome.gedit

    Of course, remember to replace /home/linuxconfig/offline-repo with your own Flatpak repo’s location, and replace flathub with the original origin remote, and org.gnome.gedit with the appropriate application ID.

    Installing an application from offline repo in Flatpak
    Installing an application from offline repo in Flatpak

Closing Thoughts

In this tutorial, we saw how to create an offline Flatpak repository on a Linux system and install applications from that repository. This is a great way to offer software to secure environments that do not have regular access to a remote repository such as FlatHub. It gives system administrators a means to curate their own catalog of installable Flatpak software and share it out to the rest of the network as they see fit. It also gives users a way to transport installable software to multiple PCs via USB flash drive.

Comments and Discussions
Linux Forum