English Portuguese (Brazil)
Packaging Tutorial
Creating a Flatpak of an application that is already packaged in Fedora involves two steps. First you need to create a module for the application. This module will be used to rebuild the application RPM and RPMs. Then you need to create a container out of the module. In the Fedora context, flatpaks are just another form of container, and are handled very similar to the Docker containers used for server applications.
Just as for packages, the instructions for building modules and containers are stored in git on src.fedoraproject.org and builds are coordinated by koji.fedoraproject.org. The flatpak for a an application can be found on src.fedoraproject.org in the repository `flatpaks/<application>`; this git repository contains two files: `<application>.yaml`, which defines the contents of the module, and `container.yaml`, which defines how the module is turned into a Flatpak container.
Install the necessary tools:
$ sudo dnf install flatpak-module-tools fedmod
Make sure that your user is in the `mock` group (both local module builds and local container builds use https://github.com/rpm-software-management/mock/wiki[mock]).
$ sudo usermod -a -G mock $USER
(You may need to log out and log back in.)
And install the Fedora Flatpak Runtime if you don't already have it installed:
$ flatpak remote-add fedora-testing oci+https://registry.fedoraproject.org#testing
$ flatpak remote-modify --enable fedora-testing
$ flatpak install fedora-testing org.fedoraproject.Platform/x86_64/f33
Creating `<application>.yaml` and `container.yaml`
$ mkdir feedreader && cd feedreader
$ fedmod fetch-metadata
$ fedmod rpm2flatpak --flatpak-common --flathub=feedreader feedreader
This generates initial versions of the two files. The `--flatpak-common` option makes the generated module depend on the flatpak-common module. This is not the default, since flatpak-common is still a bit experimental, but is often quite useful in making your module smaller and easier to build. The `--flathub=feedreader` option searches Flathub for an application whose name or application ID matches `feedreader`, and uses the Flathub manifest to initialize `container.yaml`. If multiple matches are found, they are displayed, and you'll need to re-run `fedmod rpm2flatpak` with a more specific search string.
First we'll look at the module definition file:
document: modulemd
version: 2
summary: RSS desktop client <1>
description: >- <1>
FeedReader is a modern desktop application designed to complement existing web-based
RSS accounts. It combines all the advantages of web based services like synchronization
across all your devices with everything you expect from a modern desktop application.
- buildrequires:
flatpak-common: [f33]
flatpak-runtime: [f33]
platform: [f33]
flatpak-common: [f33]
flatpak-runtime: [f33]
platform: [f33]
profiles: <2>
- feedreader
feedreader: <3>
buildorder: 10
rationale: Application package
ref: f33 <4>
gnome-online-accounts: <5>
rationale: Runtime dependency
ref: f33
gumbo-parser: <5>
rationale: Runtime dependency
ref: f33
libpeas: <5>
rationale: Runtime dependency
ref: f33
Source and description come from RPM metadata
The default profile lists RPMs to be included along with their dependencies