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

Richard Hughes hughsient at kemper.freedesktop.org
Wed Sep 12 14:52:27 PDT 2007


 backends/BACKENDS                        |   32 +++---
 backends/alpm/pk-backend-alpm.c          |   64 ++++++-------
 backends/apt/pk-backend-apt.cpp          |   30 +++---
 backends/box/pk-backend-box.c            |   32 +++++-
 backends/conary/helpers/conaryBackend.py |    3 
 backends/yum/pk-backend-yum.c            |   13 ++
 configure.ac                             |    2 
 data/Makefile.am                         |    7 +
 data/packages.db                         |binary
 data/transactions.db                     |binary
 src/Makefile.am                          |    3 
 src/pk-engine.c                          |   10 +-
 src/pk-transaction-db.c                  |  150 +++++++++++++++++++++++++++++++
 src/pk-transaction-db.h                  |   56 +++++++++++
 14 files changed, 329 insertions(+), 73 deletions(-)

New commits:
diff-tree 9de7efe78f9cf33aa75f4fb44b3a57d80ea062f3 (from f5dd63d73b52341eed2d835af0b8f90ac8f889a2)
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Sep 12 22:51:22 2007 +0100

    add the start of the database code. Nothing works yet

diff --git a/configure.ac b/configure.ac
index 45e8cf6..fe2bc5f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -110,6 +110,7 @@ AC_SUBST(SYSCONFDIR, $sysconfdir)
 AC_SUBST(DATADIR, $datadir)
 AC_SUBST(BINDIR, $bindir)
 AC_SUBST(SBINDIR, $sbindir)
+AC_SUBST(LOCALSTATEDIR, $localstatedir)
 
 AC_ARG_WITH([packagekit_user],
 	    AS_HELP_STRING([--with-packagekit-user=<user>],
@@ -337,6 +338,7 @@ fi
     
 
 AC_SUBST(PK_CONF_DIR, "\$(sysconfdir)/PackageKit")
+AC_SUBST(PK_DB_DIR, "\$(localstatedir)/db/PackageKit")
 AC_SUBST(PK_PLUGIN_DIR, "\$(libdir)/packagekit-backend")
 AC_SUBST(PK_PLUGIN_CFLAGS, "-I\$(top_srcdir)/src -I\$(top_srcdir)/libpackagekit $GLIB_CFLAGS $DBUS_CFLAGS $GMODULE_CFLAGS")
 AC_SUBST(PK_PLUGIN_LIBS, "$GLIB_LIBS $DBUS_LIBS $GMODULE_LIBS")
diff --git a/data/Makefile.am b/data/Makefile.am
index a96d1fc..02e8c04 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -15,9 +15,16 @@ localcache_DATA =					\
 	job_count.dat					\
 	$(NULL)
 
+databasedir = $(PK_DB_DIR)
+database_DATA =						\
+	packages.db					\
+	transactions.db					\
+	$(NULL)
+
 EXTRA_DIST =						\
 	$(service_in_files)				\
 	$(localcache_DATA)				\
+	$(database_DATA)				\
 	$(NULL)
 
 clean-local:
diff --git a/data/packages.db b/data/packages.db
new file mode 100644
index 0000000..23386fe
Binary files /dev/null and b/data/packages.db differ
diff --git a/data/transactions.db b/data/transactions.db
new file mode 100644
index 0000000..2a780e0
Binary files /dev/null and b/data/transactions.db differ
diff --git a/src/Makefile.am b/src/Makefile.am
index 92255be..5b17032 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -25,6 +25,7 @@ INCLUDES =						\
 	-DVERSION="\"$(VERSION)\"" 			\
 	-DPK_DATA=\"$(pkgdatadir)\"			\
 	-DLOCALSTATEDIR=\""$(localstatedir)"\" 		\
+	-DDATABASEDIR=\""$(PK_DB_DIR)"\"		\
 	-I$(top_srcdir)/libpackagekit			\
 	-I$(top_srcdir)/libselftest			\
 	$(NULL)
@@ -55,6 +56,8 @@ packagekitd_SOURCES =					\
 	pk-engine.c					\
 	pk-network.h					\
 	pk-network.c					\
+	pk-transaction-db.h				\
+	pk-transaction-db.c				\
 	$(NULL)
 
 packagekitd_LDADD =					\
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 85fffc0..d79a077 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -46,6 +46,7 @@
 
 #include "pk-backend-internal.h"
 #include "pk-engine.h"
+#include "pk-transaction-db.h"
 #include "pk-job-list.h"
 #include "pk-marshal.h"
 
@@ -62,6 +63,7 @@ struct PkEnginePrivate
 	DBusConnection		*connection;
 	gchar			*backend;
 	PkJobList		*job_list;
+	PkTransactionDb		*transaction_db;
 };
 
 enum {
@@ -1456,14 +1458,16 @@ guint
 pk_engine_get_seconds_idle (PkEngine *engine)
 {
 	guint idle;
+	guint size;
 
 	g_return_val_if_fail (engine != NULL, 0);
 	g_return_val_if_fail (PK_IS_ENGINE (engine), 0);
 
 	/* check for jobs running - a job that takes a *long* time might not
 	 * give sufficient percentage updates to not be marked as idle */
-	if (pk_job_list_get_size (engine->priv->job_list) != 0) {
-		pk_debug ("engine idle zero as jobs in progress");
+	size = pk_job_list_get_size (engine->priv->job_list);
+	if (size != 0) {
+		pk_debug ("engine idle zero as %i jobs in progress", size);
 		return 0;
 	}
 
@@ -1562,6 +1566,7 @@ pk_engine_init (PkEngine *engine)
 
 	engine->priv = PK_ENGINE_GET_PRIVATE (engine);
 	engine->priv->job_list = pk_job_list_new ();
+	engine->priv->transaction_db = pk_transaction_db_new ();
 	engine->priv->timer = g_timer_new ();
 	engine->priv->backend = NULL;
 
@@ -1603,6 +1608,7 @@ pk_engine_finalize (GObject *object)
 	g_free (engine->priv->backend);
 	polkit_context_unref (engine->priv->pk_context);
 	g_object_unref (engine->priv->job_list);
+	g_object_unref (engine->priv->transaction_db);
 
 	G_OBJECT_CLASS (pk_engine_parent_class)->finalize (object);
 }
diff --git a/src/pk-transaction-db.c b/src/pk-transaction-db.c
new file mode 100644
index 0000000..2c8f43b
--- /dev/null
+++ b/src/pk-transaction-db.c
@@ -0,0 +1,150 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Richard Hughes <richard at hughsie.com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+#include <errno.h>
+
+#include <string.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+#include <glib/gi18n.h>
+#include <sqlite3.h>
+
+#include "pk-debug.h"
+#include "pk-transaction-db.h"
+#include "pk-marshal.h"
+
+static void     pk_transaction_db_class_init	(PkTransactionDbClass *klass);
+static void     pk_transaction_db_init		(PkTransactionDb      *tdb);
+static void     pk_transaction_db_finalize	(GObject        *object);
+
+#define PK_TRANSACTION_DB_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PK_TYPE_TRANSACTION_DB, PkTransactionDbPrivate))
+#define PK_TRANSACTION_DB_FILE		DATABASEDIR "/transactions.db"
+
+struct PkTransactionDbPrivate
+{
+	sqlite3			*db;
+};
+
+G_DEFINE_TYPE (PkTransactionDb, pk_transaction_db, G_TYPE_OBJECT)
+
+/**
+ * pk_transaction_db_add:
+ **/
+gboolean
+pk_transaction_db_add (PkTransactionDb *tdb, const gchar *tid)
+{
+	return TRUE;
+}
+
+/**
+ * pk_transaction_db_class_init:
+ * @klass: The PkTransactionDbClass
+ **/
+static void
+pk_transaction_db_class_init (PkTransactionDbClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	object_class->finalize = pk_transaction_db_finalize;
+	g_type_class_add_private (klass, sizeof (PkTransactionDbPrivate));
+}
+
+/**
+ * pk_transaction_sqlite_callback:
+ **/
+static gint
+pk_transaction_sqlite_callback (void *data, gint argc, gchar **argv, gchar **col_name)
+{
+//	PkTransactionDb *tdb = PK_TRANSACTION_DB (data);
+	gint i;
+	for (i=0; i<argc; i++) {
+		g_print ("%s = %s\n", col_name[i], argv[i]);
+	}
+	g_print ("\n");
+	return 0;
+}
+
+/**
+ * pk_transaction_db_init:
+ **/
+static void
+pk_transaction_db_init (PkTransactionDb *tdb)
+{
+	const gchar *statement;
+	gchar *error_msg = NULL;
+	gint rc;
+
+	tdb->priv = PK_TRANSACTION_DB_GET_PRIVATE (tdb);
+	pk_debug ("trying to open database '%s'", PK_TRANSACTION_DB_FILE);
+	rc = sqlite3_open (PK_TRANSACTION_DB_FILE, &tdb->priv->db);
+	if (rc) {
+		pk_warning ("Can't open database: %s\n", sqlite3_errmsg (tdb->priv->db));
+		sqlite3_close (tdb->priv->db);
+		return;
+	}
+
+	statement = "SELECT time date FROM transactions WHERE transaction_id = \"13;acaef\"";
+	rc = sqlite3_exec (tdb->priv->db, statement, pk_transaction_sqlite_callback, 0, &error_msg);
+	if (rc != SQLITE_OK) {
+		pk_warning ("SQL error: %s\n", error_msg);
+		sqlite3_free (error_msg);
+	}
+}
+
+/**
+ * pk_transaction_db_finalize:
+ * @object: The object to finalize
+ **/
+static void
+pk_transaction_db_finalize (GObject *object)
+{
+	PkTransactionDb *tdb;
+	g_return_if_fail (object != NULL);
+	g_return_if_fail (PK_IS_TRANSACTION_DB (object));
+	tdb = PK_TRANSACTION_DB (object);
+	g_return_if_fail (tdb->priv != NULL);
+
+	/* close the database */
+	sqlite3_close (tdb->priv->db);
+
+	G_OBJECT_CLASS (pk_transaction_db_parent_class)->finalize (object);
+}
+
+/**
+ * pk_transaction_db_new:
+ *
+ * Return value: a new PkTransactionDb object.
+ **/
+PkTransactionDb *
+pk_transaction_db_new (void)
+{
+	PkTransactionDb *tdb;
+	tdb = g_object_new (PK_TYPE_TRANSACTION_DB, NULL);
+	return PK_TRANSACTION_DB (tdb);
+}
diff --git a/src/pk-transaction-db.h b/src/pk-transaction-db.h
new file mode 100644
index 0000000..6e187ba
--- /dev/null
+++ b/src/pk-transaction-db.h
@@ -0,0 +1,56 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Richard Hughes <richard at hughsie.com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __PK_TRANSACTION_DB_H
+#define __PK_TRANSACTION_DB_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define PK_TYPE_TRANSACTION_DB		(pk_transaction_db_get_type ())
+#define PK_TRANSACTION_DB(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), PK_TYPE_TRANSACTION_DB, PkTransactionDb))
+#define PK_TRANSACTION_DB_CLASS(k)	(G_TYPE_CHECK_CLASS_CAST((k), PK_TYPE_TRANSACTION_DB, PkTransactionDbClass))
+#define PK_IS_TRANSACTION_DB(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), PK_TYPE_TRANSACTION_DB))
+#define PK_IS_TRANSACTION_DB_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), PK_TYPE_TRANSACTION_DB))
+#define PK_TRANSACTION_DB_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), PK_TYPE_TRANSACTION_DB, PkTransactionDbClass))
+
+typedef struct PkTransactionDbPrivate PkTransactionDbPrivate;
+
+typedef struct
+{
+	 GObject		 parent;
+	 PkTransactionDbPrivate	*priv;
+} PkTransactionDb;
+
+typedef struct
+{
+	GObjectClass	parent_class;
+} PkTransactionDbClass;
+
+GType		 pk_transaction_db_get_type		(void);
+PkTransactionDb	*pk_transaction_db_new			(void);
+gboolean	 pk_transaction_db_add			(PkTransactionDb	*tdb,
+							 const gchar		*tid);
+
+G_END_DECLS
+
+#endif /* __PK_TRANSACTION_DB_H */
diff-tree f5dd63d73b52341eed2d835af0b8f90ac8f889a2 (from parents)
Merge: f074a5cb78a3a31fd6b9ef2d806218a6cb73bb3d b823f0c412aebe97df8d8474cca88fa0f4e3bbba
Author: Ken VanDine <ken at vandine.org>
Date:   Wed Sep 12 17:00:04 2007 -0400

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

diff-tree b823f0c412aebe97df8d8474cca88fa0f4e3bbba (from 87c26095606e5eef4566efd68fd7590e5f3e2619)
Author: Grzegorz Dabrowski <gdx at o2.pl>
Date:   Wed Sep 12 22:21:23 2007 +0000

    [box] implemented search by details

diff --git a/backends/BACKENDS b/backends/BACKENDS
index 6674f2a..f06a832 100644
--- a/backends/BACKENDS
+++ b/backends/BACKENDS
@@ -6,7 +6,7 @@ refresh-cache     |   X    |  X  |  X  |
 get-updates       |   X    |  X  |     |  X  |      |
 update-system     |        |  X  |     |     |      |
 search-name       |   X    |  X  |  X  |  X  |  X   |
-search-details    |        |  X  |  X  |     |      |
+search-details    |        |  X  |  X  |  X  |      |
 search-file       |        |  X  |     |  X  |      |
 search-group      |        |     |     |     |      |
 install           |        |  X  |     |     |      |
diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
index fd44da2..4f8e9fa 100644
--- a/backends/box/pk-backend-box.c
+++ b/backends/box/pk-backend-box.c
@@ -31,6 +31,13 @@
 #include <libbox/libbox-db-utils.h>
 #include <libbox/libbox-db-repos.h>
 
+enum PkgSearchType {
+    SEARCH_TYPE_NAME = 0,
+    SEARCH_TYPE_DETAILS = 1,
+    SEARCH_TYPE_FILE = 2
+};
+
+
 typedef struct {
 	PkBackend *backend;
 	gchar *search;
@@ -146,13 +153,15 @@ find_packages_real (PkBackend *backend, 
 	if (text == TRUE) {
 		search_filter = search_filter | PKG_TEXT;
 	}
-	pk_debug("filter: %d", search_filter);
+	if (mode == SEARCH_TYPE_DETAILS) {
+		search_filter = search_filter | PKG_SEARCH_DETAILS;
+	}
 
 	pk_backend_no_percentage_updates (backend);
 
 	db = db_open();
 
-	if (mode == 1) {
+	if (mode == SEARCH_TYPE_FILE) {
 		/* TODO: allow filtering */
 		list = box_db_repos_search_file (db, search);
 		add_packages_from_list (backend, list);
@@ -414,6 +423,17 @@ backend_refresh_cache (PkBackend *backen
 	pk_backend_spawn_helper (backend, "refresh-cache.sh", NULL);
 }
 
+
+/**
+ * backend_search_details:
+ */
+static void
+backend_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+	g_return_if_fail (backend != NULL);
+	find_packages (backend, search, filter, SEARCH_TYPE_DETAILS);
+}
+
 /**
  * backend_search_file:
  */
@@ -421,7 +441,7 @@ static void
 backend_search_file (PkBackend *backend, const gchar *filter, const gchar *search)
 {
 	g_return_if_fail (backend != NULL);
-	find_packages (backend, search, filter, 1);
+	find_packages (backend, search, filter, SEARCH_TYPE_FILE);
 }
 
 /**
@@ -431,7 +451,7 @@ static void
 backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
 {
 	g_return_if_fail (backend != NULL);
-	find_packages (backend, search, filter, 0);
+	find_packages (backend, search, filter, SEARCH_TYPE_NAME);
 }
 
 PK_BACKEND_OPTIONS (
@@ -451,7 +471,7 @@ PK_BACKEND_OPTIONS (
 	NULL,					/* install_package */
 	backend_refresh_cache,			/* refresh_cache */
 	NULL,					/* remove_package */
-	NULL,					/* search_details */
+	backend_search_details,			/* search_details */
 	backend_search_file,			/* search_file */
 	NULL,					/* search_group */
 	backend_search_name,			/* search_name */
diff-tree f074a5cb78a3a31fd6b9ef2d806218a6cb73bb3d (from 87c26095606e5eef4566efd68fd7590e5f3e2619)
Author: Ken VanDine <ken at vandine.org>
Date:   Wed Sep 12 16:59:53 2007 -0400

    Updated get_description to return detail

diff --git a/backends/conary/helpers/conaryBackend.py b/backends/conary/helpers/conaryBackend.py
index 19d03b4..070edb4 100644
--- a/backends/conary/helpers/conaryBackend.py
+++ b/backends/conary/helpers/conaryBackend.py
@@ -218,9 +218,10 @@ class PackageKitConaryBackend(PackageKit
             desc += "%s \n" % version
             desc = desc.replace('\n\n',';')
             desc = desc.replace('\n',' ')
+            detail = ""
             url = "http://www.foresightlinux.org/packages/" + name + ".html"
             group = "other"
-            self.description(id, group, desc, url)
+            self.description(desc, id, group, detail, url)
         else:
             self.error(ERROR_INTERNAL_ERROR,'Package was not found')
 
diff-tree 87c26095606e5eef4566efd68fd7590e5f3e2619 (from 12c1d595984603581c5b9cdabcdb571afaf7bf8a)
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Sep 12 18:58:48 2007 +0100

    remove lots of trailing whitespace in the backends

diff --git a/backends/alpm/pk-backend-alpm.c b/backends/alpm/pk-backend-alpm.c
index fe199d1..e0ac1b6 100644
--- a/backends/alpm/pk-backend-alpm.c
+++ b/backends/alpm/pk-backend-alpm.c
@@ -34,7 +34,7 @@
 static int progress_percentage;
 static int subprogress_percentage;
 
-typedef struct _PackageSource 
+typedef struct _PackageSource
 {
   pmpkg_t *pkg;
   gchar *repo;
@@ -52,14 +52,14 @@ trans_event_cb (pmtransevt_t event, void
 {
 }
 
-void 
-trans_conv_cb (pmtransconv_t conv, 
-	       void *data1, void *data2, void *data3, 
+void
+trans_conv_cb (pmtransconv_t conv,
+	       void *data1, void *data2, void *data3,
 	       int *response)
 {
 }
 
-void 
+void
 trans_prog_cb (pmtransprog_t prog, const char *pkgname, int percent,
                        int n, int remain)
 {
@@ -72,7 +72,7 @@ update_subprogress (void *data)
   if (subprogress_percentage == -1)
     return FALSE;
 
-  pk_debug ("alpm: subprogress is %i", subprogress_percentage);  
+  pk_debug ("alpm: subprogress is %i", subprogress_percentage);
 
   pk_backend_change_percentage ((PkBackend *)data, subprogress_percentage);
   return TRUE;
@@ -96,7 +96,7 @@ my_list_mmerge (alpm_list_t *left, alpm_
   if (left == NULL && right == NULL)
     return NULL;
 
-  if (left == NULL) 
+  if (left == NULL)
     return right;
   if (right == NULL)
     return left;
@@ -118,7 +118,7 @@ my_list_mmerge (alpm_list_t *left, alpm_
       lp->next = left;
       left->prev = lp;
       left = left->next;
-    } 
+    }
     else {
       lp->next = right;
       right->prev = lp;
@@ -169,7 +169,7 @@ my_list_remove_node (alpm_list_t *node)
   return(ret);
 }
 
-static int 
+static int
 list_cmp_fn (const void *n1, const void *n2)
 {
   return 0;
@@ -177,15 +177,15 @@ list_cmp_fn (const void *n1, const void 
 
 static void
 add_package (PkBackend *backend, PackageSource *package)
-{ 
+{
   gchar *pkg_string;
   gchar *arch = (gchar *)alpm_pkg_get_arch (package->pkg);
 
   if (arch == NULL) arch = "lala";
 
-  pkg_string = pk_package_id_build(alpm_pkg_get_name (package->pkg), 
-				     alpm_pkg_get_version (package->pkg), 
-				     arch, 
+  pkg_string = pk_package_id_build(alpm_pkg_get_name (package->pkg),
+				     alpm_pkg_get_version (package->pkg),
+				     arch,
 				     package->repo);
 
   pk_backend_package (backend, package->installed, pkg_string, alpm_pkg_get_desc (package->pkg));
@@ -268,7 +268,7 @@ pkg_is_installed (const gchar *name, con
 
   result = find_packages (name, localdb);
   if (result == NULL) return FALSE;
-  if (!alpm_list_count (result)) return FALSE; 
+  if (!alpm_list_count (result)) return FALSE;
 
   if (version == NULL)
     return TRUE;
@@ -312,8 +312,8 @@ backend_destroy (PkBackend *backend)
 {
 	g_return_if_fail (backend != NULL);
 	if (alpm_release () == -1)
-	  pk_backend_error_code (backend, 
-				 PK_ERROR_ENUM_INTERNAL_ERROR,  
+	  pk_backend_error_code (backend,
+				 PK_ERROR_ENUM_INTERNAL_ERROR,
 				 "Failed to release control");
 }
 
@@ -328,28 +328,28 @@ backend_initalize (PkBackend *backend)
 
 	if (alpm_initialize () == -1)
 	  {
-	    pk_backend_error_code (backend, 
-				 PK_ERROR_ENUM_INTERNAL_ERROR,  
+	    pk_backend_error_code (backend,
+				 PK_ERROR_ENUM_INTERNAL_ERROR,
 				 "Failed to initialize package manager");
 	    pk_debug ("alpm: %s", alpm_strerror (pm_errno));
 	    //return;
 	  }
-	
+
 	if (alpm_parse_config ("/etc/pacman.conf", NULL, "") != 0)
 	  {
-	    pk_backend_error_code (backend, 
-				 PK_ERROR_ENUM_INTERNAL_ERROR,  
+	    pk_backend_error_code (backend,
+				 PK_ERROR_ENUM_INTERNAL_ERROR,
 				 "Failed to parse config file");
 	    pk_debug ("alpm: %s", alpm_strerror (pm_errno));
 	    backend_destroy (backend);
 	    return;
 	  }
-	
+
 
 	if (alpm_db_register ("local") == NULL)
 	  {
-	    pk_backend_error_code (backend, 
-				 PK_ERROR_ENUM_INTERNAL_ERROR,  
+	    pk_backend_error_code (backend,
+				 PK_ERROR_ENUM_INTERNAL_ERROR,
 				 "Failed to load local database");
 	    backend_destroy (backend);
 	    return;
@@ -464,7 +464,7 @@ backend_refresh_cache (PkBackend *backen
 	//alpm_list_t *problems = NULL;
 
 	if (alpm_trans_init (PM_TRANS_TYPE_SYNC, 0,
-		        trans_event_cb, trans_conv_cb, 
+		        trans_event_cb, trans_conv_cb,
 			trans_prog_cb) != 0)
 	   {
 	    pk_backend_error_code (backend,
@@ -486,14 +486,14 @@ backend_refresh_cache (PkBackend *backen
 	  }*/
 
 	alpm_list_t *i = NULL;
-	pk_backend_change_job_status (backend, PK_STATUS_ENUM_REFRESH_CACHE); 
+	pk_backend_change_job_status (backend, PK_STATUS_ENUM_REFRESH_CACHE);
 	g_timeout_add (PROGRESS_UPDATE_INTERVAL, update_subprogress, backend);
-	for (i = dbs; i; i = alpm_list_next (i))	
+	for (i = dbs; i; i = alpm_list_next (i))
 	  {
 	    if (alpm_db_update (force, (pmdb_t *)i->data))
 	      {
-		pk_backend_error_code (backend, 
-				       PK_ERROR_ENUM_TRANSACTION_ERROR,  
+		pk_backend_error_code (backend,
+				       PK_ERROR_ENUM_TRANSACTION_ERROR,
 				       alpm_strerror (pm_errno));
 		alpm_list_free (dbs);
 		pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
@@ -618,10 +618,10 @@ backend_search_name (PkBackend *backend,
 	  }
 
 	if (!installed) filter_packages_installed (result, TRUE);
-	if (!ninstalled) filter_packages_installed (result, FALSE);	
-	
+	if (!ninstalled) filter_packages_installed (result, FALSE);
+
 	add_packages_from_list (backend, alpm_list_first (result));
-	pk_backend_finished  (backend, PK_EXIT_ENUM_SUCCESS); 
+	pk_backend_finished  (backend, PK_EXIT_ENUM_SUCCESS);
 }
 
 /**
diff --git a/backends/apt/pk-backend-apt.cpp b/backends/apt/pk-backend-apt.cpp
index 05697d4..e2c01d5 100644
--- a/backends/apt/pk-backend-apt.cpp
+++ b/backends/apt/pk-backend-apt.cpp
@@ -129,13 +129,13 @@ class UpdatePercentage:public pkgAcquire
 		old = -1;
 		backend = tk;
 	}
-	
+
 	virtual bool MediaChange(string Media,string Drive)
 	{
 		pk_debug("PANIC!: we don't handle mediachange");
 		return FALSE;
 	}
-	
+
 	virtual bool Pulse(pkgAcquire *Owner)
 	{
 		pkgAcquireStatus::Pulse(Owner);
@@ -146,11 +146,11 @@ class UpdatePercentage:public pkgAcquire
 			pk_backend_change_sub_percentage(backend,((guint)(percent*100.0))%100);
 			old = percent;
 		}
-		return true;	
+		return true;
 	}
 };
 
-// do_update_thread - Update the package lists 
+// do_update_thread - Update the package lists
 // Swiped from apt-get's update mode
 void *do_update_thread(gpointer data)
 {
@@ -159,7 +159,7 @@ void *do_update_thread(gpointer data)
 	bool Failed = false;
 	bool TransientNetworkFailure = false;
 	OpTextProgress Prog;
-	
+
 	/* easy as that */
 	pk_backend_change_job_status(ud->backend, PK_STATUS_ENUM_REFRESH_CACHE);
 
@@ -235,7 +235,7 @@ void *do_update_thread(gpointer data)
 		}
 	}
 
-	// Prepare the cache.   
+	// Prepare the cache.
 	Cache = getCache();
 	if (Cache->BuildCaches(Prog,false) == false)
 	{
@@ -347,13 +347,13 @@ static void LocalitySort(AptCompFile **b
 
 static gboolean buildExDesc(ExDescFile *DFList, unsigned int pid, pkgCache::VerIterator V)
 {
-	// Find the proper version to use. 
+	// Find the proper version to use.
 	DFList[pid].available = false;
 	if (V.end() == false)
 	{
 	#ifdef APT_PKG_RPM
 		DFList[pid].Df = V.FileList();
-	#else	
+	#else
 		DFList[pid].Df = V.DescriptionList().FileList();
 	#endif
 		DFList[pid].verstr = V.VerStr();
@@ -375,7 +375,7 @@ static gboolean buildExDesc(ExDescFile *
 			DFList[pid].available = true;
 			if (hasLocal)
 				break;
-		}	 
+		}
 	}
 	return DFList[pid].available;
 }
@@ -422,7 +422,7 @@ static void *get_search_thread(gpointer 
 		if (st->depth == SEARCH_NAME && DFList[P->ID].NameMatch == false)
 			continue;
 
-		// Find the proper version to use. 
+		// Find the proper version to use.
 		pkgCache::VerIterator V = Plcy.GetCandidateVer(P);
 		buildExDesc(DFList, P->ID, V);
 	}
@@ -516,7 +516,7 @@ pk_backend_search(PkBackend * backend, c
 static GHashTable *PackageRecord(pkgCache::VerIterator V)
 {
 	GHashTable *ret = NULL;
-	
+
 	pkgCache & pkgCache = *(getCache());
 	// Find an appropriate file
 	pkgCache::VerFileIterator Vf = V.FileList();
@@ -527,16 +527,16 @@ static GHashTable *PackageRecord(pkgCach
 		if (Vf.end() == true)
 			Vf = V.FileList();
 	}
-		
+
 	// Check and load the package list file
 	pkgCache::PkgFileIterator I = Vf.File();
 	if (I.IsOk() == false)
 		return NULL;
-	
+
 	FileFd PkgF(I.FileName(),FileFd::ReadOnly);
 	if (_error->PendingError() == true)
 		return NULL;
-	
+
 	// Read the record
 	char *Buffer = new char[pkgCache.HeaderP->MaxVerFileSize+1];
 	Buffer[V.FileList()->Size] = '\0';
@@ -591,7 +591,7 @@ static void *get_description_thread(gpoi
 		if (strcmp(dt->pi->name, P.Name())!=0)
 			continue;
 
-		// Find the proper version to use. 
+		// Find the proper version to use.
 		pkgCache::VerIterator V = Plcy.GetCandidateVer(P);
 		GHashTable *pkg = PackageRecord(V);
 		pk_backend_description(dt->backend,dt->pi->name,
diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
index 06f371b..fd44da2 100644
--- a/backends/box/pk-backend-box.c
+++ b/backends/box/pk-backend-box.c
@@ -218,7 +218,7 @@ find_packages (PkBackend *backend, const
 			pk_backend_error_code(backend, PK_ERROR_ENUM_CREATE_THREAD_FAILED, "Failed to create thread");
 			pk_backend_finished(backend, PK_EXIT_ENUM_FAILED);
 		}
-		
+
 	}
 }
 
diff-tree 12c1d595984603581c5b9cdabcdb571afaf7bf8a (from ef43307e0715dfe075d1ef02c034bc1edf173e23)
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Sep 12 18:56:17 2007 +0100

    allow the yum backend to search file (thanks) and correct some of the BACKENDS formatting

diff --git a/backends/BACKENDS b/backends/BACKENDS
index f6dcb13..6674f2a 100644
--- a/backends/BACKENDS
+++ b/backends/BACKENDS
@@ -1,18 +1,18 @@
 Current status of the backends
 
-                |   conary  |   yum |   apt |   box |   alpm|
--------------------------------------------------------------
-refresh-cache   |     X     |   X   |   X   |   X   |       |
-search-name     |     X     |   X   |   X   |   X   |   X   |
-search-details  |           |   X   |   X   |       |       |
-get-updates     |     X     |   X   |       |   X   |       |
-update-system   |           |   X   |       |       |       |
-install         |           |   X   |       |       |       |
-remove          |           |   X   |       |       |       |
-get-deps        |           |   X   |       |       |       |
-get-description |     X     |   X   |   X   |   X   |       |
-search-file     |           |   X   |       |   X   |       |
-get-requeres    |           |       |       |       |       |
-search-group    |           |       |       |       |       |
-                |           |       |       |       |       |
-                
\ No newline at end of file
+                  | conary | yum | apt | box | alpm |
+-----------------------------------------------------
+refresh-cache     |   X    |  X  |  X  |  X  |      |
+get-updates       |   X    |  X  |     |  X  |      |
+update-system     |        |  X  |     |     |      |
+search-name       |   X    |  X  |  X  |  X  |  X   |
+search-details    |        |  X  |  X  |     |      |
+search-file       |        |  X  |     |  X  |      |
+search-group      |        |     |     |     |      |
+install           |        |  X  |     |     |      |
+remove            |        |  X  |     |     |      |
+get-depends       |        |  X  |     |     |      |
+get-requires      |        |     |     |     |      |
+get-description   |   X    |  X  |  X  |  X  |      |
+get-update-detail |        |     |     |     |      |
+
diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c
index 04fd06a..278d75c 100644
--- a/backends/yum/pk-backend-yum.c
+++ b/backends/yum/pk-backend-yum.c
@@ -166,6 +166,17 @@ backend_search_details (PkBackend *backe
 }
 
 /**
+ * backend_search_file:
+ */
+static void
+backend_search_file (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_allow_interrupt (backend, TRUE);
+	pk_backend_spawn_helper (backend, "search-file.py", filter, search, NULL);
+}
+
+/**
  * backend_search_group:
  */
 static void
@@ -232,7 +243,7 @@ PK_BACKEND_OPTIONS (
 	backend_refresh_cache,			/* refresh_cache */
 	backend_remove_package,			/* remove_package */
 	backend_search_details,			/* search_details */
-	NULL,					/* search_file */
+	backend_search_file,			/* search_file */
 	backend_search_group,			/* search_group */
 	backend_search_name,			/* search_name */
 	backend_update_package,			/* update_package */



More information about the PackageKit mailing list