[neon/snap-packaging/discover-snap/ago/update-source-for-desktop-support] /: Update source to newer commit with needed patches

Antoine Gonzalez null at kde.org
Thu Jul 25 13:43:02 BST 2024


Git commit d888faade16cd6e0d550c8a5b7e8edda6c9c98dc by Antoine Gonzalez.
Committed on 25/07/2024 at 12:42.
Pushed by daspood into branch 'ago/update-source-for-desktop-support'.

Update source to newer commit with needed patches

D  +0    -232  patches/810-snap-backend-updates.patch
D  +0    -133  patches/873-snap-backend-desktop-launch-BACKPORT.patch
M  +7    -10   snapcraft.yaml

https://invent.kde.org/neon/snap-packaging/discover-snap/-/commit/d888faade16cd6e0d550c8a5b7e8edda6c9c98dc

diff --git a/patches/810-snap-backend-updates.patch b/patches/810-snap-backend-updates.patch
deleted file mode 100644
index 8391d29..0000000
--- a/patches/810-snap-backend-updates.patch
+++ /dev/null
@@ -1,232 +0,0 @@
-From 41040a1f085a8294e42321f684a55106038d6a45 Mon Sep 17 00:00:00 2001
-From: Kevin Ottens <kevin.ottens at enioka.com>
-Date: Thu, 4 Apr 2024 11:48:23 +0200
-Subject: [PATCH 1/3] snap: cache the size information in the SnapResource
-
-Depending where the latest QSnapdSnap object is coming from it might old
-or not a value for the download and installed sizes. To avoid loosing
-those between refreshSnap() calls we thus cache them in the SnapResource
-itself.
----
- .../backends/SnapBackend/SnapBackend.cpp      |  1 +
- .../backends/SnapBackend/SnapResource.cpp     | 37 +++++++++++++++++--
- .../backends/SnapBackend/SnapResource.h       |  6 +++
- 3 files changed, 40 insertions(+), 4 deletions(-)
-
-diff --git a/libdiscover/backends/SnapBackend/SnapBackend.cpp b/libdiscover/backends/SnapBackend/SnapBackend.cpp
-index 0e60bf4646..1b9e2857fb 100644
---- a/libdiscover/backends/SnapBackend/SnapBackend.cpp
-+++ b/libdiscover/backends/SnapBackend/SnapBackend.cpp
-@@ -270,6 +270,7 @@ void SnapBackend::refreshStates()
-             bool contained = kContains(resources, [res](const StreamResult &in) {
-                 return in.resource == res;
-             });
-+            res->updateSizes();
-             if (contained)
-                 res->setState(AbstractResource::Installed);
-             else
-diff --git a/libdiscover/backends/SnapBackend/SnapResource.cpp b/libdiscover/backends/SnapBackend/SnapResource.cpp
-index b7c33835c0..007ea21b84 100644
---- a/libdiscover/backends/SnapBackend/SnapResource.cpp
-+++ b/libdiscover/backends/SnapBackend/SnapResource.cpp
-@@ -72,6 +72,8 @@ const QStringList SnapResource::s_topObjects({QStringLiteral("qrc:/qml/Permissio
- SnapResource::SnapResource(QSharedPointer<QSnapdSnap> snap, AbstractResource::State state, SnapBackend *backend)
-     : AbstractResource(backend)
-     , m_state(state)
-+    , m_installedSize(0)
-+    , m_downloadSize(0)
-     , m_snap(snap)
- {
-     setObjectName(snap->name());
-@@ -100,8 +102,11 @@ QString SnapResource::comment()
- 
- quint64 SnapResource::size()
- {
--    // return isInstalled() ? m_snap->installedSize() : m_snap->downloadSize();
--    return m_snap->downloadSize();
-+    if (m_state == AbstractResource::Installed) {
-+        return installedSize();
-+    } else {
-+        return downloadSize();
-+    }
- }
- 
- QVariant SnapResource::icon() const
-@@ -298,9 +303,12 @@ void SnapResource::setSnap(const QSharedPointer<QSnapdSnap> &snap)
-     if (m_snap == snap)
-         return;
- 
--    const bool newSize = m_snap->installedSize() != snap->installedSize() || m_snap->downloadSize() != snap->downloadSize();
-+    const auto oldSize = size();
-     m_snap = snap;
--    if (newSize)
-+    updateSizes();
-+    const auto newSize = size();
-+
-+    if (newSize != oldSize)
-         Q_EMIT sizeChanged();
- 
-     Q_EMIT newSnap();
-@@ -468,6 +476,27 @@ void SnapResource::setChannel(const QString &channelName)
- #endif
- }
- 
-+quint64 SnapResource::installedSize() const
-+{
-+    return m_installedSize;
-+}
-+
-+quint64 SnapResource::downloadSize() const
-+{
-+    return m_downloadSize;
-+}
-+
-+void SnapResource::updateSizes()
-+{
-+    if (m_snap->installedSize() > 0) {
-+        m_installedSize = m_snap->installedSize();
-+    }
-+
-+    if (m_snap->downloadSize() > 0) {
-+        m_downloadSize = m_snap->downloadSize();
-+    }
-+}
-+
- void SnapResource::refreshSnap()
- {
-     auto request = client()->find(QSnapdClient::FindFlag::MatchName, m_snap->name());
-diff --git a/libdiscover/backends/SnapBackend/SnapResource.h b/libdiscover/backends/SnapBackend/SnapResource.h
-index e7f4413edb..4f46036a34 100644
---- a/libdiscover/backends/SnapBackend/SnapResource.h
-+++ b/libdiscover/backends/SnapBackend/SnapResource.h
-@@ -68,6 +68,10 @@ public:
-     QString channel() const;
-     void setChannel(const QString &channel);
- 
-+    quint64 installedSize() const;
-+    quint64 downloadSize() const;
-+    void updateSizes();
-+
-     QSharedPointer<QSnapdSnap> snap() const
-     {
-         return m_snap;
-@@ -82,6 +86,8 @@ public:
-     void refreshSnap();
-     void gotIcon();
-     AbstractResource::State m_state;
-+    quint64 m_installedSize;
-+    quint64 m_downloadSize;
- 
-     QSharedPointer<QSnapdSnap> m_snap;
-     mutable QVariant m_icon;
--- 
-GitLab
-
-
-From e5c32ebe81a489912eeab8c01de04506845bc144 Mon Sep 17 00:00:00 2001
-From: Kevin Ottens <kevin.ottens at enioka.com>
-Date: Thu, 4 Apr 2024 11:48:32 +0200
-Subject: [PATCH 2/3] snap: start checking for updates
-
-It indeed auto-updates by default but a) this is not instant, one might
-open Discover in between two auto-update attempts and b) snapd can be
-configured to disable auto-updates.
-
-Modify the backend to have a proper list of updates being reported in
-order to cover the two cases above.
----
- .../backends/SnapBackend/SnapBackend.cpp      | 19 +++++++++++++++++++
- .../backends/SnapBackend/SnapBackend.h        |  4 +---
- 2 files changed, 20 insertions(+), 3 deletions(-)
-
-diff --git a/libdiscover/backends/SnapBackend/SnapBackend.cpp b/libdiscover/backends/SnapBackend/SnapBackend.cpp
-index 1b9e2857fb..82e66a963e 100644
---- a/libdiscover/backends/SnapBackend/SnapBackend.cpp
-+++ b/libdiscover/backends/SnapBackend/SnapBackend.cpp
-@@ -84,6 +84,8 @@ SnapBackend::SnapBackend(QObject *parent)
-     , m_updater(new StandardBackendUpdater(this))
-     , m_reviews(OdrsReviewsBackend::global())
- {
-+    connect(m_updater, &StandardBackendUpdater::updatesCountChanged, this, &SnapBackend::updatesCountChanged);
-+
-     connect(m_reviews.data(), &OdrsReviewsBackend::ratingsReady, this, [this] {
-         m_reviews->emitRatingFetched(this, kTransform<QList<AbstractResource *>>(m_resources.values(), [](AbstractResource *r) {
-                                          return r;
-@@ -257,6 +259,22 @@ Transaction *SnapBackend::removeApplication(AbstractResource *_app)
-     return new SnapTransaction(&m_client, app, Transaction::RemoveRole, AbstractResource::None);
- }
- 
-+void SnapBackend::checkForUpdates()
-+{
-+    auto ret = new StoredResultsStream({populate(m_client.findRefreshable())});
-+    connect(ret, &StoredResultsStream::finishedResources, this, [this](const QVector<StreamResult> &resources) {
-+        for (SnapResource *res : std::as_const(m_resources)) {
-+            bool contained = kContains(resources, [res](const StreamResult &in) {
-+                return in.resource == res;
-+            });
-+            if (contained) {
-+                res->setState(AbstractResource::Upgradeable);
-+                res->updateSizes();
-+            }
-+        }
-+    });
-+}
-+
- QString SnapBackend::displayName() const
- {
-     return QStringLiteral("Snap");
-@@ -276,6 +294,7 @@ void SnapBackend::refreshStates()
-             else
-                 res->setState(AbstractResource::None);
-         }
-+        checkForUpdates();
-     });
- }
- 
-diff --git a/libdiscover/backends/SnapBackend/SnapBackend.h b/libdiscover/backends/SnapBackend/SnapBackend.h
-index 8a9b6d3a65..7e2f885bb2 100644
---- a/libdiscover/backends/SnapBackend/SnapBackend.h
-+++ b/libdiscover/backends/SnapBackend/SnapBackend.h
-@@ -43,9 +43,7 @@ public:
-     {
-         return m_fetching;
-     }
--    void checkForUpdates() override
--    {
--    }
-+    void checkForUpdates() override;
-     bool hasApplications() const override
-     {
-         return true;
--- 
-GitLab
-
-
-From 03f3e05cae6484126410efef0f4e43310cb92e10 Mon Sep 17 00:00:00 2001
-From: Kevin Ottens <kevin.ottens at enioka.com>
-Date: Thu, 4 Apr 2024 15:04:49 +0200
-Subject: [PATCH 3/3] snap: place a refresh request for upgradeable packages
-
-This allows to manually upgrade snap packages as well.
-
-BUG: 476654
----
- libdiscover/backends/SnapBackend/SnapTransaction.cpp | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/libdiscover/backends/SnapBackend/SnapTransaction.cpp b/libdiscover/backends/SnapBackend/SnapTransaction.cpp
-index d1c1d7e39f..9d300f499e 100644
---- a/libdiscover/backends/SnapBackend/SnapTransaction.cpp
-+++ b/libdiscover/backends/SnapBackend/SnapTransaction.cpp
-@@ -24,6 +24,8 @@ SnapTransaction::SnapTransaction(QSnapdClient *client, SnapResource *app, Role r
- {
-     if (role == RemoveRole)
-         setRequest(m_client->remove(app->packageName()));
-+    else if (app->state() == AbstractResource::Upgradeable)
-+        setRequest(m_client->refresh(app->packageName()));
-     else
-         setRequest(m_client->install(app->packageName()));
- }
--- 
-GitLab
-
diff --git a/patches/873-snap-backend-desktop-launch-BACKPORT.patch b/patches/873-snap-backend-desktop-launch-BACKPORT.patch
deleted file mode 100644
index 3f3842f..0000000
--- a/patches/873-snap-backend-desktop-launch-BACKPORT.patch
+++ /dev/null
@@ -1,133 +0,0 @@
-diff --git a/libdiscover/backends/SnapBackend/CMakeLists.txt b/libdiscover/backends/SnapBackend/CMakeLists.txt
-index a3bb0f005..ecb1f763a 100644
---- a/libdiscover/backends/SnapBackend/CMakeLists.txt
-+++ b/libdiscover/backends/SnapBackend/CMakeLists.txt
-@@ -1,7 +1,23 @@
- add_subdirectory(libsnapclient)
- 
--add_library(snap-backend MODULE SnapResource.cpp SnapBackend.cpp SnapTransaction.cpp snapui.qrc)
--target_link_libraries(snap-backend Qt::Gui Qt::Core Qt::Concurrent KF6::CoreAddons KF6::ConfigCore Discover::Common Snapd::Core)
-+set(snap-backend_SRCS
-+        SnapResource.cpp
-+        SnapBackend.cpp
-+        SnapTransaction.cpp
-+        snapui.qrc
-+)
-+ecm_qt_declare_logging_category(snap-backend_SRCS HEADER libdiscover_snap_debug.h IDENTIFIER LIBDISCOVER_SNAP_LOG CATEGORY_NAME org.kde.plasma.libdiscover.snap DESCRIPTION "libdiscover snap backend" EXPORT DISCOVER)
-+add_library(snap-backend MODULE ${snap-backend_SRCS})
-+target_link_libraries(snap-backend
-+    Qt::Gui
-+    Qt::Core
-+    Qt::Concurrent
-+    KF6::CoreAddons
-+    KF6::ConfigCore
-+    KF6::KIOGui
-+    Discover::Common
-+    Snapd::Core
-+)
- 
- if ("${Snapd_VERSION}" VERSION_GREATER 1.40)
-     target_compile_definitions(snap-backend PRIVATE -DSNAP_COMMON_IDS -DSNAP_CHANNELS)
-diff --git a/libdiscover/backends/SnapBackend/SnapResource.cpp b/libdiscover/backends/SnapBackend/SnapResource.cpp
-index 4374c8790..ca17b2425 100644
---- a/libdiscover/backends/SnapBackend/SnapResource.cpp
-+++ b/libdiscover/backends/SnapBackend/SnapResource.cpp
-@@ -6,9 +6,13 @@
- 
- #include "SnapResource.h"
- #include "SnapBackend.h"
-+#include "libdiscover_snap_debug.h"
-+#include <KIO/ApplicationLauncherJob>
-+#include <KService>
- #include <KLocalizedString>
- #include <QBuffer>
- #include <QDebug>
-+#include <QFile>
- #include <QImageReader>
- #include <QProcess>
- #include <QStandardItemModel>
-@@ -282,9 +286,62 @@ void SnapResource::fetchScreenshots()
-     Q_EMIT screenshotsFetched(screenshots);
- }
- 
-+/**
-+ * Tries to obtain a launchable desktop file for this snap, in this order:
-+ *
-+ * 1. Any app with the same name as the snap and a desktop file (the main app)
-+ * 2. The first app with a desktop file (the next best app)
-+ * 3. The expected desktop file for the main app
-+ *
-+ * @return The path to the selected launchable desktop file.
-+ */
-+QString SnapResource::launchableDesktopFile() const
-+{
-+    QString desktopFile;
-+    qCDebug(LIBDISCOVER_SNAP_LOG) << "Snap: " << packageName() << " - " << m_snap->appCount() << " app(s) detected";
-+    for (int i = 0; i < m_snap->appCount(); i++) {
-+        if (m_snap->app(i)->desktopFile().isEmpty()) {
-+            qCDebug(LIBDISCOVER_SNAP_LOG) << "App " << i << ": " << m_snap->app(i)->name() << ": " << "No desktop file, skipping";
-+            continue;
-+        }
-+        if (packageName().compare(m_snap->app(i)->name(), Qt::CaseInsensitive) == 0) {
-+            qCDebug(LIBDISCOVER_SNAP_LOG) << "App " << i << ": " << m_snap->app(i)->name() << ": " << "Main app, stopping search";
-+            desktopFile = m_snap->app(i)->desktopFile();
-+            break;
-+        }
-+        if (desktopFile.isEmpty()) {
-+            qCDebug(LIBDISCOVER_SNAP_LOG) << "App " << i << ": " << m_snap->app(i)->name() << ": " << "First candidate, keeping for now";
-+            desktopFile = m_snap->app(i)->desktopFile();
-+        }
-+    }
-+    if (desktopFile.isEmpty()) {
-+        qCWarning(LIBDISCOVER_SNAP_LOG) << "No desktop file found for this snap, trying expected path for the main app desktop file";
-+        desktopFile = QStringLiteral("/var/lib/snapd/desktop/applications/")
-+                      + packageName()
-+                      + QStringLiteral("_")
-+                      + packageName()
-+                      + QStringLiteral(".desktop");
-+    }
-+    return desktopFile;
-+}
-+
-+/**
-+ * Launches a snap using its desktop file.
-+ *
-+ * If no desktop file is found, defaults back to `snap run`, which will fail in Ubuntu Core environments.
-+ */
- void SnapResource::invokeApplication() const
- {
--    QProcess::startDetached(QStringLiteral("snap"), {QStringLiteral("run"), packageName()});
-+    QString desktopFile = launchableDesktopFile();
-+    if (QFile::exists(desktopFile)) {
-+        qCDebug(LIBDISCOVER_SNAP_LOG) << "Launching desktop file " << desktopFile;
-+        KService::Ptr service = KService::serviceByDesktopPath(desktopFile);
-+        KIO::ApplicationLauncherJob *job = new KIO::ApplicationLauncherJob(service);
-+        job->start();
-+    } else {
-+        qCWarning(LIBDISCOVER_SNAP_LOG) << "No desktop file found, defaulting to snap run";
-+        QProcess::startDetached(QStringLiteral("snap"), {QStringLiteral("run"), packageName()});
-+    }
- }
- 
- AbstractResource::Type SnapResource::type() const
-@@ -358,7 +415,7 @@ public:
-                     // qDebug() << "xxx" << plug->name() << plug->label() << plug->interface() << slot->snap() << "slot:" << slot->name() <<
-                     // slot->snap() << slot->interface() << slot->label();
-                     item->setCheckable(true);
--                    item->setCheckState(plug->connectionCount() > 0 ? Qt::Checked : Qt::Unchecked);
-+                    item->setCheckState(plug->connectedSlotCount() > 0 ? Qt::Checked : Qt::Unchecked);
-                     item->setData(plug->name(), PlugNameRole);
-                     item->setData(slot->snap(), SlotSnapRole);
-                     item->setData(slot->name(), SlotNameRole);
-diff --git a/libdiscover/backends/SnapBackend/SnapResource.h b/libdiscover/backends/SnapBackend/SnapResource.h
-index 7a3a8abbd..b35ce5586 100644
---- a/libdiscover/backends/SnapBackend/SnapResource.h
-+++ b/libdiscover/backends/SnapBackend/SnapResource.h
-@@ -42,6 +42,7 @@ public:
-     {
-         return true;
-     }
-+    QString launchableDesktopFile() const;
-     void invokeApplication() const override;
-     void fetchChangelog() override;
-     void fetchScreenshots() override;
diff --git a/snapcraft.yaml b/snapcraft.yaml
index 81e4668..45a7aee 100644
--- a/snapcraft.yaml
+++ b/snapcraft.yaml
@@ -5,11 +5,9 @@
 
 # FIXME's:
 # - plasma-discover:
-#       -> snapd-glib's snapd_snap_get_apps returns frequently returns an empty list
-#       -> APPARMOR denied on `/proc/sys/kernel/core_pattern` file read
+#       -> snapd-glib's snapd_snap_get_apps frequently returns an empty list
 # - plasma-discover-notifier:
 #       -> no snapd backend exists for notifier
-#       -> APPARMOR denied on `/proc/sys/kernel/core_pattern` file read
 
 ---
 name: plasma-discover
@@ -113,7 +111,7 @@ parts:
         - usr/share/metainfo/org.kde.discover.appdata.xml
         source: https://invent.kde.org/plasma/discover.git
         source-type: git
-        source-branch: v6.0.5  # v6.0.80 onwards require ECM 6.2.0, kde-neon-6 extension only has 6.1.0
+        source-commit: 982be0af4c25c2fc6187bd4414fb4fac769d2271 # FIXME: First master commit containing all necessary patches, will need to be set to a stable release ASAP
         plugin: cmake
         build-packages:
         - libsnapd-glib-dev
@@ -125,19 +123,18 @@ parts:
         - libappstreamqt-3
         override-pull: |
             craftctl default
-            # Apply patches
-            git apply $CRAFT_PROJECT_DIR/patches/810-snap-backend-updates.patch
-            git apply $CRAFT_PROJECT_DIR/patches/873-snap-backend-desktop-launch-BACKPORT.patch
+            # Force-disable PackageKit backend which does not have an associated cmake variable
+            sed -i '37,39d' $SNAPCRAFT_PART_SRC/libdiscover/backends/CMakeLists.txt
             # Force-disable KNS backend which does not have an associated cmake variable
-            sed -i '11,13d' $SNAPCRAFT_PART_SRC/libdiscover/backends/CMakeLists.txt
+            sed -i '33,35d' $SNAPCRAFT_PART_SRC/libdiscover/backends/CMakeLists.txt
         cmake-parameters:
         - "--log-level=STATUS"
         - "-DBUILD_DummyBackend=OFF"
         - "-DBUILD_FlatpakBackend=OFF"
+        - "-DBUILD_SteamOSBackend=OFF"
+        - "-DBUILD_SnapBackend=ON"
         - "-DBUILD_FwupdBackend=OFF"
         - "-DBUILD_RpmOstreeBackend=OFF"
-        - "-DBUILD_SnapBackend=ON"
-        - "-DBUILD_SteamOSBackend=OFF"
         - "-DBUILD_TESTING=OFF"
         - "-DBUILD_WITH_QT6=ON"
         - "-DBUILD_SHARED_LIBS=TRUE"


More information about the Neon-commits mailing list