[PackageKit-commit] packagekit: Branch 'PACKAGEKIT_0_6_X' - 20 commits

Richard Hughes hughsient at kemper.freedesktop.org
Mon Nov 7 03:03:59 PST 2011


 NEWS                               |   21 ++++
 RELEASE                            |   11 +-
 backends/entropy/entropyBackend.py |   60 ++++++++++---
 backends/yum/yumBackend.py         |    7 +
 backends/zif/pk-backend-zif.c      |  164 ++++++++++++++++++++++---------------
 backends/zypp/pk-backend-zypp.cpp  |    3 
 backends/zypp/zypp-utils.cpp       |    9 ++
 configure.ac                       |    2 
 contrib/PackageKit.spec.in         |    4 
 docs/html/pk-download.html         |    2 
 lib/python/packagekit/backend.py   |   45 ++++++++++
 src/pk-backend-spawn.c             |  120 +++++++++++++++------------
 src/pk-backend.c                   |   27 ++++++
 src/pk-backend.h                   |    4 
 src/pk-main.c                      |   12 ++
 src/run-pk.sh                      |    2 
 16 files changed, 346 insertions(+), 147 deletions(-)

New commits:
commit feba3e98845975a459866bde3b12c0266e6b806f
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Nov 7 11:02:10 2011 +0000

    Release version 0.6.20

diff --git a/NEWS b/NEWS
index 37792d9..d881f6d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,24 @@
+Version 0.6.20
+~~~~~~~~~~~~~~
+Released: 2011-11-07
+
+Libraries:
+ - python: Implement and use utf8 stream writer for stdout, stderr (Nils Philippsen)
+
+Backends:
+ - entropy: Add forward compatibility with upcoming API changes (Fabio Erculiani)
+ - entropy: Update entropy library path (Fabio Erculiani)
+ - yum: Add ourselves to YumBase.run_with_package_names (Nils Philippsen)
+ - yum: Don't let yum.misc.setup_locale() override stdout codec (Nils Philippsen)
+ - zif: Always show the update metadata if available by using the correct repo (Richard Hughes)
+ - zif: Do not report packages as installable if they are already installed (Richard Hughes)
+ - zif: Refresh the cache rather than just cleaning it for RefreshCache (Richard Hughes)
+ - zypp: Dont call build pool inside the loop (Duncan Mac-Vicar P)
+ - zypp: Only load repositories once (Duncan Mac-Vicar P)
+
+New Features:
+ - Add command line option to keep environment (Nils Philippsen)
+
 Version 0.6.19
 ~~~~~~~~~~~~~~
 Released: 2011-10-04
diff --git a/docs/html/pk-download.html b/docs/html/pk-download.html
index f4bfbaf..c8a97aa 100644
--- a/docs/html/pk-download.html
+++ b/docs/html/pk-download.html
@@ -72,6 +72,8 @@ Releases are normally on the first working Monday of each month.
 </p>
 <table>
 <tr><td><b>Version</b></td><td>&nbsp;&nbsp;</td><td><b>Date</b></td></tr>
+<tr><td>0.6.20</td><td></td><td>2011-11-07</td></tr>
+<tr><td>0.6.19</td><td></td><td>2011-10-04</td></tr>
 <tr><td>0.6.18</td><td></td><td>2011-09-05</td></tr>
 <tr><td>0.6.17</td><td></td><td>2011-08-01</td></tr>
 <tr><td>0.6.16</td><td></td><td>2011-07-04</td></tr>
commit 98688b30caa1997c7510befbdeff0cca82245f35
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Nov 1 11:07:55 2011 +0000

    zif: Don't call zif_init() in newer versions of the library

diff --git a/backends/zif/pk-backend-zif.c b/backends/zif/pk-backend-zif.c
index fb5b15b..c7aec99 100644
--- a/backends/zif/pk-backend-zif.c
+++ b/backends/zif/pk-backend-zif.c
@@ -1579,8 +1579,10 @@ pk_backend_initialize (PkBackend *backend)
 	g_list_foreach (mounts, (GFunc) g_object_unref, NULL);
 	g_list_free (mounts);
 
+#if !ZIF_CHECK_VERSION(0,2,6)
 	/* init rpm */
 	zif_init ();
+#endif
 
 	/* TODO: hook up errors */
 	priv->cancellable = g_cancellable_new ();
commit 1f0cfd364987c0ead5b3da65752c8b991f97b8bb
Author: Richard Hughes <richard at hughsie.com>
Date:   Fri Oct 21 17:43:07 2011 +0100

    zif: Always show the update metadata if available by using the correct repo

diff --git a/backends/zif/pk-backend-zif.c b/backends/zif/pk-backend-zif.c
index e658792..fb5b15b 100644
--- a/backends/zif/pk-backend-zif.c
+++ b/backends/zif/pk-backend-zif.c
@@ -3217,6 +3217,16 @@ pk_backend_get_changelog_text (GPtrArray *changesets)
 }
 
 /**
+ * pk_backend_sort_stores_cb:
+ **/
+static gint
+pk_backend_sort_stores_cb (ZifStore **a, ZifStore **b)
+{
+	return g_strcmp0 (zif_store_get_id (*b),
+			  zif_store_get_id (*a));
+}
+
+/**
  * pk_backend_get_update_detail_thread:
  */
 static gboolean
@@ -3258,6 +3268,12 @@ pk_backend_get_update_detail_thread (PkBackend *backend)
 		goto out;
 	}
 
+	/* sort the store array so updates repos are listed first, for
+	 * when the exact same package version is present in 'updates'
+	 * -and- 'fedora' */
+	g_ptr_array_sort (store_array,
+			  (GCompareFunc) pk_backend_sort_stores_cb);
+
 	/* this section done */
 	ret = zif_state_done (priv->state, &error);
 	if (!ret) {
commit 279f4296c8d9acc98c488970eebe5136f0d42103
Author: Richard Hughes <richard at hughsie.com>
Date:   Fri Oct 21 17:24:16 2011 +0100

    zif: Ensure the downloading status is set correctly

diff --git a/backends/zif/pk-backend-zif.c b/backends/zif/pk-backend-zif.c
index 3f502f4..e658792 100644
--- a/backends/zif/pk-backend-zif.c
+++ b/backends/zif/pk-backend-zif.c
@@ -1450,12 +1450,10 @@ pk_backend_state_action_changed_cb (ZifState *state,
 	case ZIF_STATE_ACTION_DOWNLOADING:
 		/* try to map the ZifStateAction to a PkStatusEnum */
 		if (zif_package_id_check (action_hint)) {
-			status = PK_STATUS_ENUM_DOWNLOAD;
 			pk_backend_package (backend,
 					    PK_INFO_ENUM_DOWNLOADING,
 					    action_hint,
 					    "");
-			break;
 		}
 		if (g_strrstr (action_hint, "repomd") != NULL)
 			status = PK_STATUS_ENUM_DOWNLOAD_REPOSITORY;
@@ -1469,6 +1467,8 @@ pk_backend_state_action_changed_cb (ZifState *state,
 			status = PK_STATUS_ENUM_DOWNLOAD_GROUP;
 		else if (g_strrstr (action_hint, "updatinfo") != NULL)
 			status = PK_STATUS_ENUM_DOWNLOAD_UPDATEINFO;
+		else
+			status = PK_STATUS_ENUM_DOWNLOAD;
 		break;
 	case ZIF_STATE_ACTION_CHECKING:
 	case ZIF_STATE_ACTION_LOADING_REPOS:
commit 3be5c0fbab797a181ff4bd39aac98f13e7ca99bc
Author: Richard Hughes <richard at hughsie.com>
Date:   Fri Oct 21 12:44:53 2011 +0100

    zif: Add an unhandled ZifStateAction mapping
    
    Also convert to a switch so the compiler warns us of this in the future.

diff --git a/backends/zif/pk-backend-zif.c b/backends/zif/pk-backend-zif.c
index 4f21ffd..3f502f4 100644
--- a/backends/zif/pk-backend-zif.c
+++ b/backends/zif/pk-backend-zif.c
@@ -1432,23 +1432,30 @@ pk_backend_status_changed_cb (PkBackend *backend, PkStatusEnum status, gpointer
  * pk_backend_state_action_changed_cb:
  **/
 static void
-pk_backend_state_action_changed_cb (ZifState *state, ZifStateAction action, const gchar *action_hint, PkBackend *backend)
+pk_backend_state_action_changed_cb (ZifState *state,
+				    ZifStateAction action,
+				    const gchar *action_hint,
+				    PkBackend *backend)
 {
 	PkStatusEnum status = PK_STATUS_ENUM_UNKNOWN;
 
-	/* ignore this */
-	if (action == ZIF_STATE_ACTION_UNKNOWN)
-		goto out;
+	g_debug ("got state %s with hint %s",
+		 zif_state_action_to_string (action),
+		 action_hint);
 
-	/* try to map the ZifStateAction to a PkStatusEnum */
-	if (action == ZIF_STATE_ACTION_DOWNLOADING) {
+	switch (action) {
+	case ZIF_STATE_ACTION_UNKNOWN:
+		/* ignore this */
+		break;
+	case ZIF_STATE_ACTION_DOWNLOADING:
+		/* try to map the ZifStateAction to a PkStatusEnum */
 		if (zif_package_id_check (action_hint)) {
 			status = PK_STATUS_ENUM_DOWNLOAD;
 			pk_backend_package (backend,
 					    PK_INFO_ENUM_DOWNLOADING,
 					    action_hint,
 					    "");
-			goto out;
+			break;
 		}
 		if (g_strrstr (action_hint, "repomd") != NULL)
 			status = PK_STATUS_ENUM_DOWNLOAD_REPOSITORY;
@@ -1462,79 +1469,62 @@ pk_backend_state_action_changed_cb (ZifState *state, ZifStateAction action, cons
 			status = PK_STATUS_ENUM_DOWNLOAD_GROUP;
 		else if (g_strrstr (action_hint, "updatinfo") != NULL)
 			status = PK_STATUS_ENUM_DOWNLOAD_UPDATEINFO;
-		goto out;
-	}
-
-	/* general cache loading */
-	if (action == ZIF_STATE_ACTION_CHECKING ||
-	    action == ZIF_STATE_ACTION_LOADING_REPOS ||
+		break;
+	case ZIF_STATE_ACTION_CHECKING:
+	case ZIF_STATE_ACTION_LOADING_REPOS:
+	case ZIF_STATE_ACTION_DECOMPRESSING:
 #if ZIF_CHECK_VERSION(0,2,4)
-	    action == ZIF_STATE_ACTION_LOADING_RPMDB ||
+	case ZIF_STATE_ACTION_LOADING_RPMDB:
 #endif
-	    action == ZIF_STATE_ACTION_DECOMPRESSING) {
+		/* general cache loading */
 		status = PK_STATUS_ENUM_LOADING_CACHE;
-		goto out;
-	}
-
-	/* package install */
-	if (action == ZIF_STATE_ACTION_INSTALLING) {
+		break;
+	case ZIF_STATE_ACTION_INSTALLING:
+		/* package install */
 		status = PK_STATUS_ENUM_INSTALL;
 		pk_backend_package (backend,
 				    PK_INFO_ENUM_INSTALLING,
 				    action_hint,
 				    "");
-		goto out;
-	}
-
-	/* package remove */
-	if (action == ZIF_STATE_ACTION_REMOVING) {
+		break;
+	case ZIF_STATE_ACTION_REMOVING:
 		status = PK_STATUS_ENUM_REMOVE;
 		pk_backend_package (backend,
 				    PK_INFO_ENUM_REMOVING,
 				    action_hint,
 				    "");
-		goto out;
-	}
-
-	/* package update */
-	if (action == ZIF_STATE_ACTION_UPDATING) {
+		break;
+	case ZIF_STATE_ACTION_UPDATING:
 		status = PK_STATUS_ENUM_UPDATE;
 		pk_backend_package (backend,
 				    PK_INFO_ENUM_UPDATING,
 				    action_hint,
 				    "");
-		goto out;
-	}
-
-	/* package update */
-	if (action == ZIF_STATE_ACTION_CLEANING) {
+		break;
+	case ZIF_STATE_ACTION_CLEANING:
 		status = PK_STATUS_ENUM_CLEANUP;
 		pk_backend_package (backend,
 				    PK_INFO_ENUM_CLEANUP,
 				    action_hint,
 				    "");
-		goto out;
-	}
-
-	/* rpm test commit */
-	if (action == ZIF_STATE_ACTION_TEST_COMMIT) {
+		break;
+	case ZIF_STATE_ACTION_TEST_COMMIT:
 		status = PK_STATUS_ENUM_TEST_COMMIT;
-		goto out;
-	}
-
-	/* depsolving */
-	if (action == ZIF_STATE_ACTION_DEPSOLVING_CONFLICTS ||
-	    action == ZIF_STATE_ACTION_DEPSOLVING_INSTALL ||
-	    action == ZIF_STATE_ACTION_DEPSOLVING_REMOVE ||
+		break;
+	case ZIF_STATE_ACTION_DEPSOLVING_CONFLICTS:
+	case ZIF_STATE_ACTION_DEPSOLVING_INSTALL:
+	case ZIF_STATE_ACTION_DEPSOLVING_REMOVE:
+	case ZIF_STATE_ACTION_DEPSOLVING_UPDATE:
 #if ZIF_CHECK_VERSION(0,2,4)
-	    action == ZIF_STATE_ACTION_CHECKING_UPDATES ||
+	case ZIF_STATE_ACTION_CHECKING_UPDATES:
 #endif
-	    action == ZIF_STATE_ACTION_DEPSOLVING_UPDATE) {
 		status = PK_STATUS_ENUM_DEP_RESOLVE;
-		goto out;
+		break;
+	case ZIF_STATE_ACTION_PREPARING:
+		status = PK_STATUS_ENUM_TEST_COMMIT;
+	/* deliberately no "default:" as we want to be notified of
+	 * unhandled enums by the compiler */
 	}
-
-out:
 	if (status != PK_STATUS_ENUM_UNKNOWN)
 		pk_backend_set_status (backend, status);
 }
commit 9d6c8ff195e1fa4218b1c0a52bbe57dd36c47679
Author: Richard Hughes <richard at hughsie.com>
Date:   Fri Oct 21 12:22:09 2011 +0100

    zif: Do not report packages as installable if they are already installed

diff --git a/backends/zif/pk-backend-zif.c b/backends/zif/pk-backend-zif.c
index 73a6fda..4f21ffd 100644
--- a/backends/zif/pk-backend-zif.c
+++ b/backends/zif/pk-backend-zif.c
@@ -399,16 +399,37 @@ out:
 static GPtrArray *
 pk_backend_filter_package_array (GPtrArray *array, PkBitfield filters)
 {
+	GHashTable *hash_installed;
+	gpointer found;
 	GPtrArray *result = NULL;
 	guint i;
 	ZifPackage *package;
 
+	hash_installed = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL);
 	result = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
 
+	/* do not show a remote package if the same version is installed */
+	for (i=0;i<array->len;i++) {
+		package = g_ptr_array_index (array, i);
+		if (!zif_package_is_installed (package))
+			continue;
+		g_hash_table_insert (hash_installed,
+				     (gpointer) zif_package_get_name_version_arch (package),
+				     GINT_TO_POINTER (1));
+	}
+
 	/* pre-result */
 	for (i=0;i<array->len;i++) {
 		package = g_ptr_array_index (array, i);
 
+		/* is installed package existing? */
+		if (!zif_package_is_installed (package)) {
+			found = g_hash_table_lookup (hash_installed,
+						     zif_package_get_name_version_arch (package));
+			if (found != NULL)
+				continue;
+		}
+
 		/* installed */
 		if (pk_bitfield_contain (filters,
 					 PK_FILTER_ENUM_INSTALLED)) {
@@ -472,6 +493,7 @@ pk_backend_filter_package_array (GPtrArray *array, PkBitfield filters)
 	if (pk_bitfield_contain (filters, PK_FILTER_ENUM_NEWEST))
 		zif_package_array_filter_newest (result);
 
+	g_hash_table_destroy (hash_installed);
 	return result;
 }
 
commit 301ce499c525982e22a255c1fe25762b2eed3980
Author: Richard Hughes <richard at hughsie.com>
Date:   Sun Oct 9 08:29:27 2011 +0100

    zif: Refresh the cache rather than just cleaning it for RefreshCache

diff --git a/backends/zif/pk-backend-zif.c b/backends/zif/pk-backend-zif.c
index 1c470b8..73a6fda 100644
--- a/backends/zif/pk-backend-zif.c
+++ b/backends/zif/pk-backend-zif.c
@@ -4369,20 +4369,14 @@ pk_backend_refresh_cache_thread (PkBackend *backend)
 	/* set steps */
 	ret = zif_state_set_steps (priv->state,
 				   NULL,
-				   50, /* get stores */
-				   50, /* refresh them */
+				   5, /* get stores */
+				   95, /* refresh them */
 				   -1);
 	g_assert (ret);
 
 	pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
 	pk_backend_set_percentage (backend, 0);
 
-	/* don't nuke the metadata */
-	if (!force) {
-		g_debug ("not supported yet");
-		goto out;
-	}
-
 	/* get a store_array of remote stores */
 	store_array = zif_store_array_new ();
 	state_local = zif_state_get_child (priv->state);
@@ -4409,17 +4403,29 @@ pk_backend_refresh_cache_thread (PkBackend *backend)
 		goto out;
 	}
 
-	/* clean all the repos */
+	/* refresh all the repos */
 	state_local = zif_state_get_child (priv->state);
 	zif_state_set_error_handler (priv->state, (ZifStateErrorHandlerCb) pk_backend_error_handler_cb, backend);
-	ret = zif_store_array_clean (store_array, state_local, &error);
+	ret = zif_store_array_refresh (store_array, force, state_local, &error);
 	if (!ret) {
 		pk_backend_error_code (backend,
 				       pk_backend_convert_error (error),
-				       "failed to clean: %s", error->message);
+				       "failed to refresh: %s", error->message);
+		g_error_free (error);
+		goto out;
+	}
+
+	/* this section done */
+	ret = zif_state_done (priv->state, &error);
+	if (!ret) {
+		pk_backend_error_code (backend,
+				       PK_ERROR_ENUM_TRANSACTION_CANCELLED,
+				       "cancelled: %s",
+				       error->message);
 		g_error_free (error);
 		goto out;
 	}
+
 out:
 	pk_backend_finished (backend);
 	if (store_array != NULL)
commit 6aca7d622b0e3415e3d80252e6ba44550fa96cc1
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Oct 5 12:43:57 2011 +0100

    trivial: Update the Fedora example spec file

diff --git a/contrib/PackageKit.spec.in b/contrib/PackageKit.spec.in
index c832b2b..1b084d5 100644
--- a/contrib/PackageKit.spec.in
+++ b/contrib/PackageKit.spec.in
@@ -48,7 +48,7 @@ BuildRequires: pango-devel
 BuildRequires: pm-utils-devel
 BuildRequires: fontconfig-devel
 BuildRequires: gobject-introspection-devel
-BuildRequires: zif-devel >= 0.1.3
+BuildRequires: zif-devel >= 0.2.5
 
 # functionality moved to udev itself
 Obsoletes: PackageKit-udev-helper < %{version}-%{release}
@@ -74,7 +74,7 @@ A backend for PackageKit to enable yum functionality.
 %package zif
 Summary: PackageKit Zif backend
 Group: System Environment/Libraries
-Requires: zif >= 0.1.3
+Requires: zif >= 0.2.5
 Requires: %{name} = %{version}-%{release}
 Provides: PackageKit-backend
 
commit 01226fbdfc6cd9f03183048c7531ed324d4b5412
Author: Nils Philippsen <nils at redhat.com>
Date:   Wed Oct 26 17:33:18 2011 +0200

    yum: don't let yum.misc.setup_locale() override stdout codec
    
    Use our own stdout/stderr wrappers, as what codecs.getwriter() supplies
    only works for unicode, but not for already encoded data.
    (cherry picked from commit 31b9a6942a65f8eeeb67c6ea376429e8c5eac43f)

diff --git a/backends/yum/yumBackend.py b/backends/yum/yumBackend.py
index 479ee2d..dfed1a2 100755
--- a/backends/yum/yumBackend.py
+++ b/backends/yum/yumBackend.py
@@ -3482,7 +3482,7 @@ class PackageKitYumBase(yum.YumBase):
             raise PkError(ERROR_FAILED_CONFIG_PARSING, _to_unicode(e))
 
         # setup to use LANG for descriptions
-        yum.misc.setup_locale(override_time=True)
+        yum.misc.setup_locale(override_time=True, override_codecs=False)
 
         self.missingGPGKey = None
         self.dsCallback = DepSolveCallback(backend)
commit a7d50f5f4a9f69e33075fbe05d4ae42158d1b9c9
Author: Nils Philippsen <nils at redhat.com>
Date:   Wed Oct 26 17:31:36 2011 +0200

    python: implement and use utf8 stream writer for stdout, stderr
    
    The C-side (glib) really wants stuff to be encoded in UTF-8.
    (cherry picked from commit b5a5011f31d6062cd00ee6b02ddf356d691e67e6)

diff --git a/lib/python/packagekit/backend.py b/lib/python/packagekit/backend.py
index ae7bbad..4c7fd2c 100644
--- a/lib/python/packagekit/backend.py
+++ b/lib/python/packagekit/backend.py
@@ -37,8 +37,49 @@ def _to_unicode(txt, encoding='utf-8'):
             txt = unicode(txt, encoding, errors='replace')
     return txt
 
+def _to_utf8(txt, errors='replace'):
+    '''convert practically anything to a utf-8-encoded byte string'''
+
+    # convert to unicode object
+    if isinstance(txt, str):
+        txt = txt.decode('utf-8', errors=errors)
+    if not isinstance(txt, basestring):
+        # try to convert non-string objects like exceptions
+        try:
+            # if txt.__unicode__() exists, or txt.__str__() returns ASCII
+            txt = unicode(txt)
+        except UnicodeDecodeError:
+            # if txt.__str__() exists
+            txt = str(txt).decode('utf-8', errors=errors)
+        except:
+            # no __str__(), __unicode__() methods, use representation
+            txt = unicode(repr(txt))
+
+    # return encoded as UTF-8
+    return txt.encode('utf-8', errors=errors)
+
 # Classes
 
+class _UTF8Writer(codecs.StreamWriter):
+
+    encoding = 'utf-8'
+
+    def __init__(self, stream, errors='replace'):
+        codecs.StreamWriter.__init__(self, stream, errors)
+
+    def encode(self, inp, errors='strict'):
+        try:
+            l = len(inp)
+        except TypeError:
+            try:
+                l = len(unicode(inp))
+            except:
+                try:
+                    l = len(str(inp))
+                except:
+                    l = 1
+        return (_to_utf8(inp, errors=errors), l)
+
 class PkError(Exception):
     def __init__(self, code, details):
         self.code = code
@@ -49,6 +90,10 @@ class PkError(Exception):
 class PackageKitBaseBackend:
 
     def __init__(self, cmds):
+        # Make sys.stdout/stderr cope with UTF-8
+        sys.stdout = _UTF8Writer(sys.stdout)
+        sys.stderr = _UTF8Writer(sys.stderr)
+
         # Setup a custom exception handler
         installExceptionHandler(self)
         self.cmds = cmds
commit 7b0cbdd6ee24ce5d4bc3424e1a8afdeca980182f
Author: Nils Philippsen <nils at redhat.com>
Date:   Thu Oct 20 12:05:40 2011 +0200

    Add command line option to keep environment
    
    This allows e.g. setting PYTHONPATH to use python modules not in the
    system paths. Default if run via run-pk.sh, use e.g. "env -u
    ./run-pk.sh" if you want the environment cleared.
    (cherry picked from commit 0220821e00334ebfc2d948c5109e221e9f5ac281)
    
    Conflicts:
    
    	src/pk-backend-spawn.c
    	src/pk-backend.h

diff --git a/src/pk-backend-spawn.c b/src/pk-backend-spawn.c
index 73d3197..7c57c45 100644
--- a/src/pk-backend-spawn.c
+++ b/src/pk-backend-spawn.c
@@ -699,6 +699,9 @@ static gchar **
 pk_backend_spawn_get_envp (PkBackendSpawn *backend_spawn)
 {
 	gchar **envp;
+	gchar **environ;
+	gchar **env_item;
+	gchar **env_item_split;
 	gchar *proxy_http;
 	gchar *proxy_https;
 	gchar *proxy_ftp;
@@ -706,19 +709,41 @@ pk_backend_spawn_get_envp (PkBackendSpawn *backend_spawn)
 	gchar *no_proxy;
 	gchar *pac;
 	gchar *locale;
-	gchar *line;
 	gchar *uri;
 	gchar *eulas;
 	gchar *transaction_id = NULL;
 	const gchar *value;
 	guint i;
 	guint cache_age;
-	GPtrArray *array;
+	GHashTable *env_table;
+	GHashTableIter env_iter;
+	gchar *env_key;
+	gchar *env_value;
 	gboolean ret;
 	PkHintEnum interactive;
 	PkBackendSpawnPrivate *priv = backend_spawn->priv;
 
-	array = g_ptr_array_new_with_free_func (g_free);
+	gboolean keep_environment =
+		pk_backend_get_keep_environment (backend_spawn->priv->backend);
+
+	env_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+
+	g_debug ("keep_environment: %i", keep_environment);
+
+	if (keep_environment) {
+		/* copy environment if so specified (for debugging) */
+		environ = g_get_environ ();
+		for (env_item = environ; env_item && *env_item; env_item++) {
+			env_item_split = g_strsplit (*env_item, "=", 2);
+
+			if (env_item_split && (g_strv_length (env_item_split) == 2))
+				g_hash_table_replace (env_table, g_strdup (env_item_split[0]),
+						g_strdup (env_item_split[1]));
+
+			g_strfreev (env_item_split);
+		}
+		g_strfreev (environ);
+	}
 
 	/* don't do this for all backends as it's a performance penalty */
 	if (FALSE) {
@@ -726,118 +751,107 @@ pk_backend_spawn_get_envp (PkBackendSpawn *backend_spawn)
 		g_object_get (priv->backend,
 			      "transaction-id", &transaction_id,
 			      NULL);
-		line = g_strdup_printf ("%s=%s", "transaction_id", transaction_id);
-		g_ptr_array_add (array, line);
+		g_hash_table_replace (env_table, g_strdup ("transaction_id"),
+				g_strdup (transaction_id));
 	}
 
 	/* accepted eulas */
 	eulas = pk_backend_get_accepted_eula_string (priv->backend);
-	if (eulas != NULL){
-		line = g_strdup_printf ("%s=%s", "accepted_eulas", eulas);
-		g_ptr_array_add (array, line);
-	}
+	if (eulas != NULL)
+		g_hash_table_replace (env_table, g_strdup ("accepted_eulas"), g_strdup (eulas));
 
 	/* http_proxy */
 	proxy_http = pk_backend_get_proxy_http (priv->backend);
 	if (!egg_strzero (proxy_http)) {
 		uri = pk_backend_spawn_convert_uri (proxy_http);
-		line = g_strdup_printf ("%s=%s", "http_proxy", uri);
-		g_ptr_array_add (array, line);
-		g_free (uri);
+		g_hash_table_replace (env_table, g_strdup ("http_proxy"), uri);
 	}
 
 	/* https_proxy */
 	proxy_https = pk_backend_get_proxy_https (priv->backend);
 	if (!egg_strzero (proxy_https)) {
 		uri = pk_backend_spawn_convert_uri (proxy_https);
-		line = g_strdup_printf ("%s=%s", "https_proxy", uri);
-		g_ptr_array_add (array, line);
-		g_free (uri);
+		g_hash_table_replace (env_table, g_strdup ("https_proxy"), uri);
 	}
 
 	/* ftp_proxy */
 	proxy_ftp = pk_backend_get_proxy_ftp (priv->backend);
 	if (!egg_strzero (proxy_ftp)) {
 		uri = pk_backend_spawn_convert_uri (proxy_ftp);
-		line = g_strdup_printf ("%s=%s", "ftp_proxy", uri);
-		g_ptr_array_add (array, line);
-		g_free (uri);
+		g_hash_table_replace (env_table, g_strdup ("ftp_proxy"), uri);
 	}
 
 	/* socks_proxy */
 	proxy_socks = pk_backend_get_proxy_socks (priv->backend);
 	if (!egg_strzero (proxy_socks)) {
 		uri = pk_backend_spawn_convert_uri (proxy_socks);
-		line = g_strdup_printf ("%s=%s", "socks_proxy", uri);
-		g_ptr_array_add (array, line);
-		g_free (uri);
+		g_hash_table_replace (env_table, g_strdup ("socks_proxy"), uri);
 	}
 
 	/* no_proxy */
 	no_proxy = pk_backend_get_no_proxy (priv->backend);
 	if (!egg_strzero (no_proxy)) {
 		uri = pk_backend_spawn_convert_uri (no_proxy);
-		line = g_strdup_printf ("%s=%s", "no_proxy", uri);
-		g_ptr_array_add (array, line);
-		g_free (uri);
+		g_hash_table_replace (env_table, g_strdup ("no_proxy"), uri);
 	}
 
 	/* pac */
 	pac = pk_backend_get_pac (priv->backend);
 	if (!egg_strzero (pac)) {
 		uri = pk_backend_spawn_convert_uri (pac);
-		line = g_strdup_printf ("%s=%s", "pac", uri);
-		g_ptr_array_add (array, line);
-		g_free (uri);
+		g_hash_table_replace (env_table, g_strdup ("pac"), uri);
 	}
 
 	/* LANG */
 	locale = pk_backend_get_locale (priv->backend);
-	if (!egg_strzero (locale)) {
-		line = g_strdup_printf ("%s=%s", "LANG", locale);
-		g_ptr_array_add (array, line);
-	}
+	if (!egg_strzero (locale))
+		g_hash_table_replace (env_table, g_strdup ("LANG"), g_strdup (locale));
 
 	/* ROOT */
 	value = pk_backend_get_root (priv->backend);
-	if (!egg_strzero (value)) {
-		line = g_strdup_printf ("%s=%s", "ROOT", value);
-		g_ptr_array_add (array, line);
-	}
+	if (!egg_strzero (value))
+		g_hash_table_replace (env_table, g_strdup ("ROOT"), g_strdup (value));
 
 	/* NETWORK */
 	ret = pk_backend_is_online (priv->backend);
-	line = g_strdup_printf ("%s=%s", "NETWORK", ret ? "TRUE" : "FALSE");
-	g_ptr_array_add (array, line);
+	g_hash_table_replace (env_table, g_strdup ("NETWORK"), g_strdup (ret ? "TRUE" : "FALSE"));
 
 	/* BACKGROUND */
 	ret = pk_backend_use_background (priv->backend);
-	line = g_strdup_printf ("%s=%s", "BACKGROUND", ret ? "TRUE" : "FALSE");
-	g_ptr_array_add (array, line);
+	g_hash_table_replace (env_table, g_strdup ("BACKGROUND"), g_strdup (ret ? "TRUE" : "FALSE"));
 
 	/* INTERACTIVE */
 	g_object_get (priv->backend,
 		      "interactive", &interactive,
 		      NULL);
-	line = g_strdup_printf ("%s=%s", "INTERACTIVE", interactive ? "TRUE" : "FALSE");
-	g_ptr_array_add (array, line);
+	g_hash_table_replace (env_table, g_strdup ("INTERACTIVE"), g_strdup (interactive ? "TRUE" : "FALSE"));
 
 	/* CACHE_AGE */
 	cache_age = pk_backend_get_cache_age (priv->backend);
-	if (cache_age > 0) {
-		line = g_strdup_printf ("%s=%i", "CACHE_AGE", cache_age);
-		g_ptr_array_add (array, line);
-	}
-
-	/* ensure the malicious user can't inject anthing from the session */
-	for (i=0; i<array->len; i++) {
-		line = g_ptr_array_index (array, i);
-		g_strdelimit (line, "\\;{}[]()*?%\n\r\t", '_');
-		g_debug ("setting evp '%s'", line);
+	if (cache_age > 0)
+		g_hash_table_replace (env_table, g_strdup ("CACHE_AGE"), g_strdup_printf ("%i", cache_age));
+
+	/* copy hashed environment key/value pairs to envp */
+	envp = g_new0 (gchar *, g_hash_table_size (env_table) + 1);
+	g_hash_table_iter_init (&env_iter, env_table);
+	i = 0;
+	while (g_hash_table_iter_next (&env_iter, (void**)&env_key, (void**)&env_value)) {
+		env_key = g_strdup (env_key);
+		env_value = g_strdup (env_value);
+		if (!keep_environment) {
+			/* ensure malicious users can't inject anything from the session,
+			 * unless keeping the environment is specified (used for debugging) */
+			g_strdelimit (env_key, "\\;{}[]()*?%\n\r\t", '_');
+			g_strdelimit (env_value, "\\;{}[]()*?%\n\r\t", '_');
+		}
+		envp[i] = g_strdup_printf ("%s=%s", env_key, env_value);
+		g_debug ("setting envp '%s'", envp[i]);
+		g_free (env_key);
+		g_free (env_value);
+		i++;
 	}
 
-	envp = pk_ptr_array_to_strv (array);
-	g_ptr_array_unref (array);
+	g_hash_table_destroy (env_table);
 
 	g_free (proxy_http);
 	g_free (proxy_https);
diff --git a/src/pk-backend.c b/src/pk-backend.c
index 5ab5e90..47c87d1 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -98,6 +98,7 @@ struct PkBackendPrivate
 	gboolean		 simultaneous;
 	gboolean		 use_time;
 	gboolean		 use_threads;
+	gboolean		 keep_environment;
 	gchar			*transaction_id;
 	gchar			*locale;
 	gchar			*frontend_socket;
@@ -2161,6 +2162,29 @@ pk_backend_get_allow_cancel (PkBackend *backend)
 }
 
 /**
+ * pk_backend_set_keep_environment:
+ **/
+gboolean
+pk_backend_set_keep_environment (PkBackend *backend, gboolean keep_environment)
+{
+	g_return_val_if_fail (PK_IS_BACKEND(backend), FALSE);
+
+	backend->priv->keep_environment = keep_environment;
+	return TRUE;
+}
+
+/**
+ * pk_backend_get_keep_environment:
+ **/
+gboolean
+pk_backend_get_keep_environment (PkBackend *backend)
+{
+	g_return_val_if_fail (PK_IS_BACKEND(backend), FALSE);
+
+	return backend->priv->keep_environment;
+}
+
+/**
  * pk_backend_set_role_internal:
  **/
 static gboolean
@@ -3547,6 +3571,9 @@ pk_backend_init (PkBackend *backend)
 	backend->priv->use_threads = pk_conf_get_bool (conf, "UseThreadsInBackend");
 	g_object_unref (conf);
 
+	/* initialize keep_environment once */
+	backend->priv->keep_environment = FALSE;
+
 	pk_backend_reset (backend);
 }
 
diff --git a/src/pk-backend.h b/src/pk-backend.h
index bf5a8ca..a640029 100644
--- a/src/pk-backend.h
+++ b/src/pk-backend.h
@@ -88,6 +88,8 @@ gboolean	 pk_backend_set_proxy			(PkBackend	*backend,
 							 const gchar	*pac);
 gboolean	 pk_backend_set_root			(PkBackend	*backend,
 							 const gchar	*root);
+gboolean	 pk_backend_set_keep_environment (PkBackend	*backend,
+							 gboolean keep_environment);
 gchar		*pk_backend_get_name			(PkBackend	*backend)
 							 G_GNUC_WARN_UNUSED_RESULT;
 gboolean	 pk_backend_get_is_finished		(PkBackend	*backend);
@@ -96,6 +98,8 @@ gchar		*pk_backend_get_description		(PkBackend	*backend)
 							 G_GNUC_WARN_UNUSED_RESULT;
 gchar		*pk_backend_get_author			(PkBackend	*backend)
 							 G_GNUC_WARN_UNUSED_RESULT;
+gboolean	 pk_backend_get_keep_environment (PkBackend	*backend);
+
 typedef gchar	*(*PkBackendGetCompatStringFunc)	(PkBackend	*backend);
 PkBitfield	 pk_backend_get_groups			(PkBackend	*backend);
 PkBitfield	 pk_backend_get_filters			(PkBackend	*backend);
diff --git a/src/pk-main.c b/src/pk-main.c
index 45feed9..6925da5 100644
--- a/src/pk-main.c
+++ b/src/pk-main.c
@@ -205,6 +205,7 @@ main (int argc, char *argv[])
 	gboolean use_daemon = FALSE;
 	gboolean timed_exit = FALSE;
 	gboolean immediate_exit = FALSE;
+	gboolean keep_environment = FALSE;
 	gboolean do_logging = FALSE;
 	gchar *backend_name = NULL;
 	gchar **backend_names = NULL;
@@ -236,7 +237,10 @@ main (int argc, char *argv[])
 		{ "immediate-exit", '\0', 0, G_OPTION_ARG_NONE, &immediate_exit,
 		  /* TRANSLATORS: exit straight away, used for automatic profiling */
 		  _("Exit after the engine has loaded"), NULL },
-		{ NULL}
+		{ "keep-environment", '\0', 0, G_OPTION_ARG_NONE, &keep_environment,
+		  /* TRANSLATORS: don't unset environment variables, used for debugging */
+		  _("Don't clear environment on startup"), NULL },
+		{ NULL }
 	};
 
 	setlocale (LC_ALL, "");
@@ -303,7 +307,9 @@ main (int argc, char *argv[])
 	/* we don't actually need to do this, except it rules out the
 	 * 'it works from the command line but not service activation' bugs */
 #ifdef HAVE_CLEARENV
-	clearenv ();
+	g_debug ("keep_environment: %i\n", keep_environment);
+	if (!keep_environment)
+		clearenv ();
 #endif
 
 	/* get values from the config file */
@@ -346,6 +352,8 @@ main (int argc, char *argv[])
 		goto out;
 	}
 
+	pk_backend_set_keep_environment (backend, keep_environment);
+
 	loop = g_main_loop_new (NULL, FALSE);
 
 	/* create a new engine object */
diff --git a/src/run-pk.sh b/src/run-pk.sh
index 41fa514..fa188c4 100755
--- a/src/run-pk.sh
+++ b/src/run-pk.sh
@@ -31,5 +31,5 @@ else
 fi
 export G_DEBUG=fatal_criticals
 killall packagekitd
-./packagekitd --verbose --disable-timer --backend=$BACKEND
+./packagekitd --verbose --disable-timer --keep-environment --backend=$BACKEND
 
commit ad9098532bf632da9d85818965df0f50d4cb403f
Author: Fabio Erculiani <lxnay at sabayon.org>
Date:   Fri Oct 21 20:04:17 2011 +0200

    entropy: update entropy library path

diff --git a/backends/entropy/entropyBackend.py b/backends/entropy/entropyBackend.py
index 0c82039..d6ce0ed 100755
--- a/backends/entropy/entropyBackend.py
+++ b/backends/entropy/entropyBackend.py
@@ -56,6 +56,7 @@ from packagekit.backend import PackageKitBaseBackend, get_package_id, \
 from packagekit.package import PackagekitPackage
 
 sys.path.insert(0, '/usr/lib/entropy/libraries')
+sys.path.insert(0, '/usr/lib/entropy/lib')
 from entropy.output import decolorize
 from entropy.i18n import _, _LOCALE
 from entropy.const import etpConst, const_convert_to_rawstring, \
commit 4123172086d040cefcce23fb50b94d9fb3d91212
Author: Duncan Mac-Vicar P <dmacvicar at suse.de>
Date:   Tue Jul 26 11:20:51 2011 +0200

    only load repositories once

diff --git a/backends/zypp/zypp-utils.cpp b/backends/zypp/zypp-utils.cpp
index 8fc69bd..4b84300 100644
--- a/backends/zypp/zypp-utils.cpp
+++ b/backends/zypp/zypp-utils.cpp
@@ -192,8 +192,11 @@ zypp_is_valid_repo (PkBackend *backend, RepoInfo repo)
 ResPool
 zypp_build_pool (PkBackend *backend, gboolean include_local)
 {
+	static gboolean repos_loaded = FALSE;
+
 	ZYpp::Ptr zypp = get_zypp (backend);
 
+	// the target is loaded or unloaded on request
 	if (include_local) {
 		// FIXME have to wait for fix in zypp (repeated loading of target)
 		if (sat::Pool::instance().reposFind( sat::Pool::systemRepoAlias() ).solvablesEmpty ())
@@ -211,6 +214,10 @@ zypp_build_pool (PkBackend *backend, gboolean include_local)
 		}
 	}
 
+	// we only load repositories once.
+	if (repos_loaded)
+		return zypp->pool();
+
 	// Add resolvables from enabled repos
 	RepoManager manager;
 	list<RepoInfo> repos;
@@ -230,7 +237,9 @@ zypp_build_pool (PkBackend *backend, gboolean include_local)
                         //FIXME see above, skip already cached repos
                         if (sat::Pool::instance().reposFind( repo.alias ()) == Repository::noRepository)
                                 manager.loadFromCache (repo);
+
 		}
+		repos_loaded = true;
 	} catch (const repo::RepoNoAliasException &ex) {
                 g_error ("Can't figure an alias to look in cache");
         } catch (const repo::RepoNotCachedException &ex) {
commit 51d0ce739a5d83a8ad12fa08ef5f6726a5d1488d
Author: Duncan Mac-Vicar P <dmacvicar at suse.de>
Date:   Tue Jul 26 11:21:37 2011 +0200

    dont call build pool inside the loop

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 85b7cbb..e885cb0 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -185,13 +185,12 @@ backend_get_requires_thread (PkBackend *backend)
 	//pk_backend_set_percentage (backend, 0);
 
 	PoolStatusSaver saver;
+	ResPool pool = zypp_build_pool (backend, true);
 	for (uint i = 0; package_ids[i]; i++) {
 		sat::Solvable solvable = zypp_get_package_by_id (backend, package_ids[i]);
 		PoolItem package;
 
 		if (solvable.isSystem ()) {
-			ResPool pool = zypp_build_pool (backend, true);
-
 			gboolean found = FALSE;
 			gchar **id_parts = pk_package_id_split (package_ids[i]);
 
commit 7d4744a410c3c7e31b4b535049ff8f197bf436aa
Author: Nils Philippsen <nils at redhat.com>
Date:   Mon Oct 10 11:35:11 2011 +0200

    yum: cope with missing YumBase.run_with_package_names
    
    YumBase.run_with_package_names was introduced in yum 3.2.25, better not
    stumble over it if we work with an old version.
    (cherry picked from commit c25443f52a82bfa896c31b2e03aa80a08ca24c85)

diff --git a/backends/yum/yumBackend.py b/backends/yum/yumBackend.py
index c3c6dc3..479ee2d 100755
--- a/backends/yum/yumBackend.py
+++ b/backends/yum/yumBackend.py
@@ -3456,7 +3456,8 @@ class PackageKitYumBase(yum.YumBase):
 
         # YumBase.run_with_package_names is used to record which packages are
         # involved in executing a transaction
-        self.run_with_package_names.add('PackageKit-yum')
+        if hasattr(self, 'run_with_package_names'):
+            self.run_with_package_names.add('PackageKit-yum')
 
         # load the config file
         config = ConfigParser.ConfigParser()
commit d4e19de93f6e77cf0a3d4714e653899f240b9034
Author: Nils Philippsen <nils at redhat.com>
Date:   Fri Oct 7 17:04:00 2011 +0200

    yum: add ourselves to YumBase.run_with_package_names
    (cherry picked from commit de285e72bc7ed2be2c17a3c42906e1a56cad8255)

diff --git a/backends/yum/yumBackend.py b/backends/yum/yumBackend.py
index 5f1d040..c3c6dc3 100755
--- a/backends/yum/yumBackend.py
+++ b/backends/yum/yumBackend.py
@@ -3454,6 +3454,10 @@ class PackageKitYumBase(yum.YumBase):
     def __init__(self, backend):
         yum.YumBase.__init__(self)
 
+        # YumBase.run_with_package_names is used to record which packages are
+        # involved in executing a transaction
+        self.run_with_package_names.add('PackageKit-yum')
+
         # load the config file
         config = ConfigParser.ConfigParser()
         try:
commit adff3a86838ebd454fcd9e6fa160b52585d53fe3
Author: Fabio Erculiani <lxnay at sabayon.org>
Date:   Sun Oct 9 13:18:03 2011 +0200

    Revert "python: update exception code syntax, make it work with both Python2 and Python3"
    
    This reverts commit 89f603c16473982e687c2edc9f7128070371bbbd.
    Needs further discussion.

diff --git a/lib/python/packagekit/backend.py b/lib/python/packagekit/backend.py
index fcf2fc9..ae7bbad 100644
--- a/lib/python/packagekit/backend.py
+++ b/lib/python/packagekit/backend.py
@@ -64,34 +64,34 @@ class PackageKitBaseBackend:
         # try to get LANG
         try:
             self.lang = os.environ['LANG']
-        except KeyError as e:
+        except KeyError, e:
             print "Error: No LANG envp"
 
         # try to get NETWORK state
         try:
             if os.environ['NETWORK'] == 'TRUE':
                 self.has_network = True
-        except KeyError as e:
+        except KeyError, e:
             print "Error: No NETWORK envp"
 
         # try to get BACKGROUND state
         try:
             if os.environ['BACKGROUND'] == 'TRUE':
                 self.background = True
-        except KeyError as e:
+        except KeyError, e:
             print "Error: No BACKGROUND envp"
 
         # try to get INTERACTIVE state
         try:
             if os.environ['INTERACTIVE'] == 'TRUE':
                 self.interactive = True
-        except KeyError as e:
+        except KeyError, e:
             print "Error: No INTERACTIVE envp"
 
         # try to get CACHE_AGE state
         try:
             self.cache_age = int(os.environ['CACHE_AGE'])
-        except KeyError as e:
+        except KeyError, e:
             pass
 
     def doLock(self):
@@ -749,9 +749,9 @@ class PackageKitBaseBackend:
         while True:
             try:
                 line = sys.stdin.readline().strip('\n')
-            except IOError as e:
+            except IOError, e:
                 self.error(ERROR_TRANSACTION_CANCELLED, 'could not read from stdin: %s' % str(e))
-            except KeyboardInterrupt as e:
+            except KeyboardInterrupt, e:
                 self.error(ERROR_PROCESS_KILL, 'process was killed by ctrl-c: %s' % str(e))
             if not line or line == 'exit':
                 break
commit 89f603c16473982e687c2edc9f7128070371bbbd
Author: Fabio Erculiani <lxnay at sabayon.org>
Date:   Sun Oct 9 13:06:00 2011 +0200

    python: update exception code syntax, make it work with both Python2 and Python3

diff --git a/lib/python/packagekit/backend.py b/lib/python/packagekit/backend.py
index ae7bbad..fcf2fc9 100644
--- a/lib/python/packagekit/backend.py
+++ b/lib/python/packagekit/backend.py
@@ -64,34 +64,34 @@ class PackageKitBaseBackend:
         # try to get LANG
         try:
             self.lang = os.environ['LANG']
-        except KeyError, e:
+        except KeyError as e:
             print "Error: No LANG envp"
 
         # try to get NETWORK state
         try:
             if os.environ['NETWORK'] == 'TRUE':
                 self.has_network = True
-        except KeyError, e:
+        except KeyError as e:
             print "Error: No NETWORK envp"
 
         # try to get BACKGROUND state
         try:
             if os.environ['BACKGROUND'] == 'TRUE':
                 self.background = True
-        except KeyError, e:
+        except KeyError as e:
             print "Error: No BACKGROUND envp"
 
         # try to get INTERACTIVE state
         try:
             if os.environ['INTERACTIVE'] == 'TRUE':
                 self.interactive = True
-        except KeyError, e:
+        except KeyError as e:
             print "Error: No INTERACTIVE envp"
 
         # try to get CACHE_AGE state
         try:
             self.cache_age = int(os.environ['CACHE_AGE'])
-        except KeyError, e:
+        except KeyError as e:
             pass
 
     def doLock(self):
@@ -749,9 +749,9 @@ class PackageKitBaseBackend:
         while True:
             try:
                 line = sys.stdin.readline().strip('\n')
-            except IOError, e:
+            except IOError as e:
                 self.error(ERROR_TRANSACTION_CANCELLED, 'could not read from stdin: %s' % str(e))
-            except KeyboardInterrupt, e:
+            except KeyboardInterrupt as e:
                 self.error(ERROR_PROCESS_KILL, 'process was killed by ctrl-c: %s' % str(e))
             if not line or line == 'exit':
                 break
commit d8c13d8c3e875bf1d87650646cb960a87468ba87
Author: Fabio Erculiani <lxnay at sabayon.org>
Date:   Wed Oct 5 22:39:30 2011 +0200

    entropy: add forward compatibility with upcoming API changes

diff --git a/backends/entropy/entropyBackend.py b/backends/entropy/entropyBackend.py
index fe8c609..0c82039 100755
--- a/backends/entropy/entropyBackend.py
+++ b/backends/entropy/entropyBackend.py
@@ -64,7 +64,8 @@ from entropy.client.interfaces import Client
 from entropy.core.settings.base import SystemSettings
 from entropy.misc import LogFile
 from entropy.cache import EntropyCacher
-from entropy.exceptions import SystemDatabaseError
+from entropy.exceptions import SystemDatabaseError, DependenciesNotFound, \
+    DependenciesCollision
 from entropy.db.exceptions import Error as EntropyRepositoryError
 try:
     from entropy.exceptions import DependenciesNotRemovable
@@ -589,18 +590,32 @@ class PackageKitEntropyMixin(object):
         if calculate_deps:
             self.status(STATUS_DEP_RESOLVE)
             empty_deps, deep_deps = False, False
-            run_queue, removal_queue, status = self._entropy.get_install_queue(
-                matches, empty_deps, deep_deps)
+            try:
+                queue_obj = self._entropy.get_install_queue(
+                    matches, empty_deps, deep_deps)
+                if len(queue_obj) == 2:
+                    # new api
+                    run_queue, removal_queue = queue_obj
+                else:
+                    # old api
+                    run_queue, removal_queue, status = queue_obj
+                    if status == -2:
+                        raise DependenciesNotFound(run_queue)
+                    elif status == -3:
+                        raise DependenciesCollision(run_queue)
+            except DependenciesNotFound as exc:
+                self.error(ERROR_DEP_RESOLUTION_FAILED,
+                    "Cannot find the following dependencies: %s" % (
+                    ', '.join(sorted(exc.value)),))
+                return
+            except DependenciesCollision:
+                self.error(ERROR_DEP_RESOLUTION_FAILED,
+                           "Dependencies collisions, cannot continue")
+                return
+
         else:
             run_queue = matches
             removal_queue = []
-            status = 0
-
-        if status == -2:
-            self.error(ERROR_DEP_RESOLUTION_FAILED,
-                "Cannot find the following dependencies: %s" % (
-                    ', '.join(run_queue),))
-            return
 
         self.percentage(0)
         self.status(STATUS_DOWNLOAD)
@@ -934,12 +949,26 @@ class PackageKitEntropyBackend(PackageKitBaseBackend, PackageKitEntropyMixin):
 
         empty = False
         deep = False
-        install, removal, deps_not_f = self._entropy.get_install_queue(matches,
-            empty, deep, recursive = recursive)
-
-        if deps_not_f == -2:
+        try:
+            queue_obj = self._entropy.get_install_queue(matches,
+                empty, deep, recursive = recursive)
+            if len(queue_obj) == 2:
+                # new api
+                install, removal = queue_obj
+            else:
+                # old api
+                install, removal, status = queue_obj
+                if status == -2:
+                    raise DependenciesNotFound(install)
+                elif status == -3:
+                    raise DependenciesCollision(install)
+        except DependenciesNotFound as exc:
+            self.error(ERROR_DEP_RESOLUTION_FAILED,
+                "Dependencies not found: %s" % (sorted(exc.value),))
+            return
+        except DependenciesCollision:
             self.error(ERROR_DEP_RESOLUTION_FAILED,
-                "Dependencies not found: %s" % (sorted(install),))
+                "Dependencies collisions, cannot continue")
             return
 
         # transform install into (repo, pkg_id, c_repo) list
commit d5f773de04149f8cda090bd521ae37e838ec26e3
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Oct 4 09:45:37 2011 +0100

    trivial: post release version bump

diff --git a/RELEASE b/RELEASE
index d2c30e5..2338a96 100644
--- a/RELEASE
+++ b/RELEASE
@@ -2,10 +2,10 @@ PackageKit Release Notes
 
 1. Write NEWS entries for PackageKit in the same format as usual.
 
-git shortlog PACKAGEKIT_0_6_18.. | grep -i -v trivial | grep -v Merge > NEWS.new
+git shortlog PACKAGEKIT_0_6_19.. | grep -i -v trivial | grep -v Merge > NEWS.new
 
 --------------------------------------------------------------------------------
-Version 0.6.19
+Version 0.6.20
 ~~~~~~~~~~~~~~
 Released: 2011-xx-xx
 
@@ -26,8 +26,8 @@ Bugfixes:
 
 4. Commit changes in PackageKit git:
 
-git commit -a -m "Release version 0.6.19"
-git tag -s -f -m "Release 0.6.19" PACKAGEKIT_0_6_19
+git commit -a -m "Release version 0.6.20"
+git tag -s -f -m "Release 0.6.20" PACKAGEKIT_0_6_20
 <gpg password>
 git push --tags
 git push
@@ -46,14 +46,13 @@ scp *.tar.* packagekit.org:/srv/www/html/releases/
 
 git commit -a -m "trivial: post release version bump"
 git push
-tx push --source
 
 9. Upload new html sources
 
 10. Send an email to packagekit at lists.freedesktop.org
 
 =================================================
-PackageKit 0.6.19 released!
+PackageKit 0.6.20 released!
 
 Tarballs available here: http://www.packagekit.org/releases/
 
diff --git a/configure.ac b/configure.ac
index c261882..a3ff552 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,7 +3,7 @@ AC_PREREQ(2.63)
 
 m4_define([pk_major_version], [0])
 m4_define([pk_minor_version], [6])
-m4_define([pk_micro_version], [19])
+m4_define([pk_micro_version], [20])
 m4_define([pk_version],
           [pk_major_version.pk_minor_version.pk_micro_version])
 


More information about the PackageKit-commit mailing list