Fix several reported problems with the offline-update funtionality.
This commit is contained in:
parent
ce93e7da53
commit
47ea9a0363
@ -1204,3 +1204,295 @@ index ae40281..36972be 100644
|
||||
pk_offline_update_reboot ();
|
||||
g_free (packages_data);
|
||||
g_strfreev (package_ids);
|
||||
commit e5e2ec784248a5ee15be98dbfe2e6d12bd5ec63a
|
||||
Author: Richard Hughes <richard@hughsie.com>
|
||||
Date: Tue Jul 10 11:00:56 2012 +0100
|
||||
|
||||
Never run any plugins for simulated actions
|
||||
|
||||
diff --git a/src/pk-transaction.c b/src/pk-transaction.c
|
||||
index b5292fc..a29eb82 100644
|
||||
--- a/src/pk-transaction.c
|
||||
+++ b/src/pk-transaction.c
|
||||
@@ -944,6 +944,14 @@ pk_transaction_plugin_phase (PkTransaction *transaction,
|
||||
if (transaction->priv->plugins == NULL)
|
||||
goto out;
|
||||
|
||||
+ /* never run any plugins for simulate actions */
|
||||
+ if (pk_bitfield_contain (transaction->priv->cached_transaction_flags,
|
||||
+ PK_TRANSACTION_FLAG_ENUM_SIMULATE)) {
|
||||
+ g_debug ("not running plugin function %s as simulating",
|
||||
+ function);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
/* run each plugin */
|
||||
for (i=0; i<transaction->priv->plugins->len; i++) {
|
||||
plugin = g_ptr_array_index (transaction->priv->plugins, i);
|
||||
commit 10e2461115adb7ecd9ab37c64b54484eea17e5ae
|
||||
Author: Richard Hughes <richard@hughsie.com>
|
||||
Date: Tue Jul 10 12:46:01 2012 +0100
|
||||
|
||||
Run any methods that implement pk_plugin_state_changed() when the daemon state changes
|
||||
|
||||
This can happen if any native tool is run on the command line.
|
||||
|
||||
diff --git a/src/pk-engine.c b/src/pk-engine.c
|
||||
index bd845d1..4844355 100644
|
||||
--- a/src/pk-engine.c
|
||||
+++ b/src/pk-engine.c
|
||||
@@ -58,6 +58,7 @@
|
||||
|
||||
static void pk_engine_finalize (GObject *object);
|
||||
static void pk_engine_set_locked (PkEngine *engine, gboolean is_locked);
|
||||
+static void pk_engine_plugin_phase (PkEngine *engine, PkPluginPhase phase);
|
||||
|
||||
#define PK_ENGINE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PK_TYPE_ENGINE, PkEnginePrivate))
|
||||
|
||||
@@ -379,6 +380,9 @@ pk_engine_state_changed_cb (gpointer data)
|
||||
|
||||
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
|
||||
|
||||
+ /* run the plugin hook */
|
||||
+ pk_engine_plugin_phase (engine, PK_PLUGIN_PHASE_STATE_CHANGED);
|
||||
+
|
||||
/* if network is not up, then just reschedule */
|
||||
state = pk_network_get_network_state (engine->priv->network);
|
||||
if (state == PK_NETWORK_ENUM_OFFLINE) {
|
||||
@@ -1042,6 +1046,9 @@ pk_engine_plugin_phase (PkEngine *engine,
|
||||
case PK_PLUGIN_PHASE_DESTROY:
|
||||
function = "pk_plugin_destroy";
|
||||
break;
|
||||
+ case PK_PLUGIN_PHASE_STATE_CHANGED:
|
||||
+ function = "pk_plugin_state_changed";
|
||||
+ break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
diff --git a/src/pk-plugin.h b/src/pk-plugin.h
|
||||
index bf13711..8c4ce02 100644
|
||||
--- a/src/pk-plugin.h
|
||||
+++ b/src/pk-plugin.h
|
||||
@@ -49,6 +49,7 @@ typedef enum {
|
||||
PK_PLUGIN_PHASE_TRANSACTION_FINISHED_RESULTS, /* finished with some signals */
|
||||
PK_PLUGIN_PHASE_TRANSACTION_FINISHED_END, /* finished with no signals */
|
||||
PK_PLUGIN_PHASE_DESTROY, /* plugin finalized */
|
||||
+ PK_PLUGIN_PHASE_STATE_CHANGED, /* system state has changed */
|
||||
PK_PLUGIN_PHASE_UNKNOWN
|
||||
} PkPluginPhase;
|
||||
|
||||
@@ -65,6 +66,7 @@ typedef void (*PkPluginTransactionFunc) (PkPlugin *plugin,
|
||||
const gchar *pk_plugin_get_description (void);
|
||||
void pk_plugin_initialize (PkPlugin *plugin);
|
||||
void pk_plugin_destroy (PkPlugin *plugin);
|
||||
+void pk_plugin_state_changed (PkPlugin *plugin);
|
||||
void pk_plugin_transaction_run (PkPlugin *plugin,
|
||||
PkTransaction *transaction);
|
||||
void pk_plugin_transaction_started (PkPlugin *plugin,
|
||||
commit 16513d3a3032ca61c8e5e6ade91c64c5fdde8ccc
|
||||
Author: Richard Hughes <richard@hughsie.com>
|
||||
Date: Tue Jul 10 12:46:37 2012 +0100
|
||||
|
||||
systemd-updates: Remove the prepared-updates file if the daemon state changes
|
||||
|
||||
diff --git a/src/plugins/pk-plugin-systemd-updates.c b/src/plugins/pk-plugin-systemd-updates.c
|
||||
index b0abc8d..00c099a 100644
|
||||
--- a/src/plugins/pk-plugin-systemd-updates.c
|
||||
+++ b/src/plugins/pk-plugin-systemd-updates.c
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <config.h>
|
||||
#include <gio/gio.h>
|
||||
+#include <glib/gstdio.h>
|
||||
#include <pk-plugin.h>
|
||||
|
||||
/**
|
||||
@@ -90,6 +91,31 @@ pk_plugin_array_str_exists (GPtrArray *array, const gchar *str)
|
||||
}
|
||||
|
||||
/**
|
||||
+ * pk_plugin_state_changed:
|
||||
+ */
|
||||
+void
|
||||
+pk_plugin_state_changed (PkPlugin *plugin)
|
||||
+{
|
||||
+ gchar *file;
|
||||
+
|
||||
+ /* if the state changed because of a yum command that could
|
||||
+ * have changed the updates list then nuke the prepared-updates
|
||||
+ * file */
|
||||
+ file = g_build_filename (LOCALSTATEDIR,
|
||||
+ "lib",
|
||||
+ "PackageKit",
|
||||
+ "prepared-update",
|
||||
+ NULL);
|
||||
+ if (g_file_test (file, G_FILE_TEST_EXISTS)) {
|
||||
+ g_debug ("Removing %s as state has changed", file);
|
||||
+ g_unlink (file);
|
||||
+ } else {
|
||||
+ g_debug ("No %s needed to be deleted", file);
|
||||
+ }
|
||||
+ g_free (file);
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
* pk_plugin_transaction_finished_end:
|
||||
*/
|
||||
void
|
||||
commit 3fde672000e38812dd41e5d50c225b91c3f951fa
|
||||
Author: Richard Hughes <richard@hughsie.com>
|
||||
Date: Tue Jul 10 13:00:02 2012 +0100
|
||||
|
||||
systemd-updates: Remove the prepared-updates file if GetUpdates() returns no packages
|
||||
|
||||
diff --git a/src/plugins/pk-plugin-systemd-updates.c b/src/plugins/pk-plugin-systemd-updates.c
|
||||
index 00c099a..de3e491 100644
|
||||
--- a/src/plugins/pk-plugin-systemd-updates.c
|
||||
+++ b/src/plugins/pk-plugin-systemd-updates.c
|
||||
@@ -116,11 +116,10 @@ pk_plugin_state_changed (PkPlugin *plugin)
|
||||
}
|
||||
|
||||
/**
|
||||
- * pk_plugin_transaction_finished_end:
|
||||
+ * pk_plugin_transaction_update_packages:
|
||||
*/
|
||||
-void
|
||||
-pk_plugin_transaction_finished_end (PkPlugin *plugin,
|
||||
- PkTransaction *transaction)
|
||||
+static void
|
||||
+pk_plugin_transaction_update_packages (PkTransaction *transaction)
|
||||
{
|
||||
gboolean ret;
|
||||
gchar **package_ids;
|
||||
@@ -130,20 +129,6 @@ pk_plugin_transaction_finished_end (PkPlugin *plugin,
|
||||
GPtrArray *packages;
|
||||
guint i;
|
||||
PkBitfield transaction_flags;
|
||||
- PkExitEnum exit_enum;
|
||||
- PkResults *results;
|
||||
- PkRoleEnum role;
|
||||
-
|
||||
- /* check the role */
|
||||
- role = pk_transaction_get_role (transaction);
|
||||
- if (role != PK_ROLE_ENUM_UPDATE_PACKAGES)
|
||||
- goto out;
|
||||
-
|
||||
- /* check for success */
|
||||
- results = pk_transaction_get_results (transaction);
|
||||
- exit_enum = pk_results_get_exit_code (results);
|
||||
- if (exit_enum != PK_EXIT_ENUM_SUCCESS)
|
||||
- goto out;
|
||||
|
||||
/* only write the file for only-download */
|
||||
transaction_flags = pk_transaction_get_transaction_flags (transaction);
|
||||
@@ -186,3 +171,70 @@ out:
|
||||
g_free (path);
|
||||
return;
|
||||
}
|
||||
+
|
||||
+/**
|
||||
+ * pk_plugin_transaction_get_updates:
|
||||
+ */
|
||||
+static void
|
||||
+pk_plugin_transaction_get_updates (PkTransaction *transaction)
|
||||
+{
|
||||
+ gchar *path;
|
||||
+ GPtrArray *array;
|
||||
+ PkResults *results;
|
||||
+
|
||||
+ results = pk_transaction_get_results (transaction);
|
||||
+ path = g_build_filename (LOCALSTATEDIR,
|
||||
+ "lib",
|
||||
+ "PackageKit",
|
||||
+ "prepared-update",
|
||||
+ NULL);
|
||||
+ array = pk_results_get_package_array (results);
|
||||
+ if (array->len != 0) {
|
||||
+ g_debug ("got %i updates, so ignoring %s",
|
||||
+ array->len, path);
|
||||
+ goto out;
|
||||
+ }
|
||||
+ if (g_file_test (path, G_FILE_TEST_EXISTS)) {
|
||||
+ g_debug ("Removing %s as no updates", path);
|
||||
+ g_unlink (path);
|
||||
+ } else {
|
||||
+ g_debug ("No %s present, so no need to delete", path);
|
||||
+ }
|
||||
+out:
|
||||
+ g_free (path);
|
||||
+ g_ptr_array_unref (array);
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * pk_plugin_transaction_finished_end:
|
||||
+ */
|
||||
+void
|
||||
+pk_plugin_transaction_finished_end (PkPlugin *plugin,
|
||||
+ PkTransaction *transaction)
|
||||
+{
|
||||
+ PkExitEnum exit_enum;
|
||||
+ PkResults *results;
|
||||
+ PkRoleEnum role;
|
||||
+
|
||||
+ /* check for success */
|
||||
+ results = pk_transaction_get_results (transaction);
|
||||
+ exit_enum = pk_results_get_exit_code (results);
|
||||
+ if (exit_enum != PK_EXIT_ENUM_SUCCESS)
|
||||
+ goto out;
|
||||
+
|
||||
+ /* if we're doing only-download then update prepared-updates */
|
||||
+ role = pk_transaction_get_role (transaction);
|
||||
+ if (role == PK_ROLE_ENUM_UPDATE_PACKAGES) {
|
||||
+ pk_plugin_transaction_update_packages (transaction);
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ /* if we do get-updates and there's no updates then remove
|
||||
+ * prepared-updates so the UI doesn't display update & reboot */
|
||||
+ if (role == PK_ROLE_ENUM_GET_UPDATES) {
|
||||
+ pk_plugin_transaction_get_updates (transaction);
|
||||
+ goto out;
|
||||
+ }
|
||||
+out:
|
||||
+ return;
|
||||
+}
|
||||
commit af0443450775a1876aeb4af84595b331bad19640
|
||||
Author: Richard Hughes <richard@hughsie.com>
|
||||
Date: Tue Jul 10 14:06:55 2012 +0100
|
||||
|
||||
When doing 'pkcon update' allow the user to specify filters but enforce NEWEST
|
||||
|
||||
diff --git a/client/pk-console.c b/client/pk-console.c
|
||||
index 2d16ff8..377ce28 100644
|
||||
--- a/client/pk-console.c
|
||||
+++ b/client/pk-console.c
|
||||
@@ -979,7 +979,7 @@ out:
|
||||
* pk_console_update_system:
|
||||
**/
|
||||
static gboolean
|
||||
-pk_console_update_system (GError **error)
|
||||
+pk_console_update_system (PkBitfield filters, GError **error)
|
||||
{
|
||||
gboolean ret = TRUE;
|
||||
gchar **package_ids = NULL;
|
||||
@@ -987,7 +987,10 @@ pk_console_update_system (GError **error)
|
||||
PkResults *results;
|
||||
|
||||
/* get the current updates */
|
||||
- results = pk_task_get_updates_sync (PK_TASK (task), 0, cancellable,
|
||||
+ pk_bitfield_add (filters, PK_FILTER_ENUM_NEWEST);
|
||||
+ results = pk_task_get_updates_sync (PK_TASK (task),
|
||||
+ filters,
|
||||
+ cancellable,
|
||||
(PkProgressCallback) pk_console_progress_cb, NULL,
|
||||
error);
|
||||
if (results == NULL) {
|
||||
@@ -1597,7 +1600,7 @@ main (int argc, char *argv[])
|
||||
} else if (strcmp (mode, "update") == 0) {
|
||||
if (value == NULL) {
|
||||
/* do the system update */
|
||||
- nowait = !pk_console_update_system (&error);
|
||||
+ nowait = !pk_console_update_system (filters, &error);
|
||||
} else {
|
||||
nowait = !pk_console_update_packages (argv+2, &error);
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
Summary: Package management service
|
||||
Name: PackageKit
|
||||
Version: 0.8.1
|
||||
Release: 6%{?dist}
|
||||
Release: 7%{?dist}
|
||||
License: GPLv2+ and LGPLv2+
|
||||
URL: http://www.packagekit.org
|
||||
Source0: http://www.packagekit.org/releases/%{name}-%{version}.tar.xz
|
||||
@ -472,6 +472,9 @@ update-mime-database %{_datadir}/mime &> /dev/null || :
|
||||
%{_libdir}/pkgconfig/packagekit-plugin.pc
|
||||
|
||||
%changelog
|
||||
* Tue Jul 09 2012 Richard Hughes <rhughes@redhat.com> - 0.8.1-7
|
||||
- Fix several reported problems with the offline-update funtionality.
|
||||
|
||||
* Mon Jul 09 2012 Richard Hughes <rhughes@redhat.com> - 0.8.1-6
|
||||
- Fix several reported problems with the offline-update funtionality.
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user