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

Richard Hughes hughsient at kemper.freedesktop.org
Wed Aug 29 10:36:13 PDT 2007


 client/pk-console.c      |   59 +++++++++++++++++--------
 helpers/README           |   10 ++++
 helpers/packagekit.py    |    5 +-
 helpers/test-backend.sh  |    6 +-
 helpers/yumBackend.py    |  107 ++++++++++++++++++++++++++---------------------
 libpackagekit/pk-debug.h |    6 +-
 src/pk-engine.c          |   27 +++++++++++
 src/pk-interface.xml     |    4 +
 src/pk-marshal.list      |    1 
 src/pk-spawn.c           |    2 
 src/pk-task-apt.cpp      |   63 +++++++++++++++++++++++----
 src/pk-task-common.c     |   36 +++++++++++++++
 src/pk-task-common.h     |    2 
 src/pk-task-yum.c        |   12 ++---
 src/pk-task.h            |    1 
 15 files changed, 251 insertions(+), 90 deletions(-)

New commits:
diff-tree 63867efc756af198545f2c2943e0fc4958cc4780 (from parents)
Merge: 79b8cf762eb8fe19526618675290d7baa8aabb99 c006f17364f63e7e624c42cf508df2ebf3d51c2c
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Aug 29 17:57:40 2007 +0100

    Merge branch 'master' of ssh://hughsie@hughsient.no-ip.org/srv/git/PackageKit

diff-tree 79b8cf762eb8fe19526618675290d7baa8aabb99 (from 8d595ef6ef593771a151682382801a73bdf2ba05)
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Aug 29 17:57:35 2007 +0100

    add an api call to allow actions to be cancelled

diff --git a/helpers/README b/helpers/README
index a259e3e..346b2c3 100644
--- a/helpers/README
+++ b/helpers/README
@@ -56,6 +56,16 @@ possible. Just ask, and I'll add some mo
 error in an abstract way as possible.
 For the non-translated error description use ";" to seporate the lines.
 
+Cancellation:
+
+If you have a multipart transaction that can be aborted in one phase but not
+another then the AllowInterrupt signal can be sent.
+This allows for example the yum download to be cancelled, but not the install
+transaction. By cancelling a job all subtransactions are killed.
+By default actions cannot be cancelled unless enabled in the compiled backend.
+Use "allow-interrupt<tab>true" to enable cancellation and
+"allow-interrupt<tab>false" to disable it. This can be done for any job type.
+
 ========= Search Name =========
 
 FILENAME	{backend}-search-name.*
diff --git a/src/pk-engine.c b/src/pk-engine.c
index f5fb807..8f0a553 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -71,6 +71,7 @@ enum {
 	PK_ENGINE_REQUIRE_RESTART,
 	PK_ENGINE_FINISHED,
 	PK_ENGINE_DESCRIPTION,
+	PK_ENGINE_ALLOW_INTERRUPT,
 	PK_ENGINE_LAST_SIGNAL
 };
 
@@ -381,6 +382,23 @@ pk_engine_finished_cb (PkTask *task, PkT
 }
 
 /**
+ * pk_engine_allow_interrupt_cb:
+ **/
+static void
+pk_engine_allow_interrupt_cb (PkTask *task, gboolean allow_kill, PkEngine *engine)
+{
+	guint job;
+
+	g_return_if_fail (engine != NULL);
+	g_return_if_fail (PK_IS_ENGINE (engine));
+
+	job = pk_task_get_job (task);
+
+	pk_debug ("emitting allow-interrpt job:%i, %i", job, allow_kill);
+	g_signal_emit (engine, signals [PK_ENGINE_ALLOW_INTERRUPT], 0, job, allow_kill);
+}
+
+/**
  * pk_engine_new_task:
  **/
 static PkTask *
@@ -415,6 +433,8 @@ pk_engine_new_task (PkEngine *engine)
 			  G_CALLBACK (pk_engine_finished_cb), engine);
 	g_signal_connect (task, "description",
 			  G_CALLBACK (pk_engine_description_cb), engine);
+	g_signal_connect (task, "allow-interrupt",
+			  G_CALLBACK (pk_engine_allow_interrupt_cb), engine);
 
 	/* track how long the job has been running for */
 	task->timer = g_timer_new ();
@@ -1102,6 +1122,11 @@ pk_engine_class_init (PkEngineClass *kla
 			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
 			      0, NULL, NULL, pk_marshal_VOID__UINT_STRING_UINT,
 			      G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_UINT);
+	signals [PK_ENGINE_ALLOW_INTERRUPT] =
+		g_signal_new ("allow-interrupt",
+			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+			      0, NULL, NULL, pk_marshal_VOID__UINT_BOOL,
+			      G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_BOOLEAN);
 
 	g_type_class_add_private (klass, sizeof (PkEnginePrivate));
 }
diff --git a/src/pk-interface.xml b/src/pk-interface.xml
index f6b5ee6..7190b34 100644
--- a/src/pk-interface.xml
+++ b/src/pk-interface.xml
@@ -96,6 +96,10 @@
       <arg type="s" name="status" direction="out"/> <!-- success,failed,canceled -->
       <arg type="u" name="runtime" direction="out"/> <!-- amount of time job has been running in seconds -->
     </signal>
+    <signal name="AllowInterrupt">
+      <arg type="u" name="job" direction="out"/>
+      <arg type="b" name="allow_kill" direction="out"/> <!-- if the job can be SIGKILL'd -->
+    </signal>
     <signal name="ErrorCode">
       <arg type="u" name="job" direction="out"/>
       <arg type="s" name="code" direction="out"/> <!-- enumerated type, see helpers/README -->
diff --git a/src/pk-marshal.list b/src/pk-marshal.list
index 32f30bd..b8ae724 100644
--- a/src/pk-marshal.list
+++ b/src/pk-marshal.list
@@ -9,4 +9,5 @@ VOID:UINT,UINT
 VOID:UINT,STRING
 VOID:UINT,STRING,UINT
 VOID:UINT,STRING,STRING
+VOID:UINT,BOOL
 
diff --git a/src/pk-task-common.c b/src/pk-task-common.c
index b7db407..e0010ed 100644
--- a/src/pk-task-common.c
+++ b/src/pk-task-common.c
@@ -84,7 +84,11 @@ pk_task_setup_signals (GObjectClass *obj
 			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
 			      0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
 			      G_TYPE_NONE, 0);
-
+	signals [PK_TASK_ALLOW_INTERRUPT] =
+		g_signal_new ("allow-interrupt",
+			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+			      0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
+			      G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
 	return TRUE;
 }
 
@@ -220,6 +224,21 @@ pk_task_parse_common_error (PkTask *task
 		}
 		status_enum = pk_task_status_from_text (sections[1]);
 		pk_task_change_job_status (task, status_enum);
+	} else if (strcmp (command, "allow-interrupt") == 0) {
+		if (size != 2) {
+			g_error ("invalid command '%s'", command);
+			ret = FALSE;
+			goto out;
+		}
+		if (strcmp (sections[1], "true") == 0) {
+			pk_task_allow_interrupt (task, TRUE);
+		} else if (strcmp (sections[1], "false") == 0) {
+			pk_task_allow_interrupt (task, FALSE);
+		} else {
+			pk_warning ("invalid section '%s'", sections[1]);
+			ret = FALSE;
+			goto out;
+		}
 	} else if (strcmp (command, "no-percentage-updates") == 0) {
 		if (size != 1) {
 			g_error ("invalid command '%s'", command);
@@ -515,6 +534,21 @@ pk_task_no_percentage_updates (PkTask *t
 }
 
 /**
+ * pk_task_allow_interrupt:
+ **/
+gboolean
+pk_task_allow_interrupt (PkTask *task, gboolean allow_restart)
+{
+	g_return_val_if_fail (task != NULL, FALSE);
+	g_return_val_if_fail (PK_IS_TASK (task), FALSE);
+
+	pk_debug ("emit allow-interrupt %i", allow_restart);
+	task->is_killable = allow_restart;
+	g_signal_emit (task, task->signals [PK_TASK_ALLOW_INTERRUPT], 0);
+	return TRUE;
+}
+
+/**
  * pk_task_assign:
  **/
 gboolean
diff --git a/src/pk-task-common.h b/src/pk-task-common.h
index 2a35895..d0632e1 100644
--- a/src/pk-task-common.h
+++ b/src/pk-task-common.h
@@ -67,6 +67,8 @@ gboolean	 pk_task_spawn_helper			(PkTask
 							 const gchar	*script, ...);
 gboolean	 pk_task_not_implemented_yet		(PkTask		*task,
 							 const gchar	*method);
+gboolean	 pk_task_allow_interrupt		(PkTask		*task,
+							 gboolean	 allow_restart);
 
 G_END_DECLS
 
diff --git a/src/pk-task-yum.c b/src/pk-task-yum.c
index 0fa8c3b..cf2d746 100644
--- a/src/pk-task-yum.c
+++ b/src/pk-task-yum.c
@@ -163,7 +163,7 @@ pk_task_search_name (PkTask *task, const
 	}
 
 	/* only copy this code if you can kill the process with no ill effect */
-	task->is_killable = TRUE;
+	pk_task_allow_interrupt (task, TRUE);
 
 	pk_task_no_percentage_updates (task);
 	pk_task_change_job_status (task, PK_TASK_STATUS_QUERY);
@@ -191,7 +191,7 @@ pk_task_search_details (PkTask *task, co
 	}
 
 	/* only copy this code if you can kill the process with no ill effect */
-	task->is_killable = TRUE;
+	pk_task_allow_interrupt (task, TRUE);
 
 	pk_task_change_job_status (task, PK_TASK_STATUS_QUERY);
 	pk_task_spawn_helper (task, "search-details.py", filter, search, NULL);
@@ -218,7 +218,7 @@ pk_task_search_group (PkTask *task, cons
 	}
 
 	/* only copy this code if you can kill the process with no ill effect */
-	task->is_killable = TRUE;
+	pk_task_allow_interrupt (task, TRUE);
 
 	pk_task_change_job_status (task, PK_TASK_STATUS_QUERY);
 	pk_task_spawn_helper (task, "search-group.py", filter, search, NULL);
@@ -245,7 +245,7 @@ pk_task_search_file (PkTask *task, const
 	}
 
 	/* only copy this code if you can kill the process with no ill effect */
-	task->is_killable = TRUE;
+	pk_task_allow_interrupt (task, TRUE);
 
 	pk_task_not_implemented_yet (task, "SearchFile");
 	return TRUE;
@@ -265,7 +265,7 @@ pk_task_get_deps (PkTask *task, const gc
 	}
 
 	/* only copy this code if you can kill the process with no ill effect */
-	task->is_killable = TRUE;
+	pk_task_allow_interrupt (task, TRUE);
 
 	pk_task_change_job_status (task, PK_TASK_STATUS_QUERY);
 	pk_task_spawn_helper (task, "get-deps.py", package_id, NULL);
@@ -286,7 +286,7 @@ pk_task_get_description (PkTask *task, c
 	}
 
 	/* only copy this code if you can kill the process with no ill effect */
-	task->is_killable = TRUE;
+	pk_task_allow_interrupt (task, TRUE);
 
 	pk_task_change_job_status (task, PK_TASK_STATUS_QUERY);
 	pk_task_spawn_helper (task, "get-description.py", package_id, NULL);
diff --git a/src/pk-task.h b/src/pk-task.h
index 6aac437..e1629d2 100644
--- a/src/pk-task.h
+++ b/src/pk-task.h
@@ -47,6 +47,7 @@ typedef enum {
 	PK_TASK_ERROR_CODE,
 	PK_TASK_REQUIRE_RESTART,
 	PK_TASK_FINISHED,
+	PK_TASK_ALLOW_INTERRUPT,
 	PK_TASK_LAST_SIGNAL
 } PkSignals;
 
diff-tree c006f17364f63e7e624c42cf508df2ebf3d51c2c (from 540b490640dba98d5cf21cf79fdfd43fa5941ff7)
Author: Tom Parker <palfrey at tevp.net>
Date:   Wed Aug 29 18:57:33 2007 +0200

    Add percentage completes to apt RefreshCache

diff --git a/src/pk-task-apt.cpp b/src/pk-task-apt.cpp
index 4d62b62..64f5f54 100644
--- a/src/pk-task-apt.cpp
+++ b/src/pk-task-apt.cpp
@@ -34,6 +34,7 @@
 
 #include <regex.h>
 #include <string.h>
+#include <math.h>
 
 #include "pk-debug.h"
 #include "pk-task.h"
@@ -139,6 +140,16 @@ typedef struct
 
 class UpdatePercentage:public pkgAcquireStatus
 {
+	double old;
+	PkTask *task;
+
+	public:
+	UpdatePercentage(PkTask *tk)
+	{
+		old = -1;
+		task = tk;
+	}
+	
 	virtual bool MediaChange(string Media,string Drive)
 	{
 		pk_debug("PANIC!: we don't handle mediachange");
@@ -147,6 +158,14 @@ class UpdatePercentage:public pkgAcquire
 	
 	virtual bool Pulse(pkgAcquire *Owner)
 	{
+		pkgAcquireStatus::Pulse(Owner);
+		double percent = double(CurrentBytes*100.0)/double(TotalBytes);
+		if (old!=percent)
+		{
+			pk_task_change_percentage(task,(guint)percent);
+			pk_task_change_sub_percentage(task,((guint)(percent*100.0))%100);
+			old = percent;
+		}
 		return true;	
 	}
 };
@@ -190,7 +209,7 @@ void *DoUpdate(gpointer data)
 	}
 
 	// Create the download object
-	UpdatePercentage *Stat = new UpdatePercentage();
+	UpdatePercentage *Stat = new UpdatePercentage(ud->task);
 	pkgAcquire Fetcher(Stat);
 
 	// Populate it with the source selection
diff-tree 540b490640dba98d5cf21cf79fdfd43fa5941ff7 (from 8dea123862460df758194318559af7972206ea7e)
Author: Tom Parker <palfrey at tevp.net>
Date:   Wed Aug 29 18:20:48 2007 +0200

    Add pk_task_get_actions to apt
    Add the new pk_task_get_actions (with a default set of actions
    that we don't actually do all of yet), plus throw the
    private/signals section into a similar place as the other
    backends.

diff --git a/src/pk-task-apt.cpp b/src/pk-task-apt.cpp
index 0ecdc7c..4d62b62 100644
--- a/src/pk-task-apt.cpp
+++ b/src/pk-task-apt.cpp
@@ -45,11 +45,20 @@ static void pk_task_class_init(PkTaskCla
 static void pk_task_init(PkTask * task);
 static void pk_task_finalize(GObject * object);
 
-pkgSourceList *SrcList = 0;
-
 #define PK_TASK_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PK_TYPE_TASK, PkTaskPrivate))
 
+struct PkTaskPrivate
+{
+	guint progress_percentage;
+	PkNetwork *network;
+};
+
+static guint signals[PK_TASK_LAST_SIGNAL] = { 0, };
+
+G_DEFINE_TYPE(PkTask, pk_task, G_TYPE_OBJECT)
+
 static pkgCacheFile *fileCache = NULL;
+pkgSourceList *SrcList = 0;
 
 static pkgCacheFile *getCache()
 {
@@ -82,15 +91,30 @@ static pkgCacheFile *getCache()
 	return fileCache;
 }
 
-struct PkTaskPrivate
-{
-	guint progress_percentage;
-	PkNetwork *network;
-};
 
-static guint signals[PK_TASK_LAST_SIGNAL] = { 0, };
+/**
+ * pk_task_get_actions
+ **/
+gchar *
+pk_task_get_actions (void)
+{
+	gchar *actions;
+	actions = pk_task_action_build (PK_TASK_ACTION_INSTALL,
+				        PK_TASK_ACTION_REMOVE,
+				        PK_TASK_ACTION_UPDATE,
+				        PK_TASK_ACTION_GET_UPDATES,
+				        PK_TASK_ACTION_REFRESH_CACHE,
+				        PK_TASK_ACTION_UPDATE_SYSTEM,
+				        PK_TASK_ACTION_SEARCH_NAME,
+				        PK_TASK_ACTION_SEARCH_DETAILS,
+				        PK_TASK_ACTION_SEARCH_GROUP,
+				        PK_TASK_ACTION_SEARCH_FILE,
+				        PK_TASK_ACTION_GET_DEPS,
+				        PK_TASK_ACTION_GET_DESCRIPTION,
+				        0);
+	return actions;
+}
 
-G_DEFINE_TYPE(PkTask, pk_task, G_TYPE_OBJECT)
 /**
  * pk_task_get_updates:
  **/
diff-tree 8dea123862460df758194318559af7972206ea7e (from parents)
Merge: 761ab623283120ee1a0702ca3070b69c8d21624a 8d595ef6ef593771a151682382801a73bdf2ba05
Author: Tom Parker <palfrey at tevp.net>
Date:   Wed Aug 29 18:18:05 2007 +0200

    Merge branch 'master' of ssh://pk/srv/git/PackageKit

diff-tree 8d595ef6ef593771a151682382801a73bdf2ba05 (from 26d8c802d5505af47bc3e0400c1bfebc471100e9)
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Aug 29 17:00:47 2007 +0100

    fix the help text

diff --git a/client/pk-console.c b/client/pk-console.c
index cbe5360..f3da273 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -112,18 +112,18 @@ pk_console_usage (const gchar *error)
 		g_print ("Error: %s\n", error);
 	}
 	g_print ("usage:\n");
-	g_print ("  pkcon search name power\n");
-	g_print ("  pkcon search details power\n");
-	g_print ("  pkcon search group system\n");
-	g_print ("  pkcon search file libc.so.3\n");
-	g_print ("  pkcon sync install gimp;2:2.4.0-0.rc1.1.fc8;i386;development\n");
-	g_print ("  pkcon install gimp;2:2.4.0-0.rc1.1.fc8;i386;development\n");
-	g_print ("  pkcon sync update\n");
-	g_print ("  pkcon refresh\n");
-	g_print ("  pkcon force-refresh\n");
-	g_print ("  pkcon get updates\n");
-	g_print ("  pkcon get deps gimp;2:2.4.0-0.rc1.1.fc8;i386;development\n");
-	g_print ("  pkcon get description gimp;2:2.4.0-0.rc1.1.fc8;i386;development\n");
+	g_print ("  pkcon [sync] [verbose] search name|details|group|file data\n");
+	g_print ("  pkcon [sync] [verbose] install <package_id>\n");
+	g_print ("  pkcon [sync] [verbose] remove <package_id>\n");
+	g_print ("  pkcon [sync] [verbose] update <package_id>\n");
+	g_print ("  pkcon [sync] [verbose] refresh\n");
+	g_print ("  pkcon [sync] [verbose] force-refresh\n");
+	g_print ("  pkcon [sync] [verbose] update-system\n");
+	g_print ("  pkcon [sync] [verbose] get updates\n");
+	g_print ("  pkcon [sync] [verbose] get deps <package_id>\n");
+	g_print ("  pkcon [sync] [verbose] get description <package_id>\n");
+	g_print ("\n");
+	g_print ("    package_id is typically gimp;2:2.4.0-0.rc1.1.fc8;i386;development\n");
 }
 
 /**
@@ -248,7 +248,7 @@ pk_console_parse_multiple_commands (PkTa
 		pk_debug_init (TRUE);
 	} else if (strcmp (mode, "verbose") == 0) {
 		pk_debug_init (TRUE);
-	} else if (strcmp (mode, "update") == 0) {
+	} else if (strcmp (mode, "update-system") == 0) {
 		pk_task_client_update_system (tclient);
 	} else if (strcmp (mode, "refresh") == 0) {
 		pk_task_client_refresh_cache (tclient, FALSE);
diff-tree 26d8c802d5505af47bc3e0400c1bfebc471100e9 (from 64ecf0823688f29252ce10a8a85b0d88d23d4ce8)
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Aug 29 16:52:07 2007 +0100

    rework the consoleget

diff --git a/client/pk-console.c b/client/pk-console.c
index 7d0f89a..cbe5360 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -121,9 +121,9 @@ pk_console_usage (const gchar *error)
 	g_print ("  pkcon sync update\n");
 	g_print ("  pkcon refresh\n");
 	g_print ("  pkcon force-refresh\n");
-	g_print ("  pkcon getdeps gimp;2:2.4.0-0.rc1.1.fc8;i386;development\n");
-	g_print ("  pkcon getdesc gimp;2:2.4.0-0.rc1.1.fc8;i386;development\n");
-	g_print ("  pkcon debug checkupdate\n");
+	g_print ("  pkcon get updates\n");
+	g_print ("  pkcon get deps gimp;2:2.4.0-0.rc1.1.fc8;i386;development\n");
+	g_print ("  pkcon get description gimp;2:2.4.0-0.rc1.1.fc8;i386;development\n");
 }
 
 /**
@@ -212,23 +212,37 @@ pk_console_parse_multiple_commands (PkTa
 			pk_task_client_remove_package (tclient, value, FALSE);
 			remove = 2;
 		}
-	} else if (strcmp (mode, "getdeps") == 0) {
+	} else if (strcmp (mode, "get") == 0) {
 		if (value == NULL) {
-			pk_console_usage ("you need to specify a package to find the deps for");
+			pk_console_usage ("you need to specify a get type");
+			remove = 1;
 			goto out;
-		} else {
+		} else if (strcmp (value, "deps") == 0) {
+			if (details == NULL) {
+				pk_console_usage ("you need to specify a search term");
+				remove = 2;
+				goto out;
+			} else {
+				pk_task_client_set_sync (tclient, TRUE);
+				pk_task_client_get_deps (tclient, details);
+				remove = 3;
+			}
+		} else if (strcmp (value, "description") == 0) {
+			if (details == NULL) {
+				pk_console_usage ("you need to specify a package to find the description for");
+				remove = 2;
+				goto out;
+			} else {
+				pk_task_client_set_sync (tclient, TRUE);
+				pk_task_client_get_description (tclient, details);
+				remove = 3;
+			}
+		} else if (strcmp (value, "updates") == 0) {
 			pk_task_client_set_sync (tclient, TRUE);
-			pk_task_client_get_deps (tclient, value);
+			pk_task_client_get_updates (tclient);
 			remove = 2;
-		}
-	} else if (strcmp (mode, "getdesc") == 0) {
-		if (value == NULL) {
-			pk_console_usage ("you need to specify a package to find the description for");
-			goto out;
 		} else {
-			pk_task_client_set_sync (tclient, TRUE);
-			pk_task_client_get_description (tclient, value);
-			remove = 2;
+			pk_console_usage ("invalid get type");
 		}
 	} else if (strcmp (mode, "debug") == 0) {
 		pk_debug_init (TRUE);
@@ -244,9 +258,6 @@ pk_console_parse_multiple_commands (PkTa
 		pk_task_client_set_sync (tclient, TRUE);
 	} else if (strcmp (mode, "async") == 0) {
 		pk_task_client_set_sync (tclient, FALSE);
-	} else if (strcmp (mode, "checkupdate") == 0) {
-		pk_task_client_set_sync (tclient, TRUE);
-		pk_task_client_get_updates (tclient);
 	} else {
 		pk_console_usage ("option not yet supported");
 	}
diff-tree 64ecf0823688f29252ce10a8a85b0d88d23d4ce8 (from baf9d7a01e3c653f51792777dc4c2f397d3f9719)
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Aug 29 16:45:57 2007 +0100

    add getdesc into the console helper

diff --git a/client/pk-console.c b/client/pk-console.c
index ebd36da..7d0f89a 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -116,12 +116,13 @@ pk_console_usage (const gchar *error)
 	g_print ("  pkcon search details power\n");
 	g_print ("  pkcon search group system\n");
 	g_print ("  pkcon search file libc.so.3\n");
-	g_print ("  pkcon sync install gtk2-devel\n");
-	g_print ("  pkcon install gimp update totem\n");
+	g_print ("  pkcon sync install gimp;2:2.4.0-0.rc1.1.fc8;i386;development\n");
+	g_print ("  pkcon install gimp;2:2.4.0-0.rc1.1.fc8;i386;development\n");
 	g_print ("  pkcon sync update\n");
 	g_print ("  pkcon refresh\n");
 	g_print ("  pkcon force-refresh\n");
-	g_print ("  pkcon getdeps gimp\n");
+	g_print ("  pkcon getdeps gimp;2:2.4.0-0.rc1.1.fc8;i386;development\n");
+	g_print ("  pkcon getdesc gimp;2:2.4.0-0.rc1.1.fc8;i386;development\n");
 	g_print ("  pkcon debug checkupdate\n");
 }
 
@@ -220,6 +221,15 @@ pk_console_parse_multiple_commands (PkTa
 			pk_task_client_get_deps (tclient, value);
 			remove = 2;
 		}
+	} else if (strcmp (mode, "getdesc") == 0) {
+		if (value == NULL) {
+			pk_console_usage ("you need to specify a package to find the description for");
+			goto out;
+		} else {
+			pk_task_client_set_sync (tclient, TRUE);
+			pk_task_client_get_description (tclient, value);
+			remove = 2;
+		}
 	} else if (strcmp (mode, "debug") == 0) {
 		pk_debug_init (TRUE);
 	} else if (strcmp (mode, "verbose") == 0) {
diff-tree 761ab623283120ee1a0702ca3070b69c8d21624a (from parents)
Merge: 3cc8d9bb7d4c60e4a5472785157008107d2cffbd baf9d7a01e3c653f51792777dc4c2f397d3f9719
Author: Tom Parker <palfrey at tevp.net>
Date:   Wed Aug 29 16:58:32 2007 +0200

    Merge branch 'master' of ssh://pk/srv/git/PackageKit

diff-tree 3cc8d9bb7d4c60e4a5472785157008107d2cffbd (from 9614b563c7a6b067e5531e141ab611433f5ad2ad)
Author: Tom Parker <palfrey at tevp.net>
Date:   Wed Aug 29 16:58:16 2007 +0200

    Fix pk_debug usage (in pk-engine, and with attributes)
    pk-engine was using pk_debug wrongly (missing an arg) and this
    was caught with valgrind. This fixes that, and adds attributes
    to pk_{debug,warning,error}_real such that it will cause
    compiler errors next time.

diff --git a/libpackagekit/pk-debug.h b/libpackagekit/pk-debug.h
index 9cd781c..81f68d5 100644
--- a/libpackagekit/pk-debug.h
+++ b/libpackagekit/pk-debug.h
@@ -46,15 +46,15 @@ void		pk_debug_init			(gboolean	 debug);
 void		pk_debug_real			(const gchar	*func,
 						 const gchar	*file,
 						 int		 line,
-						 const gchar	*format, ...);
+						 const gchar	*format, ...) __attribute__((format (printf,4,5)));
 void		pk_warning_real			(const gchar	*func,
 						 const gchar	*file,
 						 int		 line,
-						 const gchar	*format, ...);
+						 const gchar	*format, ...) __attribute__((format (printf,4,5)));
 void		pk_error_real			(const gchar	*func,
 						 const gchar	*file,
 						 int		 line,
-						 const gchar	*format, ...);
+						 const gchar	*format, ...) __attribute__((format (printf,4,5)));
 
 G_END_DECLS
 
diff --git a/src/pk-engine.c b/src/pk-engine.c
index f5fb807..1b7421a 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -368,7 +368,7 @@ pk_engine_finished_cb (PkTask *task, PkT
 	time = g_timer_elapsed (task->timer, NULL);
 	pk_debug ("task was running for %f seconds", time);
 
-	pk_debug ("emitting finished job:%i, '%s', %i", job, exit_text);
+	pk_debug ("emitting finished job: %i, '%s', %i", job, exit_text, (guint) time);
 	g_signal_emit (engine, signals [PK_ENGINE_FINISHED], 0, job, exit_text, (guint) time);
 
 	/* remove from array and unref */
diff-tree baf9d7a01e3c653f51792777dc4c2f397d3f9719 (from 9614b563c7a6b067e5531e141ab611433f5ad2ad)
Author: Tim Lauridsen <tla at rasmil.dk>
Date:   Wed Aug 29 16:54:11 2007 +0200

    Fixed some issues in the yumBackend

diff --git a/helpers/packagekit.py b/helpers/packagekit.py
index 0a39761..92beb43 100644
--- a/helpers/packagekit.py
+++ b/helpers/packagekit.py
@@ -66,13 +66,16 @@ class PackageKitBaseBackend:
         '''
         print >> sys.stderr, "subpercentage\t%i" % (percent)
 
-    def error(self,err,description):
+    def error(self,err,description,exit=True):
         '''
         send 'error' 
         @param err: Error Type (ERROR_NO_NETWORK, ERROR_NOT_SUPPORTED, ERROR_INTERNAL_ERROR) 
         @param description: Error description
+        @param exit: exit application with rc=1, if true 
         '''
         print >> sys.stderr,"error\t%s\t%s" % (err,description)
+        if exit:
+            sys.exit(1)
 
     def package(self,id,status,summary):
         '''
diff --git a/helpers/test-backend.sh b/helpers/test-backend.sh
index 5983f35..5784f79 100755
--- a/helpers/test-backend.sh
+++ b/helpers/test-backend.sh
@@ -1,10 +1,12 @@
 echo "start test..."
 
-package_id="gnome-power-manager;2.19.7-0.72.20070828svn.fc7.hughsie;i386;installed"
+#package_id="gnome-power-manager;2.19.7-0.72.20070828svn.fc7.hughsie;i386;installed"
+package_id="BasiliskII;1.0-0.20060501.1.fc7;x86_64;freshrpms"
+
 backend="yum"
 
 echo "get deps $package_id"
-./$backend-get-deps.py "gnome-power-manager;2.19.7-0.72.20070828svn.fc7.hughsie;i386;installed"
+./$backend-get-deps.py $package_id 
 echo "exitcode=$?"
 
 echo "get description $package_id"
diff --git a/helpers/yumBackend.py b/helpers/yumBackend.py
index 5cbfa22..d671fb0 100644
--- a/helpers/yumBackend.py
+++ b/helpers/yumBackend.py
@@ -52,6 +52,7 @@ class PackageKitYumBackend(PackageKitBas
         @param filters: package types to search (all,installed,available)
         @param key: key to seach for
         '''
+        self.yumbase.doConfigSetup(errorlevel=0,debuglevel=0)# Setup Yum Config
         self.yumbase.conf.cache = 1 # Only look in cache.
         res = self.yumbase.searchGenerator(searchlist, [key])
         fltlist = filters.split(';')
@@ -169,7 +170,7 @@ class PackageKitYumBackend(PackageKitBas
             epoch = idver[:cpos]
             idver = idver[cpos:]
         else:
-            epoch = 0
+            epoch = '0'
         (version,release) = tuple(idver.split('-'))
         return epoch,version,release
             
@@ -182,25 +183,27 @@ class PackageKitYumBackend(PackageKitBas
         # get e,v,r from package id version
         e,v,r = self._getEVR(idver)
         # search the rpmdb for the nevra
+        print n,e,v,r,a
         pkgs = self.yumbase.rpmdb.searchNevra(name=n,epoch=e,ver=v,rel=r,arch=a)
         # if the package is found, then return it
         if len(pkgs) != 0:
-            return pkgs[0]
+            return pkgs[0],True
         # search the pkgSack for the nevra
         pkgs = self.yumbase.pkgSack.searchNevra(name=n,epoch=e,ver=v,rel=r,arch=a)
         # if the package is found, then return it
         if len(pkgs) != 0:
-            return pkgs[0]
+            return pkgs[0],False
         else:
-            return None
+            return None,False
             
 
     def get_deps(self,package):
         '''
         Print a list of dependencies for a given package
         '''
+        self._setup_yum()
         name = package.split(';')[0]
-        pkg = self._findPackage(package)
+        pkg,inst = self._findPackage(package)
         results = {}
         if pkg:
             deps = self.yumbase.findDeps([pkg]).values()[0]
@@ -208,6 +211,8 @@ class PackageKitYumBackend(PackageKitBas
                 for dep in deplist:
                     if not results.has_key(dep.name):
                         results[dep.name] = dep
+        else:
+            self.error(ERROR_INTERNAL_ERROR,'Package was not found')
 
         for pkg in results.values():
             if pkg.name != name:
@@ -220,9 +225,7 @@ class PackageKitYumBackend(PackageKitBas
         Implement the {backend}-update-system functionality
         Needed to be implemented in a sub class
         '''
-        self.yumbase.doConfigSetup()                         # Setup Yum Config
-        callback = DownloadCallback(self,showNames=True)     # Download callback
-        self.yumbase.repos.setProgressBar( callback )        # Setup the download callback class
+        self._setup_yum()
         self.percentage(0)
         txmbr = self.yumbase.update() # Add all updates to Transaction
         if txmbr:
@@ -235,9 +238,7 @@ class PackageKitYumBackend(PackageKitBas
         Implement the {backend}-refresh_cache functionality
         Needed to be implemented in a sub class
         '''
-        self.yumbase.doConfigSetup()          # Setup Yum Config
-        callback = DownloadCallback(self)     # Download callback
-        self.yumbase.repos.setProgressBar( callback ) # Setup the download callback class
+        self._setup_yum()
         pct = 0
         self.percentage(pct)
         try:
@@ -268,29 +269,38 @@ class PackageKitYumBackend(PackageKitBas
         Implement the {backend}-install functionality
         This will only work with yum 3.2.4 or higher
         '''
-        self.yumbase.doConfigSetup()                         # Setup Yum Config
-        callback = DownloadCallback(self,showNames=True)     # Download callback
-        self.yumbase.repos.setProgressBar( callback )        # Setup the download callback class
+        self._setup_yum()
         self.percentage(0)
-        try:
-            txmbr = self.yumbase.install(name=package)
-            self._runYumTransaction()
-        except yum.Errors.InstallError,e:
-            msgs = ';'.join(str(e))
-            self.error(ERROR_PACKAGE_ALREADY_INSTALLED,msgs)        
-
+        pkg,inst = self._findPackage(package)
+        print pkg,inst
+        if pkg:
+            if inst:
+                self.error(ERROR_PACKAGE_ALREADY_INSTALLED,'Package already installed')        
+            try:
+                txmbr = self.yumbase.install(name=pkg.name)
+                print txmbr
+                self._runYumTransaction()
+            except yum.Errors.InstallError,e:
+                print e
+                msgs = ';'.join(e)
+                self.error(ERROR_PACKAGE_ALREADY_INSTALLED,msgs)        
+        else:
+            self.error(ERROR_PACKAGE_ALREADY_INSTALLED,"Package was not found")        
+            
     def update(self, package):
         '''
         Implement the {backend}-install functionality
         This will only work with yum 3.2.4 or higher
         '''
-        self.yumbase.doConfigSetup()                         # Setup Yum Config
-        callback = DownloadCallback(self,showNames=True)     # Download callback
-        self.yumbase.repos.setProgressBar( callback )        # Setup the download callback class
+        self._setup_yum()
         self.percentage(0)
-        txmbr = self.yumbase.update(name=package)
-        if txmbr:
-            self._runYumTransaction()
+        pkg,inst = self._findPackage(package)
+        if pkg:
+            txmbr = self.yumbase.update(name=pkg.name)
+            if txmbr:
+                self._runYumTransaction()
+            else:
+                self.error(ERROR_PACKAGE_ALREADY_INSTALLED,"No available updates")
         else:
             self.error(ERROR_PACKAGE_ALREADY_INSTALLED,"No available updates")
 
@@ -302,7 +312,7 @@ class PackageKitYumBackend(PackageKitBas
         '''
         rc,msgs =  self.yumbase.buildTransaction()
         if rc !=2:
-            retmsg = "Error in Dependency Resolution\n" +"\n".join(msgs)
+            retmsg = "Error in Dependency Resolution;" +";".join(msgs)
             self.error(ERROR_DEP_RESOLUTION_FAILED,retmsg)
         else:
             try:
@@ -325,29 +335,33 @@ class PackageKitYumBackend(PackageKitBas
         Implement the {backend}-remove functionality
         Needed to be implemented in a sub class
         '''
-        self.yumbase.doConfigSetup()                         # Setup Yum Config
-        callback = DownloadCallback(self,showNames=True)     # Download callback
-        self.yumbase.repos.setProgressBar( callback )        # Setup the download callback class
+        self._setup_yum()
         self.percentage(0)
-        txmbr = self.yumbase.remove(name=package)
-        if txmbr:
-            self._runYumTransaction()
+        pkg,inst = self._findPackage( package)
+        print pkg,inst
+        if pkg and inst:        
+            txmbr = self.yumbase.remove(name=pkg.name)
+            if txmbr:
+                print txmbr[0].po
+                self._runYumTransaction()
+            else:
+                self.error(ERROR_PACKAGE_NOT_INSTALLED,"Package is not installed")
         else:
-            self.error(ERROR_INTERNAL_ERROR,"Nothing to do")
+            self.error(ERROR_PACKAGE_NOT_INSTALLED,"Package is not installed")
 
 
     def get_description(self, package):
         '''
         Print a detailed description for a given package
         '''
-        res = self.yumbase.searchGenerator(['name'], [package])
-        for (pkg, name) in res:
-            if name[0] == package:
-                id = self.get_package_id(pkg.name, pkg.version,
-                                         pkg.arch, pkg.repo)
-                self.description(id, "%s-%s" % (pkg.version, pkg.release),
+        self._setup_yum()
+        pkg,inst = self._findPackage(package)
+        if pkg:
+            id = self.get_package_id(pkg.name, pkg.version,pkg.arch, pkg.repo)
+            self.description(id, "%s-%s" % (pkg.version, pkg.release),
                                  repr(pkg.description), pkg.url)
-                break
+        else:
+            self.error(ERROR_INTERNAL_ERROR,'Package was not found')
     
     def _show_package(self,pkg,status):
         '''  Show info about package'''
@@ -368,9 +382,7 @@ class PackageKitYumBackend(PackageKitBas
         '''
         Implement the {backend}-get-updates functionality
         '''
-        self.yumbase.doConfigSetup()                         # Setup Yum Config
-        callback = DownloadCallback(self,showNames=True)     # Download callback
-        self.yumbase.repos.setProgressBar( callback )        # Setup the download callback class
+        self._setup_yum()
         md = UpdateMetadata()
         # Added extra Update Metadata
         for repo in self.yumbase.repos.listEnabled():
@@ -391,7 +403,10 @@ class PackageKitYumBackend(PackageKitBas
                 self._show_package(pkg,0)
             
                                                                                                
-            
+    def _setup_yum(self):
+        self.yumbase.doConfigSetup(errorlevel=0,debuglevel=0) # Setup Yum Config
+        callback = DownloadCallback(self,showNames=True)      # Download callback
+        self.yumbase.repos.setProgressBar( callback )         # Setup the download callback class
 
 class DownloadCallback( BaseMeter ):
     """ Customized version of urlgrabber.progress.BaseMeter class """
diff-tree 9614b563c7a6b067e5531e141ab611433f5ad2ad (from 9bf2051a35c0d5ec535c0327774de4ede75a8883)
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Aug 29 15:40:35 2007 +0100

    on havocs advice, use SIGKILL not SIGTERM

diff --git a/src/pk-spawn.c b/src/pk-spawn.c
index 31598bb..a09b23c 100644
--- a/src/pk-spawn.c
+++ b/src/pk-spawn.c
@@ -181,7 +181,7 @@ pk_spawn_kill (PkSpawn *spawn)
 	gint retval;
 	guint ret;
 	pk_warning ("killing %i", spawn->priv->child_pid);
-	retval = kill (spawn->priv->child_pid, SIGTERM);
+	retval = kill (spawn->priv->child_pid, SIGKILL);
 
 	ret = TRUE;
 	if (retval == EINVAL) {



More information about the PackageKit mailing list