An Introduction to Flatpak App Bundles

Ordinarily, Flatpak is utilized by querying online repositories for software to download and install. Installing an application from a repository (like FlatHub) means that it is very easy to maintain updates for the application and others that have been installed via Flatpak. However, Flatpak also gives us the option to install individual applications with the .flatpak extension.

This can be useful in situations where a developer has created some software that can be installed with Flatpak, but has not yet uploaded the application to a central repository for distribution and organized updates. These individual installations are distributed in what is called single-file bundles.

In this tutorial, you will learn how to get started with Flatpak app bundles by seeing how to create an app bundle and install it with Flatpak on a Linux system.

In this tutorial you will learn:

  • How to create a single app bundle in Flatpak
  • How to install and run a single app bundle
An Introduction to Flatpak App Bundles
An Introduction to Flatpak App Bundles
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

An Introduction to Flatpak App Bundles



Twitter icon Follow LinuxConfig.org on Twitter for the latest tips and tricks about Linux!

DID YOU KNOW?
Flatpak single-file bundles do not provide the user with an easy way to keep their software up to date, which is the main reason that the preferred method is to upload your work to a Flatpak remote. Furthermore, dependencies can not be automatically identified and downloaded when installing single file bundles.
  1. First we will need to download and install a runtime and SDK, as every Flatpak app requires a runtime, and the SDK is required in order to build and package the app. Install the Freedesktop 22.08 runtime with the following command:
    $ flatpak install flathub org.freedesktop.Platform//22.08 org.freedesktop.Sdk//22.08
    
  2. Create your app. If you do not already have an application that you wish to package, and just want to run this as a test, create a simple Hello World script:
    #!/bin/bash
    echo "Hello World!"
    

    Save your file as hello.sh

  3. You will also need a manifest file alongside your application. Again, just for testing purposes, we can create a simple Hello World manifest file:
    app-id: org.flatpak.Hello
    runtime: org.freedesktop.Platform
    runtime-version: '22.08'
    sdk: org.freedesktop.Sdk
    command: hello.sh
    modules:
      - name: hello
        buildsystem: simple
        build-commands:
          - install -D hello.sh /app/bin/hello.sh
        sources:
          - type: file
            path: hello.sh
    

    Save this file as org.flatpak.Hello.yml and store it in the same directory as your application or hello.sh file created above.

  4. Next, use the flatpak-builder command to create the application.
    $ flatpak-builder build-dir org.flatpak.Hello.yml
    
    Building our single app bundle in Flatpak
    Building our single app bundle in Flatpak
  5. To install the single app bundle as an individual application, we will use the following command:
    $ flatpak-builder --user --install --force-clean build-dir org.flatpak.Hello.yml
    
  6. Then we can run our application with:
    $ flatpak run org.flatpak.Hello
    


Closing Thoughts

In this tutorial, we saw how to create and install a single app bundle in Flatpak on a Linux system. Although Flatpak normally operates by downloading installing software from a repository, it also gives us the option to install and distribute individual application files without the need to host or upload them to a software repository.



Comments and Discussions
Linux Forum