[gnome-software/wip/rancell/ubuntu-ratings] Populate the needs-to-be-removed applications when refining the system upgrade
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/rancell/ubuntu-ratings] Populate the needs-to-be-removed applications when refining the system upgrade
- Date: Thu, 12 Nov 2015 02:28:38 +0000 (UTC)
commit 22c133fd77959c48c50e92ee6f0c656917c47f9f
Author: Richard Hughes <richard hughsie com>
Date: Thu Oct 29 17:03:06 2015 +0000
Populate the needs-to-be-removed applications when refining the system upgrade
src/gs-cmd.c | 4 ++-
src/gs-plugin.h | 1 +
src/plugins/gs-plugin-packagekit-refine.c | 57 +++++++++++++++++++++++++++++
src/plugins/packagekit-common.c | 4 ++
4 files changed, 65 insertions(+), 1 deletions(-)
---
diff --git a/src/gs-cmd.c b/src/gs-cmd.c
index 31ddcc1..3f123da 100644
--- a/src/gs-cmd.c
+++ b/src/gs-cmd.c
@@ -111,7 +111,7 @@ static GsPluginRefineFlags
gs_cmd_refine_flag_from_string (const gchar *flag, GError **error)
{
if (g_strcmp0 (flag, "all") == 0)
- return 0xffff;
+ return G_MAXINT32;
if (g_strcmp0 (flag, "licence") == 0)
return GS_PLUGIN_REFINE_FLAGS_REQUIRE_LICENCE;
if (g_strcmp0 (flag, "url") == 0)
@@ -136,6 +136,8 @@ gs_cmd_refine_flag_from_string (const gchar *flag, GError **error)
return GS_PLUGIN_REFINE_FLAGS_REQUIRE_RELATED;
if (g_strcmp0 (flag, "menu-path") == 0)
return GS_PLUGIN_REFINE_FLAGS_REQUIRE_MENU_PATH;
+ if (g_strcmp0 (flag, "upgrade-removed") == 0)
+ return GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPGRADE_REMOVED;
g_set_error (error,
GS_PLUGIN_ERROR,
GS_PLUGIN_ERROR_NOT_SUPPORTED,
diff --git a/src/gs-plugin.h b/src/gs-plugin.h
index f05732d..c217ec0 100644
--- a/src/gs-plugin.h
+++ b/src/gs-plugin.h
@@ -101,6 +101,7 @@ typedef enum {
GS_PLUGIN_REFINE_FLAGS_REQUIRE_ADDONS = 1 << 13,
GS_PLUGIN_REFINE_FLAGS_ALLOW_PACKAGES = 1 << 14,
GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPDATE_SEVERITY = 1 << 15,
+ GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPGRADE_REMOVED = 1 << 16,
GS_PLUGIN_REFINE_FLAGS_LAST
} GsPluginRefineFlags;
diff --git a/src/plugins/gs-plugin-packagekit-refine.c b/src/plugins/gs-plugin-packagekit-refine.c
index a815511..c3df283 100644
--- a/src/plugins/gs-plugin-packagekit-refine.c
+++ b/src/plugins/gs-plugin-packagekit-refine.c
@@ -797,6 +797,47 @@ gs_plugin_refine_requires_package_id (GsApp *app, GsPluginRefineFlags flags)
}
/**
+ * gs_plugin_packagekit_refine_distro_upgrade:
+ **/
+static gboolean
+gs_plugin_packagekit_refine_distro_upgrade (GsPlugin *plugin,
+ GsApp *app,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GList *l;
+ GsApp *app2;
+ ProgressData data;
+ g_autoptr(PkResults) results = NULL;
+ g_autoptr(GsAppList) list = NULL;
+
+ data.plugin = plugin;
+ data.ptask = NULL;
+
+ /* ask PK to simulate upgrading the system */
+ results = pk_client_upgrade_system (plugin->priv->client,
+ pk_bitfield_from_enums (PK_TRANSACTION_FLAG_ENUM_SIMULATE, -1),
+ gs_app_get_id (app),
+ PK_UPGRADE_KIND_ENUM_COMPLETE,
+ cancellable,
+ gs_plugin_packagekit_progress_cb, &data,
+ error);
+ if (results == NULL)
+ return FALSE;
+ if (!gs_plugin_packagekit_add_results (plugin, &list, results, error))
+ return FALSE;
+
+ /* add each of these as related applications */
+ for (l = list; l != NULL; l = l->next) {
+ app2 = GS_APP (l->data);
+ if (gs_app_get_state (app2) != AS_APP_STATE_AVAILABLE)
+ continue;
+ gs_app_add_related (app, app2);
+ }
+ return TRUE;
+}
+
+/**
* gs_plugin_refine:
*/
gboolean
@@ -815,6 +856,22 @@ gs_plugin_refine (GsPlugin *plugin,
g_autoptr(GList) updatedetails_all = NULL;
AsProfileTask *ptask = NULL;
+ /* when we need the cannot-be-upgraded applications, we implement this
+ * by doing a UpgradeSystem(SIMULATE) which adds the removed packages
+ * to the related-apps list with a state of %AS_APP_STATE_AVAILABLE */
+ if (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPGRADE_REMOVED) {
+ for (l = *list; l != NULL; l = l->next) {
+ app = GS_APP (l->data);
+ if (gs_app_get_kind (app) != GS_APP_KIND_DISTRO_UPGRADE)
+ continue;
+ if (!gs_plugin_packagekit_refine_distro_upgrade (plugin,
+ app,
+ cancellable,
+ error))
+ return FALSE;
+ }
+ }
+
/* get the repo_id -> repo_name mapping set up */
if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN) > 0 &&
g_hash_table_size (plugin->priv->sources) == 0) {
diff --git a/src/plugins/packagekit-common.c b/src/plugins/packagekit-common.c
index 8d497fd..ef17426 100644
--- a/src/plugins/packagekit-common.c
+++ b/src/plugins/packagekit-common.c
@@ -159,8 +159,12 @@ gs_plugin_packagekit_add_results (GsPlugin *plugin,
gs_app_set_state (app, AS_APP_STATE_INSTALLED);
break;
case PK_INFO_ENUM_AVAILABLE:
+ case PK_INFO_ENUM_REMOVING:
gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
break;
+ case PK_INFO_ENUM_INSTALLING:
+ case PK_INFO_ENUM_UPDATING:
+ break;
default:
gs_app_set_state (app, AS_APP_STATE_UNKNOWN);
g_warning ("unknown info state of %s",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]