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

Richard Hughes hughsient at kemper.freedesktop.org
Fri Apr 25 02:27:56 PDT 2008


 backends/zypp/pk-backend-zypp.cpp |   19 ++++++++++++-----
 backends/zypp/zypp-events.h       |    4 ++-
 backends/zypp/zypp-utils.cpp      |   41 +++++++++++++++++++++++++++-----------
 client/pk-console.c               |    2 -
 src/pk-backend.c                  |   20 ++++++++++++------
 src/pk-file-monitor-gio.c         |   12 +++++++----
 6 files changed, 69 insertions(+), 29 deletions(-)

New commits:
commit 1792c3478dfceb4c184a3a80888acfeb8b817449
Merge: a87cdf3... f8584cb...
Author: Richard Hughes <richard at hughsie.com>
Date:   Fri Apr 25 11:25:59 2008 +0100

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

commit f8584cb41ff4c71290aae67ea2a83e5183c89546
Author: Stefan Haas <shaas at suse.de>
Date:   Fri Apr 25 11:22:53 2008 +0200

    changed filter behaviour to accept more then one

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index d612856..6c7b8d2 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -1726,6 +1726,7 @@ backend_get_packages (PkBackend *backend, PkFilterEnum filter)
 {
 	g_return_if_fail (backend != NULL);
 	PkFilterEnum *data = g_new0(PkFilterEnum, 1);
+	*data = filter;
 
 	pk_backend_thread_create (thread, backend_get_packages_thread, data);
 }
diff --git a/backends/zypp/zypp-utils.cpp b/backends/zypp/zypp-utils.cpp
index 0d11b0e..bd4ba55 100644
--- a/backends/zypp/zypp-utils.cpp
+++ b/backends/zypp/zypp-utils.cpp
@@ -408,18 +408,30 @@ zypp_emit_packages_in_list (PkBackend *backend, std::vector<zypp::sat::Solvable>
 			it != v->end (); it++) {
 
 		gchar *package_id = zypp_build_package_id_from_resolvable (*it);
-		if (filters == PK_FILTER_ENUM_INSTALLED && !(it->isSystem ()))
-			continue;
-		if (filters == PK_FILTER_ENUM_NOT_INSTALLED && it->isSystem ())
-			continue;
-		if (filters == PK_FILTER_ENUM_ARCH) {
-			if (it->arch () != zypp::ZConfig::defaultSystemArchitecture () && it->arch () != zypp::Arch_noarch)
-				continue;
-		}
-		if (filters == PK_FILTER_ENUM_NOT_ARCH) {
-			if (it->arch () == zypp::ZConfig::defaultSystemArchitecture ())
-				continue;
+
+		// iterate through the given filters
+		if (filters != PK_FILTER_ENUM_NONE){
+			gboolean print = TRUE;
+			for (guint i = 1; i < PK_FILTER_ENUM_UNKNOWN; i*=2) {
+				if ((filters & i) == 0)
+					continue;
+				if (i == PK_FILTER_ENUM_INSTALLED && !(it->isSystem ()))
+					print = FALSE;
+				if (i == PK_FILTER_ENUM_NOT_INSTALLED && it->isSystem ())
+					print = FALSE;;
+				if (i == PK_FILTER_ENUM_ARCH) {
+					if (it->arch () != zypp::ZConfig::defaultSystemArchitecture () && it->arch () != zypp::Arch_noarch)
+						print = FALSE;
+				}
+				if (i == PK_FILTER_ENUM_NOT_ARCH) {
+					if (it->arch () == zypp::ZConfig::defaultSystemArchitecture ())
+						print = FALSE;
+				}
+			}
+			if (!print)
+				continue;		
 		}
+
 		pk_backend_package (backend,
 			    it->isSystem() == true ?
 				PK_INFO_ENUM_INSTALLED :
commit 4a59968dba8d92bee4ded555fe2e9a47c1d840b2
Author: Stefan Haas <shaas at suse.de>
Date:   Fri Apr 25 10:16:53 2008 +0200

    added summary to install callback

diff --git a/backends/zypp/zypp-events.h b/backends/zypp/zypp-events.h
index 4c05d3c..3243821 100644
--- a/backends/zypp/zypp-events.h
+++ b/backends/zypp/zypp-events.h
@@ -154,12 +154,14 @@ struct InstallResolvableReportReceiver : public zypp::callback::ReceiveReport<zy
 	{
 		clear_package_id ();
 		_package_id = zypp_build_package_id_from_resolvable (resolvable->satSolvable ());
+		gchar* summary = g_strdup(resolvable->satSolvable ().lookupStrAttribute (zypp::sat::SolvAttr::summary).c_str ());
 		//pk_debug ("InstallResolvableReportReceiver::start(): %s", _package_id == NULL ? "unknown" : _package_id);
 		if (_package_id != NULL) {
 			pk_backend_set_status (_backend, PK_STATUS_ENUM_INSTALL);
-			pk_backend_package (_backend, PK_INFO_ENUM_INSTALLING, _package_id, "TODO: Put the package summary here if possible");
+			pk_backend_package (_backend, PK_INFO_ENUM_INSTALLING, _package_id, summary);
 			reset_sub_percentage ();
 		}
+		g_free (summary);
 	}
 
 	virtual bool progress (int value, zypp::Resolvable::constPtr resolvable)
commit 78a627753c8ad97d44c22f17824dbcd55c5c2717
Author: Scott Reeves <sreeves at novell.com>
Date:   Thu Apr 24 18:17:34 2008 -0600

    fix so that the messages are not jammed together without a space between them

diff --git a/client/pk-console.c b/client/pk-console.c
index 0d71bf9..ef3d274 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -1495,7 +1495,7 @@ main (int argc, char *argv[])
 
 out:
 	if (ret == FALSE) {
-		g_print ("%s\n", _("Command failed"));
+		g_print ("\n%s\n", _("Command failed"));
 	}
 	if (error != NULL) {
 		if (g_str_has_prefix (error->message, "org.freedesktop.packagekit."))  {
commit 859ae16bab5418fedcbbc7722775944f55ebd017
Author: Scott Reeves <sreeves at novell.com>
Date:   Thu Apr 24 13:10:04 2008 -0600

    clean up reads of freed mem pointed out by valgrind

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 2fa706a..d612856 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -406,15 +406,17 @@ backend_get_depends_thread (PkBackendThread *thread, gpointer data)
 			zypp::PoolItem selectable = *it;
 			if (strcmp (selectable->name().c_str(), pi->name) == 0) {
 				// This package matches the name we're looking
-				const char *edition_str = selectable->edition ().asString ().c_str();
+				char *edition_str = g_strdup (selectable->edition ().asString ().c_str());
 
 				if (strcmp (edition_str, pi->version) == 0) {
+					g_free (edition_str);
 					// this is the one, mark it to be installed
 					pool_item = selectable;
 					pool_item_found = TRUE;
 					pk_backend_set_percentage (backend, 20);
 					break; // Found it, get out of the for loop
 				}
+				g_free (edition_str);
 			}
 		}
 
@@ -470,19 +472,21 @@ backend_get_depends_thread (PkBackendThread *thread, gpointer data)
 				it++) {
 
 			gchar *package_id;
-			const gchar *package_name;
+			gchar *package_name;
 
 			/* do not emit packages with invalid names generated above via dependencies such as "rpmlib(PayloadFilesHavePrefix) <= 4.0-1"
 			   this was causing a crash - BNC# 372429
 			   Fixme - need to find if those dependencies should actually be in the list above and if so a better way to strip them out
 			*/
-			package_name = it->second.name ().c_str();
+			package_name = g_strdup (it->second.name ().c_str());
 
 			if (package_name == NULL || *package_name == '\0')
 			{
 				pk_debug ("Skipping emitting a non valid package");
+				g_free (package_name);
 				continue;
 			}
+			g_free (package_name);
 
 			package_id = pk_package_id_build (it->second.name ().c_str(),
 					it->second.edition ().asString ().c_str(),
@@ -1620,11 +1624,13 @@ backend_get_files_thread (PkBackendThread *thread, gpointer data) {
 	zypp::sat::Solvable package;
 	for (std::vector<zypp::sat::Solvable>::iterator it = v->begin ();
 			it != v->end (); it++) {
-		const char *version = it->edition ().asString ().c_str ();
+		char *version = g_strdup (it->edition ().asString ().c_str ());
 		if (strcmp (pi->version, version) == 0) {
+			g_free (version);
 			package = *it;
 			break;
 		}
+		g_free (version);
 	}
 
 	delete (v);
commit a87cdf34a80f730ab2e3b0bbb95476d83645c357
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Apr 24 17:57:36 2008 +0100

    trivial debugging, so we know when we are doing things manually without the timeout

diff --git a/src/pk-backend.c b/src/pk-backend.c
index ecdcd36..65c2cf2 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -1407,6 +1407,7 @@ pk_backend_finalize (GObject *object)
 	/* do finish now, as we might be unreffing quickly */
 	if (backend->priv->signal_finished != 0) {
 		g_source_remove (backend->priv->signal_finished);
+		pk_debug ("doing unref quickly delay");
 		pk_backend_finished_delay (backend);
 	}
 
commit f2316c54762fe549b952ed5b97c6eb74cbe5e6b1
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Apr 24 15:57:14 2008 +0100

    we might not have called pk_file_monitor_set_file so don't unref it if it's NULL

diff --git a/src/pk-file-monitor-gio.c b/src/pk-file-monitor-gio.c
index 9f56b51..a755b97 100644
--- a/src/pk-file-monitor-gio.c
+++ b/src/pk-file-monitor-gio.c
@@ -153,10 +153,14 @@ pk_file_monitor_finalize (GObject *object)
 	file_monitor = PK_FILE_MONITOR (object);
 	g_return_if_fail (file_monitor->priv != NULL);
 
-	g_file_monitor_cancel (file_monitor->priv->monitor);
-
-	g_object_unref (file_monitor->priv->file);
-	g_object_unref (file_monitor->priv->monitor);
+	/* we might not have called pk_file_monitor_set_file */
+	if (file_monitor->priv->monitor != NULL) {
+		g_file_monitor_cancel (file_monitor->priv->monitor);
+		g_object_unref (file_monitor->priv->monitor);
+	}
+	if (file_monitor->priv->file != NULL) {
+		g_object_unref (file_monitor->priv->file);
+	}
 
 	G_OBJECT_CLASS (pk_file_monitor_parent_class)->finalize (object);
 }
commit 13fb3e4b03942dafe1d0e67ac958120d7fea5284
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Apr 24 16:05:11 2008 +0100

    unref some of the gobjects a little later, as we might need to fire finished and cancel them. only a partial fix

diff --git a/src/pk-backend.c b/src/pk-backend.c
index b7e95f7..ecdcd36 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -1404,10 +1404,6 @@ pk_backend_finalize (GObject *object)
 
 	pk_debug ("backend finalise");
 
-	g_object_unref (backend->priv->time);
-	g_object_unref (backend->priv->inhibit);
-	g_hash_table_destroy (backend->priv->eulas);
-
 	/* do finish now, as we might be unreffing quickly */
 	if (backend->priv->signal_finished != 0) {
 		g_source_remove (backend->priv->signal_finished);
@@ -1421,6 +1417,9 @@ pk_backend_finalize (GObject *object)
 
 	g_free (backend->priv->name);
 	g_free (backend->priv->c_tid);
+	g_object_unref (backend->priv->time);
+	g_object_unref (backend->priv->inhibit);
+	g_hash_table_destroy (backend->priv->eulas);
 
 	if (backend->priv->handle != NULL) {
 		g_module_close (backend->priv->handle);
commit 7112466ecf0e4213534dd850148ae98b9ec3838a
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Apr 24 18:18:16 2008 +0100

    get_groups and get_filters are not compulsory, don't assert if they are not present

diff --git a/src/pk-backend.c b/src/pk-backend.c
index 8500024..b7e95f7 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -137,7 +137,11 @@ pk_backend_get_groups (PkBackend *backend)
 {
 	g_return_val_if_fail (PK_IS_BACKEND (backend), PK_GROUP_ENUM_UNKNOWN);
 	g_return_val_if_fail (backend->priv->locked != FALSE, PK_GROUP_ENUM_UNKNOWN);
-	g_return_val_if_fail (backend->desc->get_groups != NULL, PK_GROUP_ENUM_UNKNOWN);
+
+	/* not compulsory */
+	if (backend->desc->get_groups == NULL) {
+		return PK_GROUP_ENUM_UNKNOWN;
+	}
 	return backend->desc->get_groups (backend);
 }
 
@@ -149,7 +153,11 @@ pk_backend_get_filters (PkBackend *backend)
 {
 	g_return_val_if_fail (PK_IS_BACKEND (backend), PK_FILTER_ENUM_UNKNOWN);
 	g_return_val_if_fail (backend->priv->locked != FALSE, PK_FILTER_ENUM_UNKNOWN);
-	g_return_val_if_fail (backend->desc->get_filters != NULL, PK_GROUP_ENUM_UNKNOWN);
+
+	/* not compulsory */
+	if (backend->desc->get_filters == NULL) {
+		return PK_FILTER_ENUM_UNKNOWN;
+	}
 	return backend->desc->get_filters (backend);
 }
 
commit 3fffdd6c4927ef72977828e34053eb549b986837
Author: Stefan Haas <shaas at suse.de>
Date:   Thu Apr 24 15:33:22 2008 +0200

    reset the status of a poolitem if installation fails

diff --git a/backends/zypp/zypp-utils.cpp b/backends/zypp/zypp-utils.cpp
index 17a610d..0d11b0e 100644
--- a/backends/zypp/zypp-utils.cpp
+++ b/backends/zypp/zypp-utils.cpp
@@ -532,6 +532,13 @@ zypp_perform_execution (PkBackend *backend, PerformType type, gboolean force)
 				}
 			}
 
+			// reset the status of all touched PoolItems
+			zypp::ResPool pool = zypp::ResPool::instance ();
+			for (zypp::ResPool::const_iterator it = pool.begin (); it != pool.end (); it++) {
+				if (it->status ().isToBeInstalled ())
+					it->statusReset ();
+			}
+
 			pk_backend_error_code (backend, PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, emsg);
 			g_free (emsg);
 			return FALSE;
commit 647f95e879e46872de44417141aa1abde55f5b09
Author: Stefan Haas <shaas at suse.de>
Date:   Thu Apr 24 14:22:14 2008 +0200

    better error-messages when refreshing repositories

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 943e9a2..2fa706a 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -760,7 +760,7 @@ backend_refresh_cache_thread (PkBackendThread *thread, gpointer data)
 				zypp::RepoManager::RefreshForced :
 				zypp::RepoManager::RefreshIfNeeded);
 		} catch (const zypp::Exception &ex) {
-			pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString ().c_str ());
+			pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "%s: %s", repo.alias ().c_str (), ex.asUserString ().c_str ());
 			pk_backend_finished (backend);
 			return FALSE;
 		}
@@ -776,7 +776,7 @@ backend_refresh_cache_thread (PkBackendThread *thread, gpointer data)
 		//} catch (const zypp::repo::RepoException &ex) {
 		} catch (const zypp::Exception &ex) {
 			// TODO: Handle the exceptions in manager.refreshMetadata
-			pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString().c_str() );
+			pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "%s: %s", repo.alias ().c_str (), ex.asUserString().c_str() );
 			pk_backend_finished (backend);
 			return FALSE;
 		}


More information about the PackageKit-commit mailing list