Fedora Magazine: Getting Started with Flatpak

Fedora is a distribution that does not shy away from emerging technology (after all, one of its founding principles is First). So it comes as no surprise that Fedora is on the leading edge of a revolutionary new software package system. This is not the first time Flatpak has been mentioned on the Magazine, but since Flatpak is so new, a lot has changed since last time.

What is Flatpak?

Flatpak can roughly be described as a modern replacement for RPMs, but its impact is far more significant than simply offering a new packaging format. Before we go into what Flatpak offers, first consider the current software delivery flow present in Fedora today.

  1. Upstream authors work away at a new version, ultimately producing an archive containing source code (frobnicate-0.4.2.tar.gz)
  2. Distribution packagers receive a notice that their upstream team has released a new version
  3. Distribution packagers download the source archive, and build the new version for all supported distributions, producing a binary RPM (frobnicate-0.4.2-1.fc26.x86_64.rpm) for each distribution
  4. Distribution packagers submit the binary RPMs to the appropriate update system, pushing the RPMs through the workflow so that…
  5. Finally a user can download the new version of frobnicate (dnf upgrade frobnicate)

This process from start to finish can take anywhere from a few days to months or more. Flatpak provides tooling to both the upstream developer and the end user that dramatically shortens the time between an upstream release and a binary arriving in a user’s dnf update. Now let’s revisit frobnicate, but with Flatpak in place both with the upstream developer and the end user.

  1. Upstream authors work away at a new version, ultimately producing an archive containing source code (frobnicate-0.4.2.tar.gz)
  2. Upstream authors build a Flatpak repository using flatpak-builder
  3. Upstream authors push the new repository to a URL already known to their users and/or advertised on the project website
  4. End user receives the new version of frobnicate during flatpak update

Flatpak directly connects the upstream author  with the end user; there are no distribution intermediaries involved. Flatpak uses OSTree to build a file-system containing all the dependent libraries and files necessary to run the desired program. This means a single Flatpak repository can run on all Linux distributions capable of running the flatpak program. In addition, because OSTree repositories can be branched, different versions of the same program can be installed at the same time (Imagine having both a stable, released version installed as well as a nightly developer version!). Finally, Flatpak runs each program inside a sandbox environment, requesting permission from the user before accessing hardware devices or files.

Set up repositories

Anyone can host a Flatpak repository, but it requires a server and some tooling to maintain. As a result, a few software teams have coalesced around a couple different major repositories.

GNOME

The GNOME development team hosts a repository containing nightly builds of all the core GNOME apps, as well as many additional applications. To add the gnome-nightly repository, open Terminal and run:

flatpak remote-add --if-not-exists gnome-nightly https://sdk.gnome.org/gnome-nightly.flatpakrepo
flatpak remote-add --if-not-exists gnome-apps-nightly https://sdk.gnome.org/gnome-apps-nightly.flatpakrepo

Flathub

A team of Flatpak developers have started a project known as Flathub. Flathub aims to provide a centralized repository for making Flatpak applications available to users. Flathub covers more than the GNOME application suite, and is regularly adding new applications. To add the Flathub repository, open Terminal and run:

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

Applications

GNOME Software already supports Flatpak repositories, so applications can be installed either with GNOME Software or with the flatpak command. Launch Software from the Overview, click the Search button and search for the desired application. If it is available in the traditional Fedora repositories as an RPM, there are two results.

  1. The entry labeled Source: fedoraproject.org is the RPM.
  2. The entry labeled Source: sdk.gnome.org is the Flatpak.

Select the Flatpak entry and click Install.

Once installed, Polari can be launched from the Overview like any other application; the GNOME shell already supports Flatpak applications.

The flatpak command also lists and installs apps and runtimes. To list all apps available in a specific repository, run the remote-ls command:

flatpak remote-ls flathub --app

Install an app with the install command:

flatpak install flathub com.valvesoftware.Steam

Once installed, the run command will run the application:

flatpak run com.valvesoftware.Steam

Build your own

Can’t find your favorite applications on Flathub or elsewhere as a Flatpak? Building your own is actually fairly straightfoward. If you are comfortable compiling software “by hand”, creating a Flatpak repository will seem quite familar. Flatpak repositories can be built a couple different ways, but the simplest method is to create a JSON formatted file called a “manifest”. For example, take the GNOME Dictionary:

{
  "app-id": "org.gnome.Dictionary",
  "runtime": "org.gnome.Platform",
  "runtime-version": "3.22",
  "sdk": "org.gnome.Sdk",
  "command": "gnome-dictionary",
  "finish-args": [
     "--socket=x11",
     "--share=network"
  ],
  "modules": [
    {
      "name": "gnome-dictionary",
      "sources": [
        {
          "type": "archive",
          "url": "https://download.gnome.org/sources/gnome-dictionary/3.20/gnome-dictionary-3.20.0.tar.xz",
          "sha256": "efb36377d46eff9291d3b8fec37baab2355f9dc8bc7edb791b6a625574716121"
        }
      ]
    }
  ]
}

Save this to a file, and run flatpak-builder to create a repository.

$ flatpak-builder gnome-dictionary-app-dir org.gnome.Dictionary.json

Resources

There are a growing number of useful resources for building and using Flatpaks.


Source From: fedoraplanet.org.
Original article title: Fedora Magazine: Getting Started with Flatpak.
This full article can be read at: Fedora Magazine: Getting Started with Flatpak.

Advertisement
directory-software-online-bussiness-script


Random Article You May Like

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*