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

Richard Hughes hughsient at kemper.freedesktop.org
Sun Jun 15 05:50:29 PDT 2008


 backends/poldek/pk-backend-poldek.c |  516 +++++++++++++++++++++++-------------
 backends/yum/helpers/yumBackend.py  |   54 ++-
 backends/yum/pk-backend-yum.c       |    3 
 backends/zypp/pk-backend-zypp.cpp   |   17 -
 backends/zypp/zypp-utils.cpp        |   12 
 libpackagekit/pk-package-list.c     |   27 +
 libpackagekit/pk-package-list.h     |    2 
 7 files changed, 432 insertions(+), 199 deletions(-)

New commits:
commit 86dcb5b47e27ea2c987a793f20b26e80721be221
Merge: 9a0cf41... 4c5b338...
Author: Richard Hughes <richard at hughsie.com>
Date:   Sun Jun 15 13:48:00 2008 +0100

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

commit 4c5b338a7cde2738ee3a256a1580544496886a67
Author: Marcin Banasiak <megabajt at pld-linux.org>
Date:   Sat Jun 14 22:04:39 2008 +0200

    poldek: now GetUpdateDetail returns obsoleted packages too

diff --git a/backends/poldek/pk-backend-poldek.c b/backends/poldek/pk-backend-poldek.c
index 5086636..e1bdccb 100644
--- a/backends/poldek/pk-backend-poldek.c
+++ b/backends/poldek/pk-backend-poldek.c
@@ -36,7 +36,7 @@
 #include <sigint/sigint.h>
 
 static gchar* poldek_pkg_evr (const struct pkg *pkg);
-static void poldek_backend_package (PkBackend *backend, const struct pkg *pkg, gint status);
+static void poldek_backend_package (PkBackend *backend, struct pkg *pkg, PkInfoEnum infoenum, PkFilterEnum filters);
 static long do_get_bytes_to_download (const struct poldek_ts *ts, const gchar *mark);
 static gint do_get_files_to_download (const struct poldek_ts *ts, const gchar *mark);
 static void pb_load_packages (PkBackend *backend);
@@ -239,7 +239,7 @@ poldek_vf_progress_new (void *data, const gchar *label)
 
 		if (pkgs) {
 			pkg = n_array_nth (pkgs, 0);
-			poldek_backend_package (backend, pkg, PK_INFO_ENUM_DOWNLOADING);
+			poldek_backend_package (backend, pkg, PK_INFO_ENUM_DOWNLOADING, PK_FILTER_ENUM_NONE);
 		}
 
 		poclidek_rcmd_free (rcmd);
@@ -273,6 +273,9 @@ poldek_vf_progress (void *bar, long total, long amount)
 			pd->percentage = (gint)(((float)(pd->bytesget + amount) / (float)pd->bytesdownload) * 100);
 			pd->subpercentage = (gint)(frac * 100);
 		}
+
+		pk_backend_set_sub_percentage (backend, pd->subpercentage);
+
 	} else if (ts_type == TS_TYPE_ENUM_REFRESH_CACHE) {
 		if (pd->step == 0)
 			pd->percentage = 1;
@@ -281,11 +284,6 @@ poldek_vf_progress (void *bar, long total, long amount)
 	}
 
 	pk_backend_set_percentage (backend, pd->percentage);
-
-	/* RefreshCache doesn't use subpercentage */
-	if (ts_type == TS_TYPE_ENUM_INSTALL ||
-	    ts_type == TS_TYPE_ENUM_UPDATE)
-		pk_backend_set_sub_percentage (backend, pd->subpercentage);
 }
 
 static void
@@ -426,7 +424,7 @@ ts_confirm (void *data, struct poldek_ts *ts)
 				for (i = 0; i < n_array_size (dpkgs); i++) {
 					struct pkg *pkg = n_array_nth (dpkgs, i);
 
-					poldek_backend_package (backend, pkg, PK_INFO_ENUM_REMOVING);
+					poldek_backend_package (backend, pkg, PK_INFO_ENUM_REMOVING, PK_FILTER_ENUM_NONE);
 				}
 			}
 
@@ -434,7 +432,7 @@ ts_confirm (void *data, struct poldek_ts *ts)
 				for (i = 0; i < n_array_size (rpkgs); i++) {
 					struct pkg *pkg = n_array_nth (rpkgs, i);
 
-					poldek_backend_package (backend, pkg, PK_INFO_ENUM_REMOVING);
+					poldek_backend_package (backend, pkg, PK_INFO_ENUM_REMOVING, PK_FILTER_ENUM_NONE);
 				}
 			}
 		}
@@ -485,20 +483,29 @@ pkg_cmp_name_evr_rev_recno (const struct pkg *p1, const struct pkg *p2) {
 	return rc;
 }
 
-#define	PKG_INSTALLED (1 << 30)
+static gboolean
+pkg_is_installed (struct pkg *pkg)
+{
+	struct pkgdb *db;
+	gint cmprc, is_installed = 0;
+	struct poldek_ts *ts;
 
-#define poldek_pkg_is_installed(pkg) ((pkg)->flags & PKG_INSTALLED)
+	g_return_val_if_fail (pkg != NULL, FALSE);
 
-/**
- * poldek_pkg_set_installed:
- */
-static void
-poldek_pkg_set_installed (struct pkg *pkg, gboolean installed) {
-	if (installed) {
-		pkg->flags |= PKG_INSTALLED;
-	} else {
-		pkg->flags &= (~PKG_INSTALLED);
+	/* XXX: I don't know how to get ctx->rootdir */
+	ts = poldek_ts_new (ctx, 0);
+
+	db = pkgdb_open (ts->pmctx, ts->rootdir, NULL, O_RDONLY, NULL);
+
+	if (db) {
+		is_installed = pkgdb_is_pkg_installed (db, pkg, &cmprc);
+
+		pkgdb_free (db);
 	}
+
+	poldek_ts_free (ts);
+
+	return is_installed ? TRUE : FALSE;
 }
 
 /**
@@ -782,7 +789,7 @@ do_newest (tn_array *pkgs)
 		if (pkg_cmp_name (pkgs->data[i - 1], pkgs->data[i]) == 0) {
 			struct pkg	*pkg = n_array_nth (pkgs, i);
 
-			if (!poldek_pkg_is_installed (pkg)) {
+			if (!pkg_is_installed (pkg)) {
 				n_array_remove_nth (pkgs, i);
 				continue;
 			}
@@ -1002,30 +1009,27 @@ do_depends (tn_array *installed, tn_array *available, tn_array *depends, struct
 	n_array_free (tmp);
 }
 
-/**
- * poldek_backend_package:
- */
-static void
-poldek_backend_package (PkBackend *backend, const struct pkg *pkg, gint status)
+static gchar*
+package_id_from_pkg (struct pkg *pkg, const gchar *repo)
 {
-	struct pkguinf	*pkgu;
-	gchar		*evr, *package_id, *poldek_dir;
+	gchar *evr, *package_id, *poldek_dir;
 
-	evr = poldek_pkg_evr (pkg);
+	g_return_val_if_fail (pkg != NULL, NULL);
 
-	if (poldek_pkg_is_installed(pkg)) {
-		if (status == PK_INFO_ENUM_UNKNOWN)
-			status = PK_INFO_ENUM_INSTALLED;
+	evr = poldek_pkg_evr (pkg);
 
-		poldek_dir = g_strdup ("installed");
+	if (repo) {
+		poldek_dir = g_strdup (repo);
 	} else {
-		if (status == PK_INFO_ENUM_UNKNOWN)
-			status = PK_INFO_ENUM_AVAILABLE;
-
-		if (pkg->pkgdir && pkg->pkgdir->name)
-			poldek_dir = g_strdup (pkg->pkgdir->name);
-		else
-			poldek_dir = g_strdup ("all-avail");
+		if (pkg_is_installed (pkg)) {
+			poldek_dir = g_strdup ("installed");
+		} else {
+			if (pkg->pkgdir && pkg->pkgdir->name) {
+				poldek_dir = g_strdup (pkg->pkgdir->name);
+			} else {
+				poldek_dir = g_strdup ("all-avail");
+			}
+		}
 	}
 
 	package_id = pk_package_id_build (pkg->name,
@@ -1033,18 +1037,47 @@ poldek_backend_package (PkBackend *backend, const struct pkg *pkg, gint status)
 					  pkg_arch (pkg),
 					  poldek_dir);
 
+	g_free (evr);
+	g_free (poldek_dir);
+
+	return package_id;
+}
+
+/**
+ * poldek_backend_package:
+ */
+static void
+poldek_backend_package (PkBackend *backend, struct pkg *pkg, PkInfoEnum infoenum, PkFilterEnum filters)
+{
+	struct pkguinf	*pkgu;
+	gchar		*package_id;
+
+	if (infoenum == PK_INFO_ENUM_UNKNOWN) {
+		if (pk_enums_contain (filters, PK_FILTER_ENUM_INSTALLED)) {
+			infoenum = PK_INFO_ENUM_INSTALLED;
+		} else if (pk_enums_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED)) {
+			infoenum = PK_INFO_ENUM_AVAILABLE;
+		} else {
+			if (pkg_is_installed (pkg)) {
+				infoenum = PK_INFO_ENUM_INSTALLED;
+			} else {
+				infoenum = PK_INFO_ENUM_AVAILABLE;
+			}
+		}
+	}
+
+	package_id = package_id_from_pkg (pkg, NULL);
+
 	pkgu = pkg_uinf (pkg);
 
 	if (pkgu) {
-		pk_backend_package (backend, status, package_id, pkguinf_get (pkgu, PKGUINF_SUMMARY));
+		pk_backend_package (backend, infoenum, package_id, pkguinf_get (pkgu, PKGUINF_SUMMARY));
 		pkguinf_free (pkgu);
 	} else {
-		pk_backend_package (backend, status, package_id, "");
+		pk_backend_package (backend, infoenum, package_id, "");
 	}
 
-	g_free (evr);
 	g_free (package_id);
-	g_free (poldek_dir);
 }
 
 /**
@@ -1180,16 +1213,7 @@ search_package_thread (PkBackend *backend)
 		if (!pk_enums_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED)) {
 			command = g_strdup_printf ("cd /installed; %s", search_cmd);
 			if (poclidek_rcmd_execline (cmd, command)) {
-				gint	i;
-
 				installed = poclidek_rcmd_get_packages (cmd);
-
-				/* mark packages as installed */
-				for (i = 0; i < n_array_size (installed); i++) {
-					struct pkg	*pkg = n_array_nth (installed, i);
-
-					poldek_pkg_set_installed (pkg, TRUE);
-				}
 			}
 
 			g_free (command);
@@ -1214,9 +1238,6 @@ search_package_thread (PkBackend *backend)
 
 				/* check for duplicates */
 				if (!poldek_pkg_in_array (pkg, pkgs, (tn_fn_cmp)pkg_cmp_name_evr)) {
-					/* mark package as NOT installed */
-					poldek_pkg_set_installed (pkg, FALSE);
-
 					n_array_push (pkgs, pkg_link (pkg));
 				}
 			}
@@ -1225,18 +1246,9 @@ search_package_thread (PkBackend *backend)
 
 			n_array_free (available);
 		} else if (pk_enums_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED) || available) {
-			gint	i;
-
 			pkgs = available;
-
-			for (i = 0; i < n_array_size (pkgs); i++) {
-				struct pkg	*pkg = n_array_nth (pkgs, i);
-
-				poldek_pkg_set_installed (pkg, FALSE);
-			}
 		} else if (pk_enums_contain (filters, PK_FILTER_ENUM_INSTALLED) || installed)
 			pkgs = installed;
-
 		if (pkgs) {
 			gint	i;
 
@@ -1279,7 +1291,7 @@ search_package_thread (PkBackend *backend)
 					}
 				}
 
-				poldek_backend_package (backend, pkg, PK_INFO_ENUM_UNKNOWN);
+				poldek_backend_package (backend, pkg, PK_INFO_ENUM_UNKNOWN, filters);
 			}
 			n_array_free (pkgs);
 		} else {
@@ -1512,7 +1524,7 @@ show_rpm_progress (PkBackend *backend, gchar *message)
 			for (i = 0; i < n_array_size (rpkgs); i++) {
 				struct pkg *pkg = n_array_nth (rpkgs, i);
 
-				poldek_backend_package (backend, pkg, PK_INFO_ENUM_REMOVING);
+				poldek_backend_package (backend, pkg, PK_INFO_ENUM_REMOVING, PK_FILTER_ENUM_NONE);
 
 				n_array_remove_nth (rpkgs, i);
 			}
@@ -1538,7 +1550,7 @@ show_rpm_progress (PkBackend *backend, gchar *message)
 			struct pkg *pkg = n_array_nth (arr, n);
 			guint in_arrays = 0;
 
-			poldek_backend_package (backend, pkg, pkinfo);
+			poldek_backend_package (backend, pkg, pkinfo, PK_FILTER_ENUM_NONE);
 
 			n_array_remove_nth (arr, n);
 
@@ -1841,7 +1853,7 @@ backend_get_depends_thread (PkBackend *backend)
 	for (i = 0; i < n_array_size (deppkgs); i++) {
 		struct pkg	*p = n_array_nth (deppkgs, i);
 
-		poldek_backend_package (backend, p, PK_INFO_ENUM_UNKNOWN);
+		poldek_backend_package (backend, p, PK_INFO_ENUM_UNKNOWN, pk_backend_get_uint (backend, "filters"));
 	}
 
 	pkg_free (pkg);
@@ -2038,7 +2050,7 @@ backend_get_requires_thread (PkBackend *backend)
 	for (i = 0; i < n_array_size (reqpkgs); i++) {
 		struct pkg	*p = n_array_nth (reqpkgs, i);
 
-		poldek_backend_package (backend, p, PK_INFO_ENUM_UNKNOWN);
+		poldek_backend_package (backend, p, PK_INFO_ENUM_UNKNOWN, pk_backend_get_uint (backend, "filters"));
 	}
 
 	n_array_free (reqpkgs);
@@ -2062,6 +2074,43 @@ backend_get_requires (PkBackend	*backend, PkFilterEnum filters, const gchar *pac
 /**
  * backend_get_update_detail:
  */
+static gchar*
+get_obsoletedby_pkg (struct pkg *pkg)
+{
+	tn_array *dbpkgs;
+	GString *obsoletes = NULL;
+	gint i;
+
+	g_return_val_if_fail (pkg != NULL, NULL);
+
+	/* get installed packages */
+	dbpkgs = poclidek_get_dent_packages (cctx, POCLIDEK_INSTALLEDDIR);
+
+	if (dbpkgs == NULL)
+		return NULL;
+
+	for (i = 0; i < n_array_size (dbpkgs); i++) {
+		struct pkg *dbpkg = n_array_nth (dbpkgs, i);
+
+		if (pkg_caps_obsoletes_pkg_caps (pkg, dbpkg)) {
+			gchar *package_id = package_id_from_pkg (dbpkg, "installed");
+
+			if (obsoletes) {
+				obsoletes = g_string_append_c (obsoletes, '^');
+				obsoletes = g_string_append (obsoletes, package_id);
+			} else {
+				obsoletes = g_string_new (package_id);
+			}
+
+			g_free (package_id);
+		}
+	}
+
+	n_array_free (dbpkgs);
+
+	return obsoletes ? g_string_free (obsoletes, FALSE) : NULL;
+}
+
 static gboolean
 backend_get_update_detail_thread (PkBackend *backend)
 {
@@ -2090,17 +2139,15 @@ backend_get_update_detail_thread (PkBackend *backend)
 		pkg = n_array_nth (pkgs, 0);
 
 		if (strcmp (pkg->name, pi->name) == 0) {
-			gchar	*evr, *update_id, *cve_url = NULL;
+			gchar	*updates, *obsoletes, *cve_url = NULL;
 			tn_array *cves = NULL;
 
-			evr = poldek_pkg_evr (pkg);
-			update_id = pk_package_id_build (pkg->name,
-							 evr,
-							 pkg_arch (pkg),
-							 "installed");
+			updates = package_id_from_pkg (pkg, "installed");
 
 			upkg = poldek_get_pkg_from_package_id (package_id);
 
+			obsoletes = get_obsoletedby_pkg (upkg);
+
 			if ((cves = poldek_pkg_get_cves_from_pld_changelog (upkg, pkg->btime))) {
 				GString	*string;
 				gint i;
@@ -2123,16 +2170,16 @@ backend_get_update_detail_thread (PkBackend *backend)
 
 			pk_backend_update_detail (backend,
 						  package_id,
-						  update_id,
-						  "",
+						  updates,
+						  obsoletes ? obsoletes : "",
 						  "",
 						  "",
 						  cve_url ? cve_url : "",
 						  PK_RESTART_ENUM_NONE,
 						  "");
 
-			g_free (evr);
-			g_free (update_id);
+			g_free (updates);
+			g_free (obsoletes);
 			g_free (cve_url);
 
 			n_array_cfree (&cves);
@@ -2202,11 +2249,11 @@ backend_get_updates_thread (PkBackend *backend)
 
 				/* mark held packages as blocked */
 				if (pkg->flags & PKG_HELD)
-					poldek_backend_package (backend, pkg, PK_INFO_ENUM_BLOCKED);
+					poldek_backend_package (backend, pkg, PK_INFO_ENUM_BLOCKED, PK_FILTER_ENUM_NONE);
 				else if (poldek_pkg_in_array (pkg, secupgrades, (tn_fn_cmp)pkg_cmp_name_evr))
-					poldek_backend_package (backend, pkg, PK_INFO_ENUM_SECURITY);
+					poldek_backend_package (backend, pkg, PK_INFO_ENUM_SECURITY, PK_FILTER_ENUM_NONE);
 				else
-					poldek_backend_package (backend, pkg, PK_INFO_ENUM_NORMAL);
+					poldek_backend_package (backend, pkg, PK_INFO_ENUM_NORMAL, PK_FILTER_ENUM_NONE);
 			}
 			n_array_cfree (&secupgrades);
 			n_array_free (pkgs);
commit 9a0cf4133b7d5293a3eb76363339e9d1ffa322b5
Author: Richard Hughes <richard at hughsie.com>
Date:   Sat Jun 14 16:03:56 2008 +0100

    add in a new function: pk_package_list_remove() so we can remove items from a package list

diff --git a/libpackagekit/pk-package-list.c b/libpackagekit/pk-package-list.c
index 33d7d07..0614471 100644
--- a/libpackagekit/pk-package-list.c
+++ b/libpackagekit/pk-package-list.c
@@ -309,6 +309,33 @@ pk_package_list_contains (PkPackageList *plist, const gchar *package_id)
 }
 
 /**
+ * pk_package_list_remove:
+ **/
+gboolean
+pk_package_list_remove (PkPackageList *plist, const gchar *package_id)
+{
+	PkPackageItem *item;
+	guint i;
+	guint length;
+	gboolean ret = FALSE;
+
+	g_return_val_if_fail (PK_IS_PACKAGE_LIST (plist), FALSE);
+	g_return_val_if_fail (package_id != NULL, FALSE);
+
+	length = plist->priv->array->len;
+	for (i=0; i<length; i++) {
+		item = g_ptr_array_index (plist->priv->array, i);
+		ret = pk_package_id_equal (item->package_id, package_id);
+		if (ret) {
+			pk_package_item_free (item);
+			g_ptr_array_remove_index (plist->priv->array, i);
+			break;
+		}
+	}
+	return ret;
+}
+
+/**
  * pk_package_list_contains_item:
  **/
 gboolean
diff --git a/libpackagekit/pk-package-list.h b/libpackagekit/pk-package-list.h
index 401069b..447bb98 100644
--- a/libpackagekit/pk-package-list.h
+++ b/libpackagekit/pk-package-list.h
@@ -63,6 +63,8 @@ gboolean	 pk_package_list_add_list		(PkPackageList		*plist,
 							 PkPackageList		*list);
 gboolean	 pk_package_list_contains		(PkPackageList		*plist,
 							 const gchar		*package_id);
+gboolean	 pk_package_list_remove			(PkPackageList		*plist,
+							 const gchar		*package_id);
 gboolean	 pk_package_list_contains_item		(PkPackageList		*plist,
 							 PkPackageItem		*item);
 gchar		*pk_package_list_get_string		(PkPackageList		*plist)
commit 8a0b120559bfdc8123e401dd149e4f7d2d676b66
Author: Scott Reeves <sreeves at novell.com>
Date:   Fri Jun 13 14:56:53 2008 -0600

    roll in zypp backend from openSUSE branch

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index a971707..e666c8e 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -91,6 +91,7 @@ static void
 backend_initialize (PkBackend *backend)
 {
 	zypp_logging ();
+	get_zypp ();
 	pk_debug ("zypp_backend_initialize");
 	EventDirector *eventDirector = new EventDirector (backend);
 	_eventDirectors [backend] = eventDirector;
@@ -616,7 +617,7 @@ backend_get_updates_thread (PkBackend *backend)
 
 	// get all Packages and Patches for Update
 	std::set<zypp::PoolItem> *candidates = zypp_get_patches ();
-	std::set<zypp::PoolItem> *candidates2 = new std::set<zypp::PoolItem> ();
+	//std::set<zypp::PoolItem> *candidates2 = new std::set<zypp::PoolItem> ();
 
 	if (!_updating_self) {
 		// exclude the patch-repository
@@ -625,9 +626,9 @@ backend_get_updates_thread (PkBackend *backend)
 			patchRepo = candidates->begin ()->resolvable ()->repoInfo ().alias ();
 		}
 		
-		candidates2 = zypp_get_updates (patchRepo);
+		//candidates2 = zypp_get_updates (patchRepo);
 
-		candidates->insert (candidates2->begin (), candidates2->end ());
+		//candidates->insert (candidates2->begin (), candidates2->end ());
 	}
 
 	pk_backend_set_percentage (backend, 80);
@@ -660,7 +661,7 @@ backend_get_updates_thread (PkBackend *backend)
 	}
 
 	delete (candidates);
-	delete (candidates2);
+	//delete (candidates2);
 
  	pk_backend_set_percentage (backend, 100);
 	pk_backend_finished (backend);
@@ -903,7 +904,7 @@ backend_update_system_thread (PkBackend *backend)
 
 	//get all Patches for Update
 	std::set<zypp::PoolItem> *candidates = zypp_get_patches ();
-	std::set<zypp::PoolItem> *candidates2 = new std::set<zypp::PoolItem> ();
+	//std::set<zypp::PoolItem> *candidates2 = new std::set<zypp::PoolItem> ();
 	
 	if (_updating_self) {
 		pk_backend_require_restart (backend, PK_RESTART_ENUM_SESSION, "Package Management System updated - restart needed");
@@ -917,11 +918,11 @@ backend_update_system_thread (PkBackend *backend)
 		}
 	
 		//get all Updates
-		candidates2 = zypp_get_updates (patchRepo);
+		//candidates2 = zypp_get_updates (patchRepo);
 
 		//concatenate these sets
 
-		candidates->insert (candidates2->begin (), candidates2->end ());
+		//candidates->insert (candidates2->begin (), candidates2->end ());
 	}
 
 	pk_backend_set_percentage (backend, 80);
@@ -938,7 +939,7 @@ backend_update_system_thread (PkBackend *backend)
 		return FALSE;
 	}
 
-	delete (candidates2);
+	//delete (candidates2);
 	delete (candidates);
 	pk_backend_set_percentage (backend, 100);
 	pk_backend_finished (backend);
diff --git a/backends/zypp/zypp-utils.cpp b/backends/zypp/zypp-utils.cpp
index d81d0dd..ad1d86f 100644
--- a/backends/zypp/zypp-utils.cpp
+++ b/backends/zypp/zypp-utils.cpp
@@ -639,7 +639,7 @@ zypp_get_patches ()
         for (zypp::ResPoolProxy::const_iterator it = zypp->poolProxy ().byKindBegin<zypp::Patch>();
                         it != zypp->poolProxy ().byKindEnd<zypp::Patch>(); it ++) {
                 // check if patch is needed 
-                if((*it)->candidateObj ().isBroken()) {
+                if((*it)->candidateObj ().isRelevant() && !((*it)->candidateObj ().isSatisfied())) {
                         patches->insert ((*it)->candidateObj ());
 			zypp::Patch::constPtr patch = zypp::asKind<zypp::Patch>((*it)->candidateObj ().resolvable ());
 
@@ -666,6 +666,10 @@ zypp_perform_execution (PkBackend *backend, PerformType type, gboolean force)
 
                 if (force)
                         zypp->resolver ()->setForceResolve (force);
+		if (type == UPDATE) {
+			//zypp->resolver ()->setOnlyRequires (TRUE);		
+			zypp->resolver ()->setIgnoreAlreadyRecommended (TRUE);		
+		}
 
                 // Gather up any dependencies
 		pk_backend_set_status (backend, PK_STATUS_ENUM_DEP_RESOLVE);
@@ -786,7 +790,10 @@ zypp_perform_execution (PkBackend *backend, PerformType type, gboolean force)
                         return FALSE;
                 }
 
-                zypp->resolver ()->setForceResolve (FALSE);
+		zypp->resolver ()->setForceResolve (FALSE);
+		if (type == UPDATE) {
+			zypp->resolver ()->setIgnoreAlreadyRecommended (FALSE);		
+		}
 
         } catch (const zypp::repo::RepoNotFoundException &ex) {
 		pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, ex.asUserString().c_str() );
@@ -837,6 +844,7 @@ zypp_build_package_id_capabilities (zypp::Capabilities caps)
 gboolean
 zypp_refresh_cache (PkBackend *backend, gboolean force)
 {
+	get_zypp ();  //This call is needed as it calls initializeTarget which appears to properly setup the keyring
 	if (!pk_backend_is_online (backend)) {
 		pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot refresh cache whilst offline");
 		return FALSE;
commit 9e7522a39b29a77ebb9baa31cef1b0c1a1f0c65d
Author: Marcin Banasiak <megabajt at pld-linux.org>
Date:   Fri Jun 13 18:00:07 2008 +0200

    poldek: trivial: fix GetDetails to return size of package (download size)

diff --git a/backends/poldek/pk-backend-poldek.c b/backends/poldek/pk-backend-poldek.c
index 1dd3123..5086636 100644
--- a/backends/poldek/pk-backend-poldek.c
+++ b/backends/poldek/pk-backend-poldek.c
@@ -1879,8 +1879,7 @@ backend_get_details_thread (PkBackend *backend)
 
 	pkg = poldek_get_pkg_from_package_id (package_id);
 
-	if (pkg)
-	{
+	if (pkg) {
 		struct pkguinf	*pkgu = NULL;
 		PkGroupEnum	group;
 
@@ -1895,7 +1894,7 @@ backend_get_details_thread (PkBackend *backend)
 						group,
 						pkguinf_get (pkgu, PKGUINF_DESCRIPTION),
 						pkguinf_get (pkgu, PKGUINF_URL),
-						pkg->size);
+						pkg->fsize);
 			pkguinf_free (pkgu);
 		} else {
 			pk_backend_details (backend,
@@ -1904,7 +1903,7 @@ backend_get_details_thread (PkBackend *backend)
 						group,
 						"",
 						"",
-						pkg->size);
+						pkg->fsize);
 		}
 
 		pkg_free (pkg);
commit 261dd6a2ba0aa60eab0ee8858ecdd5f001ae1e7d
Author: Marcin Banasiak <megabajt at pld-linux.org>
Date:   Fri Jun 13 17:54:36 2008 +0200

    poldek: implement percentage for installing / updating

diff --git a/backends/poldek/pk-backend-poldek.c b/backends/poldek/pk-backend-poldek.c
index f6c6ca2..1dd3123 100644
--- a/backends/poldek/pk-backend-poldek.c
+++ b/backends/poldek/pk-backend-poldek.c
@@ -93,27 +93,34 @@ typedef struct {
 	/* Numer of sources to update. It's used only by refresh cache,
 	 * as each source can have multiple files to download. I don't
 	 * know how to get numer of files which will be downloaded. */
-	gint		nsources;
+	guint		nsources;
 
 	long		bytesget;
 	long		bytesdownload;
 
 	/* how many files I have already downloaded or which I'm currently
 	 * downloading */
-	gint		filesget;
+	guint		filesget;
 	/* how many files I have to download */
-	gint		filesdownload;
+	guint		filesdownload;
 
 	gint		percentage;
-
 	gint		subpercentage;
 } PercentageData;
 
+typedef enum {
+	PB_RPM_STATE_ENUM_NONE = 0,
+	PB_RPM_STATE_ENUM_INSTALLING = (1 << 1),
+	PB_RPM_STATE_ENUM_REPACKAGING = (1 << 2)
+} PbRpmState;
+
 /* I need this to avoid showing error messages more than once.
  * It's initalized by backend_initalize() and destroyed by
  * backend_destroy(), but every method should clean it at the
  * end. */
 typedef struct {
+	PbRpmState	rpmstate;
+
 	/* last 'vfff: foo' message */
 	gchar		*vfffmsg;
 
@@ -279,18 +286,6 @@ poldek_vf_progress (void *bar, long total, long amount)
 	if (ts_type == TS_TYPE_ENUM_INSTALL ||
 	    ts_type == TS_TYPE_ENUM_UPDATE)
 		pk_backend_set_sub_percentage (backend, pd->subpercentage);
-
-	if (ts_type != TS_TYPE_ENUM_REFRESH_CACHE) {
-		if (pd->filesget == pd->filesdownload) {
-			/* we shouldn't cancel packages installation proccess */
-			poldek_backend_set_allow_cancel (backend, FALSE, FALSE);
-
-			if (ts_type == TS_TYPE_ENUM_INSTALL)
-				pk_backend_set_status (backend, PK_STATUS_ENUM_INSTALL);
-			else if (ts_type == TS_TYPE_ENUM_UPDATE)
-				pk_backend_set_status (backend, PK_STATUS_ENUM_UPDATE);
-		}
-	}
 }
 
 static void
@@ -343,98 +338,93 @@ poldek_pkg_in_array (const struct pkg *pkg, const tn_array *array, tn_fn_cmp cmp
 static int
 ts_confirm (void *data, struct poldek_ts *ts)
 {
-	tn_array	*ipkgs = NULL, *dpkgs = NULL, *rpkgs = NULL, *upkgs = NULL;
+	tn_array	*ipkgs, *dpkgs, *rpkgs;
 	PkBackend	*backend = (PkBackend *)data;
 	gint		i = 0, result = 1;
-	PercentageData *pd = pk_backend_get_pointer (backend, "percentage_ptr");
-	guint ts_type = pk_backend_get_uint (backend, "ts_type");
-	gboolean allow_deps;
 
 	ipkgs = poldek_ts_get_summary (ts, "I");
 	dpkgs = poldek_ts_get_summary (ts, "D");
 	rpkgs = poldek_ts_get_summary (ts, "R");
 
-	switch (poldek_ts_get_type (ts)) {
-		case POLDEK_TS_TYPE_INSTALL:
-			upkgs = n_array_new (4, (tn_fn_free)pkg_free, NULL);
+	if (poldek_ts_get_type (ts) == POLDEK_TS_TYPE_INSTALL) {
+		tn_array *update_pkgs, *remove_pkgs, *install_pkgs;
+		PercentageData *pd = pk_backend_get_pointer (backend, "percentage_ptr");
+		guint to_install = 0;
 
-			pd->step = 0;
+		update_pkgs = n_array_new (4, (tn_fn_free)pkg_free, NULL);
+		remove_pkgs = n_array_new (4, (tn_fn_free)pkg_free, NULL);
+		install_pkgs = n_array_new (4, (tn_fn_free)pkg_free, NULL);
 
-			pd->bytesget = 0;
-			pd->bytesdownload = poldek_get_bytes_to_download (ts);
+		pd->step = 0;
 
-			pd->filesget = 0;
-			pd->filesdownload = poldek_get_files_to_download (ts);
+		pd->bytesget = 0;
+		pd->bytesdownload = poldek_get_bytes_to_download (ts);
 
-			/* create an array with pkgs which will be updated */
-			if (rpkgs) {
-				for (i = 0; i < n_array_size (rpkgs); i++) {
-					struct pkg	*rpkg = n_array_nth (rpkgs, i);
+		pd->filesget = 0;
+		pd->filesdownload = poldek_get_files_to_download (ts);
 
-					if (poldek_pkg_in_array (rpkg, ipkgs, (tn_fn_cmp)pkg_cmp_name))
-						n_array_push (upkgs, pkg_link (rpkg));
-					else if (poldek_pkg_in_array (rpkg, dpkgs, (tn_fn_cmp)pkg_cmp_name))
-						n_array_push (upkgs, pkg_link (rpkg));
-				}
-			}
+		pberror->rpmstate = PB_RPM_STATE_ENUM_NONE;
 
-			if (rpkgs) {
-				for (i = 0; i < n_array_size (rpkgs); i++) {
-					struct pkg	*rpkg = n_array_nth (rpkgs, i);
+		/* create an array with pkgs which will be updated */
+		if (rpkgs) {
+			for (i = 0; i < n_array_size (rpkgs); i++) {
+				struct pkg	*rpkg = n_array_nth (rpkgs, i);
 
-					if (!poldek_pkg_in_array (rpkg, upkgs, (tn_fn_cmp)pkg_cmp_name))
-						poldek_backend_package (backend, rpkg, PK_INFO_ENUM_REMOVING);
-				}
+				if (poldek_pkg_in_array (rpkg, ipkgs, (tn_fn_cmp)pkg_cmp_name))
+					n_array_push (update_pkgs, pkg_link (rpkg));
+				else if (poldek_pkg_in_array (rpkg, dpkgs, (tn_fn_cmp)pkg_cmp_name))
+					n_array_push (update_pkgs, pkg_link (rpkg));
+				else
+					n_array_push (remove_pkgs, pkg_link (rpkg));
 			}
+		}
 
-			if (dpkgs) {
-				for (i = 0; i < n_array_size (dpkgs); i++) {
-					struct pkg	*dpkg = n_array_nth (dpkgs, i);
+		/* create an array with pkgs which will be installed */
+		if (ipkgs) {
+			for (i = 0; i < n_array_size (ipkgs); i++) {
+				struct pkg *ipkg = n_array_nth (ipkgs, i);
 
-					if (!poldek_pkg_in_array (dpkg, upkgs, (tn_fn_cmp)pkg_cmp_name))
-						poldek_backend_package (backend, dpkg, PK_INFO_ENUM_INSTALLING);
-				}
+				if (poldek_pkg_in_array (ipkg, update_pkgs, (tn_fn_cmp)pkg_cmp_name) == FALSE)
+					n_array_push (install_pkgs, pkg_link (ipkg));
 			}
+		}
+		if (dpkgs) {
+			for (i = 0; i < n_array_size (dpkgs); i++) {
+				struct pkg *dpkg = n_array_nth (dpkgs, i);
 
-			if (ipkgs) {
-				for (i = 0; i < n_array_size (ipkgs); i++) {
-					struct pkg	*ipkg = n_array_nth (ipkgs, i);
-
-					if (!poldek_pkg_in_array (ipkg, upkgs, (tn_fn_cmp)pkg_cmp_name))
-						poldek_backend_package (backend, ipkg, PK_INFO_ENUM_INSTALLING);
-				}
+				if (poldek_pkg_in_array (dpkg, update_pkgs, (tn_fn_cmp)pkg_cmp_name) == FALSE)
+					n_array_push (install_pkgs, pkg_link (dpkg));
 			}
+		}
 
-			for (i = 0; i < n_array_size (upkgs); i++) {
-				struct pkg	*upkg = n_array_nth (upkgs, i);
+		/* packages to install & update */
+		to_install = n_array_size (install_pkgs);
+		to_install += n_array_size (update_pkgs);
 
-				poldek_backend_package (backend, upkg, PK_INFO_ENUM_UPDATING);
-			}
+		pk_backend_set_uint (backend, "to_install", to_install);
 
-			/* set proper status if there are no packages to download */
-			if (result == 1 && pd->filesdownload == 0) {
-				/* we shouldn't cancel packages installation proccess */
-				poldek_backend_set_allow_cancel (backend, FALSE, FALSE);
+		pk_backend_set_pointer (backend, "to_update_pkgs", update_pkgs);
+		pk_backend_set_pointer (backend, "to_remove_pkgs", remove_pkgs);
+		pk_backend_set_pointer (backend, "to_install_pkgs", install_pkgs);
+	} else if (poldek_ts_get_type (ts) == POLDEK_TS_TYPE_UNINSTALL) {
+		gboolean allow_deps = pk_backend_get_bool (backend, "allow_deps");
 
-				if (ts_type == TS_TYPE_ENUM_INSTALL)
-					pk_backend_set_status (backend, PK_STATUS_ENUM_INSTALL);
-				else if (ts_type == TS_TYPE_ENUM_UPDATE)
-					pk_backend_set_status (backend, PK_STATUS_ENUM_UPDATE);
+		/* check if transaction can be performed */
+		if (allow_deps == FALSE) {
+			if (dpkgs && n_array_size (dpkgs) > 0) {
+				result = 0;
 			}
+		}
 
-			n_array_free (upkgs);
+		if (result == 1) { /* remove is allowed */
+			pk_backend_set_status (backend, PK_STATUS_ENUM_REMOVE);
 
-			break;
-		case POLDEK_TS_TYPE_UNINSTALL:
-			if (dpkgs) {
-				allow_deps = pk_backend_get_bool (backend, "allow_deps");
-				if ((allow_deps == FALSE) && (n_array_size (dpkgs) > 0)) {
-					result = 0;
-					break;
-				}
+			/* we shouldn't cancel remove proccess */
+			poldek_backend_set_allow_cancel (backend, FALSE, FALSE);
 
+			if (dpkgs) {
 				for (i = 0; i < n_array_size (dpkgs); i++) {
-					struct pkg	*pkg = n_array_nth (dpkgs, i);
+					struct pkg *pkg = n_array_nth (dpkgs, i);
 
 					poldek_backend_package (backend, pkg, PK_INFO_ENUM_REMOVING);
 				}
@@ -442,19 +432,12 @@ ts_confirm (void *data, struct poldek_ts *ts)
 
 			if (rpkgs) {
 				for (i = 0; i < n_array_size (rpkgs); i++) {
-					struct pkg	*pkg = n_array_nth (rpkgs, i);
+					struct pkg *pkg = n_array_nth (rpkgs, i);
 
 					poldek_backend_package (backend, pkg, PK_INFO_ENUM_REMOVING);
 				}
 			}
-
-			/* set proper status if removing will be performed */
-			if (result == 1) {
-				poldek_backend_set_allow_cancel (backend, FALSE, FALSE);
-				pk_backend_set_status (backend, PK_STATUS_ENUM_REMOVE);
-			}
-
-			break;
+		}
 	}
 
 	n_array_cfree (&ipkgs);
@@ -1487,12 +1470,95 @@ pb_error_clean (void)
 	g_free (pberror->vfffmsg);
 
 	pberror->tslog = g_string_erase (pberror->tslog, 0, -1);
+	pberror->rpmstate = PB_RPM_STATE_ENUM_NONE;
+}
+
+static gint
+pkg_n_strncmp (struct pkg *p, gchar *name)
+{
+	g_return_val_if_fail (p != NULL, -1);
+	g_return_val_if_fail (p->name != NULL, -1);
+	g_return_val_if_fail (name != NULL, 1);
+
+	return strncmp (p->name, name, strlen (name));
+}
+
+static void
+show_rpm_progress (PkBackend *backend, gchar *message)
+{
+	g_return_if_fail (message != NULL);
+
+	if (pberror->rpmstate & PB_RPM_STATE_ENUM_REPACKAGING) {
+		pk_debug ("repackaging '%s'", message);
+	} else if (pberror->rpmstate & PB_RPM_STATE_ENUM_INSTALLING) {
+		tn_array *upkgs, *ipkgs, *rpkgs, *arr = NULL;
+		guint to_install;
+		PkInfoEnum pkinfo;
+		gint n = -2;
+
+		pk_debug ("installing or updating '%s'", message);
+
+		to_install = pk_backend_get_uint (backend, "to_install");
+
+		ipkgs = pk_backend_get_pointer (backend, "to_install_pkgs");
+		upkgs = pk_backend_get_pointer (backend, "to_update_pkgs");
+		rpkgs = pk_backend_get_pointer (backend, "to_remove_pkgs");
+
+		/* emit remove for packages marked for removal */
+		if (rpkgs) {
+			gint i;
+
+			/* XXX: don't release rpkgs array here! */
+			for (i = 0; i < n_array_size (rpkgs); i++) {
+				struct pkg *pkg = n_array_nth (rpkgs, i);
+
+				poldek_backend_package (backend, pkg, PK_INFO_ENUM_REMOVING);
+
+				n_array_remove_nth (rpkgs, i);
+			}
+		}
+
+		if (upkgs) {
+			n = n_array_bsearch_idx_ex (upkgs, message, (tn_fn_cmp)pkg_n_strncmp);
+		}
+
+		if (n >= 0) {
+			pkinfo = PK_INFO_ENUM_UPDATING;
+			arr = upkgs;
+		} else if (ipkgs) {
+			n = n_array_bsearch_idx_ex (ipkgs, message, (tn_fn_cmp)pkg_n_strncmp);
+
+			if (n >= 0) {
+				pkinfo = PK_INFO_ENUM_INSTALLING;
+				arr = ipkgs;
+			}
+		}
+
+		if (arr) {
+			struct pkg *pkg = n_array_nth (arr, n);
+			guint in_arrays = 0;
+
+			poldek_backend_package (backend, pkg, pkinfo);
+
+			n_array_remove_nth (arr, n);
+
+			if (upkgs) {
+				in_arrays += n_array_size (upkgs);
+			}
+			if (ipkgs) {
+				in_arrays += n_array_size (ipkgs);
+			}
+
+			pk_backend_set_percentage (backend, (gint)(((float)(to_install - in_arrays) / (float)to_install) * 100));
+		}
+	}
 }
 
 static void
 poldek_backend_log (void *data, int pri, char *message)
 {
 	PkBackend *backend = (PkBackend*)data;
+	gchar *p;
 
 	/* skip messages that we don't want to show */
 	if (g_str_has_prefix (message, "Nothing")) // 'Nothing to do'
@@ -1526,6 +1592,52 @@ poldek_backend_log (void *data, int pri, char *message)
 			g_string_append_printf (pberror->tslog, "%s", message);
 		}
 	}
+
+	if (strstr (message, "Preparing...")) {
+		pberror->rpmstate |= PB_RPM_STATE_ENUM_INSTALLING;
+
+		/* we shouldn't cancel install / update proccess */
+		poldek_backend_set_allow_cancel (backend, FALSE, FALSE);
+	} else if (strstr (message, "Repackaging...")) {
+		pberror->rpmstate |= PB_RPM_STATE_ENUM_REPACKAGING;
+
+		pk_backend_set_status (backend, PK_STATUS_ENUM_REPACKAGING);
+	} else if (strstr (message, "Upgrading...")) {
+		pberror->rpmstate &= (~PB_RPM_STATE_ENUM_REPACKAGING);
+	}
+	if (pberror->rpmstate != PB_RPM_STATE_ENUM_NONE) {
+		p = g_strchug (message);
+		if (p && g_ascii_isdigit(*p)) {
+			gchar *n;
+
+			/* extract package name */
+			if ((n = strchr (p, ':') + 1) == NULL)
+				return;
+
+			p = n;
+
+			while (*p != '\0') {
+				if (g_ascii_isspace (*p)) {
+					*p = '\0';
+					break;
+				}
+				p++;
+			}
+
+			if ((pberror->rpmstate & PB_RPM_STATE_ENUM_REPACKAGING) == FALSE) {
+				guint ts_type = pk_backend_get_uint (backend, "ts_type");
+
+				/* set proper status */
+				if (ts_type == TS_TYPE_ENUM_INSTALL) {
+					pk_backend_set_status (backend, PK_STATUS_ENUM_INSTALL);
+				} else if (ts_type == TS_TYPE_ENUM_UPDATE) {
+					pk_backend_set_status (backend, PK_STATUS_ENUM_UPDATE);
+				}
+			}
+
+			show_rpm_progress (backend, n);
+		}
+	}
 }
 
 static void
@@ -1550,8 +1662,18 @@ static void
 poldek_backend_percentage_data_destroy (PkBackend *backend)
 {
 	PercentageData *data;
+	tn_array *upkgs, *ipkgs, *rpkgs;
 
 	data = (gpointer) pk_backend_get_pointer (backend, "percentage_ptr");
+
+	upkgs = (gpointer) pk_backend_get_pointer (backend, "to_update_pkgs");
+	ipkgs = (gpointer) pk_backend_get_pointer (backend, "to_install_pkgs");
+	rpkgs = (gpointer) pk_backend_get_pointer (backend, "to_remove_pkgs");
+
+	n_array_cfree (&upkgs);
+	n_array_cfree (&ipkgs);
+	n_array_cfree (&rpkgs);
+
 	g_free (data);
 }
 
@@ -2135,6 +2257,8 @@ backend_install_packages_thread (PkBackend *backend)
 	ts = poldek_ts_new (ctx, 0);
 	rcmd = poclidek_rcmd_new (cctx, ts);
 
+	ts->setop(ts, POLDEK_OP_PARTICLE, 0);
+
 	cmd = g_string_new ("install ");
 
 	/* prepare command */
commit 688a6d3492a42455a5148e266f6be0193575d9eb
Author: Tim Lauridsen <timlau at fedoraproject.org>
Date:   Fri Jun 13 12:56:02 2008 +0200

    yum: added newest support to group-search and get_packages

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 0a7591d..d98dd3b 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -337,13 +337,13 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         # basename filter if specified
         if FILTER_BASENAME in fltlist:
             package_list = self._basename_filter(package_list)
-        
-        # newest filter        
+
+        # newest filter
         if FILTER_NEWEST in fltlist:
             package_list = self._do_newest_filtering(package_list)
-                
+
         self._show_package_list(package_list)
-                
+
     def _show_package_list(self,lst):
         for (pkg,status) in lst:
             self._show_package(pkg,status)
@@ -359,8 +359,8 @@ class PackageKitYumBackend(PackageKitBaseBackend):
                 continue
             newest[key] = (pkg,state)
         return newest.values()
-        
-                        
+
+
 
     def _do_extra_filtering(self,pkg,filterList):
         ''' do extra filtering (gui,devel etc) '''
@@ -523,11 +523,13 @@ class PackageKitYumBackend(PackageKitBaseBackend):
 
         # basename filter if specified
         if FILTER_BASENAME in fltlist:
-            for (pkg,status) in self._basename_filter(package_list):
-                self._show_package(pkg,status)
-        else:
-            for (pkg,status) in package_list:
-                self._show_package(pkg,status)
+            package_list = self._basename_filter(package_list)
+
+        # newest filter
+        if FILTER_NEWEST in fltlist:
+            package_list = self._do_newest_filtering(package_list)
+
+        self._show_package_list(package_list)
 
     @handle_repo_error
     def get_packages(self,filters):
@@ -559,11 +561,13 @@ class PackageKitYumBackend(PackageKitBaseBackend):
 
         # basename filter if specified
         if FILTER_BASENAME in fltlist:
-            for (pkg,status) in self._basename_filter(package_list):
-                self._show_package(pkg,status)
-        else:
-            for (pkg,status) in package_list:
-                self._show_package(pkg,status)
+            package_list = self._basename_filter(package_list)
+
+        # newest filter
+        if FILTER_NEWEST in fltlist:
+            package_list = self._do_newest_filtering(package_list)
+
+        self._show_package_list(package_list)
 
     @handle_repo_error
     def search_file(self,filters,key):
commit 158a24c608bdcc59bb8f19a89d9c6745674a635e
Author: Richard Hughes <richard at hughsie.com>
Date:   Fri Jun 13 11:40:33 2008 +0100

    yum: we now support the NEWEST filter

diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c
index 69e2701..b867f75 100644
--- a/backends/yum/pk-backend-yum.c
+++ b/backends/yum/pk-backend-yum.c
@@ -86,7 +86,8 @@ backend_get_filters (PkBackend *backend)
 		PK_FILTER_ENUM_INSTALLED |
 		PK_FILTER_ENUM_DEVELOPMENT |
 		PK_FILTER_ENUM_BASENAME |
-		PK_FILTER_ENUM_FREE);
+		PK_FILTER_ENUM_FREE |
+		PK_FILTER_ENUM_NEWEST);
 }
 
 /**
commit 926629f9f87c0a36a040bb683c7ea9a1ebfc2077
Author: Tim Lauridsen <timlau at fedoraproject.org>
Date:   Fri Jun 13 12:26:20 2008 +0200

    yum: implemented the newest filter

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 10ff660..0a7591d 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -336,11 +336,31 @@ class PackageKitYumBackend(PackageKitBaseBackend):
 
         # basename filter if specified
         if FILTER_BASENAME in fltlist:
-            for (pkg,status) in self._basename_filter(package_list):
-                self._show_package(pkg,status)
-        else:
-            for (pkg,status) in package_list:
-                self._show_package(pkg,status)
+            package_list = self._basename_filter(package_list)
+        
+        # newest filter        
+        if FILTER_NEWEST in fltlist:
+            package_list = self._do_newest_filtering(package_list)
+                
+        self._show_package_list(package_list)
+                
+    def _show_package_list(self,lst):
+        for (pkg,status) in lst:
+            self._show_package(pkg,status)
+
+    def _do_newest_filtering(self,pkglist):
+        '''
+        Only return the newest package for each name.arch
+        '''
+        newest = {}
+        for pkg,state in pkglist:
+            key = (pkg.name, pkg.arch)
+            if key in newest and pkg <= newest[key][0]:
+                continue
+            newest[key] = (pkg,state)
+        return newest.values()
+        
+                        
 
     def _do_extra_filtering(self,pkg,filterList):
         ''' do extra filtering (gui,devel etc) '''


More information about the PackageKit-commit mailing list