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

Richard Hughes hughsient at kemper.freedesktop.org
Fri Oct 19 08:01:36 PDT 2007


 TODO                                    |   22 -------
 backends/box/pk-backend-box.c           |    4 -
 backends/dummy/pk-backend-dummy.c       |    4 -
 backends/test/pk-backend-test-fail.c    |    2 
 backends/test/pk-backend-test-succeed.c |    2 
 backends/yum/helpers/resolve.py         |    7 +-
 backends/yum/helpers/yumBackend.py      |   31 +++++-----
 backends/yum/pk-backend-yum.c           |    4 -
 client/pk-console.c                     |   97 ++++++++++++++++++++++++++------
 docs/pk-introduction.xml                |   35 +++++++++++
 libpackagekit/pk-client.c               |    7 +-
 libpackagekit/pk-client.h               |    1 
 libpackagekit/pk-common.h               |    6 -
 src/pk-backend-internal.h               |    1 
 src/pk-backend.c                        |    6 +
 src/pk-backend.h                        |    2 
 src/pk-engine.c                         |   10 ++-
 src/pk-engine.h                         |    1 
 src/pk-interface.xml                    |    1 
 19 files changed, 170 insertions(+), 73 deletions(-)

New commits:
commit 51e512d8a4c53a38b054500f40a44301490a5dde
Author: Richard Hughes <richard at hughsie.com>
Date:   Fri Oct 19 15:58:47 2007 +0100

    add pkcon install foo capability, where foo is a package_id or something else that is resolved

diff --git a/TODO b/TODO
index 9cd7741..d4128f8 100644
--- a/TODO
+++ b/TODO
@@ -22,25 +22,3 @@ Have different permissions for signed and unsigned repos.
 To do rollbacks sanely in PK we need a few things:
  * allow transaction data to be changed in _db
 
-*** Use resolve for pkcon operations ***
-'pkcon install zsh' should work as well as 'pkcon install "zsh;1.0;i386;repo"'
-
---- RELEASE BLOCKER ---
-
-def command_resolve(package, filter_enum)
-ret=client_resolve (package, filter)
-if ret wait()
-length=get_length
-if length == 1 return get_item(client, 0)
-else
-print matched too many, quit
-for each length
-print get_item(client, 1)
-
-case: INSTALL
-if not a valid package_id then
-    pacakge=command_resolve(package, ENUM_AVAILABLE);
-    if (package== NULL) {
-        error
-    }
-
diff --git a/client/pk-console.c b/client/pk-console.c
index 4e3ab78..0ad6739 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -112,7 +112,7 @@ pk_console_transaction_cb (PkClient *client, const gchar *tid, const gchar *time
 {
 	const gchar *role_text;
 	role_text = pk_role_enum_to_text (role);
-	g_print ("tid          : %s\n", tid);
+	g_print ("Transaction  : %s\n", tid);
 	g_print (" timespec    : %s\n", timespec);
 	g_print (" succeeded   : %i\n", succeeded);
 	g_print (" role        : %s\n", role_text);
@@ -129,7 +129,7 @@ pk_console_update_detail_cb (PkClient *client, const gchar *package_id,
 			     const gchar *url, const gchar *restart,
 			     const gchar *update_text, gpointer data)
 {
-	g_print ("update-detail\n");
+	g_print ("Update detail\n");
 	g_print ("  package:    '%s'\n", package_id);
 	g_print ("  updates:    '%s'\n", updates);
 	g_print ("  obsoletes:  '%s'\n", obsoletes);
@@ -145,7 +145,7 @@ static void
 pk_console_repo_detail_cb (PkClient *client, const gchar *repo_id,
 			   const gchar *description, gboolean enabled, gpointer data)
 {
-	g_print ("[%s]\n", repo_id);
+	g_print ("Repository detail for %s\n", repo_id);
 	g_print ("  %i, %s\n", enabled, description);
 }
 
@@ -155,7 +155,7 @@ pk_console_repo_detail_cb (PkClient *client, const gchar *repo_id,
 static void
 pk_console_percentage_changed_cb (PkClient *client, guint percentage, gpointer data)
 {
-	g_print ("%i%%\n", percentage);
+	g_print ("Percentage changed: %i%%\n", percentage);
 }
 
 const gchar *summary =
@@ -202,41 +202,102 @@ pk_client_wait (void)
 static void
 pk_console_finished_cb (PkClient *client, PkStatusEnum status, guint runtime, gpointer data)
 {
-	g_print ("Runtime was %i seconds\n", runtime);
+	PkRoleEnum role;
+	const gchar *role_text;
+	pk_client_get_role (client, &role, NULL);
+	role_text = pk_role_enum_to_text (role);
+	g_print ("%s runtime was %i seconds\n", role_text, runtime);
 	if (loop != NULL) {
 		g_main_loop_quit (loop);
 	}
 }
 
 /**
- * pk_console_install_package:
+ * pk_console_perhaps_resolve:
  **/
-static gboolean
-pk_console_install_package (PkClient *client, const gchar *package_id)
+static gchar *
+pk_console_perhaps_resolve (PkClient *client, PkFilterEnum filter, const gchar *package)
 {
-//xxx
 	gboolean ret;
 	gboolean valid;
 	PkClient *client_resolve;
-	valid = pk_package_id_check (package_id);
+	const gchar *filter_text;
+	guint i;
+	guint length;
+	PkPackageItem *item;
 
 	/* have we passed a complete package_id? */
+	valid = pk_package_id_check (package);
 	if (valid == TRUE) {
-		return pk_client_install_package (client, package_id);
+		return g_strdup (package);
 	}
 
 	/* we need to resolve it */
 	client_resolve = pk_client_new ();
 	g_signal_connect (client_resolve, "finished",
+	/* TODO: send local loop */
 			  G_CALLBACK (pk_console_finished_cb), NULL);
-	ret = pk_client_resolve (client_resolve, "none", package_id);
+	filter_text = pk_filter_enum_to_text (filter);
+	pk_client_set_use_buffer (client_resolve, TRUE);
+	ret = pk_client_resolve (client_resolve, filter_text, package);
 	if (ret == FALSE) {
-		pk_warning ("Resolve not supported");
+		pk_warning ("Resolve is not supported in this backend");
+		return NULL;
 	} else {
 		g_main_loop_run (loop);
 	}
-	pk_error ("resolve functionality not finished yet");
-	return TRUE;
+
+	/* get length of items found */
+	length = pk_client_package_buffer_get_size (client_resolve);
+
+	/* only found one, great! */
+	if (length == 1) {
+		item = pk_client_package_buffer_get_item (client_resolve, 0);
+		return item->package_id;
+	}
+
+	/* else list the options */
+	for (i=0; i<length; i++) {
+		item = pk_client_package_buffer_get_item (client_resolve, i);
+		g_print ("option is %s", item->package_id);
+	}
+	return NULL;
+}
+
+/**
+ * pk_console_install_package:
+ **/
+static gboolean
+pk_console_install_package (PkClient *client, const gchar *package)
+{
+	gboolean ret;
+	gchar *package_id;
+	package_id = pk_console_perhaps_resolve (client, PK_FILTER_ENUM_AVAILABLE, package);
+	if (package_id == NULL) {
+		g_print ("Could not find a package with that name to install\n");
+		return FALSE;
+	}
+	ret = pk_client_install_package (client, package_id);
+	g_free (package_id);
+	return ret;
+}
+
+/**
+ * pk_console_remove_package:
+ **/
+static gboolean
+pk_console_remove_package (PkClient *client, const gchar *package)
+{
+	gboolean ret;
+	gchar *package_id;
+	package_id = pk_console_perhaps_resolve (client, PK_FILTER_ENUM_INSTALLED, package);
+	if (package_id == NULL) {
+		g_print ("Could not find a package with that name to remove\n");
+		return FALSE;
+	}
+	ret = pk_client_remove_package (client, package_id, FALSE);
+	g_free (package_id);
+	return ret;
 }
 
 /**
@@ -306,7 +367,7 @@ pk_console_process_commands (PkClient *client, int argc, char *argv[], GError **
 			g_set_error (error, 0, 0, "you need to specify a package to remove");
 			return FALSE;
 		} else {
-			wait = pk_client_remove_package (client, value, FALSE);
+			wait = pk_console_remove_package (client, value);
 		}
 	} else if (strcmp (mode, "update") == 0) {
 		if (value == NULL) {
@@ -424,7 +485,7 @@ pk_console_description_cb (PkClient *client, const gchar *package_id,
 			   const gchar *description, const gchar *url,
 			   gulong size, const gchar *filelist, gpointer data)
 {
-	g_print ("description\n");
+	g_print ("Package description\n");
 	g_print ("  package:     '%s'\n", package_id);
 	g_print ("  licence:     '%s'\n", licence);
 	g_print ("  group:       '%s'\n", pk_group_enum_to_text (group));
commit 6d223e24ab3e0f72de956432ca16a8fd5cadf7c0
Author: Richard Hughes <richard at hughsie.com>
Date:   Fri Oct 19 15:30:38 2007 +0100

    fix the header protect lines

diff --git a/libpackagekit/pk-common.h b/libpackagekit/pk-common.h
index 194cf07..e39658f 100644
--- a/libpackagekit/pk-common.h
+++ b/libpackagekit/pk-common.h
@@ -19,8 +19,8 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
-#ifndef __PK_TASK_COMMON_H
-#define __PK_TASK_COMMON_H
+#ifndef __PK_COMMON_H
+#define __PK_COMMON_H
 
 #include <glib-object.h>
 
@@ -43,4 +43,4 @@ gboolean	 pk_string_id_equal			(const gchar	*id1,
 
 G_END_DECLS
 
-#endif /* __PK_TASK_COMMON_H */
+#endif /* __PK_COMMON_H */
commit da9c1e51003a654f1439b866eaaa203bde737d51
Author: Richard Hughes <richard at hughsie.com>
Date:   Fri Oct 19 15:27:58 2007 +0100

    add a filter parameter to Resolve so we can do the filtering in the backend

diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
index a253981..c376277 100644
--- a/backends/box/pk-backend-box.c
+++ b/backends/box/pk-backend-box.c
@@ -421,10 +421,10 @@ backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean al
  * backend_resolve:
  */
 static void
-backend_resolve (PkBackend *backend, const gchar *package)
+backend_resolve (PkBackend *backend, const gchar *filter, const gchar *package)
 {
 	g_return_if_fail (backend != NULL);
-	find_packages (backend, package, "none", SEARCH_TYPE_RESOLVE);
+	find_packages (backend, package, filter, SEARCH_TYPE_RESOLVE);
 }
 
 /**
diff --git a/backends/dummy/pk-backend-dummy.c b/backends/dummy/pk-backend-dummy.c
index dbdc763..4d23f73 100644
--- a/backends/dummy/pk-backend-dummy.c
+++ b/backends/dummy/pk-backend-dummy.c
@@ -252,9 +252,11 @@ backend_refresh_cache (PkBackend *backend, gboolean force)
  * backend_resolve:
  */
 static void
-backend_resolve (PkBackend *backend, const gchar *package_id)
+backend_resolve (PkBackend *backend, const gchar *filter, const gchar *package_id)
 {
 	g_return_if_fail (backend != NULL);
+	pk_backend_package (backend, PK_INFO_ENUM_INSTALLED,
+			    "glib2;2.14.0;i386;fedora", "The GLib library");
 	pk_backend_finished (backend);
 }
 
diff --git a/backends/test/pk-backend-test-fail.c b/backends/test/pk-backend-test-fail.c
index 8f03df2..aa75124 100644
--- a/backends/test/pk-backend-test-fail.c
+++ b/backends/test/pk-backend-test-fail.c
@@ -178,7 +178,7 @@ backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean al
  * backend_resolve:
  */
 static void
-backend_resolve (PkBackend *backend, const gchar *package_id)
+backend_resolve (PkBackend *backend, const gchar *filter, const gchar *package_id)
 {
 	g_return_if_fail (backend != NULL);
 	pk_backend_finished (backend);
diff --git a/backends/test/pk-backend-test-succeed.c b/backends/test/pk-backend-test-succeed.c
index fa87fa3..bdd3ed4 100644
--- a/backends/test/pk-backend-test-succeed.c
+++ b/backends/test/pk-backend-test-succeed.c
@@ -174,7 +174,7 @@ backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean al
  * backend_resolve:
  */
 static void
-backend_resolve (PkBackend *backend, const gchar *package_id)
+backend_resolve (PkBackend *backend, const gchar *filter, const gchar *package_id)
 {
 	g_return_if_fail (backend != NULL);
 	pk_backend_finished (backend);
diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c
index b16a281..695e762 100644
--- a/backends/yum/pk-backend-yum.c
+++ b/backends/yum/pk-backend-yum.c
@@ -233,10 +233,10 @@ backend_update_system (PkBackend *backend)
  * backend_resolve:
  */
 static void
-backend_resolve (PkBackend *backend, const gchar *package_id)
+backend_resolve (PkBackend *backend, const gchar *filter, const gchar *package_id)
 {
 	g_return_if_fail (backend != NULL);
-	pk_backend_spawn_helper (backend, "resolve.py", "none", package_id, NULL);
+	pk_backend_spawn_helper (backend, "resolve.py", filter, package_id, NULL);
 }
 
 PK_BACKEND_OPTIONS (
diff --git a/client/pk-console.c b/client/pk-console.c
index efacc89..4e3ab78 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -229,7 +229,7 @@ pk_console_install_package (PkClient *client, const gchar *package_id)
 	client_resolve = pk_client_new ();
 	g_signal_connect (client_resolve, "finished",
 			  G_CALLBACK (pk_console_finished_cb), NULL);
-	ret = pk_client_resolve (client_resolve, package_id);
+	ret = pk_client_resolve (client_resolve, "none", package_id);
 	if (ret == FALSE) {
 		pk_warning ("Resolve not supported");
 	} else {
@@ -320,7 +320,7 @@ pk_console_process_commands (PkClient *client, int argc, char *argv[], GError **
 			g_set_error (error, 0, 0, "you need to specify a package name to resolve");
 			return FALSE;
 		} else {
-			wait = pk_client_resolve (client, value);
+			wait = pk_client_resolve (client, "none", value);
 		}
 	} else if (strcmp (mode, "enable-repo") == 0) {
 		if (value == NULL) {
diff --git a/docs/pk-introduction.xml b/docs/pk-introduction.xml
index 6c9c3e7..2b81240 100644
--- a/docs/pk-introduction.xml
+++ b/docs/pk-introduction.xml
@@ -552,6 +552,13 @@
           </thead>
           <tbody>
             <row>
+              <entry><literal>filter</literal></entry>
+              <entry>
+                A correct filter, e.g. <literal>none</literal> or
+                <literal>installed;~devel</literal>
+              </entry>
+            </row>
+            <row>
               <entry><literal>search_term</literal></entry>
               <entry>A single word search term with no wildcard chars.</entry>
             </row>
@@ -589,6 +596,13 @@
           </thead>
           <tbody>
             <row>
+              <entry><literal>filter</literal></entry>
+              <entry>
+                A correct filter, e.g. <literal>none</literal> or
+                <literal>installed;~devel</literal>
+              </entry>
+            </row>
+            <row>
               <entry><literal>group_type</literal></entry>
               <entry>An enumerated group_type, or <literal>unknown</literal>.</entry>
             </row>
@@ -626,6 +640,13 @@
           </thead>
           <tbody>
             <row>
+              <entry><literal>filter</literal></entry>
+              <entry>
+                A correct filter, e.g. <literal>none</literal> or
+                <literal>installed;~devel</literal>
+              </entry>
+            </row>
+            <row>
               <entry><literal>search_term</literal></entry>
               <entry>A single word search term with no wildcard chars.</entry>
             </row>
@@ -666,6 +687,13 @@
           </thead>
           <tbody>
             <row>
+              <entry><literal>filter</literal></entry>
+              <entry>
+                A correct filter, e.g. <literal>none</literal> or
+                <literal>installed;~devel</literal>
+              </entry>
+            </row>
+            <row>
               <entry><literal>search_term</literal></entry>
               <entry>A single word search term with no wildcard chars.</entry>
             </row>
@@ -888,6 +916,13 @@
           </thead>
           <tbody>
             <row>
+              <entry><literal>filter</literal></entry>
+              <entry>
+                A correct filter, e.g. <literal>none</literal> or
+                <literal>installed;~devel</literal>
+              </entry>
+            </row>
+            <row>
               <entry><literal>package</literal></entry>
               <entry>A single package name, e.g. <literal>art-clipart</literal>.</entry>
             </row>
diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index fab6b2b..c382d52 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -1371,7 +1371,7 @@ pk_client_rollback (PkClient *client, const gchar *transaction_id)
  * pk_client_resolve:
  **/
 gboolean
-pk_client_resolve (PkClient *client, const gchar *package)
+pk_client_resolve (PkClient *client, const gchar *filter, const gchar *package)
 {
 	gboolean ret;
 	GError *error;
@@ -1387,11 +1387,13 @@ pk_client_resolve (PkClient *client, const gchar *package)
 	}
 	/* save this so we can re-issue it */
 	client->priv->role = PK_ROLE_ENUM_RESOLVE;
+	client->priv->xcached_filter = g_strdup (filter);
 	client->priv->xcached_package_id = g_strdup (package);
 
 	error = NULL;
 	ret = dbus_g_proxy_call (client->priv->proxy, "Resolve", &error,
 				 G_TYPE_STRING, client->priv->tid,
+				 G_TYPE_STRING, filter,
 				 G_TYPE_STRING, package,
 				 G_TYPE_INVALID,
 				 G_TYPE_INVALID);
@@ -2183,7 +2185,8 @@ pk_client_requeue (PkClient *client)
 	} else if (client->priv->role == PK_ROLE_ENUM_GET_UPDATE_DETAIL) {
 		pk_client_get_update_detail (client, client->priv->xcached_package_id);
 	} else if (client->priv->role == PK_ROLE_ENUM_RESOLVE) {
-		pk_client_resolve (client, client->priv->xcached_package_id);
+		pk_client_resolve (client, client->priv->xcached_filter,
+				   client->priv->xcached_package_id);
 	} else if (client->priv->role == PK_ROLE_ENUM_ROLLBACK) {
 		pk_client_rollback (client, client->priv->xcached_transaction_id);
 	} else if (client->priv->role == PK_ROLE_ENUM_GET_DESCRIPTION) {
diff --git a/libpackagekit/pk-client.h b/libpackagekit/pk-client.h
index 8196043..6d7c1f2 100644
--- a/libpackagekit/pk-client.h
+++ b/libpackagekit/pk-client.h
@@ -110,6 +110,7 @@ gboolean	 pk_client_update_package		(PkClient	*client,
 gboolean	 pk_client_install_file			(PkClient	*client,
 							 const gchar	*full_path);
 gboolean	 pk_client_resolve			(PkClient	*client,
+							 const gchar	*filter,
 							 const gchar	*package);
 gboolean	 pk_client_rollback			(PkClient	*client,
 							 const gchar	*transaction_id);
diff --git a/src/pk-backend-internal.h b/src/pk-backend-internal.h
index bcb3dee..61d4c7f 100644
--- a/src/pk-backend-internal.h
+++ b/src/pk-backend-internal.h
@@ -89,6 +89,7 @@ gboolean	 pk_backend_search_details		(PkBackend	*backend,
 							 const gchar	*filter,
 							 const gchar	*search);
 gboolean	 pk_backend_resolve			(PkBackend	*backend,
+							 const gchar	*filter,
 							 const gchar	*package);
 gboolean	 pk_backend_rollback			(PkBackend	*backend,
 							 const gchar	*transaction_id);
diff --git a/src/pk-backend.c b/src/pk-backend.c
index 16eeef9..030ad93 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -1067,7 +1067,8 @@ pk_backend_set_running (PkBackend *backend)
 		backend->desc->get_update_detail (backend,
 						  backend->priv->xcached_package_id);
 	} else if (backend->priv->role == PK_ROLE_ENUM_RESOLVE) {
-		backend->desc->resolve (backend, backend->priv->xcached_package_id);
+		backend->desc->resolve (backend, backend->priv->xcached_filter,
+					backend->priv->xcached_package_id);
 	} else if (backend->priv->role == PK_ROLE_ENUM_ROLLBACK) {
 		backend->desc->rollback (backend, backend->priv->xcached_transaction_id);
 	} else if (backend->priv->role == PK_ROLE_ENUM_GET_DESCRIPTION) {
@@ -1293,7 +1294,7 @@ pk_backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean
  * pk_backend_resolve:
  */
 gboolean
-pk_backend_resolve (PkBackend *backend, const gchar *package)
+pk_backend_resolve (PkBackend *backend, const gchar *filter, const gchar *package)
 {
 	g_return_val_if_fail (backend != NULL, FALSE);
 	if (backend->desc->resolve == NULL) {
@@ -1301,6 +1302,7 @@ pk_backend_resolve (PkBackend *backend, const gchar *package)
 		return FALSE;
 	}
 	backend->priv->xcached_package_id = g_strdup (package);
+	backend->priv->xcached_filter = g_strdup (filter);
 	pk_backend_set_role (backend, PK_ROLE_ENUM_RESOLVE);
 	return TRUE;
 }
diff --git a/src/pk-backend.h b/src/pk-backend.h
index 0fd17da..b582c99 100644
--- a/src/pk-backend.h
+++ b/src/pk-backend.h
@@ -129,7 +129,7 @@ struct _PkBackendDesc {
 	void		(*install_file)		(PkBackend *backend, const gchar *full_path);
 	void		(*refresh_cache)	(PkBackend *backend, gboolean force);
 	void		(*remove_package)	(PkBackend *backend, const gchar *package_id, gboolean allow_deps);
-	void		(*resolve)		(PkBackend *backend, const gchar *package);
+	void		(*resolve)		(PkBackend *backend, const gchar *filter, const gchar *package);
 	void		(*rollback)		(PkBackend *backend, const gchar *transaction_id);
 	void		(*search_details)	(PkBackend *backend, const gchar *filter, const gchar *search);
 	void		(*search_file)		(PkBackend *backend, const gchar *filter, const gchar *search);
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 2a6423a..67645e0 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -1262,7 +1262,7 @@ pk_engine_search_file (PkEngine *engine, const gchar *tid, const gchar *filter,
  * pk_engine_resolve:
  **/
 gboolean
-pk_engine_resolve (PkEngine *engine, const gchar *tid, const gchar *package, GError **error)
+pk_engine_resolve (PkEngine *engine, const gchar *tid, const gchar *filter, const gchar *package, GError **error)
 {
 	gboolean ret;
 	PkTransactionItem *item;
@@ -1278,6 +1278,12 @@ pk_engine_resolve (PkEngine *engine, const gchar *tid, const gchar *package, GEr
 		return FALSE;
 	}
 
+	/* check the filter */
+	ret = pk_engine_filter_check (filter, error);
+	if (ret == FALSE) {
+		return FALSE;
+	}
+
 	/* check for sanity */
 	ret = pk_validate_input (package);
 	if (ret == FALSE) {
@@ -1294,7 +1300,7 @@ pk_engine_resolve (PkEngine *engine, const gchar *tid, const gchar *package, GEr
 		return FALSE;
 	}
 
-	ret = pk_backend_resolve (item->backend, package);
+	ret = pk_backend_resolve (item->backend, filter, package);
 	if (ret == FALSE) {
 		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
 			     "Operation not yet supported by backend");
diff --git a/src/pk-engine.h b/src/pk-engine.h
index d725527..05f0b81 100644
--- a/src/pk-engine.h
+++ b/src/pk-engine.h
@@ -121,6 +121,7 @@ gboolean	 pk_engine_get_description		(PkEngine	*engine,
 							 GError		**error);
 gboolean	 pk_engine_resolve			(PkEngine	*engine,
 							 const gchar	*tid,
+							 const gchar	*filter,
 							 const gchar	*package,
 							 GError		**error);
 void		 pk_engine_rollback			(PkEngine	*engine,
diff --git a/src/pk-interface.xml b/src/pk-interface.xml
index f517537..a78556b 100644
--- a/src/pk-interface.xml
+++ b/src/pk-interface.xml
@@ -19,6 +19,7 @@
     </method>
     <method name="Resolve">
       <arg type="s" name="tid" direction="in"/>
+      <arg type="s" name="filter" direction="in"/>
       <arg type="s" name="package" direction="in"/>
     </method>
     <method name="Rollback">
commit 0e09bde1404547c920858f69723d7355a5850b12
Author: James Bowes <jbowes at dangerouslyinc.com>
Date:   Fri Oct 19 10:13:16 2007 -0400

    yum: Add filter for resolve.
    
    Resolve now accepts a filter list as its first argument, similar to search.
    The name to resolve is now the second argument.

diff --git a/backends/yum/helpers/resolve.py b/backends/yum/helpers/resolve.py
index 57d9186..aadb95b 100755
--- a/backends/yum/helpers/resolve.py
+++ b/backends/yum/helpers/resolve.py
@@ -12,8 +12,9 @@
 import sys
 
 from yumBackend import PackageKitYumBackend
-name=sys.argv[1]
-backend = PackageKitYumBackend(sys.argv[1:])
-backend.resolve(name)
+filters = sys.argv[1]
+name=sys.argv[2]
+backend = PackageKitYumBackend(sys.argv[2:])
+backend.resolve(filters, name)
 backend.unLock()
 sys.exit(0)
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 1deed9e..aadd483 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -422,27 +422,32 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         except yum.Errors.YumBaseError, e:
             self.error(ERROR_INTERNAL_ERROR,str(e))
 
-    def resolve(self, name):
+    def resolve(self, filters, name):
         '''
         Implement the {backend}-resolve functionality
         '''
         self.allow_interrupt(True);
         self.percentage(None)
 
+        fltlist = filters.split(';')
+
         # Get installed packages
         installedByKey = self.yumbase.rpmdb.searchNevra(name=name)
-        for pkg in installedByKey:
-            self._show_package(pkg,INFO_INSTALLED)
-        # Get availabe packages
-        for pkg in self.yumbase.pkgSack.returnNewestByNameArch():
-            if pkg.name == name:
-                show = True
-                for instpo in installedByKey:
-                    if pkg.EVR < instpo.EVR or pkg.EVR == instpo.EVR:  # Check if package have a smaller & equal EVR to a inst pkg
-                        show = False
-                if show:
-                    self._show_package(pkg,INFO_AVAILABLE)
-                    break
+        if FILTER_NON_INSTALLED not in fltlist:
+            for pkg in installedByKey:
+                self._show_package(pkg,INFO_INSTALLED)
+        # Get available packages
+        if FILTER_INSTALLED not in fltlist:
+            for pkg in self.yumbase.pkgSack.returnNewestByNameArch():
+                if pkg.name == name:
+                    show = True
+                    for instpo in installedByKey:
+                        # Check if package have a smaller & equal EVR to a inst pkg
+                        if pkg.EVR < instpo.EVR or pkg.EVR == instpo.EVR:
+                            show = False
+                    if show:
+                        self._show_package(pkg,INFO_AVAILABLE)
+                        break
 
     def install(self, package):
         '''
diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c
index 3b25e0d..b16a281 100644
--- a/backends/yum/pk-backend-yum.c
+++ b/backends/yum/pk-backend-yum.c
@@ -236,7 +236,7 @@ static void
 backend_resolve (PkBackend *backend, const gchar *package_id)
 {
 	g_return_if_fail (backend != NULL);
-	pk_backend_spawn_helper (backend, "resolve.py", package_id, NULL);
+	pk_backend_spawn_helper (backend, "resolve.py", "none", package_id, NULL);
 }
 
 PK_BACKEND_OPTIONS (



More information about the PackageKit mailing list