[gnome-software/wip/mcrha/mngmt-plugin] packagekit: Check app's management plugin also by the plugin name
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/mcrha/mngmt-plugin] packagekit: Check app's management plugin also by the plugin name
- Date: Tue, 7 Dec 2021 14:28:30 +0000 (UTC)
commit ceb45e06c49a753e60e122a8a7320e5a7f05c17a
Author: Milan Crha <mcrha redhat com>
Date: Tue Dec 7 15:26:18 2021 +0100
packagekit: Check app's management plugin also by the plugin name
The packagekit plugin is split into subplugins, where each is
a different instance, but the code expects to work on GsApp-s
created by a different subplugin, where the compare on the plugin
instance address does not work.
.../packagekit/gs-plugin-packagekit-refine-repos.c | 2 +-
plugins/packagekit/gs-plugin-packagekit-refresh.c | 4 ++--
plugins/packagekit/gs-plugin-packagekit.c | 24 +++++++++++-----------
plugins/packagekit/gs-plugin-systemd-updates.c | 8 ++++----
plugins/packagekit/packagekit-common.c | 15 ++++++++++++++
plugins/packagekit/packagekit-common.h | 2 ++
6 files changed, 36 insertions(+), 19 deletions(-)
---
diff --git a/plugins/packagekit/gs-plugin-packagekit-refine-repos.c
b/plugins/packagekit/gs-plugin-packagekit-refine-repos.c
index ce50d1115..11049bf89 100644
--- a/plugins/packagekit/gs-plugin-packagekit-refine-repos.c
+++ b/plugins/packagekit/gs-plugin-packagekit-refine-repos.c
@@ -126,7 +126,7 @@ gs_plugin_refine (GsPlugin *plugin,
continue;
if (gs_app_get_kind (app) != AS_COMPONENT_KIND_REPOSITORY)
continue;
- if (!gs_app_has_management_plugin (app, plugin))
+ if (!gs_plugin_packagekit_is_packagekit_app (app, plugin))
continue;
fn = gs_app_get_metadata_item (app, "repos::repo-filename");
if (fn == NULL)
diff --git a/plugins/packagekit/gs-plugin-packagekit-refresh.c
b/plugins/packagekit/gs-plugin-packagekit-refresh.c
index e0e965d1a..e0b0ae6b8 100644
--- a/plugins/packagekit/gs-plugin-packagekit-refresh.c
+++ b/plugins/packagekit/gs-plugin-packagekit-refresh.c
@@ -158,7 +158,7 @@ gs_plugin_download (GsPlugin *plugin,
/* add this app */
if (!gs_app_has_quirk (app, GS_APP_QUIRK_IS_PROXY)) {
- if (gs_app_has_management_plugin (app, plugin))
+ if (gs_plugin_packagekit_is_packagekit_app (app, plugin))
gs_app_list_add (list_tmp, app);
continue;
}
@@ -166,7 +166,7 @@ gs_plugin_download (GsPlugin *plugin,
/* add each related app */
for (guint j = 0; j < gs_app_list_length (related); j++) {
GsApp *app_tmp = gs_app_list_index (related, j);
- if (gs_app_has_management_plugin (app_tmp, plugin))
+ if (gs_plugin_packagekit_is_packagekit_app (app_tmp, plugin))
gs_app_list_add (list_tmp, app_tmp);
}
}
diff --git a/plugins/packagekit/gs-plugin-packagekit.c b/plugins/packagekit/gs-plugin-packagekit.c
index 9f933dd46..cf9e9b659 100644
--- a/plugins/packagekit/gs-plugin-packagekit.c
+++ b/plugins/packagekit/gs-plugin-packagekit.c
@@ -412,7 +412,7 @@ gs_plugin_app_install (GsPlugin *plugin,
g_autoptr(PkResults) results = NULL;
/* only process this app if was created by this plugin */
- if (!gs_app_has_management_plugin (app, plugin))
+ if (!gs_plugin_packagekit_is_packagekit_app (app, plugin))
return TRUE;
/* enable repo, handled by dedicated function */
@@ -622,7 +622,7 @@ gs_plugin_app_remove (GsPlugin *plugin,
g_auto(GStrv) package_ids = NULL;
/* only process this app if was created by this plugin */
- if (!gs_app_has_management_plugin (app, plugin))
+ if (!gs_plugin_packagekit_is_packagekit_app (app, plugin))
return TRUE;
/* disable repo, handled by dedicated function */
@@ -840,7 +840,7 @@ gs_plugin_launch (GsPlugin *plugin,
GError **error)
{
/* only process this app if was created by this plugin */
- if (!gs_app_has_management_plugin (app, plugin))
+ if (!gs_plugin_packagekit_is_packagekit_app (app, plugin))
return TRUE;
return gs_plugin_app_launch (plugin, app, error);
@@ -1314,7 +1314,7 @@ gs_plugin_packagekit_refine_details (GsPluginPackagekit *self,
continue;
/* only process this app if was created by this plugin */
- if (!gs_app_has_management_plugin (app, GS_PLUGIN (self)))
+ if (!gs_plugin_packagekit_is_packagekit_app (app, GS_PLUGIN (self)))
continue;
if (gs_app_get_source_id_default (app) == NULL)
continue;
@@ -1465,7 +1465,7 @@ gs_plugin_packagekit_refine_name_to_id (GsPluginPackagekit *self,
if (gs_app_has_quirk (app, GS_APP_QUIRK_IS_WILDCARD))
continue;
if (!gs_app_has_management_plugin (app, NULL) &&
- !gs_app_has_management_plugin (app, GS_PLUGIN (self)))
+ !gs_plugin_packagekit_is_packagekit_app (app, GS_PLUGIN (self)))
continue;
sources = gs_app_get_sources (app);
if (sources->len == 0)
@@ -1510,7 +1510,7 @@ gs_plugin_packagekit_refine_filename_to_id (GsPluginPackagekit *self,
if (gs_app_get_source_id_default (app) != NULL)
continue;
if (!gs_app_has_management_plugin (app, NULL) &&
- !gs_app_has_management_plugin (app, GS_PLUGIN (self)))
+ !gs_plugin_packagekit_is_packagekit_app (app, GS_PLUGIN (self)))
continue;
tmp = gs_app_get_id (app);
if (tmp == NULL)
@@ -1563,7 +1563,7 @@ gs_plugin_packagekit_refine_update_details (GsPluginPackagekit *self,
if (gs_app_get_source_id_default (app) == NULL)
continue;
if (!gs_app_has_management_plugin (app, NULL) &&
- !gs_app_has_management_plugin (app, GS_PLUGIN (self)))
+ !gs_plugin_packagekit_is_packagekit_app (app, GS_PLUGIN (self)))
continue;
if (gs_plugin_refine_requires_update_details (app, flags))
gs_app_list_add (updatedetails_all, app);
@@ -1627,7 +1627,7 @@ gs_plugin_refine (GsPlugin *plugin,
GsApp *app = gs_app_list_index (list, i);
/* only process this app if was created by this plugin */
- if (!gs_app_has_management_plugin (app, plugin))
+ if (!gs_plugin_packagekit_is_packagekit_app (app, plugin))
continue;
/* the scope is always system-wide */
@@ -1648,7 +1648,7 @@ gs_plugin_refine (GsPlugin *plugin,
packages = gs_app_list_new ();
for (i = 0; i < gs_app_list_length (list); i++) {
app = gs_app_list_index (list, i);
- if (!gs_app_has_management_plugin (app, plugin))
+ if (!gs_plugin_packagekit_is_packagekit_app (app, plugin))
continue;
sources = gs_app_get_sources (app);
if (sources->len == 0)
@@ -2727,7 +2727,7 @@ gs_plugin_app_upgrade_download (GsPlugin *plugin,
g_autoptr(PkResults) results = NULL;
/* only process this app if was created by this plugin */
- if (!gs_app_has_management_plugin (app, plugin))
+ if (!gs_plugin_packagekit_is_packagekit_app (app, plugin))
return TRUE;
/* check is distro-upgrade */
@@ -2800,7 +2800,7 @@ gs_plugin_enable_repo (GsPlugin *plugin,
g_autoptr(PkError) error_code = NULL;
/* only process this app if was created by this plugin */
- if (!gs_app_has_management_plugin (repo, plugin))
+ if (!gs_plugin_packagekit_is_packagekit_app (repo, plugin))
return TRUE;
/* is repo */
@@ -2855,7 +2855,7 @@ gs_plugin_disable_repo (GsPlugin *plugin,
g_autoptr(PkError) error_code = NULL;
/* only process this app if was created by this plugin */
- if (!gs_app_has_management_plugin (repo, plugin))
+ if (!gs_plugin_packagekit_is_packagekit_app (repo, plugin))
return TRUE;
/* is repo */
diff --git a/plugins/packagekit/gs-plugin-systemd-updates.c b/plugins/packagekit/gs-plugin-systemd-updates.c
index 8fde004da..0d286c7c1 100644
--- a/plugins/packagekit/gs-plugin-systemd-updates.c
+++ b/plugins/packagekit/gs-plugin-systemd-updates.c
@@ -163,7 +163,7 @@ gs_plugin_systemd_refine_app (GsPluginSystemdUpdates *self,
g_autoptr(GMutexLocker) locker = NULL;
/* only process this app if was created by this plugin */
- if (!gs_app_has_management_plugin (app, GS_PLUGIN (self)))
+ if (!gs_plugin_packagekit_is_packagekit_app (app, GS_PLUGIN (self)))
return;
/* the package is already downloaded */
@@ -445,7 +445,7 @@ _systemd_trigger_app (GsPluginSystemdUpdates *self,
return TRUE;
/* only process this app if was created by this plugin */
- if (!gs_app_has_management_plugin (app, GS_PLUGIN (self)))
+ if (!gs_plugin_packagekit_is_packagekit_app (app, GS_PLUGIN (self)))
return TRUE;
/* already in correct state */
@@ -506,7 +506,7 @@ gs_plugin_update_cancel (GsPlugin *plugin,
GsPluginSystemdUpdates *self = GS_PLUGIN_SYSTEMD_UPDATES (plugin);
/* only process this app if was created by this plugin */
- if (!gs_app_has_management_plugin (app, plugin))
+ if (!gs_plugin_packagekit_is_packagekit_app (app, plugin))
return TRUE;
/* already in correct state */
@@ -533,7 +533,7 @@ gs_plugin_app_upgrade_trigger (GsPlugin *plugin,
GError **error)
{
/* only process this app if was created by this plugin */
- if (!gs_app_has_management_plugin (app, plugin))
+ if (!gs_plugin_packagekit_is_packagekit_app (app, plugin))
return TRUE;
if (!gs_systemd_call_trigger_upgrade (plugin, PK_OFFLINE_ACTION_REBOOT, cancellable, error)) {
diff --git a/plugins/packagekit/packagekit-common.c b/plugins/packagekit/packagekit-common.c
index 042e4935d..7d78bb6d9 100644
--- a/plugins/packagekit/packagekit-common.c
+++ b/plugins/packagekit/packagekit-common.c
@@ -574,3 +574,18 @@ gs_plugin_packagekit_set_packaging_format (GsPlugin *plugin, GsApp *app)
gs_app_set_metadata (app, "GnomeSoftware::PackagingFormat", "deb");
}
}
+
+gboolean
+gs_plugin_packagekit_is_packagekit_app (GsApp *app,
+ GsPlugin *plugin)
+{
+ g_autoptr(GsPlugin) mngmt_plugin = NULL;
+
+ if (gs_app_has_management_plugin (app, plugin))
+ return TRUE;
+
+ mngmt_plugin = gs_app_dup_management_plugin (app);
+
+ return mngmt_plugin != NULL &&
+ g_strcmp0 (gs_plugin_get_name (mngmt_plugin), "packagekit") == 0;
+}
diff --git a/plugins/packagekit/packagekit-common.h b/plugins/packagekit/packagekit-common.h
index 9f5236844..b9175561a 100644
--- a/plugins/packagekit/packagekit-common.h
+++ b/plugins/packagekit/packagekit-common.h
@@ -36,5 +36,7 @@ void gs_plugin_packagekit_refine_details_app (GsPlugin *plugin,
GsApp *app);
void gs_plugin_packagekit_set_packaging_format (GsPlugin *plugin,
GsApp *app);
+gboolean gs_plugin_packagekit_is_packagekit_app (GsApp *app,
+ GsPlugin *plugin);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]