Flatpak

Flatpak is a open source framework which is used to build Linux applications which will be distribution agnostic in simpler terms you build a application in Ubuntu distro and you can run it on a RedHat Linux Distro with flatpak.There are also other open source frameworks such as AppImage and Snapcraft. The former doesn’t have a corporate support and the latter is supported by canonical.The execution speed is good in flatpak compared to snapcraft and flatpak is backed by RedHat.

Why is this gaining importance ?

Usually developers who need to write apps for linux and publish it need not release multiple versions for each and every distributions.The switching from one version to another is as simple as a switch in git branch which helps the users of the applications to navigate between releases . The apps do not rely on the underlying packages as it runs on the sandbox environment . Lastly security isn’t compromised as you are running on a different namespace backed by bubblewrap which works similar to lxc and dockers so integrating 3rd party apps on product is very easy.

How does flatpak work ?

Flatpak uses sandbox to run application the difference between a container and a sandbox is that access to user files, network, graphics and sockets should be explicitly granted.

Installing flatpak on ubuntu

The packages are not used on flatpak since snapcraft is used in ubuntu

sudo add-apt-repository ppa:alexlarsson/flatpak

sudo apt update

sudo apt install flatpak

There are multiple options which are available while using flatpak like building your application, host a flatpak repository and using applications which are already available on the flathub repository which are platform agnostic

To build the simple application and add it in repo please refer here

To install the application which are already available on the flathub repo refer here to select the distribution list and add the repo in your machine and then install apps from here

Flatpak 0.8.9 on arm64

In this blog flatpak buliding on an older version i.e 0.8.9 since i had to use this due to libc dependency 2.14 for arm64 architecture for my work. Please refer to the latest documentation since there are a lot of changes.

To keep things as simple as possible i have created a tar file which you can untar and directly run flatpak and build apps

Download the required package libs from below link and copy to / directory and extract

tar -xvf mylibs.gz

https://drive.google.com/file/d/19EHlQJ6dgEle91kURcdBCNGAiXKiKwnL/view?usp=sharing

by default flatpak uses root partitions for building apps ,however this can be configured

Install flatpak in custom location
vi /etc/flatpak/installations.d/extra.conf
[Installation "extra"]
Path=/home/flatpak/
DisplayName=Extra Installation
StorageType=harddisk

Sample hello world source

https://drive.google.com/file/d/1zWjfxdzSMh_uX4ZqOLVy1XFkCeWuYNf_/view?usp=sharing

tar -cvzf my.tar.gz -C sample/ .
flatpak-builder --disable-cache build-dir org.flatpak.Hello.json --force-clean --repo=repo
flatpak --installation=extra --user remote-add --no-gpg-verify tutorial-repo repo
flatpak build-update-repo tutorial-repo
flatpak --installation=extra --user install tutorial-repo org.flatpak.Hello
flatpak run org.flatpak.Hello

If you see any issues feel free to contact me

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.