From 83c5d15cdf808118c77fa2b6b2a9bfc77f353b37 Mon Sep 17 00:00:00 2001 From: AdenKoperczak Date: Sat, 31 May 2025 09:09:19 -0400 Subject: [PATCH 1/4] Working flatpak build --- .github/workflows/ci.yml | 38 ++++++++++++++++++- scwx-qt/res/linux/net.supercellwx.app.desktop | 7 ++++ tools/net.supercellwx.app.yml | 37 ++++++++++++++++++ 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 scwx-qt/res/linux/net.supercellwx.app.desktop create mode 100644 tools/net.supercellwx.app.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad80a89f..1d9cbd1c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -129,6 +129,8 @@ jobs: wayland-protocols \ libwayland-dev \ libwayland-egl-backend-dev \ + flatpak \ + flatpak-builder \ ${{ matrix.compiler_packages }} - name: Setup Python Environment @@ -261,7 +263,8 @@ jobs: - name: Build AppImage (Linux) if: ${{ startsWith(matrix.os, 'ubuntu') }} env: - APPIMAGE_DIR: ${{ github.workspace }}/supercell-wx/ + INSTALL_DIR: ${{ github.workspace }}/supercell-wx/ + APPIMAGE_DIR: ${{ github.workspace }}/supercell-wx-appimage/ LDAI_UPDATE_INFORMATION: gh-releases-zsync|dpaulat|supercell-wx|latest|*${{ matrix.appimage_arch }}.AppImage.zsync LDAI_OUTPUT: supercell-wx-${{ env.SCWX_VERSION }}-${{ matrix.appimage_arch }}.AppImage LINUXDEPLOY_OUTPUT_APP_NAME: supercell-wx @@ -272,6 +275,7 @@ jobs: chmod +x linuxdeploy-${{ matrix.appimage_arch }}.AppImage cp "${{ github.workspace }}/source/scwx-qt/res/icons/scwx-256.png" supercell-wx.png cp "${{ github.workspace }}/source/scwx-qt/res/linux/supercell-wx.desktop" . + cp -r "${{ env.INSTALL_DIR }}" "${{ env.APPIMAGE_DIR }}" pushd "${{ env.APPIMAGE_DIR }}" mkdir -p usr/ mv bin/ usr/ @@ -289,6 +293,38 @@ jobs: name: supercell-wx-appimage-${{ matrix.artifact_suffix }} path: ${{ github.workspace }}/*-${{ matrix.appimage_arch }}.AppImage* + - name: Build FlatPak (Linux) + if: ${{ startsWith(matrix.os, 'ubuntu') }} + env: + INSTALL_DIR: ${{ github.workspace }}/supercell-wx/ + FLATPAK_DIR: ${{ github.workspace }}/supercell-wx-flatpak/ + shell: bash + run: | + cp -r ${{ env.INSTALL_DIR }} ${{ env.FLATPAK_DIR }} + # Copy krb5 libraries to flatpak + cp /usr/lib/*/libkrb5.so* \ + /usr/lib/*/libkrb5support.so* \ + /usr/lib/*/libgssapi_krb5.so* \ + /usr/lib/*/libk5crypto.so* \ + /usr/lib/*/libkeyutils.so* \ + ${{ env.FLATPAK_DIR }}/lib + + flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo + flatpak-builder --force-clean \ + --user \ + --install-deps-from=flathub \ + --repo=flatpak-repo \ + --install flatpak-build \ + ${{ github.workspace }}/source/tools/net.supercellwx.app.yml + flatpak build-bundle flatpak-repo supercell-wx.flatpak net.supercellwx.app + + - name: Upload FlatPak (Linux) + if: ${{ startsWith(matrix.os, 'ubuntu') }} + uses: actions/upload-artifact@v4 + with: + name: supercell-wx-flatpak-${{ matrix.artifact_suffix }} + path: ${{ github.workspace }}/supercell-wx.flatpak + - name: Test Supercell Wx working-directory: ${{ github.workspace }}/build env: diff --git a/scwx-qt/res/linux/net.supercellwx.app.desktop b/scwx-qt/res/linux/net.supercellwx.app.desktop new file mode 100644 index 00000000..8e671522 --- /dev/null +++ b/scwx-qt/res/linux/net.supercellwx.app.desktop @@ -0,0 +1,7 @@ +[Desktop Entry] +Type=Application +Name=Supercell Wx +Comment=Weather Radar and Data Viewer +Exec=supercell-wx +Icon=net.supercellwx.app.png +Categories=Network;Science; diff --git a/tools/net.supercellwx.app.yml b/tools/net.supercellwx.app.yml new file mode 100644 index 00000000..9c4c3f72 --- /dev/null +++ b/tools/net.supercellwx.app.yml @@ -0,0 +1,37 @@ +id: net.supercellwx.app +version: '0.4.9' +runtime: "org.freedesktop.Platform" +runtime-version: "23.08" +sdk: "org.freedesktop.Sdk" +command: supercell-wx +modules: + - name: supercell-wx + buildsystem: simple + build-commands: + - install -Dm644 net.supercellwx.app.desktop /app/share/applications/${FLATPAK_ID}.desktop + - install -Dm644 scwx-256.png /app/share/icons/hicolor/256x256/apps/net.supercellwx.app.png + - install -Dm644 scwx-64.png /app/share/icons/hicolor/64x64/apps/net.supercellwx.app.png + - rm net.supercellwx.app.desktop scwx-256.png scwx-64.png + - cp -r * /app/ + sources: + - type: dir + path: ../../supercell-wx-flatpak + - type: file + path: ../scwx-qt/res/linux/net.supercellwx.app.desktop + - type: file + path: ../scwx-qt/res/icons/scwx-256.png + - type: file + path: ../scwx-qt/res/icons/scwx-64.png + +finish-args: + # X11 + XShm access + - --share=ipc + - --socket=fallback-x11 + # Wayland access + - --socket=wayland + # GPU acceleration if needed + - --device=dri + # Needs to talk to the network: + - --share=network + # Needs to save files locally + - --filesystem=xdg-documents From 0ff0f6ea17b43e788ce61ec820861b8c946a2347 Mon Sep 17 00:00:00 2001 From: AdenKoperczak Date: Sat, 7 Jun 2025 12:36:26 -0400 Subject: [PATCH 2/4] Add serial port permissions to flatpak --- tools/net.supercellwx.app.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/net.supercellwx.app.yml b/tools/net.supercellwx.app.yml index 9c4c3f72..a31fa255 100644 --- a/tools/net.supercellwx.app.yml +++ b/tools/net.supercellwx.app.yml @@ -31,6 +31,8 @@ finish-args: - --socket=wayland # GPU acceleration if needed - --device=dri + # Needs access to serial port devices + - --device=serial # Needs to talk to the network: - --share=network # Needs to save files locally From 28ca8df5df4ad9e6f5e0ce5108458afa2bbc24c7 Mon Sep 17 00:00:00 2001 From: AdenKoperczak Date: Sat, 7 Jun 2025 12:48:33 -0400 Subject: [PATCH 3/4] use a random pid instead of 2 to avoid overlap in flatpaks --- scwx-qt/source/scwx/qt/manager/log_manager.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scwx-qt/source/scwx/qt/manager/log_manager.cpp b/scwx-qt/source/scwx/qt/manager/log_manager.cpp index 7ab18e56..34facaa4 100644 --- a/scwx-qt/source/scwx/qt/manager/log_manager.cpp +++ b/scwx-qt/source/scwx/qt/manager/log_manager.cpp @@ -1,6 +1,8 @@ #include #include +#include +#include #include #include #include @@ -57,6 +59,14 @@ void LogManager::InitializeLogFile() QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) .toStdString(); p->pid_ = boost::this_process::get_id(); + if (p->pid_ == 2) + { + // The pid == 2 means that this is likely a flatpak. We assign a random + // number in this case to avoid overlap, scince it is always 2 in a + // flatpak + std::srand(std::time({})); + p->pid_ = std::rand(); + } p->logFile_ = fmt::format("{}/supercell-wx.{}.log", p->logPath_, p->pid_); // Create log directory if it doesn't exist From 52675721b4541751cf58aca443461cfe69986f52 Mon Sep 17 00:00:00 2001 From: AdenKoperczak Date: Sat, 7 Jun 2025 13:19:43 -0400 Subject: [PATCH 4/4] Flatpak does not have a specific one for serial, just for all --- tools/net.supercellwx.app.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/net.supercellwx.app.yml b/tools/net.supercellwx.app.yml index a31fa255..ced79027 100644 --- a/tools/net.supercellwx.app.yml +++ b/tools/net.supercellwx.app.yml @@ -30,9 +30,7 @@ finish-args: # Wayland access - --socket=wayland # GPU acceleration if needed - - --device=dri - # Needs access to serial port devices - - --device=serial + - --device=all # Needs to talk to the network: - --share=network # Needs to save files locally