From f6420f1380040e83ff44e6e1bc0a273e901b2d1f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?=
 <jeanmichael.celerier@gmail.com>
Date: Tue, 2 Jul 2024 09:33:41 -0400
Subject: [PATCH] [flatpak] Improve packaging

---
 .../Linux/Flatpak/io.ossia.score.metainfo.xml | 51 ---------------
 .../Deployment/Linux/ossia-score.appdata.xml  | 65 ++++++++++++++-----
 cmake/ScoreDeployment.cmake                   |  6 +-
 cmake/ScoreDeploymentGenericLinux.cmake       | 43 ------------
 cmake/ScoreDeploymentLinux.cmake              |  7 +-
 5 files changed, 54 insertions(+), 118 deletions(-)
 delete mode 100644 cmake/Deployment/Linux/Flatpak/io.ossia.score.metainfo.xml
 delete mode 100644 cmake/ScoreDeploymentGenericLinux.cmake

diff --git a/cmake/Deployment/Linux/Flatpak/io.ossia.score.metainfo.xml b/cmake/Deployment/Linux/Flatpak/io.ossia.score.metainfo.xml
deleted file mode 100644
index 31912e3255..0000000000
--- a/cmake/Deployment/Linux/Flatpak/io.ossia.score.metainfo.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<component type="desktop-application">
-  <id>io.ossia.score</id>
-  <metadata_license>CC-BY-SA-4.0</metadata_license>
-  <project_license>GPL-3.0</project_license>
-  <name>ossia score</name>
-  <summary>Sequencer for media artists</summary>
-  <developer id="io.github.ossia">
-    <name>ossia.io</name>
-  </developer>
-  <description>
-    ossia score is a sequencer for audio-visual artists, designed to enable the creation of interactive shows, museum installations, intermedia digital artworks, interactive music and more in an intuitive user interface.
-    
-    <ul>
-      <li>Sequence OSC, MIDI, DMX, sound, video and more, between multiple software and hardware. </li>
-      <li>Script and live-code with JavaScript, ISF Shaders, Faust, PureData or C++.</li>
-      <li>Leverage IoT protocols such as CoAP or MQTT for industrial-grade automation.</li>
-      <li>Interact with joysticks, Wiimotes, Leapmotions, Web APIs and BLE sensors.</li>
-      <li>Integrate programs from a wealth of creative programming languages such as Structure Synth, Context-Free Art and Bytebeat.</li>
-      <li>Load any kind of audio or video format and process visuals through Spout, Syphon, NDI or Shmdata.</li>
-    </ul>
-  </description>
-  <launchable type="desktop-id">io.ossia.score.desktop</launchable>
-  <content_rating type="oars-1.1" />
-  <url type="bugtracker">https://github.com/ossia/score/issues</url>
-  <url type="contact">https://discord.gg/8Hzm4UduaS</url>
-  <url type="contribute">https://ossia.io/project.html</url>
-  <url type="donation">https://opencollective.com/ossia</url>
-  <url type="help">https://ossia.io/docs.html</url>
-  <url type="homepage">https://ossia.io</url>
-  <url type="vcs-browser">https://github.com/ossia/score</url>
-  <screenshots>
-    <screenshot type="default">
-      <image>https://github.com/ossia/score/raw/master/docs/score.png?raw=true</image>
-      <caption>Sequence all kinds of media in ossia score</caption>
-    </screenshot>
-  </screenshots>
-  <releases>
-    <release version="3.2.2" date="2024-07-01">
-    <url type="details">https://github.com/ossia/score/releases/tag/v3.2.2</url>
-      <description>
-        ossia score 3.2.2 is a bugfix release with mostly non-Linux-related improvements.
-        <ul>
-          <li>Protocol fixes to CoAP and OSC</li>
-          <li>Avnd API improvements</li>
-          <li>Fix keyboard shortcut regressions</li>
-        </ul>
-      </description>
-    </release>
-  </releases>
-</component>
\ No newline at end of file
diff --git a/cmake/Deployment/Linux/ossia-score.appdata.xml b/cmake/Deployment/Linux/ossia-score.appdata.xml
index 1d8ee5b9c9..2b2fd43448 100644
--- a/cmake/Deployment/Linux/ossia-score.appdata.xml
+++ b/cmake/Deployment/Linux/ossia-score.appdata.xml
@@ -1,21 +1,50 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <component type="desktop-application">
-	<id>ossia-score</id>
-	<metadata_license>CC0-1.0</metadata_license>
-	<project_license>GPL-3.0</project_license>
-	<name>ossia score</name>
-	<summary>Interactive intermedia sequencer</summary>
-	<description>
-		<p>With ossia score you can sequence OSC, MIDI, etc. parameters between multiple software and hardware, to create interactive and intermedia scores.</p>
-	</description>
-	<launchable type="desktop-id">ossia-score.desktop</launchable>
-	<url type="homepage">http://ossia.io/</url>
-	<screenshots>
-		<screenshot type="default">
-			<image>https://raw.githubusercontent.com/ossia/score/master/Documentation/score.png</image>
-		</screenshot>
-	</screenshots>
-	<provides>
-		<id>ossia-score.desktop</id>
-	</provides>
+  <id>io.ossia.score</id>
+  <metadata_license>CC-BY-SA-4.0</metadata_license>
+  <project_license>GPL-3.0</project_license>
+  <name>ossia score</name>
+  <summary>Sequencer for media artists</summary>
+  <developer id="io.github.ossia">
+    <name>ossia.io</name>
+  </developer>
+  <description>
+    <p>ossia score is a sequencer for audio-visual artists, designed to enable the creation of interactive shows, museum installations, intermedia digital artworks, interactive music and more in an intuitive user interface.</p>
+    
+    <ul>
+      <li>Sequence OSC, MIDI, DMX, sound, video and more, between multiple software and hardware. </li>
+      <li>Script and live-code with JavaScript, ISF Shaders, Faust, PureData or C++.</li>
+      <li>Leverage IoT protocols such as CoAP or MQTT for industrial-grade automation.</li>
+      <li>Interact with joysticks, Wiimotes, Leapmotions, Web APIs and BLE sensors.</li>
+      <li>Integrate programs from a wealth of creative programming languages such as Structure Synth, Context-Free Art and Bytebeat.</li>
+      <li>Load any kind of audio or video format and process visuals through Spout, Syphon, NDI or Shmdata.</li>
+    </ul>
+  </description>
+  <launchable type="desktop-id">io.ossia.score.desktop</launchable>
+  <content_rating type="oars-1.1" />
+  <url type="bugtracker">https://github.com/ossia/score/issues</url>
+  <url type="contact">https://discord.gg/8Hzm4UduaS</url>
+  <url type="contribute">https://ossia.io/project.html</url>
+  <url type="donation">https://opencollective.com/ossia</url>
+  <url type="help">https://ossia.io/docs.html</url>
+  <url type="homepage">https://ossia.io</url>
+  <url type="vcs-browser">https://github.com/ossia/score</url>
+  <screenshots>
+    <screenshot type="default">
+      <image>https://github.com/ossia/score/raw/master/docs/score.png?raw=true</image>
+      <caption>Sequence all kinds of media in ossia score</caption>
+    </screenshot>
+  </screenshots>
+  <releases>
+    <release version="3.2.3" date="2024-07-02">
+    <url type="details">https://github.com/ossia/score/releases/tag/v3.2.3</url>
+      <description>
+        <p>ossia score 3.2.3 is a bugfix release which enables Flatpak support.</p>
+        <ul>
+          <li>Update dependencies to be flatpak-compatible</li>
+          <li>A bugfix to Nix support</li>
+        </ul>
+      </description>
+    </release>
+  </releases>
 </component>
diff --git a/cmake/ScoreDeployment.cmake b/cmake/ScoreDeployment.cmake
index d8260c30a2..903b560ce4 100644
--- a/cmake/ScoreDeployment.cmake
+++ b/cmake/ScoreDeployment.cmake
@@ -35,11 +35,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
 elseif(${CMAKE_SYSTEM_NAME} MATCHES "Android")
   include(ScoreDeploymentAndroid)
 elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
-  if(GENERIC_LINUX_DEPLOYMENT_BUILD)
-    include(ScoreDeploymentGenericLinux)
-  else()
-    include(ScoreDeploymentLinux)
-  endif()
+  include(ScoreDeploymentLinux)
 elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
 include(ScoreDeploymentWindows)
 include(ScoreDeploymentWindowsStore)
diff --git a/cmake/ScoreDeploymentGenericLinux.cmake b/cmake/ScoreDeploymentGenericLinux.cmake
deleted file mode 100644
index b77b31bc9a..0000000000
--- a/cmake/ScoreDeploymentGenericLinux.cmake
+++ /dev/null
@@ -1,43 +0,0 @@
-if(UNIX)
-
-set(SCORE_BIN_INSTALL_DIR ".")
-
-# Qt Libraries
-get_target_property(QtCore_LOCATION ${QT_PREFIX}::Core LOCATION)
-get_filename_component(QT_SO_DIR ${QtCore_LOCATION} PATH)
-# TODO Same than for windows deployment
-file(GLOB ICU_SOS "${QT_SO_DIR}/libicu*.so*")
-file(GLOB QT_SOS
-  "${QT_SO_DIR}/libQt6Core.so*"
-  "${QT_SO_DIR}/libQt6Gui.so*"
-  "${QT_SO_DIR}/libQt6Widgets.so*"
-  "${QT_SO_DIR}/libQt6Network.so*"
-  "${QT_SO_DIR}/libQt6Xml.so*"
-  "${QT_SO_DIR}/libQt6Svg.so*"
-  "${QT_SO_DIR}/libQt6Qml.so*"
-  "${QT_SO_DIR}/libQt6OpenGL.so*"
-  "${QT_SO_DIR}/libQt6WebSockets.so*"
-  "${QT_SO_DIR}/libQt6XcbQpa.so*")
-
-install(FILES
-  ${ICU_SOS}
-  ${QT_SOS}
-  DESTINATION ${SCORE_BIN_INSTALL_DIR})
-
-# Qt Platform Plugin
-install(FILES
-  "${QT_SO_DIR}/../plugins/platforms/libqxcb.so"
-  "${QT_SO_DIR}/../plugins/imageformats/libqsvg.so"
-  "${QT_SO_DIR}/../plugins/imageformats/libqjpeg.so"
-  "${QT_SO_DIR}/../plugins/generic/libqevdevkeyboardplugin.so"
-  "${QT_SO_DIR}/../plugins/generic/libqevdevmouseplugin.so"
-  "${QT_SO_DIR}/../plugins/xcbglintegrations/libqxcb-glx-integration.so"
-
-  DESTINATION ${SCORE_BIN_INSTALL_DIR}/plugins/platforms)
-
-# Qt helper script
-
-install(PROGRAMS "${SCORE_SRC}/app/score.sh"
-        DESTINATION ".")
-
-endif()
diff --git a/cmake/ScoreDeploymentLinux.cmake b/cmake/ScoreDeploymentLinux.cmake
index 4606856eb2..a99280f172 100644
--- a/cmake/ScoreDeploymentLinux.cmake
+++ b/cmake/ScoreDeploymentLinux.cmake
@@ -92,7 +92,12 @@ install(FILES "${PROJECT_BINARY_DIR}/ossia-score.desktop"
 install(FILES "${CMAKE_SOURCE_DIR}/src/lib/resources/ossia-score.png"
         DESTINATION share/pixmaps
         COMPONENT OssiaScore)
-
+install(FILES "${CMAKE_SOURCE_DIR}/src/lib/resources/ossia-score.png"
+        DESTINATION icons/hicolor/512x512/apps
+        COMPONENT OssiaScore)
+install(FILES "${CMAKE_SOURCE_DIR}/cmake/Deployment/Linux/ossia-score.appdata.xml"
+        DESTINATION share/metainfo
+        COMPONENT OssiaScore)
 
 execute_process(
     COMMAND