How to build a flatpak of an SDL2 game (Commander Genius)

So Commander Genius (https://clonekeenplus.sourceforge.io/) using Flatpak. Why? Well, Flatpak is supported by many Linux distros and can be seen as a solution to the issue that there a lot of package managers out there and you have to maintain your software for each of those.

What about Snap?

Since it is owned and controlled by Canonical pretty much and I prefer to be more independent of them, I opted for Flatpak.

As Ubuntu User you need Flatpak Support?

Yes, but that’s no problem. Just install it by issuing:

sudo apt install flatpak 

and

sudo apt install gnome-software-plugin-flatpak

After that add the flatpak repo:

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

and you are good to go.

What about AppImage?

That could be an option but I also would like to appear in some software centers which are supported by a lot of linux distros nowadays. AppImage does not have that, because it is a self contained solution which can be accessed by going to a webpage and downloading it yourself.

So Flatpak. How did you create one?

So first you install the flatpak builder and a Freedesktop SDK. On Manjaro you type something like this:

pacman -S flatpak-builder
flatpak install flathub org.freedesktop.Platform//20.08 org.freedesktop.Sdk//20.08

Now in an empty directory just create a manifest file called io.sourceforge.clonekeenplus.yml in my case with these contents:

app-id: io.sourceforge.clonekeenplus
runtime: org.freedesktop.Platform
runtime-version: '20.08'
sdk: org.freedesktop.Sdk
command: CGeniusExe
rename-desktop-file: cgenius.desktop
rename-icon: cg

modules:
  - name: cgenius
    buildsystem: cmake
    sources:
      - type: git
        url: https://gitlab.com/Dringgstein/Commander-Genius.git
    config-opts:
      - -DUSE_SDL2=yes
      - -DUSE_BOOST=false
      - -DSHAREDIR=/app/share
      - -DAPPDIR=/app/bin
    builddir: true
    post-install:
      - for s in 16 32 48 64 128 256 512; do install -D -m 644 -t $FLATPAK_DEST/share/hicolor/${s}x${s}/>
      - install -D -m 644 -t $FLATPAK_DEST/share/icons/hicolor/scalable/apps ../share/cg.svg

finish-args:
  - --device=all # needed for gamepads
  - --share=ipc  # needed for X11
  - --share=network # needed for networking (App Store downloader)
  - --socket=x11
  - --socket=pulseaudio
  - --filesystem=home

This will pull the sources from gitlab, build the sources and puts them into a sandbox with these commands:

flatpak-builder --user --install inst-dir io.sourceforge.clonekeenplus.yml

and it also performs a user installation (make install).

Now just run the game:

flatpak run io.sourceforge.clonekeenplus

That wasn’t difficult, right. To be honest I was surprised how easy it is to create a Flatpak. The following documentation really helps you on that:

https://docs.flatpak.org/en/latest/introduction.html

Now you need to check how to publish your flatpak. Very popular is flathub and of course it is important to check their rules, if you want to land into their repo:

https://github.com/flathub/flathub/wiki/App-Submission

Or you host it on your own server/repo.

Das könnte dich auch interessieren …

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert