[gnome-software/wip/temp/ubuntu-xenial-rebased: 76/329] Allow apt packages to be live updated



commit fd1c7aeed28449e4abb123ff23108b327dd88b3e
Author: Robert Ancell <robert ancell canonical com>
Date:   Wed Feb 10 15:32:05 2016 +1300

    Allow apt packages to be live updated

 src/plugins/gs-plugin-apt.c |   27 +++++++++++++++++++++++++--
 1 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/src/plugins/gs-plugin-apt.c b/src/plugins/gs-plugin-apt.c
index a338ad1..bb23e56 100644
--- a/src/plugins/gs-plugin-apt.c
+++ b/src/plugins/gs-plugin-apt.c
@@ -199,7 +199,7 @@ parse_package_info (const gchar *info, GsPluginRefineFlags flags, GList **list,
                        continue;
 
                if (g_str_has_prefix (lines[i], status_prefix)) {
-                       if (g_str_has_suffix (lines[i] + strlen (status_prefix), " installed"))
+                       if (g_str_has_suffix (lines[i] + strlen (status_prefix), " installed") && 
gs_app_get_state (app) == AS_APP_STATE_UNKNOWN)
                                gs_app_set_state (app, AS_APP_STATE_INSTALLED);
                } else if (g_str_has_prefix (lines[i], installed_size_prefix) && (flags & 
GS_PLUGIN_REFINE_FLAGS_REQUIRE_SIZE) != 0) {
                        if (gs_app_get_size (app) == 0)
@@ -209,8 +209,12 @@ parse_package_info (const gchar *info, GsPluginRefineFlags flags, GList **list,
 
                        if (gs_app_get_version (app) == NULL)
                                gs_app_set_version (app, version);
-                       if (gs_app_get_state (app) == AS_APP_STATE_INSTALLED && version_newer 
(gs_app_get_update_version (app), version))
+                       if ((gs_app_get_state (app) == AS_APP_STATE_INSTALLED ||gs_app_get_state (app) == 
AS_APP_STATE_UPDATABLE_LIVE) && version_newer (gs_app_get_update_version (app), version)) {
+                               if (gs_app_get_state (app) == AS_APP_STATE_INSTALLED)
+                                       gs_app_set_state (app, AS_APP_STATE_UNKNOWN);
+                               gs_app_set_state (app, AS_APP_STATE_UPDATABLE_LIVE);
                                gs_app_set_update_version (app, version);
+                       }
                }
        }
 
@@ -591,3 +595,22 @@ gs_plugin_add_updates (GsPlugin *plugin,
 
        return TRUE;
 }
+
+gboolean
+gs_plugin_app_update (GsPlugin *plugin,
+                     GsApp *app,
+                     GCancellable *cancellable,
+                     GError **error)
+{
+       g_printerr ("APT: gs_plugin_app_update\n");
+
+       gs_app_set_state (app, AS_APP_STATE_INSTALLING);
+       if (aptd_transaction ("UpgradePackages", app, error))
+               gs_app_set_state (app, AS_APP_STATE_INSTALLED);
+       else {
+               gs_app_set_state (app, AS_APP_STATE_UPDATABLE_LIVE);
+               return FALSE;
+       }
+
+       return TRUE;
+}


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