From c5da558c1790dbd2eba3531805d4b552465c1cd9 Mon Sep 17 00:00:00 2001
From: Amin Bandali <amin.bandali@savoirfairelinux.com>
Date: Thu, 17 Dec 2020 21:42:41 -0500
Subject: [PATCH] packaging: use recent Qt version for snap

Change-Id: I309f31ba1d23a9cbc48e2936b7591ae4fba40a76
---
 packaging/rules/snap/snapcraft.yaml | 30 ++++++++++++++++++-----------
 scripts/build-package-snap.sh       |  2 +-
 2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/packaging/rules/snap/snapcraft.yaml b/packaging/rules/snap/snapcraft.yaml
index 8b68fd8..73acaa3 100644
--- a/packaging/rules/snap/snapcraft.yaml
+++ b/packaging/rules/snap/snapcraft.yaml
@@ -137,17 +137,26 @@ apps:
     - wayland
     - x11
 
+package-repositories:
+  - type: apt
+    ppa: beineri/opt-qt-5.15.2-bionic
+    # qt515base consists of:
+    #   Qt5Concurrent, Qt5Core, Qt5DBus, Qt5EglFSDeviceIntegration,
+    #   Qt5EglFsKmsSupport, Qt5Gui, Qt5Network, Qt5OpenGL,
+    #   Qt5PrintSupport, Qt5Sql, Qt5Test, Qt5Widgets, Qt5XcbQpa,
+    #   Qt5Xml
+
 parts:
   desktop-launch:
     source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
     plugin: nil
     build-packages:
-    - gcc-8
-    - qtbase5-dev
     - dpkg-dev
+    - gcc-8
+    - qt515base
     stage-packages:
-    - libqt5gui5
-    - libqt5svg5 # for loading icon themes which are svg
+    - qt515base
+    - qt515svg # for loading icon themes which are svg
     - try: [appmenu-qt5] # not available on core18
     override-pull: |
       snapcraftctl pull
@@ -225,6 +234,10 @@ parts:
       make -j$SNAPCRAFT_PARALLEL_BUILD_COUNT
       DESTDIR=$SNAPCRAFT_PART_INSTALL make install
 
+      # set up the required environment variables
+      sed -i 's|/opt/qt515|$SNAP/opt/qt515|g' $SNAP/opt/qt515/bin/qt515-env.sh
+      . $SNAP/opt/qt515/bin/qt515-env.sh
+
       cd $SNAPCRAFT_PART_BUILD/lrc
       mkdir build
       cd build
@@ -292,8 +305,7 @@ parts:
     - libwebkit2gtk-4.0-dev
     - libyaml-cpp-dev
     - nasm # seems to be needed for building libvpx on an 18.04 base
-    - qtbase5-dev
-    - qttools5-dev
+    - qt515base
     - uuid-dev
     - yasm
     stage-packages:
@@ -316,11 +328,6 @@ parts:
     - libopus0
     - libpcre3
     - libqrencode3
-    - libqt5core5a
-    - libqt5dbus5
-    - libqt5gui5
-    - libqt5sql5
-    - libqt5sql5-sqlite
     - libsamplerate0
     - libslang2
     - libsndfile1
@@ -336,4 +343,5 @@ parts:
     - libva2
     - libvdpau-va-gl1
     - libvdpau1
+    - qt515base
     - va-driver-all
diff --git a/scripts/build-package-snap.sh b/scripts/build-package-snap.sh
index e637595..8855f84 100755
--- a/scripts/build-package-snap.sh
+++ b/scripts/build-package-snap.sh
@@ -29,7 +29,7 @@ cd /opt/ring-project/packaging/rules/snap/
 # set the version and tarball filename
 sed -i "s/RELEASE_VERSION/${RELEASE_VERSION}/g" snapcraft.yaml
 
-snapcraft
+snapcraft --enable-experimental-package-repositories # requires snapcraft >= 4.4
 
 # move the built snap to output
 mv *.snap /opt/output/
-- 
2.17.1