[PackageKit-commit] packagekit: Branch 'master' - 38 commits

Richard Hughes hughsient at kemper.freedesktop.org
Tue Sep 23 07:54:07 PDT 2008


 RELEASE                                |   16 
 backends/alpm/pk-backend-alpm.c        |  616 +++++++++++++--------------------
 backends/smart/helpers/smartBackend.py |    6 
 backends/yum/yumBackend.py             |  133 +++----
 backends/yum/yumComps.py               |    9 
 backends/yum/yumFilter.py              |   47 +-
 client/.gitignore                      |    4 
 client/Makefile.am                     |   29 -
 client/pk-generate-package-list.c      |   98 -----
 client/pk-import-desktop.c             |  317 ----------------
 client/pk-import-specspo.c             |    7 
 configure.ac                           |    2 
 docs/html/img/pk-self-check.png        |binary
 etc/PackageKit.conf.in                 |    8 
 libpackagekit/pk-extra.c               |  107 +++++
 libpackagekit/pk-extra.h               |    8 
 python/packagekit/backend.py           |   11 
 src/pk-backend-spawn.c                 |   12 
 src/pk-backend.c                       |    2 
 src/pk-main.c                          |   13 
 src/pk-refresh.c                       |    4 
 src/pk-spawn.c                         |    6 
 src/pk-transaction-list.c              |  141 ++++++-
 src/pk-transaction.c                   |    4 
 24 files changed, 632 insertions(+), 968 deletions(-)

New commits:
commit f5c51dcbb1d7351726a345687e4eed37fc6ac623
Merge: 7cda950... ea2a251...
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Sep 23 15:19:24 2008 +0100

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

commit 7cda950ad3a145ed1209aebf2eae070e7a922348
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Sep 23 15:18:27 2008 +0100

    yum: more trivial pylint fixups

diff --git a/backends/yum/yumBackend.py b/backends/yum/yumBackend.py
index 0a45ea7..05548bb 100755
--- a/backends/yum/yumBackend.py
+++ b/backends/yum/yumBackend.py
@@ -24,9 +24,6 @@
 #    Richard Hughes <richard at hughsie.com>
 
 # imports
-
-import re
-
 from packagekit.backend import *
 from packagekit.progress import *
 from packagekit.package import PackagekitPackage
@@ -107,7 +104,7 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
         signal.signal(signal.SIGQUIT,sigquit)
         PackageKitBaseBackend.__init__(self,args)
         self.yumbase = PackageKitYumBase(self)
-        self._LANG = 'C'
+        self._lang = 'C'
         self.comps = yumComps(self.yumbase)
         if not self.comps.connect():
             self.refresh_cache()
@@ -193,7 +190,7 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
         Implement the {backend}-set-locale functionality
         Needed to be implemented in a sub class
         '''
-        self._LANG = code
+        self._lang = code
 
     @handle_repo_error
     def _do_search(self,searchlist,filters,key):
@@ -294,16 +291,16 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
     def _show_meta_package(self,grpid,fltlist=[]):
         show_avail = FILTER_INSTALLED not in fltlist
         show_inst = FILTER_NOT_INSTALLED not in fltlist
-        id = "%s;;;meta" % grpid
+        package_id = "%s;;;meta" % grpid
         grp = self.yumbase.comps.return_group(grpid)
         if grp:
-            name = grp.nameByLang(self._LANG)
+            name = grp.nameByLang(self._lang)
             if grp.installed:
                 if show_inst:
-                    self.package(id,INFO_COLLECTION_INSTALLED,name)
+                    self.package(package_id,INFO_COLLECTION_INSTALLED,name)
             else:
                 if show_avail:
-                    self.package(id,INFO_COLLECTION_AVAILABLE,name)
+                    self.package(package_id,INFO_COLLECTION_AVAILABLE,name)
 
     #@handle_repo_error
     def search_group(self,filters,group_key):
@@ -637,8 +634,8 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
 
         # each unique name, emit
         for pkg in deps_list:
-            id = self._pkg_to_id(pkg)
-            self.package(id,INFO_INSTALLED,pkg.summary)
+            package_id = self._pkg_to_id(pkg)
+            self.package(package_id,INFO_INSTALLED,pkg.summary)
         self.percentage(100)
 
     def _is_inst(self,pkg):
@@ -1053,9 +1050,9 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
             for mem in members:
                 pack.extract(mem,path = tempdir)
             files = os.listdir(tempdir)
-            for file in files:
-                if file.endswith('.rpm'):
-                    inst_files.append(os.path.join(tempdir, file))
+            for fn in files:
+                if fn.endswith('.rpm'):
+                    inst_files.append(os.path.join(tempdir, fn))
 
         to_remove = []
 
@@ -1255,12 +1252,12 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
                 if not keyData:
                     self.error(ERROR_BAD_GPG_SIGNATURE,
                                "GPG key not imported, and no GPG information was found.")
-                id = self._pkg_to_id(keyData['po'])
+                package_id = self._pkg_to_id(keyData['po'])
                 fingerprint = keyData['fingerprint']()
                 hex_fingerprint = "%02x" * len(fingerprint) % tuple(map(ord, fingerprint))
                 # Borrowed from http://mail.python.org/pipermail/python-list/2000-September/053490.html
 
-                self.repo_signature_required(id,
+                self.repo_signature_required(package_id,
                                              keyData['po'].repoid,
                                              keyData['keyurl'].replace("file://",""),
                                              keyData['userid'],
@@ -1332,8 +1329,8 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
         for package in package_ids:
             grp = self._is_meta_package(package)
             if grp:
-                id = "%s;;;meta" % grp.groupid
-                desc = grp.descriptionByLang(self._LANG)
+                package_id = "%s;;;meta" % grp.groupid
+                desc = grp.descriptionByLang(self._lang)
                 desc = desc.replace('\n\n',';')
                 desc = desc.replace('\n',' ')
                 group = GROUP_COLLECTIONS
@@ -1341,7 +1338,7 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
                 size = 0
                 for pkg in pkgs:
                     size = size + pkg.size
-                self.details(id,"",group,desc,"",size)
+                self.details(package_id,"",group,desc,"",size)
 
             else:
                 pkg,inst = self._findPackage(package)
@@ -1353,12 +1350,12 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
     def _show_details_pkg(self,pkg):
 
         pkgver = self._get_package_ver(pkg)
-        id = self.get_package_id(pkg.name,pkgver,pkg.arch,pkg.repo)
+        package_id = self.get_package_id(pkg.name,pkgver,pkg.arch,pkg.repo)
         desc = pkg.description
         desc = desc.replace('\n\n',';')
         desc = desc.replace('\n',' ')
         group = self.comps.get_group(pkg.name)
-        self.details(id,pkg.license,group,desc,pkg.url,pkg.size)
+        self.details(package_id,pkg.license,group,desc,pkg.url,pkg.size)
 
     def get_files(self,package_ids):
         self._check_init()
@@ -1381,13 +1378,13 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
 
     def _pkg_to_id(self,pkg):
         pkgver = self._get_package_ver(pkg)
-        id = self.get_package_id(pkg.name,pkgver,pkg.arch,pkg.repo)
-        return id
+        package_id = self.get_package_id(pkg.name,pkgver,pkg.arch,pkg.repo)
+        return package_id
 
     def _show_package(self,pkg,status):
         '''  Show info about package'''
-        id = self._pkg_to_id(pkg)
-        self.package(id,status,pkg.summary)
+        package_id = self._pkg_to_id(pkg)
+        self.package(package_id,status,pkg.summary)
 
     def _get_status(self,notice):
         ut = notice['type']
@@ -1869,11 +1866,11 @@ class PackageKitCallback(RPMBaseCallback):
 
     def _showName(self,status):
         if type(self.curpkg) in types.StringTypes:
-            id = self.base.get_package_id(self.curpkg,'','','')
+            package_id = self.base.get_package_id(self.curpkg,'','','')
         else:
             pkgver = self.base._get_package_ver(self.curpkg)
-            id = self.base.get_package_id(self.curpkg.name,pkgver,self.curpkg.arch,self.curpkg.repo)
-        self.base.package(id,status,"")
+            package_id = self.base.get_package_id(self.curpkg.name,pkgver,self.curpkg.arch,self.curpkg.repo)
+        self.base.package(package_id,status,"")
 
     def event(self,package,action,te_current,te_total,ts_current,ts_total):
         if str(package) != str(self.curpkg):
diff --git a/backends/yum/yumComps.py b/backends/yum/yumComps.py
index a2e3e42..7444dff 100755
--- a/backends/yum/yumComps.py
+++ b/backends/yum/yumComps.py
@@ -213,6 +213,7 @@ class yumComps:
         return True
 
     def _add_db(self,name,category,groupid,pkgroup,pkgtype):
+        ''' add an item into the database '''
         self.cursor.execute('INSERT INTO groups values(?,?,?,?,?);',(name,category,groupid,pkgroup,pkgtype))
 
     def refresh(self,force=False):
@@ -256,7 +257,7 @@ class yumComps:
 
     def get_package_list(self,group_key):
         ''' for a PK group, get the packagelist for this group '''
-        all_packages = [];
+        all_packages = []
         self.cursor.execute('SELECT name FROM groups WHERE group_enum = ?;',[group_key])
         for row in self.cursor:
             all_packages.append(row[0])
@@ -272,17 +273,16 @@ class yumComps:
         return group
 
     def get_meta_packages(self):
+        ''' return all the group_id's '''
         metapkgs = set()
         self.cursor.execute('SELECT groupid FROM groups')
         for row in self.cursor:
             metapkgs.add(row[0])
         return list(metapkgs)
 
-
-
     def get_meta_package_list(self,groupid):
         ''' for a comps group, get the packagelist for this group (mandatory,default)'''
-        all_packages = [];
+        all_packages = []
         self.cursor.execute('SELECT name FROM groups WHERE groupid = ? AND ( pkgtype = "mandatory" OR pkgtype = "default");',[groupid])
         for row in self.cursor:
             all_packages.append(row[0])
@@ -318,3 +318,4 @@ if __name__ == "__main__":
     pkgs = comps.get_meta_package_list('kde-desktop')
     print pkgs
     os.unlink(db) # kill the db
+
diff --git a/backends/yum/yumFilter.py b/backends/yum/yumFilter.py
index ec25bd9..2236822 100644
--- a/backends/yum/yumFilter.py
+++ b/backends/yum/yumFilter.py
@@ -22,7 +22,6 @@
 from packagekit.backend import *
 from packagekit.package import PackagekitPackage
 
-import yum
 import rpmUtils
 import re
 
@@ -71,7 +70,7 @@ class YumFilter(object,PackagekitPackage):
 
     def _get_nevra(self,pkg):
         ''' gets the NEVRA for a pkg '''
-        return "%s-%s:%s-%s.%s" % (pkg.name,pkg.epoch,pkg.version,pkg.release,pkg.arch);
+        return "%s-%s:%s-%s.%s" % (pkg.name,pkg.epoch,pkg.version,pkg.release,pkg.arch)
 
     def _is_main_package(self,repo):
         if repo.endswith('-debuginfo'):
@@ -101,9 +100,9 @@ class YumFilter(object,PackagekitPackage):
         for (pkg,status) in package_list:
             if pkg.sourcerpm:
                 base = rpmUtils.miscutils.splitFilename(pkg.sourcerpm)[0]
-                base_list.append ((pkg,status,base,pkg.version));
+                base_list.append ((pkg,status,base,pkg.version))
             else:
-                base_list.append ((pkg,status,'nosrpm',pkg.version));
+                base_list.append ((pkg,status,'nosrpm',pkg.version))
 
         #find all the packages that match thier basename name (done seporately so we get the "best" match)
         for (pkg,status,base,version) in base_list:
@@ -155,22 +154,22 @@ class YumFilter(object,PackagekitPackage):
         return True
 
     def _do_installed_filtering(self,flt,pkg):
-        isInstalled = False
+        is_installed = False
         if flt == FILTER_INSTALLED:
-            wantInstalled = True
+            want_installed = True
         else:
-            wantInstalled = False
-        isInstalled = pkg.repo.id == 'installed'
-        return isInstalled == wantInstalled
+            want_installed = False
+        is_installed = pkg.repo.id == 'installed'
+        return is_installed == want_installed
 
     def _do_gui_filtering(self,flt,pkg):
-        isGUI = False
+        is_gui = False
         if flt == FILTER_GUI:
-            wantGUI = True
+            want_gui = True
         else:
-            wantGUI = False
-        isGUI = self._check_for_gui(pkg)
-        return isGUI == wantGUI
+            want_gui = False
+        is_gui = self._check_for_gui(pkg)
+        return is_gui == want_gui
 
     def _check_for_gui(self,pkg):
         '''  Check if the GUI_KEYS regex matches any package requirements'''
@@ -181,24 +180,24 @@ class YumFilter(object,PackagekitPackage):
         return False
 
     def _do_devel_filtering(self,flt,pkg):
-        isDevel = False
+        is_devel = False
         if flt == FILTER_DEVELOPMENT:
-            wantDevel = True
+            want_devel = True
         else:
-            wantDevel = False
+            want_devel = False
         regex =  re.compile(r'(-devel)|(-debuginfo)|(-static)|(-libs)')
         if regex.search(pkg.name):
-            isDevel = True
-        return isDevel == wantDevel
+            is_devel = True
+        return is_devel == want_devel
 
     def _do_free_filtering(self,flt,pkg):
-        isFree = False
+        is_free = False
         if flt == FILTER_FREE:
-            wantFree = True
+            want_free = True
         else:
-            wantFree = False
+            want_free = False
 
-        isFree = self.check_license_field(pkg.license)
+        is_free = self.check_license_field(pkg.license)
 
-        return isFree == wantFree
+        return is_free == want_free
 
commit ea2a25135f84edb2ec63bebbf697b650cc249518
Merge: c8a2e7f... 16bea44...
Author: Valeriy Lyasotskiy <onestep at ukr.net>
Date:   Tue Sep 23 17:02:18 2008 +0300

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

commit c8a2e7f64fbd0634d45ef869c681e61ac170e563
Author: Valeriy Lyasotskiy <onestep at ukr.net>
Date:   Tue Sep 23 16:53:29 2008 +0300

    alpm: search-details stuff changed and moved to another thread, cleaned up unneeded functions

diff --git a/backends/alpm/pk-backend-alpm.c b/backends/alpm/pk-backend-alpm.c
index 8ff72e2..25fbda6 100644
--- a/backends/alpm/pk-backend-alpm.c
+++ b/backends/alpm/pk-backend-alpm.c
@@ -19,6 +19,8 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+#define _GNU_SOURCE
+
 #define ALPM_CONFIG_PATH "/etc/pacman.conf"
 
 #define ALPM_ROOT "/"
@@ -63,19 +65,6 @@ typedef enum {
 	PK_ALPM_SEARCH_TYPE_GROUP
 } PkAlpmSearchType;
 
-typedef struct _PackageSource
-{
-	pmpkg_t *pkg;
-	gchar *repo;
-	guint installed;
-} PackageSource;
-
-void
-package_source_free (PackageSource *source)
-{
-	g_free (source);
-}
-
 gchar *
 pkg_to_package_id_str (pmpkg_t *pkg, const gchar *repo)
 {
@@ -283,96 +272,6 @@ emit_package (PkBackend *backend, pmpkg_t *pkg, const gchar *repo, PkInfoEnum in
 	g_free (package_id_str);
 }
 
-static void
-add_packages_from_list (PkBackend *backend, alpm_list_t *list)
-{
-	PackageSource *package = NULL;
-
-	if (list == NULL)
-		egg_warning ("alpm: add_packages_from_list called for empty list!");
-
-	alpm_list_t *iterator;
-	for (iterator = list; iterator; iterator = alpm_list_next (iterator)) {
-		package = (PackageSource *) iterator->data;
-
-		PkInfoEnum info;
-		if (package->installed)
-			info = PK_INFO_ENUM_INSTALLED;
-		else
-			info = PK_INFO_ENUM_AVAILABLE;
-
-		emit_package (backend, package->pkg, package->repo, info);
-	}
-}
-
-alpm_list_t *
-find_packages_by_details (const gchar *name, pmdb_t *db)
-{
-	if (db == NULL || name == NULL)
-		return NULL;
-
-	alpm_list_t *result = NULL;
-
-	// determine if repository is local
-	gboolean repo_is_local = (db == alpm_option_get_localdb ());
-	// determine repository name
-	const gchar *repo;
-	if (repo_is_local)
-		repo = ALPM_LOCAL_DB_ALIAS;
-	else
-		repo = alpm_db_get_name (db);
-	// set search term
-	alpm_list_t *needle = NULL;
-	needle = alpm_list_add (needle, (gchar *) name);
-	// execute query
-	alpm_list_t *query_result = alpm_db_search (db, needle);
-
-	alpm_list_t *iterator;
-	for (iterator = query_result; iterator; iterator = alpm_list_next (iterator)) {
-		PackageSource *source = g_malloc (sizeof (PackageSource));
-
-		source->pkg = (pmpkg_t *) alpm_list_getdata (iterator);
-		source->repo = (gchar *) repo;
-		source->installed = repo_is_local;
-
-		result = alpm_list_add (result, (PackageSource *) source);
-	}
-
-	alpm_list_free (query_result);
-	alpm_list_free (needle);
-	return result;
-}
-
-gboolean
-pkg_is_installed (const gchar *name, const gchar *version)
-{
-	pmdb_t *localdb = NULL;
-	alpm_list_t *result = NULL;
-
-	if (name == NULL)
-		return FALSE;
-
-	localdb = alpm_option_get_localdb ();
-	if (localdb == NULL)
-		return FALSE;
-
-	result = find_packages_by_details (name, localdb);
-	if (result == NULL)
-		return FALSE;
-	if (!alpm_list_count (result))
-		return FALSE;
-
-	if (version == NULL)
-		return TRUE;
-
-	alpm_list_t *icmp = NULL;
-	for (icmp = result; icmp; icmp = alpm_list_next (icmp))
-		if (strcmp (alpm_pkg_get_version ((pmpkg_t *) icmp->data), version) == 0)
-			return TRUE;
-
-	return FALSE;
-}
-
 /**
  * strtrim:
  * Trim whitespaces and newlines from a string
@@ -961,6 +860,14 @@ backend_search (PkBackend *backend, pmdb_t *repo, const gchar *needle, PkAlpmSea
 			case PK_ALPM_SEARCH_TYPE_NAME:
 				match = strstr (alpm_pkg_get_name (pkg), needle) != NULL;
 				break;
+			case PK_ALPM_SEARCH_TYPE_DETAILS:
+				/* TODO: strcasestr() is a non-standard extension, replace it? */
+				/* workaround for buggy packages with no description */
+				if (alpm_pkg_get_desc (pkg) == NULL)
+					match = FALSE;
+				else
+					match = strcasestr (alpm_pkg_get_desc (pkg), needle) != NULL;
+				break;
 			case PK_ALPM_SEARCH_TYPE_GROUP:
 				match = FALSE;
 				alpm_list_t *groups;
@@ -1417,36 +1324,44 @@ backend_resolve (PkBackend *backend, PkBitfield filters, gchar **package_ids)
 }
 
 /**
- * backend_search_details:
+ * backend_search_details_thread:
  */
-static void
-backend_search_details (PkBackend *backend, PkBitfield filters, const gchar *search)
+static gboolean
+backend_search_details_thread (PkBackend *backend)
 {
-	alpm_list_t *result = NULL;
-
-	pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+	const gchar *search = pk_backend_get_string (backend, "search");
+	PkBitfield filters = pk_backend_get_uint (backend, "filters");
 
 	gboolean search_installed = pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED);
 	gboolean search_not_installed = pk_bitfield_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED);
 
 	if (!search_not_installed) {
-		// Search in local db
-		result = alpm_list_join (result, find_packages_by_details (search, alpm_option_get_localdb ()));
+		/* search in local db */
+		backend_search (backend, alpm_option_get_localdb (), search, PK_ALPM_SEARCH_TYPE_DETAILS);
 	}
 
 	if (!search_installed) {
-		// Search in sync dbs
-		alpm_list_t *iterator;
-		for (iterator = alpm_option_get_syncdbs (); iterator; iterator = alpm_list_next (iterator))
-			result = alpm_list_join (result, find_packages_by_details (search, (pmdb_t *) alpm_list_getdata(iterator)));
+		/* search in sync repos */
+		alpm_list_t *repos;
+		/* iterate repos */
+		for (repos = alpm_option_get_syncdbs (); repos; repos = alpm_list_next (repos))
+			backend_search (backend, alpm_list_getdata (repos), search, PK_ALPM_SEARCH_TYPE_DETAILS);
 	}
 
-	add_packages_from_list (backend, alpm_list_first (result));
+	pk_backend_finished (backend);
+	return TRUE;
+}
 
-	alpm_list_free_inner (result, (alpm_list_fn_free) package_source_free);
-	alpm_list_free (result);
+/**
+ * backend_search_details:
+ */
+static void
+backend_search_details (PkBackend *backend, PkBitfield filters, const gchar *search)
+{
+	pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+	pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
 
-	pk_backend_finished (backend);
+	pk_backend_thread_create (backend, backend_search_details_thread);
 }
 
 /**
commit b774fd31d424ea96141c25a3c6f087ca9d576ec4
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Sep 23 14:47:24 2008 +0100

    yum: fix up a load of issues with rpmlint in yumBackend

diff --git a/backends/yum/yumBackend.py b/backends/yum/yumBackend.py
index 8a29917..0a45ea7 100755
--- a/backends/yum/yumBackend.py
+++ b/backends/yum/yumBackend.py
@@ -281,7 +281,7 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
 
         step = int(800/len(collections))
         print step
-        pct=20
+        pct = 20
         i = 0
         for col in collections:
             i += 1
@@ -445,7 +445,7 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
         self.yumbase.conf.cache = 0 # Allow new files
         self.allow_cancel(True)
         self.status(STATUS_DOWNLOAD)
-        percentage = 0;
+        percentage = 0
         bump = 100 / len(package_ids)
         files = []
 
@@ -593,7 +593,7 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
         self.percentage(None)
         self.status(STATUS_INFO)
 
-        percentage = 0;
+        percentage = 0
         bump = 100 / len(package_ids)
         deps_list = []
         resolve_list = []
@@ -608,7 +608,7 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
                 else:
                     txmbr = self.yumbase.groupRemove(grp.groupid)
                     rc,msgs =  self.yumbase.buildTransaction()
-                    if rc !=2:
+                    if rc != 2:
                         self.error(ERROR_DEP_RESOLUTION_FAILED,self._format_msgs(msgs))
                     else:
                         for txmbr in self.yumbase.tsInfo:
@@ -622,7 +622,7 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
                     txmbrs = self.yumbase.remove(po=pkg)
                     if txmbrs:
                         rc,msgs =  self.yumbase.buildTransaction()
-                        if rc !=2:
+                        if rc != 2:
                             self.error(ERROR_DEP_RESOLUTION_FAILED,self._format_msgs(msgs))
                         else:
                             for txmbr in self.yumbase.tsInfo:
@@ -649,7 +649,7 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
         # search for a requested arch first
         ret = self._is_inst(pkg)
         if ret:
-            return True;
+            return True
 
         # then fallback to i686 if i386
         if pkg.arch == 'i386':
@@ -718,18 +718,18 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
             for pkg in pkgs:
                 if best:
                     if pkg.EVR > best.EVR:
-                        best=pkg
+                        best = pkg
                 else:
-                    best=pkg
+                    best = pkg
 
         # then give up and see if there's one available
         if not best:
             for pkg in pkglist:
                 if best:
                     if pkg.EVR > best.EVR:
-                        best=pkg
+                        best = pkg
                 else:
-                    best=pkg
+                    best = pkg
         return best
 
     def _get_best_depends(self,pkgs,recursive):
@@ -804,7 +804,7 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
         pkgfilter = YumFilter(fltlist)
         recursive = self._text_to_boolean(recursive_text)
 
-        percentage = 0;
+        percentage = 0
         bump = 100 / len(package_ids)
         deps_list = []
         resolve_list = []
@@ -884,7 +884,7 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
         '''
         Implement the {backend}-refresh_cache functionality
         '''
-        self.allow_cancel(True);
+        self.allow_cancel(True)
         self.percentage(0)
         self.status(STATUS_REFRESH_CACHE)
 
@@ -900,10 +900,10 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
             for repo in self.yumbase.repos.listEnabled():
                 repo.metadata_expire = 0
                 self.yumbase.repos.populateSack(which=[repo.id],mdtype='metadata',cacheonly=1)
-                pct+=bump
+                pct += bump
                 self.percentage(pct)
                 self.yumbase.repos.populateSack(which=[repo.id],mdtype='filelists',cacheonly=1)
-                pct+=bump
+                pct += bump
                 self.percentage(pct)
 
             self.percentage(95)
@@ -913,11 +913,11 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
             self.percentage(100)
 
         except yum.Errors.RepoError,e:
-                message = self._format_msgs(e.value)
-                if message.find ("No more mirrors to try") != -1:
-                    self.error(ERROR_NO_MORE_MIRRORS_TO_TRY,message)
-                else:
-                    self.error(ERROR_REPO_CONFIGURATION_ERROR,message)
+            message = self._format_msgs(e.value)
+            if message.find ("No more mirrors to try") != -1:
+                self.error(ERROR_NO_MORE_MIRRORS_TO_TRY,message)
+            else:
+                self.error(ERROR_REPO_CONFIGURATION_ERROR,message)
         except yum.Errors.YumBaseError,e:
             self.error(ERROR_UNKNOWN,"cannot refresh cache: %s" % str(e))
 
@@ -930,7 +930,7 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
         Implement the {backend}-resolve functionality
         '''
         self._check_init(lazy_cache=True)
-        self.allow_cancel(True);
+        self.allow_cancel(True)
         self.percentage(None)
         self.yumbase.doConfigSetup(errorlevel=0,debuglevel=0)# Setup Yum Config
         self.yumbase.conf.cache = 0 # TODO: can we just look in the cache?
@@ -1088,9 +1088,9 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
         # If trusted is true, it means that we will only install trusted files
         if trusted == 'yes':
             # disregard the default
-            self.yumbase.conf.gpgcheck=1
+            self.yumbase.conf.gpgcheck = 1
 
-            # self.yumbase.installLocal fails for unsigned packages when self.yumbase.conf.gpgcheck=1
+            # self.yumbase.installLocal fails for unsigned packages when self.yumbase.conf.gpgcheck = 1
             # This means we don't run runYumTransaction, and don't get the GPG failure in
             # PackageKitYumBase(_checkSignatures) -- so we check here
             for inst_file in inst_files:
@@ -1100,7 +1100,7 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
                 except yum.Errors.YumGPGCheckError,e:
                     self.error(ERROR_MISSING_GPG_SIGNATURE,str(e))
         else:
-            self.yumbase.conf.gpgcheck=0
+            self.yumbase.conf.gpgcheck = 0
 
         # common checks copied from yum
         for inst_file in inst_files:
@@ -1162,11 +1162,10 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
             return False
 
         if len(self.yumbase.conf.exclude) > 0:
-           exactmatch, matched, unmatched = \
-                   parsePackages([po], self.yumbase.conf.exclude, casematch=1)
-           if po in exactmatch + matched:
-               self.error(ERROR_PACKAGE_INSTALL_BLOCKED, "Installation of %s is excluded by yum configuration." % pkg)
-               return False
+            exactmatch, matched, unmatched = parsePackages([po], self.yumbase.conf.exclude, casematch=1)
+            if po in exactmatch + matched:
+                self.error(ERROR_PACKAGE_INSTALL_BLOCKED, "Installation of %s is excluded by yum configuration." % pkg)
+                return False
 
         return True
 
@@ -1177,7 +1176,7 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
         '''
         self._check_init()
         self.yumbase.conf.cache = 0 # Allow new files
-        self.allow_cancel(False);
+        self.allow_cancel(False)
         self.percentage(0)
         self.status(STATUS_RUNNING)
         txmbrs = []
@@ -1215,9 +1214,9 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
 
     def _format_msgs(self,msgs):
         if isinstance(msgs,basestring):
-             msgs = msgs.split('\n')
+            msgs = msgs.split('\n')
         text = ";".join(msgs)
-        text = self._truncate(text, 1024);
+        text = self._truncate(text, 1024)
         text = text.replace(";Please report this error in bugzilla","")
         text = text.replace("Missing Dependency: ","")
         text = text.replace(" (installed)","")
@@ -1232,7 +1231,7 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
             rc,msgs =  self.yumbase.buildTransaction()
         except yum.Errors.RepoError,e:
             self.error(ERROR_REPO_NOT_AVAILABLE,str(e))
-        if rc !=2:
+        if rc != 2:
             self.error(ERROR_DEP_RESOLUTION_FAILED,self._format_msgs(msgs))
         else:
             self._check_for_reboot()
@@ -1286,7 +1285,7 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
         '''
         self._check_init()
         self.yumbase.conf.cache = 0 # Allow new files
-        self.allow_cancel(False);
+        self.allow_cancel(False)
         self.percentage(0)
         self.status(STATUS_RUNNING)
 
@@ -1339,7 +1338,7 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
                 desc = desc.replace('\n',' ')
                 group = GROUP_COLLECTIONS
                 pkgs = self._get_group_packages(grp)
-                size = 0;
+                size = 0
                 for pkg in pkgs:
                     size = size + pkg.size
                 self.details(id,"",group,desc,"",size)
@@ -1444,7 +1443,7 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
 
         # find the newest release
         newest = None
-        last_version = 0;
+        last_version = 0
         for section in config.sections():
             # we only care about stable versions
             if config.has_option(section,'stable') and config.getboolean(section,'stable'):
@@ -1741,7 +1740,7 @@ class DownloadCallback(BaseMeter):
         self.lastPct = 0
         self.totalPct = 0
         self.pkgs = None
-        self.numPkgs=0
+        self.numPkgs = 0
         self.bump = 0.0
 
     def setPackages(self,pkgs,startPct,numPct):
@@ -1929,9 +1928,9 @@ class DepSolveCallback(object):
         self.backend = backend
 
     def start(self):
-       if not self.started:
-           self.backend.status(STATUS_DEP_RESOLVE)
-           self.backend.percentage(None)
+        if not self.started:
+            self.backend.status(STATUS_DEP_RESOLVE)
+            self.backend.percentage(None)
 
     # Be lazy and not define the others explicitly
     def _do_nothing(self,*args,**kwargs):
commit 16bea44b16fd8b1ac36cc5939caf1017eece12eb
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Sep 23 14:43:31 2008 +0100

    yum: fix the name of the enum when no mirrors are found

diff --git a/backends/yum/yumBackend.py b/backends/yum/yumBackend.py
index b445e0d..8a29917 100755
--- a/backends/yum/yumBackend.py
+++ b/backends/yum/yumBackend.py
@@ -915,7 +915,7 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
         except yum.Errors.RepoError,e:
                 message = self._format_msgs(e.value)
                 if message.find ("No more mirrors to try") != -1:
-                    self.error(ERROR_FILE_NO_MORE_MIRRORS_TO_TRY,message)
+                    self.error(ERROR_NO_MORE_MIRRORS_TO_TRY,message)
                 else:
                     self.error(ERROR_REPO_CONFIGURATION_ERROR,message)
         except yum.Errors.YumBaseError,e:
commit 18b20e334595ca43ba44a3f6fbf2a7f7ed0a79f9
Merge: b236533... b2a6528...
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Sep 23 14:21:08 2008 +0100

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

commit b236533532dddcc75d0c3155bdfc93f460bc0fae
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Sep 23 14:11:50 2008 +0100

    Revert "Revert "change the default of RefreshCacheScanDesktopFiles and RefreshCacheUpdatePackageList to true. Distros that have slow methods may want to disable these""
    
    This reverts commit 0da977a67ea3e74e556b847e0085737bbb1f28fe.

diff --git a/etc/PackageKit.conf.in b/etc/PackageKit.conf.in
index 8e58e9a..fae5ad4 100644
--- a/etc/PackageKit.conf.in
+++ b/etc/PackageKit.conf.in
@@ -50,13 +50,13 @@ DefaultBackend=@defaultbackend@
 #
 # NOTE: Don't enable this for backends that are slow doing SearchFile()
 #
-# default=false
-RefreshCacheScanDesktopFiles=false
+# default=true
+RefreshCacheScanDesktopFiles=true
 
 # Update the package list when we RefreshCache
 #
 # NOTE: Don't enable this for backends that are slow doing GetPackages()
 #
-# default=false
-RefreshCacheUpdatePackageList=false
+# default=true
+RefreshCacheUpdatePackageList=true
 
commit b2a6528bf1fac70d5d3f6b3b362d19f60d81b4c6
Merge: b05e1a7... 4afe6eb...
Author: Anders F Bjorklund <afb at users.sourceforge.net>
Date:   Tue Sep 23 14:30:19 2008 +0200

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

commit b05e1a7a521427edebd61f40fe24f6dca026dd83
Author: Anders F Bjorklund <afb at users.sourceforge.net>
Date:   Tue Sep 23 14:29:59 2008 +0200

    smart: restore the missing installed collections

diff --git a/backends/smart/helpers/smartBackend.py b/backends/smart/helpers/smartBackend.py
index d799317..5706b3b 100755
--- a/backends/smart/helpers/smartBackend.py
+++ b/backends/smart/helpers/smartBackend.py
@@ -712,7 +712,8 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
             package = packages[0]
             infos = []
             for loader in package.loaders:
-                if channels and loader.getChannel() not in channels:
+                if channels and loader.getChannel() not in channels and not \
+                (package.installed and self._package_is_collection(package)):
                     continue
                 info = loader.getInfo(package)
                 infos.append(info)
@@ -1058,7 +1059,8 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
                 status = INFO_UNKNOWN
         for loader in package.loaders:
             channel = loader.getChannel()
-            if package.installed and not channel.getType().endswith('-sys'):
+            if package.installed and not channel.getType().endswith('-sys') \
+            and not self._package_is_collection(package):
                 continue
             info = loader.getInfo(package)
             summary = info.getSummary()
commit 4afe6eb6645484a5ccf3c0e8be4c916c99f8ba0f
Author: Valeriy Lyasotskiy <onestep at ukr.net>
Date:   Tue Sep 23 15:27:54 2008 +0300

    alpm: get-packages stuff changed and moved to another thread, removed unneeded get_packages function

diff --git a/backends/alpm/pk-backend-alpm.c b/backends/alpm/pk-backend-alpm.c
index cb52473..8ff72e2 100644
--- a/backends/alpm/pk-backend-alpm.c
+++ b/backends/alpm/pk-backend-alpm.c
@@ -56,6 +56,7 @@ GHashTable *group_map;
 alpm_list_t *syncfirst;
 
 typedef enum {
+	PK_ALPM_SEARCH_TYPE_NULL,
 	PK_ALPM_SEARCH_TYPE_RESOLVE,
 	PK_ALPM_SEARCH_TYPE_NAME,
 	PK_ALPM_SEARCH_TYPE_DETAILS,
@@ -342,41 +343,6 @@ find_packages_by_details (const gchar *name, pmdb_t *db)
 	return result;
 }
 
-alpm_list_t *
-get_packages (pmdb_t *db)
-{
-	if (db == NULL)
-		return NULL;
-
-	alpm_list_t *result = NULL;
-
-	// determine if repository is local
-	gboolean repo_is_local = (db == alpm_option_get_localdb ());
-	// determine repository name
-	const gchar *repo;
-	if (repo_is_local)
-		repo = ALPM_LOCAL_DB_ALIAS;
-	else
-		repo = alpm_db_get_name (db);
-	// get list of packages in repository
-	alpm_list_t *cache = alpm_db_getpkgcache (db);
-
-	alpm_list_t *iterator;
-	for (iterator = cache; iterator; iterator = alpm_list_next (iterator)) {
-		pmpkg_t *pkg = alpm_list_getdata (iterator);
-
-		PackageSource *source = g_malloc (sizeof (PackageSource));
-
-		source->pkg = (pmpkg_t *) pkg;
-		source->repo = (gchar *) repo;
-		source->installed = repo_is_local;
-
-		result = alpm_list_add (result, (PackageSource *) source);
-	}
-
-	return result;
-}
-
 gboolean
 pkg_is_installed (const gchar *name, const gchar *version)
 {
@@ -959,43 +925,108 @@ backend_get_files (PkBackend *backend, gchar **package_ids)
 	pk_backend_finished (backend);
 }
 
+void
+backend_search (PkBackend *backend, pmdb_t *repo, const gchar *needle, PkAlpmSearchType search_type) {
+	/* package cache */
+	alpm_list_t *pkg_cache;
+
+	/* utility variables */
+	const gchar *repo_name;
+	PkInfoEnum info;
+	gboolean match;
+
+	if (repo == alpm_option_get_localdb ()) {
+		repo_name = ALPM_LOCAL_DB_ALIAS;
+		info = PK_INFO_ENUM_INSTALLED;
+	} else {
+		repo_name = alpm_db_get_name (repo);
+		info = PK_INFO_ENUM_AVAILABLE;
+	}
+
+	/* get package cache for specified repo */
+	pkg_cache = alpm_db_getpkgcache (repo);
+
+	alpm_list_t *iterator;
+	/* iterate package cache */
+	for (iterator = pkg_cache; iterator; iterator = alpm_list_next (iterator)) {
+		pmpkg_t *pkg = alpm_list_getdata (iterator);
+
+		switch (search_type) {
+			case PK_ALPM_SEARCH_TYPE_NULL:
+				match = TRUE;
+				break;
+			case PK_ALPM_SEARCH_TYPE_RESOLVE:
+				match = strcmp (alpm_pkg_get_name (pkg), needle) == 0;
+				break;
+			case PK_ALPM_SEARCH_TYPE_NAME:
+				match = strstr (alpm_pkg_get_name (pkg), needle) != NULL;
+				break;
+			case PK_ALPM_SEARCH_TYPE_GROUP:
+				match = FALSE;
+				alpm_list_t *groups;
+				/* iterate groups */
+				for (groups = alpm_pkg_get_groups (pkg); groups && !match; groups = alpm_list_next (groups)) {
+					gchar *group = (gchar *) g_hash_table_lookup (group_map, (char *) alpm_list_getdata (groups));
+					if (group == NULL)
+						group = "other";
+					match = strcmp (group, needle) == 0;
+				}
+				break;
+			default:
+				match = FALSE;
+		}
+
+		if (match) {
+			/* we found what we wanted */
+			emit_package (backend, pkg, repo_name, info);
+		}
+	}
+}
+
 /**
- * backend_get_packages:
+ * backend_get_packages_thread:
  */
-static void
-backend_get_packages (PkBackend *backend, PkBitfield filters)
+static gboolean
+backend_get_packages_thread (PkBackend *backend)
 {
-	alpm_list_t *result = NULL;
-
-	pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+	PkBitfield filters = pk_backend_get_uint (backend, "filters");
 
 	gboolean search_installed = pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED);
 	gboolean search_not_installed = pk_bitfield_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED);
 
 	if (!search_not_installed) {
-		// Search in local db
-		result = alpm_list_join (result, get_packages (alpm_option_get_localdb ()));
+		/* search in local db */
+		backend_search (backend, alpm_option_get_localdb (), NULL, PK_ALPM_SEARCH_TYPE_NULL);
 	}
 
 	if (!search_installed) {
-		// Search in sync dbs
-		alpm_list_t *iterator;
-		for (iterator = alpm_option_get_syncdbs (); iterator; iterator = alpm_list_next (iterator))
-			result = alpm_list_join (result, get_packages ((pmdb_t *) alpm_list_getdata(iterator)));
+		/* search in sync repos */
+		alpm_list_t *repos;
+		/* iterate repos */
+		for (repos = alpm_option_get_syncdbs (); repos; repos = alpm_list_next (repos))
+			backend_search (backend, alpm_list_getdata (repos), NULL, PK_ALPM_SEARCH_TYPE_NULL);
 	}
 
-	add_packages_from_list (backend, alpm_list_first (result));
+	pk_backend_finished (backend);
+	return TRUE;
+}
 
-	alpm_list_free_inner (result, (alpm_list_fn_free) package_source_free);
-	alpm_list_free (result);
+/**
+ * backend_get_packages:
+ */
+static void
+backend_get_packages (PkBackend *backend, PkBitfield filters)
+{
+	pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+	pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
 
-	pk_backend_finished (backend);
+	pk_backend_thread_create (backend, backend_get_packages_thread);
 }
 
 /**
  * backend_get_repo_list:
  */
-void
+static void
 backend_get_repo_list (PkBackend *backend, PkBitfield filters)
 {
 	pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
@@ -1015,6 +1046,9 @@ backend_get_repo_list (PkBackend *backend, PkBitfield filters)
 	pk_backend_finished (backend);
 }
 
+/**
+ * backend_get_update_detail:
+ */
 static void
 backend_get_update_detail (PkBackend *backend, gchar **package_ids)
 {
@@ -1338,61 +1372,6 @@ backend_remove_packages (PkBackend *backend, gchar **package_ids, gboolean allow
 	pk_backend_thread_create (backend, backend_remove_packages_thread);
 }
 
-void
-backend_search (PkBackend *backend, pmdb_t *repo, const gchar *needle, PkAlpmSearchType search_type) {
-	/* package cache */
-	alpm_list_t *pkg_cache;
-
-	/* utility variables */
-	const gchar *repo_name;
-	PkInfoEnum info;
-	gboolean match;
-
-	if (repo == alpm_option_get_localdb ()) {
-		repo_name = ALPM_LOCAL_DB_ALIAS;
-		info = PK_INFO_ENUM_INSTALLED;
-	} else {
-		repo_name = alpm_db_get_name (repo);
-		info = PK_INFO_ENUM_AVAILABLE;
-	}
-
-	/* get package cache for specified repo */
-	pkg_cache = alpm_db_getpkgcache (repo);
-
-	alpm_list_t *iterator;
-	/* iterate package cache */
-	for (iterator = pkg_cache; iterator; iterator = alpm_list_next (iterator)) {
-		pmpkg_t *pkg = alpm_list_getdata (iterator);
-
-		switch (search_type) {
-			case PK_ALPM_SEARCH_TYPE_RESOLVE:
-				match = strcmp (alpm_pkg_get_name (pkg), needle) == 0;
-				break;
-			case PK_ALPM_SEARCH_TYPE_NAME:
-				match = strstr (alpm_pkg_get_name (pkg), needle) != NULL;
-				break;
-			case PK_ALPM_SEARCH_TYPE_GROUP:
-				match = FALSE;
-				alpm_list_t *groups;
-				/* iterate groups */
-				for (groups = alpm_pkg_get_groups (pkg); groups && !match; groups = alpm_list_next (groups)) {
-					gchar *group = (gchar *) g_hash_table_lookup (group_map, (char *) alpm_list_getdata (groups));
-					if (group == NULL)
-						group = "other";
-					match = strcmp (group, needle) == 0;
-				}
-				break;
-			default:
-				match = TRUE;
-		}
-
-		if (match) {
-			/* we found what we wanted */
-			emit_package (backend, pkg, repo_name, info);
-		}
-	}
-}
-
 /**
  * backend_resolve_thread:
  */
commit 21114cb563e89c5b8e7b2ad148c953507971cd4f
Merge: 6e49785... 77622db...
Author: Valeriy Lyasotskiy <onestep at ukr.net>
Date:   Tue Sep 23 14:58:25 2008 +0300

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

commit 77622db8a41480b8e2b94dbe664d48634e1660bb
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Sep 23 12:53:25 2008 +0100

    trivial: add a self check screenshot

diff --git a/docs/html/img/pk-self-check.png b/docs/html/img/pk-self-check.png
new file mode 100644
index 0000000..b9c7b71
Binary files /dev/null and b/docs/html/img/pk-self-check.png differ
commit 38f77f46677127b9cc69348a6360579565c64af1
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Sep 23 12:41:12 2008 +0100

    bugfix: check if an instance is already running which can happen when developing PackageKit

diff --git a/src/pk-main.c b/src/pk-main.c
index 88e6ed0..9a87470 100644
--- a/src/pk-main.c
+++ b/src/pk-main.c
@@ -32,6 +32,8 @@
 #include <dbus/dbus-glib-lowlevel.h>
 
 #include "egg-debug.h"
+#include "egg-dbus-monitor.h"
+
 #include "pk-conf.h"
 #include "pk-engine.h"
 #include "pk-transaction.h"
@@ -167,6 +169,7 @@ main (int argc, char *argv[])
 {
 	GMainLoop *loop;
 	DBusGConnection *system_connection;
+	EggDbusMonitor *monitor;
 	gboolean ret;
 	gboolean verbose = FALSE;
 	gboolean disable_timer = FALSE;
@@ -215,6 +218,16 @@ main (int argc, char *argv[])
 		goto exit_program;
 	}
 
+	/* check if an instance is already running */
+	monitor = egg_dbus_monitor_new ();
+	egg_dbus_monitor_assign (monitor, EGG_DBUS_MONITOR_SYSTEM, PK_DBUS_SERVICE);
+	ret = egg_dbus_monitor_is_connected (monitor);
+	g_object_unref (monitor);
+	if (ret) {
+		g_print ("Already running service which provides %s\n", PK_DBUS_SERVICE);
+		goto exit_program;
+	}
+
 	/* do stuff on ctrl-c */
 	signal (SIGINT, pk_main_sigint_handler);
 
commit 6e497858f454409fa89091cf2ab60c67f90e5d4b
Merge: ca04617... 57dfc86...
Author: Valeriy Lyasotskiy <onestep at ukr.net>
Date:   Tue Sep 23 14:39:14 2008 +0300

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

commit ca04617938cd62507670f13fe55b9f5d7ee67dff
Author: Valeriy Lyasotskiy <onestep at ukr.net>
Date:   Tue Sep 23 14:38:23 2008 +0300

    alpm: search-group stuff changed and moved to another thread, removed unneeded find_packages_by_group function

diff --git a/backends/alpm/pk-backend-alpm.c b/backends/alpm/pk-backend-alpm.c
index 48edd79..cb52473 100644
--- a/backends/alpm/pk-backend-alpm.c
+++ b/backends/alpm/pk-backend-alpm.c
@@ -51,7 +51,7 @@ int subprogress_percentage;
 PkBackend *backend_instance = NULL;
 gchar *dl_file_name;
 
-GHashTable *group_mapping;
+GHashTable *group_map;
 
 alpm_list_t *syncfirst;
 
@@ -343,60 +343,6 @@ find_packages_by_details (const gchar *name, pmdb_t *db)
 }
 
 alpm_list_t *
-find_packages_by_group (const gchar *name, pmdb_t *db)
-{
-	if (db == NULL || name == NULL)
-		return NULL;
-
-	alpm_list_t *result = NULL;
-
-	// determine if repository is local
-	gboolean repo_is_local = (db == alpm_option_get_localdb ());
-	// determine if we are searching for packages which belong to an unmapped group
-	gboolean search_other = (strcmp("other", name) == 0);
-	// determine repository name
-	const gchar *repo;
-	if (repo_is_local)
-		repo = ALPM_LOCAL_DB_ALIAS;
-	else
-		repo = alpm_db_get_name (db);
-	// get list of packages in repository
-	alpm_list_t *pkgcache = alpm_db_getpkgcache (db);
-
-	// we will iterate on the whole package cache - this can be slow
-	// other way is to iterate on group cache
-	alpm_list_t *iterator;
-	for (iterator = pkgcache; iterator; iterator = alpm_list_next (iterator)) {
-		pmpkg_t *pkg = alpm_list_getdata (iterator);
-
-		gboolean match = FALSE;
-
-		// iterate on groups list
-		alpm_list_t *group_iterator;
-		for (group_iterator = alpm_pkg_get_groups (pkg); group_iterator; group_iterator = alpm_list_next (group_iterator)) {
-			gchar *mapped_group = (gchar *) g_hash_table_lookup (group_mapping, (char *) alpm_list_getdata (group_iterator));
-			// if we hit unknown group, we can treat it as "other"
-			if ((mapped_group == NULL && search_other) || (mapped_group != NULL && strcmp (mapped_group, name) == 0)) {
-				match = TRUE;
-				break;
-			}
-		}
-
-		if (match) {
-			PackageSource *source = g_malloc (sizeof (PackageSource));
-
-			source->pkg = (pmpkg_t *) pkg;
-			source->repo = (gchar *) repo;
-			source->installed = repo_is_local;
-
-			result = alpm_list_add (result, (PackageSource *) source);
-		}
-	}
-
-	return result;
-}
-
-alpm_list_t *
 get_packages (pmdb_t *db)
 {
 	if (db == NULL)
@@ -750,7 +696,7 @@ backend_initialize (PkBackend *backend)
 	// initialize backend_instance for use in callback functions
 	backend_instance = backend;
 
-	egg_debug ("alpm: hi!");
+	egg_debug ("alpm: initializing backend");
 
 	if (alpm_initialize () == -1) {
 		pk_backend_error_code (backend, PK_ERROR_ENUM_FAILED_INITIALIZATION, "Failed to initialize package manager");
@@ -776,37 +722,37 @@ backend_initialize (PkBackend *backend)
 	alpm_option_set_dlcb (cb_dl_progress);
 
 	/* fill in group mapping */
-	group_mapping = g_hash_table_new (g_str_hash, g_str_equal);
-	g_hash_table_insert (group_mapping, "gnome", "desktop-gnome");
-	g_hash_table_insert (group_mapping, "gnome-extra", "desktop-gnome");
-	g_hash_table_insert (group_mapping, "compiz-gnome", "desktop-gnome");
-	g_hash_table_insert (group_mapping, "kde", "desktop-kde");
-	g_hash_table_insert (group_mapping, "compiz-kde", "desktop-kde");
-	g_hash_table_insert (group_mapping, "compiz-fusion-kde", "desktop-kde");
-	g_hash_table_insert (group_mapping, "lxde", "desktop-other");
-	g_hash_table_insert (group_mapping, "rox-desktop", "desktop-other");
-	g_hash_table_insert (group_mapping, "e17-cvs", "desktop-other");
-	g_hash_table_insert (group_mapping, "e17-extra-cvs", "desktop-other");
-	g_hash_table_insert (group_mapping, "e17-libs-cvs", "desktop-other");
-	g_hash_table_insert (group_mapping, "xfce4", "desktop-xfce");
-	g_hash_table_insert (group_mapping, "xfce4-goodies", "desktop-xfce");
-	g_hash_table_insert (group_mapping, "bmp-io-plugins", "multimedia");
-	g_hash_table_insert (group_mapping, "bmp-plugins", "multimedia");
-	g_hash_table_insert (group_mapping, "bmp-visualization-plugins", "multimedia");
-	g_hash_table_insert (group_mapping, "gstreamer0.10-plugins", "multimedia");
-	g_hash_table_insert (group_mapping, "ladspa-plugins", "multimedia");
-	g_hash_table_insert (group_mapping, "pvr", "multimedia");
-	g_hash_table_insert (group_mapping, "mythtv-extras", "multimedia");
-	g_hash_table_insert (group_mapping, "xmms-effect-plugins", "multimedia");
-	g_hash_table_insert (group_mapping, "xmms-io-plugins", "multimedia");
-	g_hash_table_insert (group_mapping, "xmms-plugins", "multimedia");
-	g_hash_table_insert (group_mapping, "base-devel", "programming");
-	g_hash_table_insert (group_mapping, "texlive-lang", "publishing");
-	g_hash_table_insert (group_mapping, "texlive-lang-doc", "publishing");
-	g_hash_table_insert (group_mapping, "texlive-most", "publishing");
-	g_hash_table_insert (group_mapping, "texlive-most-doc", "publishing");
-	g_hash_table_insert (group_mapping, "texlive-most-svn", "publishing");
-	g_hash_table_insert (group_mapping, "base", "system");
+	group_map = g_hash_table_new (g_str_hash, g_str_equal);
+	g_hash_table_insert (group_map, "gnome", "desktop-gnome");
+	g_hash_table_insert (group_map, "gnome-extra", "desktop-gnome");
+	g_hash_table_insert (group_map, "compiz-gnome", "desktop-gnome");
+	g_hash_table_insert (group_map, "kde", "desktop-kde");
+	g_hash_table_insert (group_map, "compiz-kde", "desktop-kde");
+	g_hash_table_insert (group_map, "compiz-fusion-kde", "desktop-kde");
+	g_hash_table_insert (group_map, "lxde", "desktop-other");
+	g_hash_table_insert (group_map, "rox-desktop", "desktop-other");
+	g_hash_table_insert (group_map, "e17-cvs", "desktop-other");
+	g_hash_table_insert (group_map, "e17-extra-cvs", "desktop-other");
+	g_hash_table_insert (group_map, "e17-libs-cvs", "desktop-other");
+	g_hash_table_insert (group_map, "xfce4", "desktop-xfce");
+	g_hash_table_insert (group_map, "xfce4-goodies", "desktop-xfce");
+	g_hash_table_insert (group_map, "bmp-io-plugins", "multimedia");
+	g_hash_table_insert (group_map, "bmp-plugins", "multimedia");
+	g_hash_table_insert (group_map, "bmp-visualization-plugins", "multimedia");
+	g_hash_table_insert (group_map, "gstreamer0.10-plugins", "multimedia");
+	g_hash_table_insert (group_map, "ladspa-plugins", "multimedia");
+	g_hash_table_insert (group_map, "pvr", "multimedia");
+	g_hash_table_insert (group_map, "mythtv-extras", "multimedia");
+	g_hash_table_insert (group_map, "xmms-effect-plugins", "multimedia");
+	g_hash_table_insert (group_map, "xmms-io-plugins", "multimedia");
+	g_hash_table_insert (group_map, "xmms-plugins", "multimedia");
+	g_hash_table_insert (group_map, "base-devel", "programming");
+	g_hash_table_insert (group_map, "texlive-lang", "publishing");
+	g_hash_table_insert (group_map, "texlive-lang-doc", "publishing");
+	g_hash_table_insert (group_map, "texlive-most", "publishing");
+	g_hash_table_insert (group_map, "texlive-most-doc", "publishing");
+	g_hash_table_insert (group_map, "texlive-most-svn", "publishing");
+	g_hash_table_insert (group_map, "base", "system");
 
 	egg_debug ("alpm: ready to go");
 }
@@ -817,7 +763,7 @@ backend_initialize (PkBackend *backend)
 static void
 backend_destroy (PkBackend *backend)
 {
-	g_hash_table_destroy (group_mapping);
+	g_hash_table_destroy (group_map);
 
 	if (alpm_release () == -1) {
 		pk_backend_error_code (backend, PK_ERROR_ENUM_FAILED_FINALISE, "Failed to release package manager");
@@ -1425,6 +1371,17 @@ backend_search (PkBackend *backend, pmdb_t *repo, const gchar *needle, PkAlpmSea
 			case PK_ALPM_SEARCH_TYPE_NAME:
 				match = strstr (alpm_pkg_get_name (pkg), needle) != NULL;
 				break;
+			case PK_ALPM_SEARCH_TYPE_GROUP:
+				match = FALSE;
+				alpm_list_t *groups;
+				/* iterate groups */
+				for (groups = alpm_pkg_get_groups (pkg); groups && !match; groups = alpm_list_next (groups)) {
+					gchar *group = (gchar *) g_hash_table_lookup (group_map, (char *) alpm_list_getdata (groups));
+					if (group == NULL)
+						group = "other";
+					match = strcmp (group, needle) == 0;
+				}
+				break;
 			default:
 				match = TRUE;
 		}
@@ -1514,36 +1471,44 @@ backend_search_details (PkBackend *backend, PkBitfield filters, const gchar *sea
 }
 
 /**
- * backend_search_group:
+ * backend_search_group_thread:
  */
-static void
-backend_search_group (PkBackend *backend, PkBitfield filters, const gchar *search)
+static gboolean
+backend_search_group_thread (PkBackend *backend)
 {
-	alpm_list_t *result = NULL;
-
-	pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+	const gchar *search = pk_backend_get_string (backend, "search");
+	PkBitfield filters = pk_backend_get_uint (backend, "filters");
 
 	gboolean search_installed = pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED);
 	gboolean search_not_installed = pk_bitfield_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED);
 
 	if (!search_not_installed) {
-		// Search in local db
-		result = alpm_list_join (result, find_packages_by_group (search, alpm_option_get_localdb ()));
+		/* search in local db */
+		backend_search (backend, alpm_option_get_localdb (), search, PK_ALPM_SEARCH_TYPE_GROUP);
 	}
 
 	if (!search_installed) {
-		// Search in sync dbs
-		alpm_list_t *iterator;
-		for (iterator = alpm_option_get_syncdbs (); iterator; iterator = alpm_list_next (iterator))
-			result = alpm_list_join (result, find_packages_by_group (search, (pmdb_t *) alpm_list_getdata(iterator)));
+		/* search in sync repos */
+		alpm_list_t *repos;
+		/* iterate repos */
+		for (repos = alpm_option_get_syncdbs (); repos; repos = alpm_list_next (repos))
+			backend_search (backend, alpm_list_getdata (repos), search, PK_ALPM_SEARCH_TYPE_GROUP);
 	}
 
-	add_packages_from_list (backend, alpm_list_first (result));
+	pk_backend_finished (backend);
+	return TRUE;
+}
 
-	alpm_list_free_inner (result, (alpm_list_fn_free) package_source_free);
-	alpm_list_free (result);
+/**
+ * backend_search_group:
+ */
+static void
+backend_search_group (PkBackend *backend, PkBitfield filters, const gchar *search)
+{
+	pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+	pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
 
-	pk_backend_finished (backend);
+	pk_backend_thread_create (backend, backend_search_group_thread);
 }
 
 /**
commit 57dfc864741dcd2ab6fcdf30493e1516506acee4
Merge: 95a2dcf... 59171ae...
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Sep 23 12:17:31 2008 +0100

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

commit 95a2dcf78ba0e2ae6262bfae897a16b0e26408c8
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Sep 23 11:43:36 2008 +0100

    bugfix: when we have more than one transaction queued, don't try to run them all at once
    
    This bug was never triggered before as we were running eachpk_transaction_run in a loop
    and so blocked at this point. Now we are idle_add'ing them, it's possible for all of
    the remaining queue to be dispatched at the same time.
    This fixes the bug where the dispatcher would sometimes fail to run the second method
    and PkSpawn would error out with 'trying to set timeout when already set'.

diff --git a/src/pk-transaction-list.c b/src/pk-transaction-list.c
index d8da409..23bbcf0 100644
--- a/src/pk-transaction-list.c
+++ b/src/pk-transaction-list.c
@@ -296,6 +296,7 @@ pk_transaction_list_transaction_finished_cb (PkTransaction *transaction, const g
 		    !item->finished) {
 			egg_debug ("running %s as previous one finished", item->tid);
 			pk_transaction_list_run_item (tlist, item);
+			break;
 		}
 	}
 }
commit 346d50935d244fae13cab3d9860df7ce23da011e
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Sep 23 11:36:06 2008 +0100

    trivial: add some unit tests to PkTransactionList for multiple scheduling that we fail totally... bugfix coming up

diff --git a/src/pk-transaction-list.c b/src/pk-transaction-list.c
index ceeb031..d8da409 100644
--- a/src/pk-transaction-list.c
+++ b/src/pk-transaction-list.c
@@ -544,6 +544,27 @@ pk_transaction_list_test_delay_cb (EggTest *test)
 	egg_test_loop_quit (test);
 }
 
+/**
+ * pk_transaction_list_test_get_item:
+ **/
+static PkTransactionItem *
+pk_transaction_list_test_get_item (PkTransactionList *tlist)
+{
+	PkTransactionItem *item;
+	gchar *tid;
+
+	/* get tid */
+	tid = pk_transaction_id_generate ();
+
+	/* create PkTransaction instance */
+	pk_transaction_list_create (tlist, tid);
+	item = pk_transaction_list_get_from_tid (tlist, tid);
+	g_free (tid);
+
+	/* return object */
+	return item;
+}
+
 void
 pk_transaction_list_test (EggTest *test)
 {
@@ -553,6 +574,9 @@ pk_transaction_list_test (EggTest *test)
 	guint size;
 	gchar **array;
 	PkTransactionItem *item;
+	PkTransactionItem *item1;
+	PkTransactionItem *item2;
+	PkTransactionItem *item3;
 
 	if (!egg_test_start (test, "PkTransactionList"))
 		return;
@@ -772,27 +796,15 @@ pk_transaction_list_test (EggTest *test)
 	 ****************  Chained transactions    ******************
 	 ************************************************************/
 
-	gchar *tid1;
-	gchar *tid2;
-	PkTransactionItem *item1;
-	PkTransactionItem *item2;
-
-	tid1 = pk_transaction_id_generate ();
-	tid2 = pk_transaction_id_generate ();
-
-	pk_transaction_list_create (tlist, tid1);
-	pk_transaction_list_create (tlist, tid2);
-
-	item1 = pk_transaction_list_get_from_tid (tlist, tid1);
-	item2 = pk_transaction_list_get_from_tid (tlist, tid2);
-
-	g_free (tid1);
-	g_free (tid2);
+	/* create three instances in list */
+	item1 = pk_transaction_list_test_get_item (tlist);
+	item2 = pk_transaction_list_test_get_item (tlist);
+	item3 = pk_transaction_list_test_get_item (tlist);
 
 	/************************************************************/
-	egg_test_title (test, "get both items in queue");
+	egg_test_title (test, "get all items in queue");
 	size = pk_transaction_list_get_size (tlist);
-	if (size == 2)
+	if (size == 3)
 		egg_test_success (test, NULL);
 	else
 		egg_test_failed (test, "size %i", size);
@@ -811,17 +823,21 @@ pk_transaction_list_test (EggTest *test)
 			  G_CALLBACK (pk_transaction_list_test_finished_cb), test);
 	g_signal_connect (item2->transaction, "finished",
 			  G_CALLBACK (pk_transaction_list_test_finished_cb), test);
+	g_signal_connect (item3->transaction, "finished",
+			  G_CALLBACK (pk_transaction_list_test_finished_cb), test);
 
 	/* this starts one action */
 	pk_transaction_get_updates (item1->transaction, "none", NULL);
 	/* this should be chained after the first action completes */
 	pk_transaction_search_name (item2->transaction, "none", "power", NULL);
+	/* this starts be chained after the second action completes */
+	pk_transaction_get_updates (item3->transaction, "none", NULL);
 
 	/************************************************************/
-	egg_test_title (test, "get transactions (committed, not finished) in progress (both)");
+	egg_test_title (test, "get transactions (committed, not finished) in progress (all)");
 	array = pk_transaction_list_get_array (tlist);
 	size = g_strv_length (array);
-	if (size == 2)
+	if (size == 3)
 		egg_test_success (test, NULL);
 	else
 		egg_test_failed (test, "size %i", size);
@@ -832,18 +848,18 @@ pk_transaction_list_test (EggTest *test)
 	egg_test_loop_check (test);
 
 	/************************************************************/
-	egg_test_title (test, "get both items in queue");
+	egg_test_title (test, "get all items in queue");
 	size = pk_transaction_list_get_size (tlist);
-	if (size == 2)
+	if (size == 3)
 		egg_test_success (test, NULL);
 	else
 		egg_test_failed (test, "size %i", size);
 
 	/************************************************************/
-	egg_test_title (test, "get transactions (committed, not finished) (just one)");
+	egg_test_title (test, "get transactions (committed, not finished) (two, first one finished)");
 	array = pk_transaction_list_get_array (tlist);
 	size = g_strv_length (array);
-	if (size == 1)
+	if (size == 2)
 		egg_test_success (test, NULL);
 	else
 		egg_test_failed (test, "size %i", size);
@@ -865,20 +881,74 @@ pk_transaction_list_test (EggTest *test)
 		egg_test_failed (test, "wrong flags: running[%i] committed[%i] finished[%i]",
 				 item2->running, item2->committed, item2->finished);
 
+	/************************************************************/
+	egg_test_title (test, "make sure item3 has correct flags");
+	if (item3->running == FALSE && item3->committed == TRUE && item3->finished == FALSE)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "wrong flags: running[%i] committed[%i] finished[%i]",
+				 item3->running, item3->committed, item3->finished);
+
 	/* wait for second action */
 	egg_test_loop_wait (test, 6000);
 	egg_test_loop_check (test);
 
 	/************************************************************/
-	egg_test_title (test, "get both items in queue");
+	egg_test_title (test, "get all items in queue");
 	size = pk_transaction_list_get_size (tlist);
-	if (size == 2)
+	if (size == 3)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "size %i", size);
+
+	/************************************************************/
+	egg_test_title (test, "get transactions (committed, not finished) in progress (one)");
+	array = pk_transaction_list_get_array (tlist);
+	size = g_strv_length (array);
+	if (size == 1)
 		egg_test_success (test, NULL);
 	else
 		egg_test_failed (test, "size %i", size);
+	g_strfreev (array);
+
+	/************************************************************/
+	egg_test_title (test, "make sure item1 has correct flags");
+	if (item1->running == FALSE && item1->committed == TRUE && item1->finished == TRUE)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "wrong flags: running[%i] committed[%i] finished[%i]",
+				 item1->running, item1->committed, item1->finished);
+
+	/************************************************************/
+	egg_test_title (test, "make sure item2 has correct flags");
+	if (item2->running == FALSE && item2->committed == TRUE && item2->finished == TRUE)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "wrong flags: running[%i] committed[%i] finished[%i]",
+				 item2->running, item2->committed, item2->finished);
 
 	/************************************************************/
-	egg_test_title (test, "get transactions (committed, not finished) in progress (neither)");
+	egg_test_title (test, "make sure item3 has correct flags");
+	if (item3->running == TRUE && item3->committed == TRUE && item3->finished == FALSE)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "wrong flags: running[%i] committed[%i] finished[%i]",
+				 item3->running, item3->committed, item3->finished);
+
+	/* wait for third action */
+	egg_test_loop_wait (test, 6000);
+	egg_test_loop_check (test);
+
+	/************************************************************/
+	egg_test_title (test, "get all items in queue");
+	size = pk_transaction_list_get_size (tlist);
+	if (size == 3)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "size %i", size);
+
+	/************************************************************/
+	egg_test_title (test, "get transactions (committed, not finished) in progress (none)");
 	array = pk_transaction_list_get_array (tlist);
 	size = g_strv_length (array);
 	if (size == 0)
@@ -903,6 +973,14 @@ pk_transaction_list_test (EggTest *test)
 		egg_test_failed (test, "wrong flags: running[%i] committed[%i] finished[%i]",
 				 item2->running, item2->committed, item2->finished);
 
+	/************************************************************/
+	egg_test_title (test, "make sure item3 has correct flags");
+	if (item3->running == FALSE && item3->committed == TRUE && item3->finished == TRUE)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "wrong flags: running[%i] committed[%i] finished[%i]",
+				 item3->running, item3->committed, item3->finished);
+
 	/* wait for Cleanup */
 	g_timeout_add_seconds (5, (GSourceFunc) pk_transaction_list_test_delay_cb, test);
 	egg_test_loop_wait (test, 6000);
commit 59171aebb5b42e45d5908550bf58c671bce305de
Merge: a347633... c9a0119...
Author: Valeriy Lyasotskiy <onestep at ukr.net>
Date:   Tue Sep 23 13:21:08 2008 +0300

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

commit a347633c4d3ec76dd43d3c7de8cd4870b612c518
Author: Valeriy Lyasotskiy <onestep at ukr.net>
Date:   Tue Sep 23 13:20:29 2008 +0300

    alpm: removed unneeded find_packages_by_name function

diff --git a/backends/alpm/pk-backend-alpm.c b/backends/alpm/pk-backend-alpm.c
index 43b3042..48edd79 100644
--- a/backends/alpm/pk-backend-alpm.c
+++ b/backends/alpm/pk-backend-alpm.c
@@ -343,43 +343,6 @@ find_packages_by_details (const gchar *name, pmdb_t *db)
 }
 
 alpm_list_t *
-find_packages_by_name (const gchar *name, pmdb_t *db)
-{
-	if (db == NULL || name == NULL)
-		return NULL;
-
-	alpm_list_t *result = NULL;
-
-	// determine if repository is local
-	gboolean repo_is_local = (db == alpm_option_get_localdb ());
-	// determine repository name
-	const gchar *repo;
-	if (repo_is_local)
-		repo = ALPM_LOCAL_DB_ALIAS;
-	else
-		repo = alpm_db_get_name (db);
-	// get list of packages in repository
-	alpm_list_t *pkgcache = alpm_db_getpkgcache (db);
-
-	alpm_list_t *iterator;
-	for (iterator = pkgcache; iterator; iterator = alpm_list_next (iterator)) {
-		pmpkg_t *pkg = alpm_list_getdata (iterator);
-
-		if (strstr (alpm_pkg_get_name (pkg), name) != NULL) {
-			PackageSource *source = g_malloc (sizeof (PackageSource));
-
-			source->pkg = (pmpkg_t *) pkg;
-			source->repo = (gchar *) repo;
-			source->installed = repo_is_local;
-
-			result = alpm_list_add (result, (PackageSource *) source);
-		}
-	}
-
-	return result;
-}
-
-alpm_list_t *
 find_packages_by_group (const gchar *name, pmdb_t *db)
 {
 	if (db == NULL || name == NULL)
commit f907e488fa5ffeb4afc5b318255974f7ec94cc69
Author: Valeriy Lyasotskiy <onestep at ukr.net>
Date:   Tue Sep 23 13:17:40 2008 +0300

    alpm: search-name stuff changed and moved to another thread

diff --git a/backends/alpm/pk-backend-alpm.c b/backends/alpm/pk-backend-alpm.c
index e0dccba..43b3042 100644
--- a/backends/alpm/pk-backend-alpm.c
+++ b/backends/alpm/pk-backend-alpm.c
@@ -55,6 +55,13 @@ GHashTable *group_mapping;
 
 alpm_list_t *syncfirst;
 
+typedef enum {
+	PK_ALPM_SEARCH_TYPE_RESOLVE,
+	PK_ALPM_SEARCH_TYPE_NAME,
+	PK_ALPM_SEARCH_TYPE_DETAILS,
+	PK_ALPM_SEARCH_TYPE_GROUP
+} PkAlpmSearchType;
+
 typedef struct _PackageSource
 {
 	pmpkg_t *pkg;
@@ -1423,13 +1430,14 @@ backend_remove_packages (PkBackend *backend, gchar **package_ids, gboolean allow
 }
 
 void
-resolve_package (PkBackend *backend, pmdb_t *repo, gchar *name) {
+backend_search (PkBackend *backend, pmdb_t *repo, const gchar *needle, PkAlpmSearchType search_type) {
 	/* package cache */
 	alpm_list_t *pkg_cache;
 
 	/* utility variables */
 	const gchar *repo_name;
 	PkInfoEnum info;
+	gboolean match;
 
 	if (repo == alpm_option_get_localdb ()) {
 		repo_name = ALPM_LOCAL_DB_ALIAS;
@@ -1439,22 +1447,35 @@ resolve_package (PkBackend *backend, pmdb_t *repo, gchar *name) {
 		info = PK_INFO_ENUM_AVAILABLE;
 	}
 
-	/* start search */
-	pkg_cache = alpm_db_getpkgcache (alpm_option_get_localdb ());
+	/* get package cache for specified repo */
+	pkg_cache = alpm_db_getpkgcache (repo);
 
 	alpm_list_t *iterator;
 	/* iterate package cache */
 	for (iterator = pkg_cache; iterator; iterator = alpm_list_next (iterator)) {
 		pmpkg_t *pkg = alpm_list_getdata (iterator);
 
-		if (strcmp (alpm_pkg_get_name (pkg), name) == 0) {
+		switch (search_type) {
+			case PK_ALPM_SEARCH_TYPE_RESOLVE:
+				match = strcmp (alpm_pkg_get_name (pkg), needle) == 0;
+				break;
+			case PK_ALPM_SEARCH_TYPE_NAME:
+				match = strstr (alpm_pkg_get_name (pkg), needle) != NULL;
+				break;
+			default:
+				match = TRUE;
+		}
+
+		if (match) {
 			/* we found what we wanted */
 			emit_package (backend, pkg, repo_name, info);
-			break;
 		}
 	}
 }
 
+/**
+ * backend_resolve_thread:
+ */
 static gboolean
 backend_resolve_thread (PkBackend *backend)
 {
@@ -1468,17 +1489,15 @@ backend_resolve_thread (PkBackend *backend)
 
 		if (!search_not_installed) {
 			/* search in local db */
-			resolve_package (backend, alpm_option_get_localdb (), package_ids[iterator]);
+			backend_search (backend, alpm_option_get_localdb (), package_ids[iterator], PK_ALPM_SEARCH_TYPE_RESOLVE);
 		}
 
 		if (!search_installed) {
 			/* search in sync repos */
-			alpm_list_t *repo_iterator;
+			alpm_list_t *repos;
 			/* iterate repos */
-			for (repo_iterator = alpm_option_get_syncdbs (); repo_iterator; repo_iterator = alpm_list_next (repo_iterator)) {
-				pmdb_t *repo = alpm_list_getdata (repo_iterator);
-				resolve_package (backend, repo, package_ids[iterator]);
-			}
+			for (repos = alpm_option_get_syncdbs (); repos; repos = alpm_list_next (repos))
+				backend_search (backend, alpm_list_getdata (repos), package_ids[iterator], PK_ALPM_SEARCH_TYPE_RESOLVE);
 		}
 	}
 
@@ -1565,36 +1584,44 @@ backend_search_group (PkBackend *backend, PkBitfield filters, const gchar *searc
 }
 
 /**
- * backend_search_name:
+ * backend_search_name_thread:
  */
-static void
-backend_search_name (PkBackend *backend, PkBitfield filters, const gchar *search)
+static gboolean
+backend_search_name_thread (PkBackend *backend)
 {
-	alpm_list_t *result = NULL;
-
-	pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+	const gchar *search = pk_backend_get_string (backend, "search");
+	PkBitfield filters = pk_backend_get_uint (backend, "filters");
 
 	gboolean search_installed = pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED);
 	gboolean search_not_installed = pk_bitfield_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED);
 
 	if (!search_not_installed) {
-		// Search in local db
-		result = alpm_list_join (result, find_packages_by_name (search, alpm_option_get_localdb ()));
+		/* search in local db */
+		backend_search (backend, alpm_option_get_localdb (), search, PK_ALPM_SEARCH_TYPE_NAME);
 	}
 
 	if (!search_installed) {
-		// Search in sync dbs
-		alpm_list_t *iterator;
-		for (iterator = alpm_option_get_syncdbs (); iterator; iterator = alpm_list_next (iterator))
-			result = alpm_list_join (result, find_packages_by_name (search, (pmdb_t *) alpm_list_getdata(iterator)));
+		/* search in sync repos */
+		alpm_list_t *repos;
+		/* iterate repos */
+		for (repos = alpm_option_get_syncdbs (); repos; repos = alpm_list_next (repos))
+			backend_search (backend, alpm_list_getdata (repos), search, PK_ALPM_SEARCH_TYPE_NAME);
 	}
 
-	add_packages_from_list (backend, alpm_list_first (result));
+	pk_backend_finished (backend);
+	return TRUE;
+}
 
-	alpm_list_free_inner (result, (alpm_list_fn_free) package_source_free);
-	alpm_list_free (result);
+/**
+ * backend_search_name:
+ */
+static void
+backend_search_name (PkBackend *backend, PkBitfield filters, const gchar *search)
+{
+	pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+	pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
 
-	pk_backend_finished (backend);
+	pk_backend_thread_create (backend, backend_search_name_thread);
 }
 
 /**
commit c9a01198d494f06ae9e0b3e2a002f941da118f00
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Sep 23 10:45:23 2008 +0100

    bugfix: don't send ::Finished() when the script exits because of a dispatcher exit
    
    What we are seeing here is the backend being finished when it is in another transaction
    and hence returns no results and then puts up warnings that there was no status reports.
    This only seems to happen when we are making the dispatcher be reloaded again and again,
    for instance using pk-import-specspo and a RefreshCache() at the same time

diff --git a/src/pk-backend-spawn.c b/src/pk-backend-spawn.c
index 5609580..9878340 100644
--- a/src/pk-backend-spawn.c
+++ b/src/pk-backend-spawn.c
@@ -409,8 +409,12 @@ pk_backend_spawn_exit_cb (PkSpawn *spawn, PkSpawnExitType exit, PkBackendSpawn *
 
 	/* only emit if not finished */
 	if (!backend_spawn->priv->finished) {
-		egg_debug ("script exited without doing finished");
-		pk_backend_finished (backend_spawn->priv->backend);
+		/* ignore when we exit from a dispatcher */
+		if (exit != PK_SPAWN_EXIT_TYPE_DISPATCHER_EXIT &&
+		    exit != PK_SPAWN_EXIT_TYPE_DISPATCHER_CHANGED) {
+			egg_warning ("script exited without doing finished");
+			pk_backend_finished (backend_spawn->priv->backend);
+		}
 	}
 }
 
commit d37a030e767cd9af93ea4618697c58166159a4f4
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Sep 23 10:42:10 2008 +0100

    trivial: add some better debugging to help debug a crash

diff --git a/src/pk-transaction-list.c b/src/pk-transaction-list.c
index 5de8122..ceeb031 100644
--- a/src/pk-transaction-list.c
+++ b/src/pk-transaction-list.c
@@ -293,8 +293,10 @@ pk_transaction_list_transaction_finished_cb (PkTransaction *transaction, const g
 		item = (PkTransactionItem *) g_ptr_array_index (tlist->priv->array, i);
 		if (item->committed &&
 		    !item->running &&
-		    !item->finished)
+		    !item->finished) {
+			egg_debug ("running %s as previous one finished", item->tid);
 			pk_transaction_list_run_item (tlist, item);
+		}
 	}
 }
 
@@ -397,8 +399,10 @@ pk_transaction_list_commit (PkTransactionList *tlist, const gchar *tid)
 	g_signal_emit (tlist, signals [PK_TRANSACTION_LIST_CHANGED], 0);
 
 	/* do the transaction now if we have no other in progress */
-	if (pk_transaction_list_number_running (tlist) == 0)
+	if (pk_transaction_list_number_running (tlist) == 0) {
+		egg_debug ("running %s as no others in progress", item->tid);
 		pk_transaction_list_run_item (tlist, item);
+	}
 
 	return TRUE;
 }
commit 09d89286fc759600527db4ac97db1f8479b71c04
Merge: 2113267... 29a230f...
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Sep 23 10:37:27 2008 +0100

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

commit 2113267063ef6b8851e67797703aa7a7ab80e87a
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Sep 23 10:37:02 2008 +0100

    trivial: use pk_extra_set_access in pk-import-specspo

diff --git a/client/pk-import-specspo.c b/client/pk-import-specspo.c
index d898dfc..aacc1a6 100644
--- a/client/pk-import-specspo.c
+++ b/client/pk-import-specspo.c
@@ -179,6 +179,13 @@ main (int argc, char *argv[])
 	package_array = pk_import_get_package_list ();
 
 	extra = pk_extra_new ();
+	ret = pk_extra_set_access (extra, PK_EXTRA_ACCESS_WRITE_ONLY);
+	if (!ret) {
+		if (!quiet)
+			g_print ("%s", _("Could not set database readonly"));
+		goto out;
+	}
+
 	ret = pk_extra_set_database (extra, database_location);
 	if (!ret) {
 		if (!quiet) {
commit 483c1d621de342d1a588c4008caf4476a225c26f
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Sep 23 10:34:36 2008 +0100

    trivial: improve some debugging in PkSpawn

diff --git a/src/pk-spawn.c b/src/pk-spawn.c
index 54699c3..a7b71ca 100644
--- a/src/pk-spawn.c
+++ b/src/pk-spawn.c
@@ -319,7 +319,7 @@ pk_spawn_send_stdin (PkSpawn *spawn, const gchar *command)
 	/* write to the waiting process */
 	wrote = write (spawn->priv->stdin_fd, buffer, length);
 	if (wrote != length) {
-		egg_warning ("failed to write '%s'", buffer);
+		egg_warning ("wrote %i/%i bytes on fd %i", wrote, length, spawn->priv->stdin_fd);
 		ret = FALSE;
 	}
 out:
@@ -400,7 +400,9 @@ pk_spawn_argv (PkSpawn *spawn, gchar **argv, gchar **envp)
 			g_free (command);
 			if (ret)
 				return TRUE;
-			/* we failed, so fall on through to kill and respawn */
+
+			/* so fall on through to kill and respawn */
+			egg_warning ("failed to write, so trying to kill and respawn");
 		}
 
 		/* kill off existing instance */
commit 29a230feccee17862483f3fb9c23bf5161d27018
Author: Tim Lauridsen <timlau at fedoraproject.org>
Date:   Tue Sep 23 10:42:20 2008 +0200

    yum: added set-locale support and return translated collection name & decription

diff --git a/backends/yum/yumBackend.py b/backends/yum/yumBackend.py
index c62c060..b445e0d 100755
--- a/backends/yum/yumBackend.py
+++ b/backends/yum/yumBackend.py
@@ -107,7 +107,7 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
         signal.signal(signal.SIGQUIT,sigquit)
         PackageKitBaseBackend.__init__(self,args)
         self.yumbase = PackageKitYumBase(self)
-
+        self._LANG = 'C'
         self.comps = yumComps(self.yumbase)
         if not self.comps.connect():
             self.refresh_cache()
@@ -188,6 +188,12 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
             if key in grpid:
                 self._show_meta_package(grpid,filters)
 
+    def set_locale(self,code):
+        '''
+        Implement the {backend}-set-locale functionality
+        Needed to be implemented in a sub class
+        '''
+        self._LANG = code
 
     @handle_repo_error
     def _do_search(self,searchlist,filters,key):
@@ -291,12 +297,13 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
         id = "%s;;;meta" % grpid
         grp = self.yumbase.comps.return_group(grpid)
         if grp:
+            name = grp.nameByLang(self._LANG)
             if grp.installed:
                 if show_inst:
-                    self.package(id,INFO_COLLECTION_INSTALLED,grp.name)
+                    self.package(id,INFO_COLLECTION_INSTALLED,name)
             else:
                 if show_avail:
-                    self.package(id,INFO_COLLECTION_AVAILABLE,grp.name)
+                    self.package(id,INFO_COLLECTION_AVAILABLE,name)
 
     #@handle_repo_error
     def search_group(self,filters,group_key):
@@ -1327,7 +1334,7 @@ class PackageKitYumBackend(PackageKitBaseBackend,PackagekitPackage):
             grp = self._is_meta_package(package)
             if grp:
                 id = "%s;;;meta" % grp.groupid
-                desc = grp.description
+                desc = grp.descriptionByLang(self._LANG)
                 desc = desc.replace('\n\n',';')
                 desc = desc.replace('\n',' ')
                 group = GROUP_COLLECTIONS
diff --git a/python/packagekit/backend.py b/python/packagekit/backend.py
index 8f7ce66..7b05a51 100644
--- a/python/packagekit/backend.py
+++ b/python/packagekit/backend.py
@@ -410,6 +410,13 @@ class PackageKitBaseBackend:
         '''
         self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
 
+    def set_locale(self,code):
+        '''
+        Implement the {backend}-set-locale functionality
+        Needed to be implemented in a sub class
+        '''
+        self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
+
     def customTracebackHandler(self,tb):
         '''
         Custom Traceback Handler
@@ -551,6 +558,10 @@ class PackageKitBaseBackend:
             search = args[2]
             self.what_provides(filters,provides_type,search)
             self.finished();
+        elif cmd == 'set-locale':
+            code = args[0]
+            self.set_locale(code)
+            self.finished();
         else:
             errmsg = "command '%s' is not known" % cmd
             self.error(ERROR_INTERNAL_ERROR,errmsg,exit=False)
commit 9b2731bd49f9a1c7312ad0c3cc90e9621769903f
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Sep 23 09:42:10 2008 +0100

    trivial: remove pk-import-desktop and pk-generate-package-list as we can do this in the server now

diff --git a/client/.gitignore b/client/.gitignore
index 82b5baa..c0aa981 100644
--- a/client/.gitignore
+++ b/client/.gitignore
@@ -6,11 +6,7 @@ pk-marshal.c
 pkcon
 pkmon
 pkgenpack
-pk-update-icon
-pk-application
-pk-import-desktop
 pk-import-specspo
-pk-generate-package-list
 pk-self-test
 *.glade.bak
 *.gladep
diff --git a/client/Makefile.am b/client/Makefile.am
index f77c624..29c369b 100644
--- a/client/Makefile.am
+++ b/client/Makefile.am
@@ -29,9 +29,7 @@ bin_PROGRAMS =						\
 	$(NULL)
 
 libexec_PROGRAMS =					\
-	pk-import-desktop				\
 	pk-import-specspo				\
-	pk-generate-package-list			\
 	$(NULL)
 
 pkcon_SOURCES =						\
@@ -81,33 +79,6 @@ pkgenpack_LDADD = 					\
 	$(PK_LIBS)					\
 	$(NULL)
 
-pk_generate_package_list_SOURCES =			\
-	egg-debug.c					\
-	egg-debug.h					\
-	pk-generate-package-list.c			\
-	$(NULL)
-
-pk_generate_package_list_LDADD =			\
-	$(GLIB_LIBS)					\
-	$(PK_LIBS)					\
-	$(NULL)
-
-pk_import_desktop_SOURCES =				\
-	egg-debug.c					\
-	egg-debug.h					\
-	egg-string.c					\
-	egg-string.h					\
-	pk-import-common.c				\
-	pk-import-common.h				\
-	pk-import-desktop.c				\
-	$(NULL)
-
-pk_import_desktop_LDADD =				\
-	$(GLIB_LIBS)					\
-	$(SQLITE_LIBS)					\
-	$(PK_LIBS)					\
-	$(NULL)
-
 pk_import_specspo_SOURCES =				\
 	egg-debug.c					\
 	egg-debug.h					\
diff --git a/client/pk-generate-package-list.c b/client/pk-generate-package-list.c
deleted file mode 100644
index 4aaa851..0000000
--- a/client/pk-generate-package-list.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 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 <string.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <glib.h>
-#include <glib/gi18n.h>
-#include <dbus/dbus-glib.h>
-
-#include <egg-debug.h>
-#include <pk-client.h>
-#include <pk-common.h>
-#include <pk-package-id.h>
-
-#define PK_PACKAGE_LIST_LOCATION	"/var/lib/PackageKit/package-list.txt"
-
-/**
- * main:
- **/
-int
-main (int argc, char *argv[])
-{
-	PkClient *client;
-	GOptionContext *context;
-	gboolean verbose = FALSE;
-	gboolean quiet = FALSE;
-	gboolean ret;
-	GError *error = NULL;
-	PkPackageList *list = NULL;
-
-	const GOptionEntry options[] = {
-		{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
-			"Show extra debugging information", NULL },
-		{ "quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet,
-			"Do not show any output to the console", NULL },
-		{ NULL}
-	};
-
-	g_type_init ();
-
-	context = g_option_context_new ("pk-generate-package-list");
-	g_option_context_add_main_entries (context, options, NULL);
-	g_option_context_parse (context, &argc, &argv, NULL);
-	g_option_context_free (context);
-
-	egg_debug_init (verbose);
-
-	client = pk_client_new ();
-	pk_client_set_use_buffer (client, TRUE, NULL);
-	pk_client_set_synchronous (client, TRUE, NULL);
-
-	/* get the package list with no filter */
-	ret = pk_client_get_packages (client, PK_FILTER_ENUM_NONE, &error);
-	if (!ret) {
-		if (!quiet)
-			g_print ("Failed to get package lists: %s\n", error->message);
-		g_error_free (error);
-		goto out;
-	}
-
-	/* check that we only matched one package */
-	list = pk_client_get_package_list (client);
-	ret = pk_package_list_to_file (list, PK_PACKAGE_LIST_LOCATION);
-	if (!ret) {
-		if (!quiet)
-			g_print ("Failed to write to disk\n");
-		goto out;
-	}
-
-out:
-	if (list != NULL) {
-		g_object_unref (list);
-	}
-	g_object_unref (client);
-	return 0;
-}
diff --git a/client/pk-import-desktop.c b/client/pk-import-desktop.c
deleted file mode 100644
index 87fd0fd..0000000
--- a/client/pk-import-desktop.c
+++ /dev/null
@@ -1,324 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 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 <string.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <glib.h>
-#include <glib/gi18n.h>
-#include <dbus/dbus-glib.h>
-
-#include "egg-debug.h"
-#include "egg-string.h"
-
-#include <pk-client.h>
-#include <pk-common.h>
-#include <pk-package-id.h>
-#include <pk-extra.h>
-
-#include "pk-import-common.h"
-
-static PkClient *client = NULL;
-static PkExtra *extra = NULL;
-static gboolean quiet = FALSE;
-
-/**
- * pk_desktop_get_name_for_file:
- **/
-static gchar *
-pk_desktop_get_name_for_file (const gchar *filename)
-{
-	guint size;
-	gchar *name = NULL;
-	const PkPackageObj *obj;
-	gboolean ret;
-	GError *error = NULL;
-	PkPackageList *list = NULL;
-
-	/* use PK to find the correct package */
-	ret = pk_client_reset (client, &error);
-	if (!ret) {
-		egg_warning ("failed to reset client: %s", error->message);
-		g_error_free (error);
-		goto out;
-	}
-
-	ret = pk_client_search_file (client, pk_bitfield_value (PK_FILTER_ENUM_INSTALLED), filename, &error);
-	if (!ret) {
-		egg_warning ("failed to search file: %s", error->message);
-		g_error_free (error);
-		goto out;
-	}
-
-	/* check that we only matched one package */
-	list = pk_client_get_package_list (client);
-	size = pk_package_list_get_size (list);
-	if (size != 1) {
-		egg_warning ("not correct size, %i", size);
-		goto out;
-	}
-
-	/* get the obj */
-	obj = pk_package_list_get_obj (list, 0);
-	if (obj == NULL) {
-		egg_warning ("cannot get obj");
-		goto out;
-	}
-
-	/* strip the name */
-	name = g_strdup (obj->id->name);
-
-out:
-	if (list != NULL)
-		g_object_unref (list);
-	return name;
-}
-
-/**
- * pk_import_get_locale:
- **/
-static gchar *
-pk_import_get_locale (const gchar *buffer)
-{
-	guint len;
-	gchar *locale;
-	gchar *result;
-	result = g_strrstr (buffer, "[");
-	if (result == NULL)
-		return NULL;
-	locale = g_strdup (result+1);
-	len = egg_strlen (locale, 20);
-	locale[len-1] = '\0';
-	return locale;
-}
-
-/**
- * pk_desktop_process_desktop:
- **/
-static void
-pk_desktop_process_desktop (const gchar *package_name, const gchar *filename)
-{
-	GKeyFile *key;
-	gboolean ret;
-	guint i;
-	gchar *name = NULL;
-	gchar *name_unlocalised = NULL;
-	gchar *exec = NULL;
-	gchar *icon = NULL;
-	gchar *comment = NULL;
-	gchar *genericname = NULL;
-	const gchar *locale = NULL;
-	gchar **key_array;
-	gsize len;
-	gchar *locale_temp;
-	static GPtrArray *locale_array = NULL;
-
-	key = g_key_file_new ();
-	ret = g_key_file_load_from_file (key, filename, G_KEY_FILE_KEEP_TRANSLATIONS, NULL);
-	if (!ret) {
-		egg_warning ("cannot open desktop file %s", filename);
-		return;
-	}
-
-	/* get this specific locale list */
-	key_array = g_key_file_get_keys (key, G_KEY_FILE_DESKTOP_GROUP, &len, NULL);
-	locale_array = g_ptr_array_new ();
-	for (i=0; i<len; i++) {
-		if (g_str_has_prefix (key_array[i], "Name")) {
-			/* set the locale */
-			locale_temp = pk_import_get_locale (key_array[i]);
-			if (locale_temp != NULL)
-				g_ptr_array_add (locale_array, g_strdup (locale_temp));
-		}
-	}
-	g_strfreev (key_array);
-
-	if (!quiet)
-		g_print ("PackageName:\t%s\t[", package_name);
-
-	/* get the default entry */
-	name_unlocalised = g_key_file_get_string (key, G_KEY_FILE_DESKTOP_GROUP, "Name", NULL);
-	if (!egg_strzero (name_unlocalised)) {
-		if (!quiet)
-			g_print ("C");
-		pk_extra_set_locale (extra, "C");
-		pk_extra_set_data_locale (extra, package_name, name_unlocalised);
-	}
-
-	/* for each locale */
-	for (i=0; i<locale_array->len; i++) {
-		locale = g_ptr_array_index (locale_array, i);
-		/* compare the translated against the default */
-		name = g_key_file_get_locale_string (key, G_KEY_FILE_DESKTOP_GROUP, "Name", locale, NULL);
-
-		/* if different, then save */
-		if (egg_strequal (name_unlocalised, name) == FALSE) {
-			if (!quiet)
-				g_print (" %s", locale);
-			comment = g_key_file_get_locale_string (key, G_KEY_FILE_DESKTOP_GROUP,
-								"Comment", locale, NULL);
-			genericname = g_key_file_get_locale_string (key, G_KEY_FILE_DESKTOP_GROUP,
-								    "GenericName", locale, NULL);
-			egg_debug ("PackageName=%s, Locale=%s, Name=%s, GenericName=%s, Comment=%s",
-				  package_name, locale, name, genericname, comment);
-			pk_extra_set_locale (extra, locale);
-
-			/* save in order of priority */
-			if (comment != NULL)
-				pk_extra_set_data_locale (extra, package_name, comment);
-			else if (genericname != NULL)
-				pk_extra_set_data_locale (extra, package_name, genericname);
-			else
-				pk_extra_set_data_locale (extra, package_name, name);
-			g_free (comment);
-			g_free (genericname);
-		}
-		g_free (name);
-	}
-	g_ptr_array_foreach (locale_array, (GFunc) g_free, NULL);
-	g_ptr_array_free (locale_array, TRUE);
-	g_free (name_unlocalised);
-	if (!quiet)
-		g_print ("]\n");
-
-	exec = g_key_file_get_string (key, G_KEY_FILE_DESKTOP_GROUP, "Exec", NULL);
-	icon = g_key_file_get_string (key, G_KEY_FILE_DESKTOP_GROUP, "Icon", NULL);
-	egg_debug ("PackageName=%s, Exec=%s, Icon=%s", package_name, exec, icon);
-	pk_extra_set_data_package (extra, package_name, icon, exec);
-	g_free (icon);
-	g_free (exec);
-
-	g_key_file_free (key);
-}
-
-/**
- * pk_desktop_process_directory:
- **/
-static void
-pk_desktop_process_directory (const gchar *directory)
-{
-	GDir *dir;
-	const gchar *name;
-	GPatternSpec *pattern;
-	gboolean match;
-	gchar *filename;
-	gchar *package_name;
-
-	dir = g_dir_open (directory, 0, NULL);
-	if (dir == NULL) {
-		egg_warning ("not a valid desktop dir!");
-		return;
-	}
-
-	pattern = g_pattern_spec_new ("*.desktop");
-	name = g_dir_read_name (dir);
-	while (name != NULL) {
-		/* ITS4: ignore, not used for allocation and has to be NULL terminated */
-		match = g_pattern_match (pattern, strlen (name), name, NULL);
-		if (match) {
-			filename = g_build_filename (directory, name, NULL);
-
-			/* get the name */
-			package_name = pk_desktop_get_name_for_file (filename);
-
-			/* process the file */
-			if (package_name != NULL)
-				pk_desktop_process_desktop (package_name, filename);
-			else {
-				if (!quiet)
-					g_print ("%s ignored, failed to get package name\n", filename);
-			}
-			g_free (package_name);
-			g_free (filename);
-		}
-		name = g_dir_read_name (dir);
-	}
-	g_dir_close (dir);
-}
-
-/**
- * main:
- **/
-int
-main (int argc, char *argv[])
-{
-	GOptionContext *context;
-	gboolean verbose = FALSE;
-	gboolean ret;
-	gchar *database_location = NULL;
-	gchar *desktop_location = NULL;
-
-	const GOptionEntry options[] = {
-		{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
-			"Show extra debugging information", NULL },
-		{ "database-location", '\0', 0, G_OPTION_ARG_STRING, &database_location,
-			"Database location (default set from daemon)", NULL },
-		{ "desktop-location", '\0', 0, G_OPTION_ARG_STRING, &desktop_location,
-			"Desktop location (default " PK_IMPORT_APPLICATIONSDIR ")", NULL },
-		{ "quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet,
-			"Do not show any output to the console", NULL },
-		{ NULL}
-	};
-
-	g_type_init ();
-
-	context = g_option_context_new ("pk-desktop");
-	g_option_context_add_main_entries (context, options, NULL);
-	g_option_context_parse (context, &argc, &argv, NULL);
-	g_option_context_free (context);
-
-	egg_debug_init (verbose);
-
-	/* set defaults */
-	if (desktop_location == NULL)
-		desktop_location = PK_IMPORT_APPLICATIONSDIR;
-
-	client = pk_client_new ();
-	pk_client_set_use_buffer (client, TRUE, NULL);
-	pk_client_set_synchronous (client, TRUE, NULL);
-
-	extra = pk_extra_new ();
-	ret = pk_extra_set_access (extra, PK_EXTRA_ACCESS_WRITE_ONLY);
-	if (!ret) {
-		if (!quiet)
-			g_print ("%s", _("Could not set database readonly"));
-		goto out;
-	}
-
-	ret = pk_extra_set_database (extra, database_location);
-	if (!ret) {
-		if (!quiet) {
-			g_print (_("Could not open database: %s"), database_location);
-			g_print ("\n%s\n", _("You probably need to run this program as the root user"));
-		}
-		goto out;
-	}
-
-	pk_desktop_process_directory (desktop_location);
-
-out:
-	g_object_unref (extra);
-	g_object_unref (client);
-	return 0;
-}
commit c037f8596111b418ee3eb95403eceb71f6f844ab
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Sep 23 09:38:50 2008 +0100

    trivial: fix up the conf filename now we don't crash the daemon...

diff --git a/src/pk-transaction.c b/src/pk-transaction.c
index f72dc04..aadd8e5 100644
--- a/src/pk-transaction.c
+++ b/src/pk-transaction.c
@@ -516,12 +516,12 @@ pk_transaction_finished_cb (PkBackend *backend, PkExitEnum exit, PkTransaction *
 				  G_CALLBACK (pk_transaction_progress_changed_cb), transaction);
 
 		/* generate the package list */
-		ret = pk_conf_get_bool (transaction->priv->conf, "RefreshCacheUpdatePackageListBugfix");
+		ret = pk_conf_get_bool (transaction->priv->conf, "RefreshCacheUpdatePackageList");
 		if (ret)
 			pk_refresh_update_package_list (refresh);
 
 		/* refresh the desktop icon cache */
-		ret = pk_conf_get_bool (transaction->priv->conf, "RefreshCacheScanDesktopFilesBugfix");
+		ret = pk_conf_get_bool (transaction->priv->conf, "RefreshCacheScanDesktopFiles");
 		if (ret)
 			pk_refresh_import_desktop_files (refresh);
 
commit f53c08867a6afdb6747f6ea2152fb0d7d7cbd88b
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Sep 23 09:37:33 2008 +0100

    trivial: reduce the backend grace time to 10ms as we want to process requests faster than 20/sec

diff --git a/src/pk-backend.c b/src/pk-backend.c
index dcab0ca..08c92a5 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -74,7 +74,7 @@
  * This delay is required as some threads may take some time to cancel or a
  * spawned executable to disappear of the system DBUS.
  */
-#define PK_BACKEND_FINISHED_TIMEOUT_GRACE	50 /* ms */
+#define PK_BACKEND_FINISHED_TIMEOUT_GRACE	10 /* ms */
 
 struct _PkBackendPrivate
 {
commit 6e9d34072489280bda3849c276af6ea6a42db008
Merge: 70e2fa9... 8b622fb...
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Sep 23 08:37:02 2008 +0100

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

commit 8b622fb5a5c0f689254e19c0e03f5b2e8053edc8
Author: Valeriy Lyasotskiy <onestep at ukr.net>
Date:   Tue Sep 23 02:56:29 2008 +0300

    alpm: added support for new pacman, resolver stuff changed and moved to another thread

diff --git a/backends/alpm/pk-backend-alpm.c b/backends/alpm/pk-backend-alpm.c
index 10ce101..e0dccba 100644
--- a/backends/alpm/pk-backend-alpm.c
+++ b/backends/alpm/pk-backend-alpm.c
@@ -53,6 +53,8 @@ gchar *dl_file_name;
 
 GHashTable *group_mapping;
 
+alpm_list_t *syncfirst;
+
 typedef struct _PackageSource
 {
 	pmpkg_t *pkg;
@@ -174,9 +176,9 @@ cb_trans_progress (pmtransprog_t event, const char *pkgname, int percent, int ho
 }
 
 void
-cb_dl_progress (const char *filename, int file_xfered, int file_total, int list_xfered, int list_total)
+cb_dl_progress (const char *filename, off_t xfered, off_t total)
 {
-	if (file_xfered == file_total) {
+	if (xfered == total) {
 		/* free filename copy when file is downloaded */
 		g_free (dl_file_name);
 		dl_file_name = NULL;
@@ -204,7 +206,7 @@ cb_dl_progress (const char *filename, int file_xfered, int file_total, int list_
 		}
 	}
 
-	int percent = (int) ((float) file_xfered / (float) file_total) * 100;
+	int percent = (int) ((float) xfered) / ((float) total) * 100;
 	egg_debug ("alpm: download percentage of %s is %i", filename, percent);
 	// pk_backend_set_percentage ((PkBackend *) install_backend, percent);
 }
@@ -263,40 +265,35 @@ pkg_equals_to (pmpkg_t *pkg, const gchar *name, const gchar *version)
 	return TRUE;
 }
 
-static void
-add_package (PkBackend *backend, PackageSource *package)
+void
+emit_package (PkBackend *backend, pmpkg_t *pkg, const gchar *repo, PkInfoEnum info)
 {
-	egg_debug ("add_package: hi, package_name=%s", alpm_pkg_get_name(package->pkg));
+	egg_debug ("alpm: emitting package with name %s", alpm_pkg_get_name (pkg));
 
-	gchar *arch = (gchar *) alpm_pkg_get_arch (package->pkg);
-	if (arch == NULL)
-		arch = "unknown";
-
-	gchar *package_id_str = pkg_to_package_id_str (package->pkg, package->repo);
-
-	PkInfoEnum info;
-	if (package->installed)
-		info = PK_INFO_ENUM_INSTALLED;
-	else
-		info = PK_INFO_ENUM_AVAILABLE;
-
-	pk_backend_package (backend, info, package_id_str, alpm_pkg_get_desc (package->pkg));
-
-	g_free(package_id_str);
+	gchar *package_id_str = pkg_to_package_id_str (pkg, repo);
+	pk_backend_package (backend, info, package_id_str, alpm_pkg_get_desc (pkg));
+	g_free (package_id_str);
 }
 
 static void
 add_packages_from_list (PkBackend *backend, alpm_list_t *list)
 {
 	PackageSource *package = NULL;
-	alpm_list_t *li = NULL;
 
 	if (list == NULL)
-		egg_warning ("add_packages_from_list: list is empty!");
+		egg_warning ("alpm: add_packages_from_list called for empty list!");
+
+	alpm_list_t *iterator;
+	for (iterator = list; iterator; iterator = alpm_list_next (iterator)) {
+		package = (PackageSource *) iterator->data;
+
+		PkInfoEnum info;
+		if (package->installed)
+			info = PK_INFO_ENUM_INSTALLED;
+		else
+			info = PK_INFO_ENUM_AVAILABLE;
 
-	for (li = list; li != NULL; li = alpm_list_next (li)) {
-		package = (PackageSource *) li->data;
-		add_package (backend, package);
+		emit_package (backend, package->pkg, package->repo, info);
 	}
 }
 
@@ -339,7 +336,7 @@ find_packages_by_details (const gchar *name, pmdb_t *db)
 }
 
 alpm_list_t *
-find_packages_by_name (const gchar *name, pmdb_t *db, gboolean exact)
+find_packages_by_name (const gchar *name, pmdb_t *db)
 {
 	if (db == NULL || name == NULL)
 		return NULL;
@@ -361,13 +358,7 @@ find_packages_by_name (const gchar *name, pmdb_t *db, gboolean exact)
 	for (iterator = pkgcache; iterator; iterator = alpm_list_next (iterator)) {
 		pmpkg_t *pkg = alpm_list_getdata (iterator);
 
-		gboolean match;
-		if (exact)
-			match = strcmp (alpm_pkg_get_name (pkg), name) == 0;
-		else
-			match = strstr (alpm_pkg_get_name (pkg), name) != NULL;
-
-		if (match) {
+		if (strstr (alpm_pkg_get_name (pkg), name) != NULL) {
 			PackageSource *source = g_malloc (sizeof (PackageSource));
 
 			source->pkg = (pmpkg_t *) pkg;
@@ -607,6 +598,16 @@ set_repeating_option(const char *ptr, const char *option, void (*optionfunc) (co
 }
 
 /**
+ * option_add_syncfirst:
+ * Add package name to SyncFirst list
+ * @param name name of the package to be added
+ */
+static void
+option_add_syncfirst(const char *name) {
+	syncfirst = alpm_list_add(syncfirst, strdup(name));
+}
+
+/**
  * parse_config:
  * Parse config file and set all the needed options
  * Based heavily on the pacman source code
@@ -722,6 +723,8 @@ parse_config (const char *file, const char *givensection, pmdb_t * const givendb
 						set_repeating_option (ptr, "IgnoreGroup", alpm_option_add_ignoregrp);
 					} else if (strcmp (key, "HoldPkg") == 0) {
 						set_repeating_option (ptr, "HoldPkg", alpm_option_add_holdpkg);
+					} else if (strcmp (key, "SyncFirst") == 0) {
+						set_repeating_option (ptr, "SyncFirst", option_add_syncfirst);
 					} else if (strcmp (key, "DBPath") == 0) {
 						alpm_option_set_dbpath (ptr);
 					} else if (strcmp (key, "CacheDir") == 0) {
@@ -908,8 +911,6 @@ backend_get_depends (PkBackend *backend, PkBitfield filters, gchar **package_ids
 			return;
 		}
 
-		egg_debug ("alpm: filters is: %i", filters);
-
 		alpm_list_t *list_iterator;
 		for (list_iterator = alpm_pkg_get_depends (pkg); list_iterator; list_iterator = alpm_list_next (list_iterator)) {
 			pmdepend_t *dep = alpm_list_getdata (list_iterator);
@@ -1164,7 +1165,7 @@ backend_install_files_thread (PkBackend *backend)
 	gchar **full_paths = pk_backend_get_strv (backend, "full_paths");
 
 	/* create a new transaction */
-	if (alpm_trans_init (PM_TRANS_TYPE_ADD, 0, cb_trans_evt, cb_trans_conv, cb_trans_progress) == -1) {
+	if (alpm_trans_init (PM_TRANS_TYPE_UPGRADE, 0, cb_trans_evt, cb_trans_conv, cb_trans_progress) == -1) {
 		pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerrorlast ());
 		pk_backend_finished (backend);
 		return FALSE;
@@ -1421,40 +1422,80 @@ backend_remove_packages (PkBackend *backend, gchar **package_ids, gboolean allow
 	pk_backend_thread_create (backend, backend_remove_packages_thread);
 }
 
-/**
- * backend_resolve:
- */
-static void
-backend_resolve (PkBackend *backend, PkBitfield filters, gchar **packages)
-{
-	alpm_list_t *result = NULL;
+void
+resolve_package (PkBackend *backend, pmdb_t *repo, gchar *name) {
+	/* package cache */
+	alpm_list_t *pkg_cache;
 
-	pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+	/* utility variables */
+	const gchar *repo_name;
+	PkInfoEnum info;
+
+	if (repo == alpm_option_get_localdb ()) {
+		repo_name = ALPM_LOCAL_DB_ALIAS;
+		info = PK_INFO_ENUM_INSTALLED;
+	} else {
+		repo_name = alpm_db_get_name (repo);
+		info = PK_INFO_ENUM_AVAILABLE;
+	}
+
+	/* start search */
+	pkg_cache = alpm_db_getpkgcache (alpm_option_get_localdb ());
+
+	alpm_list_t *iterator;
+	/* iterate package cache */
+	for (iterator = pkg_cache; iterator; iterator = alpm_list_next (iterator)) {
+		pmpkg_t *pkg = alpm_list_getdata (iterator);
+
+		if (strcmp (alpm_pkg_get_name (pkg), name) == 0) {
+			/* we found what we wanted */
+			emit_package (backend, pkg, repo_name, info);
+			break;
+		}
+	}
+}
+
+static gboolean
+backend_resolve_thread (PkBackend *backend)
+{
+	gchar **package_ids = pk_backend_get_strv (backend, "package_ids");
+	PkBitfield filters = pk_backend_get_uint (backend, "filters");
 
 	int iterator;
-	for (iterator = 0; iterator < g_strv_length (packages); ++iterator) {
+	for (iterator = 0; iterator < g_strv_length (package_ids); ++iterator) {
 		gboolean search_installed = pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED);
 		gboolean search_not_installed = pk_bitfield_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED);
 
 		if (!search_not_installed) {
-			// Search in local db
-			result = alpm_list_join (result, find_packages_by_name (packages[iterator], alpm_option_get_localdb (), TRUE));
+			/* search in local db */
+			resolve_package (backend, alpm_option_get_localdb (), package_ids[iterator]);
 		}
 
 		if (!search_installed) {
-			// Search in sync dbs
-			alpm_list_t *db_iterator;
-			for (db_iterator = alpm_option_get_syncdbs (); db_iterator; db_iterator = alpm_list_next (db_iterator))
-				result = alpm_list_join (result, find_packages_by_name (packages[iterator], (pmdb_t *) alpm_list_getdata(db_iterator), TRUE));
+			/* search in sync repos */
+			alpm_list_t *repo_iterator;
+			/* iterate repos */
+			for (repo_iterator = alpm_option_get_syncdbs (); repo_iterator; repo_iterator = alpm_list_next (repo_iterator)) {
+				pmdb_t *repo = alpm_list_getdata (repo_iterator);
+				resolve_package (backend, repo, package_ids[iterator]);
+			}
 		}
-
-		add_packages_from_list (backend, alpm_list_first (result));
-
-		alpm_list_free_inner (result, (alpm_list_fn_free) package_source_free);
-		alpm_list_free (result);
 	}
 
 	pk_backend_finished (backend);
+	return TRUE;
+}
+
+/**
+ * backend_resolve:
+ */
+static void
+backend_resolve (PkBackend *backend, PkBitfield filters, gchar **package_ids)
+{
+	pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+	pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
+
+	pk_backend_thread_create (backend, backend_resolve_thread);
 }
 
 /**
@@ -1538,14 +1579,14 @@ backend_search_name (PkBackend *backend, PkBitfield filters, const gchar *search
 
 	if (!search_not_installed) {
 		// Search in local db
-		result = alpm_list_join (result, find_packages_by_name (search, alpm_option_get_localdb (), FALSE));
+		result = alpm_list_join (result, find_packages_by_name (search, alpm_option_get_localdb ()));
 	}
 
 	if (!search_installed) {
 		// Search in sync dbs
 		alpm_list_t *iterator;
 		for (iterator = alpm_option_get_syncdbs (); iterator; iterator = alpm_list_next (iterator))
-			result = alpm_list_join (result, find_packages_by_name (search, (pmdb_t *) alpm_list_getdata(iterator), FALSE));
+			result = alpm_list_join (result, find_packages_by_name (search, (pmdb_t *) alpm_list_getdata(iterator)));
 	}
 
 	add_packages_from_list (backend, alpm_list_first (result));
commit 70e2fa9fc6d821c98eeaa46c6181deb5c06fd11d
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Sep 22 21:23:43 2008 +0100

    trivial: use pk_extra_set_access to speed up the database access

diff --git a/client/pk-import-desktop.c b/client/pk-import-desktop.c
index ba8378b..87fd0fd 100644
--- a/client/pk-import-desktop.c
+++ b/client/pk-import-desktop.c
@@ -299,6 +299,13 @@ main (int argc, char *argv[])
 	pk_client_set_synchronous (client, TRUE, NULL);
 
 	extra = pk_extra_new ();
+	ret = pk_extra_set_access (extra, PK_EXTRA_ACCESS_WRITE_ONLY);
+	if (!ret) {
+		if (!quiet)
+			g_print ("%s", _("Could not set database readonly"));
+		goto out;
+	}
+
 	ret = pk_extra_set_database (extra, database_location);
 	if (!ret) {
 		if (!quiet) {
diff --git a/src/pk-refresh.c b/src/pk-refresh.c
index 6453667..039f8c1 100644
--- a/src/pk-refresh.c
+++ b/src/pk-refresh.c
@@ -154,6 +154,9 @@ pk_refresh_import_desktop_files_process_desktop (PkRefresh *refresh, const gchar
 	}
 	g_strfreev (key_array);
 
+	/* make sure this is still set, as we are sharing PkExtra */
+	pk_extra_set_access (refresh->priv->extra, PK_EXTRA_ACCESS_WRITE_ONLY);
+
 	/* get the default entry */
 	name_unlocalised = g_key_file_get_string (key, G_KEY_FILE_DESKTOP_GROUP, "Name", NULL);
 	if (!egg_strzero (name_unlocalised)) {
@@ -460,6 +463,7 @@ pk_refresh_init (PkRefresh *refresh)
 				  G_CALLBACK (pk_refresh_package_cb), refresh);
 
 	refresh->priv->extra = pk_extra_new ();
+	pk_extra_set_access (refresh->priv->extra, PK_EXTRA_ACCESS_WRITE_ONLY);
 
 	/* use the default location */
 	ret = pk_extra_set_database (refresh->priv->extra, NULL);
commit 09ec9690452b752e36b01730032f13c9074ed2f1
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Sep 22 21:14:31 2008 +0100

    bugfix: turn off synchronous fsync when using PkExtra as the data isn't valuable, and we can reduce the time of the desktop scanning by 80%

diff --git a/libpackagekit/pk-extra.c b/libpackagekit/pk-extra.c
index f365749..904d5f1 100644
--- a/libpackagekit/pk-extra.c
+++ b/libpackagekit/pk-extra.c
@@ -664,6 +664,9 @@ pk_extra_set_database (PkExtra *extra, const gchar *filename)
 		}
 	}
 
+	/* we don't need to keep syncing */
+	sqlite3_exec (extra->priv->db, "PRAGMA synchronous=OFF", NULL, NULL, NULL);
+
 	/* try to populate a working cache */
 	if (extra->priv->access == PK_EXTRA_ACCESS_READ_ONLY ||
 	    extra->priv->access == PK_EXTRA_ACCESS_READ_WRITE)
commit 634b89965671f4a3416945ea22d2d0442b4d4517
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Sep 22 21:07:53 2008 +0100

    trivial: don't debug every line from stdout

diff --git a/src/pk-backend-spawn.c b/src/pk-backend-spawn.c
index dd1fc25..5609580 100644
--- a/src/pk-backend-spawn.c
+++ b/src/pk-backend-spawn.c
@@ -423,11 +423,9 @@ pk_backend_spawn_stdout_cb (PkBackendSpawn *spawn, const gchar *line, PkBackendS
 	gboolean ret;
 	g_return_if_fail (PK_IS_BACKEND_SPAWN (backend_spawn));
 
-	egg_debug ("stdout from %p = '%s'", spawn, line);
 	ret = pk_backend_spawn_parse_stdout (backend_spawn, line);
-	if (!ret) {
+	if (!ret)
 		egg_debug ("failed to parse '%s'", line);
-	}
 }
 
 /**
commit a40e0daa390aaafe027b02231b73a919f146b3d7
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Sep 22 21:07:00 2008 +0100

    feature: add in new API pk_extra_set_access() so we can avoid loading data when we are just writing to a database

diff --git a/libpackagekit/pk-extra.c b/libpackagekit/pk-extra.c
index 4f57d83..f365749 100644
--- a/libpackagekit/pk-extra.c
+++ b/libpackagekit/pk-extra.c
@@ -67,6 +67,7 @@ struct _PkExtraPrivate
 	sqlite3			*db;
 	GHashTable		*hash_locale;
 	GHashTable		*hash_package;
+	PkExtraAccess		 access;
 };
 
 typedef struct
@@ -329,7 +330,9 @@ pk_extra_set_locale (PkExtra *extra, const gchar *locale)
 	}
 
 	/* try to populate a working cache */
-	pk_extra_populate_locale_cache (extra);
+	if (extra->priv->access == PK_EXTRA_ACCESS_READ_ONLY ||
+	    extra->priv->access == PK_EXTRA_ACCESS_READ_WRITE)
+		pk_extra_populate_locale_cache (extra);
 
 	return TRUE;
 }
@@ -361,6 +364,12 @@ pk_extra_get_summary (PkExtra *extra, const gchar *package)
 	g_return_val_if_fail (PK_IS_EXTRA (extra), NULL);
 	g_return_val_if_fail (package != NULL, NULL);
 
+	/* write only */
+	if (extra->priv->access == PK_EXTRA_ACCESS_WRITE_ONLY) {
+		egg_warning ("database opened write only");
+		return NULL;
+	}
+
 	/* super quick if exists in cache */
 	obj = g_hash_table_lookup (extra->priv->hash_locale, package);
 	if (obj == NULL)
@@ -382,6 +391,12 @@ pk_extra_get_icon_name (PkExtra *extra, const gchar *package)
 	g_return_val_if_fail (PK_IS_EXTRA (extra), NULL);
 	g_return_val_if_fail (package != NULL, NULL);
 
+	/* write only */
+	if (extra->priv->access == PK_EXTRA_ACCESS_WRITE_ONLY) {
+		egg_warning ("database opened write only");
+		return NULL;
+	}
+
 	/* super quick if exists in cache */
 	obj = g_hash_table_lookup (extra->priv->hash_package, package);
 	if (obj == NULL)
@@ -403,6 +418,12 @@ pk_extra_get_exec (PkExtra *extra, const gchar *package)
 	g_return_val_if_fail (PK_IS_EXTRA (extra), NULL);
 	g_return_val_if_fail (package != NULL, NULL);
 
+	/* write only */
+	if (extra->priv->access == PK_EXTRA_ACCESS_WRITE_ONLY) {
+		egg_warning ("database opened write only");
+		return NULL;
+	}
+
 	/* super quick if exists in cache */
 	obj = g_hash_table_lookup (extra->priv->hash_package, package);
 	if (obj == NULL)
@@ -436,6 +457,12 @@ pk_extra_set_data_locale (PkExtra *extra, const gchar *package, const gchar *sum
 		return FALSE;
 	}
 
+	/* read only */
+	if (extra->priv->access == PK_EXTRA_ACCESS_READ_ONLY) {
+		egg_warning ("database opened read only");
+		return FALSE;
+	}
+
 	/* the row might already exist */
 	statement = g_strdup_printf ("DELETE FROM localised WHERE "
 				     "package = '%s' AND locale = '%s'",
@@ -467,9 +494,11 @@ pk_extra_set_data_locale (PkExtra *extra, const gchar *package, const gchar *sum
 	}
 
 	/* add to cache */
-	obj = g_new (PkExtraLocaleObj, 1);
-	obj->summary = g_strdup (summary);
-	g_hash_table_insert (extra->priv->hash_locale, g_strdup (package), (gpointer) obj);
+	if (extra->priv->access == PK_EXTRA_ACCESS_READ_WRITE) {
+		obj = g_new (PkExtraLocaleObj, 1);
+		obj->summary = g_strdup (summary);
+		g_hash_table_insert (extra->priv->hash_locale, g_strdup (package), (gpointer) obj);
+	}
 
 	return TRUE;
 }
@@ -499,6 +528,12 @@ pk_extra_set_data_package (PkExtra *extra, const gchar *package, const gchar *ic
 		return FALSE;
 	}
 
+	/* read only */
+	if (extra->priv->access == PK_EXTRA_ACCESS_READ_ONLY) {
+		egg_warning ("database opened read only");
+		return FALSE;
+	}
+
 	/* the row might already exist */
 	statement = g_strdup_printf ("DELETE FROM data WHERE package = '%s'", package);
 	sqlite3_exec (extra->priv->db, statement, NULL, extra, NULL);
@@ -527,16 +562,32 @@ pk_extra_set_data_package (PkExtra *extra, const gchar *package, const gchar *ic
 	}
 
 	/* add to cache */
-	egg_debug ("adding package:%s", package);
-	obj = g_new (PkExtraPackageObj, 1);
-	obj->icon_name = g_strdup (icon_name);
-	obj->exec = g_strdup (exec);
-	g_hash_table_insert (extra->priv->hash_package, g_strdup (package), (gpointer) obj);
+	if (extra->priv->access == PK_EXTRA_ACCESS_READ_WRITE) {
+		egg_debug ("adding package:%s", package);
+		obj = g_new (PkExtraPackageObj, 1);
+		obj->icon_name = g_strdup (icon_name);
+		obj->exec = g_strdup (exec);
+		g_hash_table_insert (extra->priv->hash_package, g_strdup (package), (gpointer) obj);
+	}
 
 	return TRUE;
 }
 
 /**
+ * pk_extra_set_access:
+ * @extra: a valid #PkExtra instance
+ *
+ * Return value: the current locale
+ **/
+gboolean
+pk_extra_set_access (PkExtra *extra, PkExtraAccess access)
+{
+	g_return_val_if_fail (PK_IS_EXTRA (extra), FALSE);
+	extra->priv->access = access;
+	return TRUE;
+}
+
+/**
  * pk_extra_set_database:
  * @extra: a valid #PkExtra instance
  * @filename: a valid database, or NULL to use the default or previously set value
@@ -614,7 +665,9 @@ pk_extra_set_database (PkExtra *extra, const gchar *filename)
 	}
 
 	/* try to populate a working cache */
-	pk_extra_populate_package_cache (extra);
+	if (extra->priv->access == PK_EXTRA_ACCESS_READ_ONLY ||
+	    extra->priv->access == PK_EXTRA_ACCESS_READ_WRITE)
+		pk_extra_populate_package_cache (extra);
 
 	return TRUE;
 }
@@ -664,6 +717,7 @@ pk_extra_init (PkExtra *extra)
 	extra->priv->db = NULL;
 	extra->priv->locale = NULL;
 	extra->priv->locale_base = NULL;
+	extra->priv->access = PK_EXTRA_ACCESS_READ_WRITE;
 	extra->priv->hash_package = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, pk_free_package_obj);
 	extra->priv->hash_locale = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, pk_free_locale_obj);
 }
@@ -877,6 +931,36 @@ pk_extra_test (EggTest *test)
 	}
 	egg_test_success (test, "%i get_summary loops completed in %ims", i*5, egg_test_elapsed (test));
 
+	/************************************************************/
+	egg_test_title (test, "try to set wo");
+	ret = pk_extra_set_access (extra, PK_EXTRA_ACCESS_WRITE_ONLY);
+	egg_test_assert (test, ret);
+
+	/************************************************************/
+	egg_test_title (test, "try to write");
+	ret = pk_extra_set_data_package (extra, "gnome-power-manager", "gpm-prefs.png", "gnome-power-preferences");
+	egg_test_assert (test, ret);
+
+	/************************************************************/
+	egg_test_title (test, "try to read");
+	summary = pk_extra_get_summary (extra, "gnome-power-manager");
+	egg_test_assert (test, summary == NULL);
+
+	/************************************************************/
+	egg_test_title (test, "try to set ro");
+	ret = pk_extra_set_access (extra, PK_EXTRA_ACCESS_READ_ONLY);
+	egg_test_assert (test, ret);
+
+	/************************************************************/
+	egg_test_title (test, "try to read");
+	summary = pk_extra_get_summary (extra, "gnome-power-manager");
+	egg_test_assert (test, summary != NULL);
+
+	/************************************************************/
+	egg_test_title (test, "try to write");
+	ret = pk_extra_set_data_package (extra, "gnome-power-manager", "gpm-prefs.png", "gnome-power-preferences");
+	egg_test_assert (test, !ret);
+
 	g_object_unref (extra);
 	g_unlink ("extra.db");
 
diff --git a/libpackagekit/pk-extra.h b/libpackagekit/pk-extra.h
index 67a0f63..54c8866 100644
--- a/libpackagekit/pk-extra.h
+++ b/libpackagekit/pk-extra.h
@@ -57,6 +57,12 @@ struct _PkExtraClass
 	GObjectClass	parent_class;
 };
 
+typedef enum {
+	PK_EXTRA_ACCESS_READ_ONLY,
+	PK_EXTRA_ACCESS_WRITE_ONLY,
+	PK_EXTRA_ACCESS_READ_WRITE
+} PkExtraAccess;
+
 GType		 pk_extra_get_type			(void) G_GNUC_CONST;
 PkExtra		*pk_extra_new				(void);
 
@@ -66,6 +72,8 @@ const gchar	*pk_extra_get_locale			(PkExtra	*extra);
 gboolean	 pk_extra_set_database			(PkExtra	*extra,
 							 const gchar	*filename)
 							 G_GNUC_WARN_UNUSED_RESULT;
+gboolean	 pk_extra_set_access			(PkExtra	*extra,
+							 PkExtraAccess	 access);
 
 const gchar	*pk_extra_get_summary			(PkExtra	*extra,
 							 const gchar	*package);
commit 36939fc06862075fd06884a6e42a660180b7caf2
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Sep 22 16:01:30 2008 +0100

    trivial: post release version bump

diff --git a/RELEASE b/RELEASE
index c999517..88c15b0 100644
--- a/RELEASE
+++ b/RELEASE
@@ -3,8 +3,8 @@ PackageKit Release Notes
 1. Write NEWS entries for PackageKit and gnome-packagekit in the same
    format as usual. Ignore any trivial commits.
 
-git-shortlog PACKAGEKIT_0_3_3.. | grep -v trivial | grep -v Merge > NEWS.new
-git-shortlog GNOME_PACKAGEKIT_0_3_3.. | grep -v trivial | grep -v Merge > NEWS.new
+git-shortlog PACKAGEKIT_0_3_4.. | grep -v trivial | grep -v Merge > NEWS.new
+git-shortlog GNOME_PACKAGEKIT_0_3_4.. | grep -v trivial | grep -v Merge > NEWS.new
 
 2. Add download date to docs/html/pk-download.html, save file.
 
@@ -12,8 +12,8 @@ git-shortlog GNOME_PACKAGEKIT_0_3_3.. | grep -v trivial | grep -v Merge > NEWS.n
 
 4. Commit changes in PackageKit git:
 
-git commit -a -m "Release version 0.3.4"
-git tag -a -f -m "Release 0.3.4" PACKAGEKIT_0_3_4
+git commit -a -m "Release version 0.3.5"
+git tag -a -f -m "Release 0.3.5" PACKAGEKIT_0_3_5
 git push --tags
 git push
 git push git+ssh://hughsient@git.freedesktop.org/git/packagekit
@@ -21,8 +21,8 @@ git push --tags git+ssh://hughsient@git.freedesktop.org/git/packagekit
 
 5. Commit changes in gnome-packagekit git:
 
-git commit -a -m "Release version 0.3.4"
-git-tag GNOME_PACKAGEKIT_0_3_4
+git commit -a -m "Release version 0.3.5"
+git-tag GNOME_PACKAGEKIT_0_3_5
 git push --tags
 git push
 
@@ -42,9 +42,9 @@ git push
 10. Send an email to packagekit at lists.freedesktop.org
 
 =================================================
-Subject: PackageKit and gnome-packagekit 0.3.4 released!
+Subject: PackageKit and gnome-packagekit 0.3.5 released!
 
-Today I released PackageKit and gnome-packagekit 0.3.4.
+Today I released PackageKit and gnome-packagekit 0.3.5.
 
 PackageKit release notes: http://gitweb.freedesktop.org/?p=packagekit.git;a=blob;f=NEWS
 
diff --git a/configure.ac b/configure.ac
index 5157f9f..8214429 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
 AC_PREREQ(2.52)
 
-AC_INIT(PackageKit, 0.3.4)
+AC_INIT(PackageKit, 0.3.5)
 AC_CONFIG_SRCDIR(src)
 AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
 AM_CONFIG_HEADER(config.h)


More information about the PackageKit-commit mailing list