[Linux] Flatpak packaging request
Would be nice if this was available on https://flathub.org/
I made a manifest over here: https://github.com/renner0e/flathub/tree/io.github.kavishdevar.Librepods
currently it fails with this error:
finn@bazzite:~/librepodssetup/flathub$ just run
flatpak run io.github.kavishdevar.Librepods
airpodsApp: Initializing AirPodsTrayApp
airpodsApp: Connected to MPRIS service: "org.mpris.MediaPlayer2.firefox.instance_1_351"
airpodsApp: Ear detection behavior is already set to: 0
airpodsApp: Connecting to device: "Yessin’s AirPods"
airpodsApp: AirPodsTrayApp initialized
airpodsApp: Socket error: QBluetoothSocket::SocketError::ServiceNotFoundError , "Service cannot be found"
airpodsApp: Retrying connection (attempt 1 )
error: Recipe `run` failed on line 13 with exit code 139
the binary itself works if you just execute it. Probably needs some weird permission or something.
I don't have the hardware myself so I can't really test this :(
Thank you for your work! I also tried it, but also got an error. the app itself opens/works, but we get a error for the Bluetooth service discovery, which is needed for the app to work. I thinking we would have to create a issue at the Flatpak Qt runtime repo
there are other Bluetooth QT apps on flathub. Maybe we can look at what they do? https://github.com/EbonJaeger/bluejay/
hello @renner0e, I've encountered the same issue while packaging librepods in a fedora container. The missing dependency is bluez.
Running this on fedora container fixed it: sudo dnf install bluez
I suspect it is missing from KDE runtime as well.
correct it's not added in the kde runtime, but the fdo one has it already, this is not the issue I think
flatpak run --user --command=cat org.freedesktop.Sdk//25.08 /usr/manifest.json | jq -r '."modules"|.[]|."name"'|sed -E 's#.*/(.*)\.bst#\1#' | sort -u | grep -i bluez
bluez-base
bluez-libs
You're right, for flatpak it was not bluez the issue.
Anyway, I looked at the CMakeLists.txt and the minimum QT6 version is: 6.4 After changing the runtime and Sdk to 6.4 the app runs without issues.
This is what I observed:
- 6.3 - doesn't compile
- 6.4 - OK
- 6.5 - OK
- 6.6 - OK
- 6.7 - Crash
- 6.8 - Crash
- 6.9 - Crash
The issue now is that all those that are OK are EOL runtimes.
You're right, for flatpak it was not the bluez the issue.
Anyway, I looked at the CMakeLists.txt and the minimum QT6 version is: 6.4 After changing the runtime and Sdk to 6.4 the app runs without issues.
This is what I observed:
- 6.3 - doesn't compile
- 6.4 - OK
- 6.5 - OK
- 6.6 - OK
- 6.7 - Crash
- 6.8 - Crash
- 6.9 - Crash
The issue now is that all those that are OK are EOL runtimes.
Thank you for investigating that!
I have removed the specific version requirement. And, I tested on my PC without flatpak. Lemme know if anything else is needed for flatpak.
funnily enough, at some point the application stopped building for me
FB: Running 'flatpak build --die-with-parent --env=FLATPAK_BUILDER_BUILDDIR=/run/build/librepods --nofilesystem=host:reset --filesystem=/var/home/user/git/flatpaks/librepods/.flatpak-builder/build/librepods-1 --bind-mount=/home/user/git/flatpaks/librepods/.flatpak-builder/build/librepods-1=/var/home/user/git/flatpaks/librepods/.flatpak-builder/build/librepods-1 --bind-mount=/run/build/librepods=/var/home/user/git/flatpaks/librepods/.flatpak-builder/build/librepods-1 --bind-mount=/run/active-build=/var/home/user/git/flatpaks/librepods/.flatpak-builder/build/librepods-1 --build-dir=/run/build/librepods/linux/_flatpak_build --bind-mount=/run/ccache=/home/user/git/flatpaks/librepods/.flatpak-builder/ccache --env=SOURCE_DATE_EPOCH=1760964324 '--env=CFLAGS=-O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer ' '--env=CXXFLAGS=-O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer ' '--env=LDFLAGS=-L/app/lib -Wl,-z,relro,-z,now -Wl,--as-needed ' --env=CCACHE_DIR=/run/ccache/disabled --env=PATH=/app/bin:/usr/bin --env=LD_LIBRARY_PATH=/app/lib --env=PKG_CONFIG_PATH=/app/lib/pkgconfig:/app/share/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig --env=FLATPAK_BUILDER_N_JOBS=24 /home/user/git/flatpaks/librepods/.flatpak-builder/rofiles/rofiles-MRVzDS cmake '-DCMAKE_INSTALL_PREFIX:PATH='\''/app'\''' '-DCMAKE_INSTALL_LIBDIR:PATH='\''lib'\''' -G Ninja .. -DCMAKE_BUILD_TYPE=Release' on host
-- The CXX compiler identification is GNU 14.3.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Performing Test HAVE_STDATOMIC
-- Performing Test HAVE_STDATOMIC - Success
-- Found WrapAtomic: TRUE
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so
-- Found WrapOpenGL: TRUE
-- Found WrapVulkanHeaders: /usr/include
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "3.3.5")
-- Found PkgConfig: /usr/bin/pkg-config (found version "2.5.1")
-- Checking for module 'libpulse'
-- Found libpulse, version 17.0-dirty
CMake Warning (dev) at /usr/lib/x86_64-linux-gnu/cmake/Qt6Core/Qt6CoreMacros.cmake:3458 (message):
Qt policy QTP0001 is not set: ':/qt/qml/' is the default resource prefix
for QML modules. Check https://doc.qt.io/qt-6/qt-cmake-policy-qtp0001.html
for policy details. Use the qt_policy command to set the policy and
suppress this warning.
Call Stack (most recent call first):
/usr/lib/x86_64-linux-gnu/cmake/Qt6Qml/Qt6QmlMacros.cmake:740 (__qt_internal_setup_policy)
/usr/lib/x86_64-linux-gnu/cmake/Qt6Qml/Qt6QmlMacros.cmake:1296 (qt6_add_qml_module)
CMakeLists.txt:44 (qt_add_qml_module)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring done (0.6s)
-- Generating done (0.0s)
-- Build files have been written to: /run/build/librepods/linux/_flatpak_build
FB: host_command_exited_cb 14832 0
FB: Running 'flatpak build --die-with-parent --env=FLATPAK_BUILDER_BUILDDIR=/run/build/librepods --nofilesystem=host:reset --filesystem=/var/home/user/git/flatpaks/librepods/.flatpak-builder/build/librepods-1 --bind-mount=/home/user/git/flatpaks/librepods/.flatpak-builder/build/librepods-1=/var/home/user/git/flatpaks/librepods/.flatpak-builder/build/librepods-1 --bind-mount=/run/build/librepods=/var/home/user/git/flatpaks/librepods/.flatpak-builder/build/librepods-1 --bind-mount=/run/active-build=/var/home/user/git/flatpaks/librepods/.flatpak-builder/build/librepods-1 --build-dir=/run/build/librepods/linux/_flatpak_build --bind-mount=/run/ccache=/home/user/git/flatpaks/librepods/.flatpak-builder/ccache --env=SOURCE_DATE_EPOCH=1760964324 '--env=CFLAGS=-O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer ' '--env=CXXFLAGS=-O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer ' '--env=LDFLAGS=-L/app/lib -Wl,-z,relro,-z,now -Wl,--as-needed ' --env=CCACHE_DIR=/run/ccache/disabled --env=PATH=/app/bin:/usr/bin --env=LD_LIBRARY_PATH=/app/lib --env=PKG_CONFIG_PATH=/app/lib/pkgconfig:/app/share/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig --env=FLATPAK_BUILDER_N_JOBS=24 /home/user/git/flatpaks/librepods/.flatpak-builder/rofiles/rofiles-MRVzDS ninja -j24 -l48' on host
[28/39] Building CXX object CMakeFiles/librepods.dir/ble/bleutils.cpp.o
/run/build/librepods/linux/ble/bleutils.cpp: In static member function ‘static QByteArray BLEUtils::e(const QByteArray&, const QByteArray&)’:
/run/build/librepods/linux/ble/bleutils.cpp:72:28: warning: ‘int AES_set_encrypt_key(const unsigned char*, int, AES_KEY*)’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
72 | if (AES_set_encrypt_key(reinterpret_cast<const unsigned char *>(reversedKey.constData()), 128, &aesKey) != 0)
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /run/build/librepods/linux/ble/bleutils.cpp:1:
/usr/include/openssl/aes.h:51:5: note: declared here
51 | int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
| ^~~~~~~~~~~~~~~~~~~
/run/build/librepods/linux/ble/bleutils.cpp:78:16: warning: ‘void AES_encrypt(const unsignedchar*, unsigned char*, const AES_KEY*)’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
78 | AES_encrypt(reinterpret_cast<const unsigned char *>(reversedData.constData()), out, &aesKey);
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/openssl/aes.h:57:6: note: declared here
57 | void AES_encrypt(const unsigned char *in, unsigned char *out,
| ^~~~~~~~~~~
/run/build/librepods/linux/ble/bleutils.cpp: In static member function ‘static QByteArray BLEUtils::decryptLastBytes(const QByteArray&, const QByteArray&)’:
/run/build/librepods/linux/ble/bleutils.cpp:120:28: warning: ‘int AES_set_decrypt_key(const unsigned char*, int, AES_KEY*)’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
120 | if (AES_set_decrypt_key(reinterpret_cast<const unsigned char *>(key.constData()), 128, &aesKey) != 0)
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/openssl/aes.h:54:5: note: declared here
54 | int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
| ^~~~~~~~~~~~~~~~~~~
/run/build/librepods/linux/ble/bleutils.cpp:132:20: warning: ‘void AES_cbc_encrypt(const unsigned char*, unsigned char*, size_t, const AES_KEY*, unsigned char*, int)’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
132 | AES_cbc_encrypt(reinterpret_cast<const unsigned char *>(block.constData()), out,16, &aesKey, iv, AES_DECRYPT);
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/openssl/aes.h:66:6: note: declared here
66 | void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
| ^~~~~~~~~~~~~~~
[36/39] Building CXX object CMakeFiles/libre....dir/librepods_autogen/mocs_compilation.cpp.oFB: host_command_exited_cb 14953 35072
Error: module librepods: Child process exited with code 137
FB: Unmounting read-only fs: fusermount -uz /home/user/git/flatpaks/librepods/.flatpak-builder/rofiles/rofiles-MRVzDS
I can still build it
flatpak run org.flatpak.Builder --force-clean --install --install-deps-from=flathub build --user io.github.kavishdevar.Librepods.yaml
app-id: io.github.kavishdevar.Librepods
runtime: org.kde.Platform
sdk: org.kde.Sdk
runtime-version: "6.6"
base-version: "6.6"
command: librepods
finish-args:
- --share=ipc
- --socket=session-bus # For MPRIS (media player control)
- --socket=system-bus # For BlueZ (Bluetooth daemon)
- --socket=pulseaudio # For audio control (pactl) - use pipewire if on PipeWire
- --allow=bluetooth # For direct Bluetooth access
- --socket=wayland # For Wayland compatibility
- --socket=fallback-x11 # For X11 compatibility
- --filesystem=~/.config/AirPodsTrayApp # To save QSettings
- --filesystem=xdg-config/autostart # For autostart functionality
- --device=all # For full hardware access
- --talk-name=org.bluez # Explicit BlueZ D-Bus access
- --share=network
modules:
- name: librepods
buildsystem: cmake-ninja
builddir: true
subdir: linux
config-opts:
- -DCMAKE_BUILD_TYPE=Release
sources:
- type: git
url: https://github.com/kavishdevar/librepods
commit: e437572355d7390cd51dcd16ee5456ce8abf3cab
Huh, I don't understand the problem here:
flatpak run --command=sh --allow=bluetooth org.freedesktop.Sdk//24.08
[📦 org.freedesktop.Sdk ~]$ python3
Python 3.12.12 (main, Nov 10 2011, 15:00:00) [GCC 14.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> sock = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_SEQPACKET, socket.BTPROTO_L2CAP)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.12/socket.py", line 233, in __init__
_socket.socket.__init__(self, family, type, proto, fileno)
OSError: [Errno 97] Address family not supported by protocol
Does anyone know how to get around this?
sock = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_SEQPACKET, socket.BTPROTO_L2CAP)
this seems to work, you need network permission
flatpak run --command=sh --allow=bluetooth --share=network org.freedesktop.Sdk//25.08
[📦 org.freedesktop.Sdk ~]$ python3
Python 3.13.8 (main, Nov 10 2011, 15:00:00) [GCC 15.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> sock = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_SEQPACKET, socket.BTPROTO_L2CAP)
>>>
oh, who could've guessed that the bluetooth permission isn't sufficient for bluetooth! thanks!
In the works! No platform-dependent stuff.
(And yes, I am gonna add support for various headphones, not just AirPods, similar to MagicPods for Windows)
Now the only problem is CI, I think flathub doesn't allow the build process to have network access, so I would probably have to put all crates in a tarball that can be downloaded and built. Any better suggestions? Flathub says that they could make exceptions, but I don't know if it's worth the effort.
Alternatively, (I know the description of the issue says Flathub), I could host a flatpakrepo too.
Open for suggestions! I am looking for ways to package and distribute the new app.
@kavishdevar use this https://github.com/flatpak/flatpak-builder-tools/tree/master/cargo
Flathub will not allow network access during the build, you'd throw out all the reproducibility out the window.
you may want to consider a maintenance script like this here
https://github.com/flathub/io.github.doukutsu_rs.doukutsu-rs/blob/master/update-deps.sh
building a flatpak in ci could be as easy as this https://github.com/wwmm/easyeffects/blob/master/.github/workflows/CI.yaml
or this https://github.com/kolunmi/bazaar/blob/master/.github/workflows/build-flatpak.yml
Exactly what I was need- thank you, @renner0e!