[gnome-software/gnome-42: 1/2] packagekit: Update package installed check to use new manual and auto statuses
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/gnome-42: 1/2] packagekit: Update package installed check to use new manual and auto statuses
- Date: Mon, 23 May 2022 07:01:05 +0000 (UTC)
commit 44b57330d01092a2c635f3c47c2115f2c404fc88
Author: Robert Ancell <robert ancell canonical com>
Date: Thu Apr 28 12:05:06 2022 +1200
packagekit: Update package installed check to use new manual and auto statuses
The apt backend replaced the "installed" status with "auto" or "manual" in:
https://github.com/PackageKit/PackageKit/commit/cfd297aeb51bde67269d74c5a762634314e918b6
Without this change using when using PackageKit >= 1.2.5 .deb packages are not able to be uninstalled.
Fixes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1720
plugins/packagekit/gs-plugin-packagekit.c | 28 ++++++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
---
diff --git a/plugins/packagekit/gs-plugin-packagekit.c b/plugins/packagekit/gs-plugin-packagekit.c
index 0ddd7392c..e8ceff9cc 100644
--- a/plugins/packagekit/gs-plugin-packagekit.c
+++ b/plugins/packagekit/gs-plugin-packagekit.c
@@ -287,6 +287,27 @@ gs_plugin_packagekit_finalize (GObject *object)
typedef gboolean (*GsAppFilterFunc) (GsApp *app);
+static gboolean
+package_is_installed (const gchar *package_id)
+{
+ g_auto(GStrv) split = NULL;
+ const gchar *data;
+
+ split = pk_package_id_split (package_id);
+ if (split == NULL) {
+ return FALSE;
+ }
+
+ data = split[PK_PACKAGE_ID_DATA];
+ if (g_str_has_prefix (data, "installed") ||
+ g_str_has_prefix (data, "manual:") ||
+ g_str_has_prefix (data, "auto:")) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
/* The elements in the returned #GPtrArray reference memory from within the
* @apps list, so the array is only valid as long as @apps is not modified or
* freed. The array is not NULL-terminated. */
@@ -308,8 +329,7 @@ app_list_get_package_ids (GsAppList *apps,
for (guint j = 0; j < app_source_ids->len; j++) {
const gchar *package_id = g_ptr_array_index (app_source_ids, j);
- if (ignore_installed &&
- g_strstr_len (package_id, -1, ";installed") != NULL)
+ if (ignore_installed && package_is_installed (package_id))
continue;
g_ptr_array_add (list_package_ids, (gchar *) package_id);
@@ -605,7 +625,7 @@ gs_plugin_app_install (GsPlugin *plugin,
for (i = 0; i < source_ids->len; i++) {
package_id = g_ptr_array_index (source_ids, i);
- if (g_strstr_len (package_id, -1, ";installed") != NULL)
+ if (package_is_installed (package_id))
continue;
g_ptr_array_add (array_package_ids, (gpointer) package_id);
}
@@ -741,7 +761,7 @@ gs_plugin_app_remove (GsPlugin *plugin,
package_ids = g_new0 (gchar *, source_ids->len + 1);
for (i = 0; i < source_ids->len; i++) {
package_id = g_ptr_array_index (source_ids, i);
- if (g_strstr_len (package_id, -1, ";installed") == NULL)
+ if (!package_is_installed (package_id))
continue;
package_ids[cnt++] = g_strdup (package_id);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]