[gnome-software] Correctly trigger systemd offline updates when only processing OS updates



commit 9aef042835c9cc304ddf319709e73113898bbff2
Author: Richard Hughes <richard hughsie com>
Date:   Tue May 24 10:51:08 2016 +0100

    Correctly trigger systemd offline updates when only processing OS updates
    
    The 'OS Updates' object is a virtual update that contains the actual
    package-backed GsApp's as related packages. As such, we need to look at the
    related packages for each update as well as the applications themselves when
    working out if we need to set up the trigger action.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1337336

 src/plugins/gs-plugin-systemd-updates.c |   33 +++++++++++++++++++++++++-----
 1 files changed, 27 insertions(+), 6 deletions(-)
---
diff --git a/src/plugins/gs-plugin-systemd-updates.c b/src/plugins/gs-plugin-systemd-updates.c
index c23655f..8fb1c5b 100644
--- a/src/plugins/gs-plugin-systemd-updates.c
+++ b/src/plugins/gs-plugin-systemd-updates.c
@@ -134,6 +134,32 @@ gs_plugin_add_updates (GsPlugin *plugin,
        return TRUE;
 }
 
+static gboolean
+gs_plugin_systemd_updates_requires_trigger (GsApp *app)
+{
+       GPtrArray *related;
+       guint i;
+
+       /* look at related apps too */
+       related = gs_app_get_related (app);
+       for (i = 0; i < related->len; i++) {
+               GsApp *app_tmp = g_ptr_array_index (related, i);
+               if (gs_plugin_systemd_updates_requires_trigger (app_tmp))
+                       return TRUE;
+       }
+
+       /* if we can process this online do not require a trigger */
+       if (gs_app_get_state (app) != AS_APP_STATE_UPDATABLE)
+               return FALSE;
+
+       /* only process this app if was created by this plugin */
+       if (g_strcmp0 (gs_app_get_management_plugin (app), "packagekit") != 0)
+               return FALSE;
+
+       /* success! */
+       return TRUE;
+}
+
 gboolean
 gs_plugin_update (GsPlugin *plugin,
                  GsAppList *apps,
@@ -145,12 +171,7 @@ gs_plugin_update (GsPlugin *plugin,
        /* any apps to process offline */
        for (i = 0; i < gs_app_list_length (apps); i++) {
                GsApp *app = gs_app_list_index (apps, i);
-
-               /* only process this app if was created by this plugin */
-               if (g_strcmp0 (gs_app_get_management_plugin (app), "packagekit") != 0)
-                       continue;
-
-               if (gs_app_get_state (app) == AS_APP_STATE_UPDATABLE) {
+               if (gs_plugin_systemd_updates_requires_trigger (app)) {
                        return pk_offline_trigger (PK_OFFLINE_ACTION_REBOOT,
                                                   cancellable, error);
                }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]