Building my first Flatpak
First things first, I’ve had a SteamDeck for some time now. Even though you can use it for its primary purpose, playing games 😆, there’s so much you can do with it.
At my family’s home there is a radio antenna on the roof, that can be used with the typical ham radio handhelds and transceivers. In my case, I have it setup with a Raspberry Pi, a RTL-SDR v4 dongle connected to it and to the antenna. That way I can listen to HF, UHF and VHF bands from anywhere I want.
That concludes the server part. There are a few clients that can be used to connect to the Pi via RTL-TCP, some of them are GQRX, SDRSharp, CubicSDR, and SDR++. The former is what I have been using lately.
I was looking for a more portable way to access the SDR, so the SteamDeck was a perfect fit for this. There’s is only one problem, everything in SteamOS is usually installed via Flatpak because by default SteamOS sits behind an immutable file system, so having SDR++ via Flatpak would be great, but looking on the official repos there is no Flatpak package.
The beginning
This is a short definition about what a Flatpak is
Flatpak is a technology for distributing and running sandboxed desktop applications on Linux. It allows developers to package their applications with all necessary dependencies, making it easier to distribute software across different Linux distributions.
There are some basic things that are necessary for building a Flatpak:
- The YAML manifest: where modules, metadata and build steps are defined
- The icon and desktop file
This is an example of the manifest file:
id: org.sdrpp.App
runtime: org.kde.Platform
runtime-version: '5.15-23.08'
sdk: org.kde.Sdk
command: sdrpp
finish-args:
- --share=network
- --socket=pulseaudio
- --filesystem=home
- --device=usb
- --socket=x11
- --device=dri
modules:
- name: rtl-sdr
buildsystem: cmake
config-opts:
- -DINSTALL_UDEV_RULES=OFF
- -DDETACH_KERNEL_DRIVER=ON
sources:
- type: git
url: https://github.com/rtlsdrblog/rtl-sdr-blog.git
branch: v1.3.6
...
The runtime defines a set of libraries where the program is going to run on. In this case, SDR++ is a QT app so the KDE Runtime would guarantee the least hassle to make this run.
Each module defines a dependency, needed to build the software from source, you can also set where does it fetch the sources from with the sources:
tag, doesn’t matter if sources are local or not. After reading the SDR++ repo for quite a while i managed to gather all the module dependencies and their options. I only built this with the RTL-SDR driver and ‘didnt bother with compatibility for other drivers as that would have made the build process even more complex.
In finish-args you define the permissions the final app will need.
Handicaps
I had a few problems trying to run the app due to an error linking stdc++fs whilte trying to build the source. After battling a little bit with ChatGPT it led me to the right path: modify the upstream code so it doesn’t try to link stdc++fs
. (modern GCC versions (≥9) integrate std::filesystem directly into libstdc++, so explicitly linking -lstdc++fs results in an error because it doesn’t exist!)
Trial and error
I was building and trying to run the app with these commands:
flatpak-builder --force-clean build-dir org.sdrpp.App.yaml --install build-dir --user
flatpak run org.sdrpp.App.yaml
You can also open a shell inside the Flatpak environment like this for debugging:
flatpak run --command=sh --devel org.sdrpp.App
Now that was running it is time to add the icons and the .desktop file shortcut to make it pretty. You can check the repo here