[packagekit] packagekit: Branch 'master' - 9 commits

Richard Hughes hughsient at kemper.freedesktop.org
Mon Nov 5 15:00:30 PST 2007


 backends/yum/pk-backend-yum.c |    2 -
 client/pk-console.c           |    6 ++--
 libpackagekit/pk-client.c     |    8 +++---
 src/pk-backend-internal.h     |    3 +-
 src/pk-backend.c              |   32 +++++++++++++++++++------
 src/pk-engine.c               |   53 ++++++++++++++++++++++++++++++++----------
 src/pk-time.c                 |    1 
 src/pk-transaction-list.c     |   14 ++++++++++-
 8 files changed, 91 insertions(+), 28 deletions(-)

New commits:
commit a38c6745e0d4c1348b68ad6b4c2d04e757823e43
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Nov 5 22:32:40 2007 +0000

    don't emit error for the transaction if cancel is not valid - cancel operates on an existing tid and shouldn't have control of the finished or error signals

diff --git a/src/pk-backend-internal.h b/src/pk-backend-internal.h
index 7eb4a49..cd83a77 100644
--- a/src/pk-backend-internal.h
+++ b/src/pk-backend-internal.h
@@ -65,7 +65,8 @@ gboolean	 pk_backend_load			(PkBackend      *backend,
 gboolean	 pk_backend_run				(PkBackend      *backend);
 gboolean	 pk_backend_unload			(PkBackend      *backend);
 const gchar	*pk_backend_get_name			(PkBackend	*backend);
-gboolean	 pk_backend_cancel			(PkBackend	*backend);
+gboolean	 pk_backend_cancel			(PkBackend	*backend,
+							 gchar		**error_text);
 gboolean	 pk_backend_get_depends			(PkBackend	*backend,
 							 const gchar	*package_id);
 gboolean	 pk_backend_get_update_detail		(PkBackend	*backend,
diff --git a/src/pk-backend.c b/src/pk-backend.c
index 3209973..bee1f79 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -1146,25 +1146,28 @@ pk_backend_allow_interrupt (PkBackend *backend, gboolean allow_restart)
  * pk_backend_cancel:
  */
 gboolean
-pk_backend_cancel (PkBackend *backend)
+pk_backend_cancel (PkBackend *backend, gchar **error_text)
 {
 	g_return_val_if_fail (backend != NULL, FALSE);
+	g_return_val_if_fail (error_text != NULL, FALSE);
+
+	/* not implemented yet */
 	if (backend->desc->cancel == NULL) {
-		pk_backend_not_implemented_yet (backend, "Cancel");
+		*error_text = g_strdup ("Operation not yet supported by backend");
 		return FALSE;
 	}
 	/* check to see if we have an action */
 	if (backend->priv->assigned == FALSE) {
-		pk_warning ("Not assigned");
+		*error_text = g_strdup ("Not yet assigned");
 		return FALSE;
 	}
 	/* check if it's safe to kill */
 	if (backend->priv->is_killable == FALSE) {
-		pk_warning ("tried to kill a process that is not safe to kill");
+		*error_text = g_strdup ("Tried to kill a process that is not safe to kill");
 		return FALSE;
 	}
 	if (backend->priv->spawn == NULL) {
-		pk_warning ("tried to kill a process that does not exist");
+		*error_text = g_strdup ("Tried to kill a process that does not exist");
 		return FALSE;
 	}
 	backend->desc->cancel (backend);
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 7cec33b..d79703c 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -2324,6 +2324,7 @@ gboolean
 pk_engine_cancel (PkEngine *engine, const gchar *tid, GError **error)
 {
 	gboolean ret;
+	gchar *error_text = NULL;
 	PkTransactionItem *item;
 
 	g_return_val_if_fail (engine != NULL, FALSE);
@@ -2346,10 +2347,11 @@ pk_engine_cancel (PkEngine *engine, const gchar *tid, GError **error)
 		return TRUE;
 	}
 
-	ret = pk_backend_cancel (item->backend);
+	/* try to cancel the transaction */
+	ret = pk_backend_cancel (item->backend, &error_text);
 	if (ret == FALSE) {
-		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
-			     "Operation not yet supported by backend");
+		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED, error_text);
+		g_free (error_text);
 		return FALSE;
 	}
 
commit 176b9d07063e2990c7baf434076bb8001288734a
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Nov 5 21:15:01 2007 +0000

    check backends do not send finished more than once

diff --git a/src/pk-backend.c b/src/pk-backend.c
index 6393d5b..3209973 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -78,6 +78,7 @@ struct _PkBackendPrivate
 	gboolean		 during_initialize;
 	gboolean		 assigned;
 	gboolean		 set_error;
+	gboolean		 finished;
 	PkNetwork		*network;
 	PkInhibit		*inhibit;
 	/* needed for gui coldplugging */
@@ -1047,7 +1048,7 @@ pk_backend_finished (PkBackend *backend)
 	/* are we trying to finish in init? */
 	if (backend->priv->during_initialize == TRUE) {
 		g_print ("You can't call pk_backend_finished in backend_initialize!\n");
-		pk_error ("Internal error, cannot continue");
+		pk_error ("Internal error, cannot continue!");
 	}
 
 	/* check we have no threads running */
@@ -1059,9 +1060,22 @@ pk_backend_finished (PkBackend *backend)
 		g_print ("   - Return from the function like normal\n");
 		g_print ("* pk_thread_list_create:\n");
 		g_print ("   -  If used internally you _have_ to use pk_thread_list_wait\n");
-		pk_error ("Internal error, cannot continue (will segfault in the near future...)");
+		pk_error ("Internal error, cannot continue!");
 	}
 
+	/* check we have not already finished */
+	if (backend->priv->finished == TRUE) {
+		g_print ("Backends cannot request Finished more than once!\n");
+		g_print ("If you are using :\n");
+		g_print ("* pk_backend_thread_helper\n");
+		g_print ("   - You should _not_ use pk_backend_finished directly");
+		g_print ("   - Return from the function like normal\n");
+		pk_error ("Internal error, cannot continue!");
+	}
+
+	/* we can't ever be re-used */
+	backend->priv->finished = TRUE;
+
 	/* remove any inhibit */
 	pk_inhibit_remove (backend->priv->inhibit, backend);
 
@@ -1893,6 +1907,7 @@ pk_backend_init (PkBackend *backend)
 	backend->priv->is_killable = FALSE;
 	backend->priv->set_error = FALSE;
 	backend->priv->during_initialize = FALSE;
+	backend->priv->finished = FALSE;
 	backend->priv->spawn = NULL;
 	backend->priv->handle = NULL;
 	backend->priv->xcached_enabled = FALSE;
commit 7f9bba9e66d03103e5211878c043741321c97d21
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Nov 5 21:02:04 2007 +0000

    PkClient restart should be an enumerated type, not free text

diff --git a/client/pk-console.c b/client/pk-console.c
index a71d359..8d94220 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -117,7 +117,7 @@ pk_console_transaction_cb (PkClient *client, const gchar *tid, const gchar *time
 static void
 pk_console_update_detail_cb (PkClient *client, const gchar *package_id,
 			     const gchar *updates, const gchar *obsoletes,
-			     const gchar *url, const gchar *restart,
+			     const gchar *url, PkRestartEnum restart,
 			     const gchar *update_text, gpointer data)
 {
 	g_print ("Update detail\n");
@@ -131,8 +131,8 @@ pk_console_update_detail_cb (PkClient *client, const gchar *package_id,
 	if (pk_strzero (url) == FALSE) {
 		g_print ("  url:        '%s'\n", url);
 	}
-	if (pk_strzero (restart) == FALSE) {
-		g_print ("  restart:    '%s'\n", restart);
+	if (restart != PK_RESTART_ENUM_NONE) {
+		g_print ("  restart:    '%s'\n", pk_restart_enum_to_text (restart));
 	}
 	if (pk_strzero (update_text) == FALSE) {
 		g_print ("  update_text:'%s'\n", update_text);
diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index 4015eb5..785d3a7 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -438,10 +438,11 @@ pk_client_update_detail_cb (DBusGProxy  *proxy,
 			    const gchar *updates,
 			    const gchar *obsoletes,
 			    const gchar *url,
-			    const gchar *restart,
+			    const gchar *restart_text,
 			    const gchar *update_text,
 			    PkClient    *client)
 {
+	PkRestartEnum restart;
 	g_return_if_fail (client != NULL);
 	g_return_if_fail (PK_IS_CLIENT (client));
 
@@ -451,7 +452,8 @@ pk_client_update_detail_cb (DBusGProxy  *proxy,
 	}
 
 	pk_debug ("emit update-detail %s, %s, %s, %s, %s, %s",
-		  package_id, updates, obsoletes, url, restart, update_text);
+		  package_id, updates, obsoletes, url, restart_text, update_text);
+	restart = pk_restart_enum_from_text (restart_text);
 	g_signal_emit (client , signals [PK_CLIENT_UPDATE_DETAIL], 0,
 		       package_id, updates, obsoletes, url, restart, update_text);
 }
@@ -2288,7 +2290,7 @@ pk_client_class_init (PkClientClass *klass)
 			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
 			      0, NULL, NULL, pk_marshal_VOID__STRING_STRING_STRING_STRING_STRING_STRING,
 			      G_TYPE_NONE, 6, G_TYPE_STRING, G_TYPE_STRING,
-			      G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
+			      G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING);
 	signals [PK_CLIENT_DESCRIPTION] =
 		g_signal_new ("description",
 			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
commit 6b9652173d7d9caddac7e3a7ddc9fab28263d8c8
Merge: 315a010... 75e0ea5...
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Nov 5 20:12:30 2007 +0000

    Merge branch 'master' of git+ssh://hughsie@git.packagekit.org/srv/git/PackageKit

commit 315a0100e7f88e6fb41b103ae6f4c37189ebba34
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Nov 5 20:08:38 2007 +0000

    check if transaction is already finished to try to find a backtrace reported by Grzegorz

diff --git a/src/pk-transaction-list.c b/src/pk-transaction-list.c
index c58bda3..37ba2ec 100644
--- a/src/pk-transaction-list.c
+++ b/src/pk-transaction-list.c
@@ -125,11 +125,16 @@ pk_transaction_list_create (PkTransactionList *tlist)
 gboolean
 pk_transaction_list_remove (PkTransactionList *tlist, PkTransactionItem *item)
 {
+	gboolean ret;
+
 	g_return_val_if_fail (tlist != NULL, FALSE);
 	g_return_val_if_fail (PK_IS_TRANSACTION_LIST (tlist), FALSE);
 
 	/* valid item */
-	g_ptr_array_remove (tlist->priv->array, item);
+	ret = g_ptr_array_remove (tlist->priv->array, item);
+	if (ret == FALSE) {
+		pk_warning ("could not remove %p as not present in list", item);
+	}
 	g_object_unref (item->package_list);
 	g_free (item->tid);
 	g_free (item);
@@ -176,6 +181,13 @@ pk_transaction_list_backend_finished_cb (PkBackend *backend, PkExitEnum exit, Pk
 	if (item == NULL) {
 		pk_error ("no transaction list found!");
 	}
+
+	/* transaction is already finished? */
+	if (item->finished == TRUE) {
+		pk_warning ("transaction %s finished twice!", item->tid);
+		return;
+	}
+
 	pk_debug ("transaction %s completed, marking finished", item->tid);
 	item->finished = TRUE;
 
commit 75e0ea5bb630060f04e70432b1cfa73a48ea61ee
Author: Grzegorz Dabrowski <gdx at o2.pl>
Date:   Mon Nov 5 19:37:33 2007 +0000

    release memory allocated by dbus_g_method_get_sender()

diff --git a/src/pk-engine.c b/src/pk-engine.c
index cf6becd..7cec33b 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -1558,6 +1558,7 @@ pk_engine_update_system (PkEngine *engine, const gchar *tid, DBusGMethodInvocati
 	gboolean ret;
 	GError *error;
 	PkTransactionItem *item;
+	gchar *sender;
 
 	g_return_if_fail (engine != NULL);
 	g_return_if_fail (PK_IS_ENGINE (engine));
@@ -1574,7 +1575,9 @@ pk_engine_update_system (PkEngine *engine, const gchar *tid, DBusGMethodInvocati
 	}
 
 	/* check if the action is allowed from this client - if not, set an error */
-	ret = pk_engine_action_is_allowed (engine, dbus_g_method_get_sender (context), PK_ROLE_ENUM_UPDATE_SYSTEM, &error);
+	sender = dbus_g_method_get_sender (context);
+	ret = pk_engine_action_is_allowed (engine, sender, PK_ROLE_ENUM_UPDATE_SYSTEM, &error);
+	g_free (sender);
 	if (ret == FALSE) {
 		dbus_g_method_return_error (context, error);
 		return;
@@ -1619,6 +1622,7 @@ pk_engine_remove_package (PkEngine *engine, const gchar *tid, const gchar *packa
 	PkTransactionItem *item;
 	gboolean ret;
 	GError *error;
+	gchar *sender;
 
 	g_return_if_fail (engine != NULL);
 	g_return_if_fail (PK_IS_ENGINE (engine));
@@ -1653,7 +1657,9 @@ pk_engine_remove_package (PkEngine *engine, const gchar *tid, const gchar *packa
 	}
 
 	/* check if the action is allowed from this client - if not, set an error */
-	ret = pk_engine_action_is_allowed (engine, dbus_g_method_get_sender (context), PK_ROLE_ENUM_REMOVE_PACKAGE, &error);
+	sender = dbus_g_method_get_sender (context);
+	ret = pk_engine_action_is_allowed (engine, sender, PK_ROLE_ENUM_REMOVE_PACKAGE, &error);
+	g_free (sender);
 	if (ret == FALSE) {
 		dbus_g_method_return_error (context, error);
 		return;
commit 08730bc656faab1c690b700d21c549fee07a6c70
Author: Grzegorz Dabrowski <gdx at o2.pl>
Date:   Mon Nov 5 19:27:35 2007 +0000

    fixed memleaks

diff --git a/src/pk-engine.c b/src/pk-engine.c
index 427859f..cf6becd 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -806,6 +806,7 @@ pk_engine_refresh_cache (PkEngine *engine, const gchar *tid, gboolean force,
 	gboolean ret;
 	PkTransactionItem *item;
 	GError *error;
+	gchar *sender;
 
 	g_return_if_fail (engine != NULL);
 	g_return_if_fail (PK_IS_ENGINE (engine));
@@ -822,7 +823,9 @@ pk_engine_refresh_cache (PkEngine *engine, const gchar *tid, gboolean force,
 	}
 
 	/* check if the action is allowed from this client - if not, set an error */
-	ret = pk_engine_action_is_allowed (engine, dbus_g_method_get_sender (context), PK_ROLE_ENUM_REFRESH_CACHE, &error);
+	sender = dbus_g_method_get_sender (context);
+	ret = pk_engine_action_is_allowed (engine, sender, PK_ROLE_ENUM_REFRESH_CACHE, &error);
+	g_free (sender);
 	if (ret == FALSE) {
 		dbus_g_method_return_error (context, error);
 		return;
@@ -1689,6 +1692,7 @@ pk_engine_install_package (PkEngine *engine, const gchar *tid, const gchar *pack
 	gboolean ret;
 	PkTransactionItem *item;
 	GError *error;
+	gchar *sender;
 
 	g_return_if_fail (engine != NULL);
 	g_return_if_fail (PK_IS_ENGINE (engine));
@@ -1723,7 +1727,9 @@ pk_engine_install_package (PkEngine *engine, const gchar *tid, const gchar *pack
 	}
 
 	/* check if the action is allowed from this client - if not, set an error */
-	ret = pk_engine_action_is_allowed (engine, dbus_g_method_get_sender (context), PK_ROLE_ENUM_INSTALL_PACKAGE, &error);
+	sender = dbus_g_method_get_sender (context);
+	ret = pk_engine_action_is_allowed (engine, sender, PK_ROLE_ENUM_INSTALL_PACKAGE, &error);
+	g_free (sender);
 	if (ret == FALSE) {
 		dbus_g_method_return_error (context, error);
 		return;
@@ -1762,6 +1768,7 @@ pk_engine_install_file (PkEngine *engine, const gchar *tid, const gchar *full_pa
 	gboolean ret;
 	PkTransactionItem *item;
 	GError *error;
+	gchar *sender;
 
 	g_return_if_fail (engine != NULL);
 	g_return_if_fail (PK_IS_ENGINE (engine));
@@ -1787,7 +1794,9 @@ pk_engine_install_file (PkEngine *engine, const gchar *tid, const gchar *full_pa
 	}
 
 	/* check if the action is allowed from this client - if not, set an error */
-	ret = pk_engine_action_is_allowed (engine, dbus_g_method_get_sender (context), PK_ROLE_ENUM_INSTALL_FILE, &error);
+	sender = dbus_g_method_get_sender (context);
+	ret = pk_engine_action_is_allowed (engine, sender, PK_ROLE_ENUM_INSTALL_FILE, &error);
+	g_free (sender);
 	if (ret == FALSE) {
 		dbus_g_method_return_error (context, error);
 		return;
@@ -1826,6 +1835,7 @@ pk_engine_rollback (PkEngine *engine, const gchar *tid, const gchar *transaction
 	gboolean ret;
 	PkTransactionItem *item;
 	GError *error;
+	gchar *sender;
 
 	g_return_if_fail (engine != NULL);
 	g_return_if_fail (PK_IS_ENGINE (engine));
@@ -1851,7 +1861,9 @@ pk_engine_rollback (PkEngine *engine, const gchar *tid, const gchar *transaction
 	}
 
 	/* check if the action is allowed from this client - if not, set an error */
-	ret = pk_engine_action_is_allowed (engine, dbus_g_method_get_sender (context), PK_ROLE_ENUM_ROLLBACK, &error);
+	sender = dbus_g_method_get_sender (context);
+	ret = pk_engine_action_is_allowed (engine, sender, PK_ROLE_ENUM_ROLLBACK, &error);
+	g_free (sender);
 	if (ret == FALSE) {
 		dbus_g_method_return_error (context, error);
 		return;
@@ -1890,6 +1902,7 @@ pk_engine_update_package (PkEngine *engine, const gchar *tid, const gchar *packa
 	gboolean ret;
 	PkTransactionItem *item;
 	GError *error;
+	gchar *sender;
 
 	g_return_if_fail (engine != NULL);
 	g_return_if_fail (PK_IS_ENGINE (engine));
@@ -1924,7 +1937,9 @@ pk_engine_update_package (PkEngine *engine, const gchar *tid, const gchar *packa
 	}
 
 	/* check if the action is allowed from this client - if not, set an error */
-	ret = pk_engine_action_is_allowed (engine, dbus_g_method_get_sender (context), PK_ROLE_ENUM_UPDATE_PACKAGE, &error);
+	sender = dbus_g_method_get_sender (context);
+	ret = pk_engine_action_is_allowed (engine, sender, PK_ROLE_ENUM_UPDATE_PACKAGE, &error);
+	g_free (sender);
 	if (ret == FALSE) {
 		dbus_g_method_return_error (context, error);
 		return;
@@ -2004,6 +2019,7 @@ pk_engine_repo_enable (PkEngine *engine, const gchar *tid, const gchar *repo_id,
 	gboolean ret;
 	PkTransactionItem *item;
 	GError *error;
+	gchar *sender;
 
 	g_return_if_fail (engine != NULL);
 	g_return_if_fail (PK_IS_ENGINE (engine));
@@ -2029,7 +2045,9 @@ pk_engine_repo_enable (PkEngine *engine, const gchar *tid, const gchar *repo_id,
 	}
 
 	/* check if the action is allowed from this client - if not, set an error */
-	ret = pk_engine_action_is_allowed (engine, dbus_g_method_get_sender (context), PK_ROLE_ENUM_REPO_ENABLE, &error);
+	sender = dbus_g_method_get_sender (context);
+	ret = pk_engine_action_is_allowed (engine, sender, PK_ROLE_ENUM_REPO_ENABLE, &error);
+	g_free (sender);
 	if (ret == FALSE) {
 		dbus_g_method_return_error (context, error);
 		return;
@@ -2069,6 +2087,7 @@ pk_engine_repo_set_data (PkEngine *engine, const gchar *tid, const gchar *repo_i
 	gboolean ret;
 	PkTransactionItem *item;
 	GError *error;
+	gchar *sender;
 
 	g_return_if_fail (engine != NULL);
 	g_return_if_fail (PK_IS_ENGINE (engine));
@@ -2094,7 +2113,9 @@ pk_engine_repo_set_data (PkEngine *engine, const gchar *tid, const gchar *repo_i
 	}
 
 	/* check if the action is allowed from this client - if not, set an error */
-	ret = pk_engine_action_is_allowed (engine, dbus_g_method_get_sender (context), PK_ROLE_ENUM_REPO_SET_DATA, &error);
+	sender = dbus_g_method_get_sender (context);
+	ret = pk_engine_action_is_allowed (engine, sender, PK_ROLE_ENUM_REPO_SET_DATA, &error);
+	g_free (sender);
 	if (ret == FALSE) {
 		dbus_g_method_return_error (context, error);
 		return;
commit 1d9efcd47a02aca771fca8386755a59ebf6d69fd
Author: Grzegorz Dabrowski <gdx at o2.pl>
Date:   Mon Nov 5 19:13:41 2007 +0000

    fixed memleak

diff --git a/src/pk-time.c b/src/pk-time.c
index 990f352..a5db30d 100644
--- a/src/pk-time.c
+++ b/src/pk-time.c
@@ -241,6 +241,7 @@ pk_time_finalize (GObject *object)
 	time = PK_TIME (object);
 	g_return_if_fail (time->priv != NULL);
 	g_ptr_array_free (time->priv->array, TRUE);
+	g_timer_destroy (time->priv->timer);
 
 	G_OBJECT_CLASS (pk_time_parent_class)->finalize (object);
 }
commit bbd73184bdb5a22cba88e6a24e88132613d9c12e
Author: Tim Lauridsen <tla at rasmil.dk>
Date:   Mon Nov 5 13:07:30 2007 +0100

    yum : changed my email address

diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c
index 44c9341..fed2a63 100644
--- a/backends/yum/pk-backend-yum.c
+++ b/backends/yum/pk-backend-yum.c
@@ -69,7 +69,7 @@ backend_get_filters (PkBackend *backend, PkEnumList *elist)
 
 PK_BACKEND_OPTIONS (
 	"YUM",					/* description */
-	"Tim Lauridsen <tla at rasmil.dk>",	/* author */
+	"Tim Lauridsen <timlau at fedoraproject.org>",	/* author */
 	NULL,					/* initalize */
 	NULL,					/* destroy */
 	backend_get_groups,			/* get_groups */



More information about the PackageKit mailing list