File PackageKit-zypp-add-repo-in-packageid.patch of Package PackageKit.33122
From 6c8f4502ebba71b3a9edf950da91993493f32e7f Mon Sep 17 00:00:00 2001
From: Jonathan Kang <jonathankang@gnome.org>
Date: Wed, 28 Sep 2022 14:42:27 +0800
Subject: [PATCH] zypp: add repository data in package id
GNOME Software expects a package id like
"foobar;1.0;noarch;installed:repo". While what zypp backend didn't
provide the repo information in package id. This leads to an bug where
GNOME Software doesn't show how many applications are installed from
a specific repository, as described in the following bug.
https://bugzilla.suse.com/show_bug.cgi?id=1202585
---
backends/zypp/pk-backend-zypp.cpp | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
Index: PackageKit-1.2.4/backends/zypp/pk-backend-zypp.cpp
===================================================================
--- PackageKit-1.2.4.orig/backends/zypp/pk-backend-zypp.cpp
+++ PackageKit-1.2.4/backends/zypp/pk-backend-zypp.cpp
@@ -169,18 +169,30 @@ zypp_build_package_id_from_resolvable (c
{
gchar *package_id;
const char *arch;
+ g_autofree gchar *repo = NULL;
if (isKind<SrcPackage>(resolvable))
arch = "source";
else
arch = resolvable.arch ().asString ().c_str ();
- string repo = resolvable.repository ().alias();
- if (resolvable.isSystem())
- repo = "installed";
+ if (resolvable.isSystem ()) {
+ PoolItem pi;
+ PoolItem installedPI { resolvable };
+ ui::Selectable::Ptr selectable { ui::Selectable::get (resolvable) };
+
+ if (selectable->identicalAvailableObj (installedPI) != NULL)
+ pi = selectable->identicalAvailableObj (installedPI);
+ else
+ pi = selectable->updateCandidateObj ();
+
+ repo = g_strconcat ("installed:", pi.repository ().alias ().c_str (), NULL);
+ } else
+ repo = g_strdup (resolvable.repository ().alias ().c_str ());
+
package_id = pk_package_id_build (resolvable.name ().c_str (),
resolvable.edition ().asString ().c_str (),
- arch, repo.c_str ());
+ arch, repo);
return package_id;
}