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

Richard Hughes hughsient at kemper.freedesktop.org
Thu Nov 29 23:54:58 PST 2007


 backends/zypp/pk-backend-zypp.cpp |  183 +++++++++++++++-----------------------
 backends/zypp/zypp-events.h       |   21 ----
 backends/zypp/zypp-utils.cpp      |  108 ++++++++++++++++++++++
 backends/zypp/zypp-utils.h        |   32 ++++++
 contrib/Makefile.am               |    7 +
 contrib/packagekit-bugreport.sh   |   17 +++
 src/pk-backend.c                  |   21 ++--
 src/pk-main.c                     |    6 +
 src/run-pk.sh                     |    5 +
 9 files changed, 262 insertions(+), 138 deletions(-)

New commits:
commit ac4623bb3e8867ca642838702f80a65d5d67d3c8
Author: Boyd Timothy <btimothy at gmail.com>
Date:   Thu Nov 29 16:56:22 2007 -0700

    For now, don't let the user interrupt during package install when using the zypp backend.

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 6b94476..eda2f6d 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -341,6 +341,9 @@ backend_install_package (PkBackend *backend, const gchar *package_id)
 {
 	g_return_if_fail (backend != NULL);
 
+	// For now, don't let the user cancel the install once it's started
+	pk_backend_allow_interrupt (backend, FALSE);
+
 	//printf("package_id is %s\n", package_id);
 	gchar *package_to_install = g_strdup (package_id);
 	pk_backend_thread_create (backend, backend_install_package_thread, package_to_install);
commit 5fcc9bfa9c7976506a8a2949e3d8879adf3ea2f4
Author: Boyd Timothy <btimothy at gmail.com>
Date:   Thu Nov 29 16:45:12 2007 -0700

    Modified the zypp backend to not query the SQL database directly and instead just query the cached repository information.

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index ed90f97..6b94476 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -447,80 +447,50 @@ backend_refresh_cache (PkBackend *backend, gboolean force)
 	}
 }
 
-static int
-select_callback (void* data,int argc ,char** argv, char** cl_name)
-{
-	// printf ("Enter select_callback\n");
-
-	SQLData *sql_data = (SQLData *) data;
-	/* FIXME - for now we prefer later versions, i586 */
-	if (sql_data->name == NULL ||
-			(g_ascii_strcasecmp (argv[SQL_VERSION], sql_data->version) > 0) ||
-			!g_ascii_strcasecmp ("i586", argv[SQL_ARCH]) ) {
-		//printf ("Adding to data struct\n");
-		g_free (sql_data->name);
-		g_free (sql_data->version);
-		g_free (sql_data->release);
-		g_free (sql_data->repo);
-		g_free (sql_data->arch);
-		sql_data->name = g_strdup (argv[SQL_NAME]);
-		sql_data->version = g_strdup (argv[SQL_VERSION]);
-		sql_data->release = g_strdup (argv[SQL_RELEASE]);
-		sql_data->repo = g_strdup (argv[SQL_REPO]);
-		sql_data->arch = g_strdup (argv[SQL_ARCH]);
-	}
-	/*
-	for (int i = 0; i < argc; i++) {
-		printf ("%s=%s\n", cl_name[i], argv[i] ? argv[i] : "null");
-	}
-	*/
-	return 0;
-}
-
 static gboolean
 backend_resolve_thread (PkBackend *backend, gpointer data)
 {
-	char * error_string;
-	const char * select_statement_template = "SELECT p.name,p.version,p.release,r.alias,t.name FROM resolvables p JOIN repositories r ON p.repository_id = r.id JOIN types t ON p.arch = t.id WHERE p.name LIKE \"%s\"";
-	gchar *select_statement;
 	gchar *package_id;
-	gchar *full_version;
-	SQLData *sql_data = g_new0(SQLData, 1);
-							  
+	ResolveData *rdata = (ResolveData*) data;
 	pk_backend_change_status (backend, PK_STATUS_ENUM_QUERY);
 
-	// printf("\n\nEnter backend_resolve_thread\n");
-	ResolveData *rdata = (ResolveData*) data;
+	std::vector<zypp::PoolItem> *v;
+	v = zypp_get_packages_by_name ((const gchar *)rdata->name);
 
-	sqlite3 *db;
-	if (sqlite3_open("/var/cache/zypp/zypp.db", &db) != 0) {
-		pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Failed to open database");
-		pk_backend_finished (backend);
-		return FALSE;
+	zypp::ResObject::constPtr package = NULL;
+	for (std::vector<zypp::PoolItem>::iterator it = v->begin ();
+			it != v->end (); it++) {
+		zypp::ResObject::constPtr pkg = (*it);
+		const char *version = pkg->edition ().asString ().c_str ();
+		if (package == NULL) {
+			package = pkg;
+		} else if (g_ascii_strcasecmp (version, package->edition ().asString ().c_str ()) > 0) {
+			package = pkg;
+		}
 	}
 
-	select_statement = g_strdup_printf (select_statement_template, rdata->name);
-	sqlite3_exec (db, select_statement, select_callback, sql_data, &error_string);
-	sqlite3_close (db);
+	delete (v);
 
-	if (sql_data->name == NULL) {
-		//did not get any matches
+	if (package == NULL) {
+		pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "couldn't find package");
+		g_free (rdata->name);
+		g_free (rdata->filter);
+		g_free (rdata);
 		pk_backend_finished (backend);
 		return FALSE;
 	}
-	full_version = g_strconcat (sql_data->version, "-", sql_data->release, NULL);
-	package_id = pk_package_id_build(sql_data->name, full_version, sql_data->arch, "opensuse");
-	//printf("about to return package_id of:%s\n", package_id);
-	//FIXME - return real PK_INFO_ENUM_*
-	pk_backend_package (backend, PK_INFO_ENUM_AVAILABLE,
-				package_id, "description generated by zypp backend");
+
+	package_id = zypp_build_package_id_from_resolvable (package);
+	// TODO: Determine whether the package is installed and emit either PK_INFO_ENUM_AVAILABLE or PK_INFO_ENUM_INSTALLED
+	pk_backend_package (backend,
+			    PK_INFO_ENUM_AVAILABLE,
+			    package_id,
+			    package->description ().c_str ());
 
 	g_free (rdata->name);
 	g_free (rdata->filter);
 	g_free (rdata);
-	g_free (full_version);
 	g_free (package_id);
-	g_free (select_statement);
 	pk_backend_finished (backend);
 	return TRUE;
 }
diff --git a/backends/zypp/zypp-events.h b/backends/zypp/zypp-events.h
index a868c77..46d72d4 100644
--- a/backends/zypp/zypp-events.h
+++ b/backends/zypp/zypp-events.h
@@ -6,6 +6,8 @@
 #include <pk-backend.h>
 #include <zypp/ZYppCallbacks.h>
 
+#include "zypp-utils.h"
+
 /*
 typedef struct {
 	PkBackend *backend;
@@ -47,23 +49,6 @@ struct ZyppBackendReceiver
 	}
 
 	/**
-	 * Build a package_id from the specified resolvable.  The returned
-	 * gchar * should be freed with g_free ().
-	 */
-	gchar *
-	build_package_id_from_resolvable (zypp::Resolvable::constPtr resolvable)
-	{
-		gchar *package_id;
-		
-		package_id = pk_package_id_build (resolvable->name ().c_str (),
-						  resolvable->edition ().asString ().c_str (),
-						  resolvable->arch ().asString ().c_str (),
-						  "opensuse");
-
-		return package_id;
-	}
-
-	/**
 	 * Build a package_id from the specified zypp::Url.  The returned
 	 * gchar * should be freed with g_free ().  Returns NULL if the
 	 * URL does not contain information about an RPM.
@@ -167,7 +152,7 @@ struct InstallResolvableReportReceiver : public zypp::callback::ReceiveReport<zy
 	virtual void start (zypp::Resolvable::constPtr resolvable)
 	{
 		clear_package_id ();
-		_package_id = build_package_id_from_resolvable (resolvable);
+		_package_id = zypp_build_package_id_from_resolvable (resolvable);
 		//fprintf (stderr, "\n\n----> InstallResolvableReportReceiver::start(): %s\n\n", _package_id == NULL ? "unknown" : _package_id);
 		if (_package_id != NULL) {
 			pk_backend_change_status (_backend, PK_STATUS_ENUM_INSTALL);
diff --git a/backends/zypp/zypp-utils.cpp b/backends/zypp/zypp-utils.cpp
index 4a0e8f7..4034f07 100644
--- a/backends/zypp/zypp-utils.cpp
+++ b/backends/zypp/zypp-utils.cpp
@@ -18,6 +18,8 @@
 #include <zypp/Patch.h>
 #include <zypp/Package.h>
 
+#include <pk-backend.h>
+
 #include "zypp-utils.h"
 
 /**
@@ -110,5 +112,24 @@ zypp_get_packages_by_name (const gchar *package_name)
 	return v;
 }
 
+/**
+ * Build a package_id from the specified resolvable.  The returned
+ * gchar * should be freed with g_free ().
+ */
+gchar *
+zypp_build_package_id_from_resolvable (zypp::Resolvable::constPtr resolvable)
+{
+	gchar *package_id;
+	
+	package_id = pk_package_id_build (resolvable->name ().c_str (),
+					  resolvable->edition ().asString ().c_str (),
+					  resolvable->arch ().asString ().c_str (),
+					  "opensuse");
+	// TODO: Figure out how to check if resolvable is really a ResObject and then cast it to a ResObject and pull of the repository alias for our "data" part in the package id
+//					  ((zypp::ResObject::constPtr)resolvable)->repository ().info ().alias ().c_str ());
+
+	return package_id;
+}
+
 #endif // _ZYPP_UTILS_H_
 
diff --git a/backends/zypp/zypp-utils.h b/backends/zypp/zypp-utils.h
index 47ee5d6..b44beae 100644
--- a/backends/zypp/zypp-utils.h
+++ b/backends/zypp/zypp-utils.h
@@ -31,12 +31,13 @@ gboolean zypp_is_changeable_media (const zypp::Url &url);
  * Build and return a ResPool that contains all local resolvables
  * and ones found in the enabled repositories.
  */
-zypp::ResPool zypp_build_full_pool ();
+zypp::ResPool zypp_build_pool (gboolean include_local);
 
 /**
  * Returns a list of packages that match the specified package_name.
  */
 std::vector<zypp::PoolItem> * zypp_get_packages_by_name (const gchar *package_name);
 
+gchar * zypp_build_package_id_from_resolvable (zypp::Resolvable::constPtr resolvable);
 #endif // _ZYPP_UTILS_H_
 
commit 0c5394c0093b6a32a680411413662a3ef8d86843
Author: Boyd Timothy <btimothy at gmail.com>
Date:   Thu Nov 29 16:01:55 2007 -0700

    Moving some common code to zypp-util.h/cpp and cleaning up backend_get_description.

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 11da1c0..ed90f97 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -25,6 +25,7 @@
 #include <pk-backend.h>
 #include <unistd.h>
 #include <pk-debug.h>
+#include <string>
 
 #include <zypp/ZYppFactory.h>
 #include <zypp/ResObject.h>
@@ -45,6 +46,7 @@
 #include <sqlite3.h>
 
 #include <map>
+#include <list>
 
 #include "zypp-utils.h"
 #include "zypp-events.h"
@@ -93,19 +95,6 @@ typedef struct {
 	gboolean force;
 } RefreshData;
 
-// some typedefs and functions to shorten Zypp names
-typedef zypp::ResPoolProxy ZyppPool;
-inline ZyppPool zyppPool() { return zypp::getZYpp()->poolProxy(); }
-typedef zypp::ui::Selectable::Ptr ZyppSelectable;
-typedef zypp::ui::Selectable*		ZyppSelectablePtr;
-typedef zypp::ResObject::constPtr	ZyppObject;
-typedef zypp::Package::constPtr		ZyppPackage;
-typedef zypp::Patch::constPtr		ZyppPatch;
-typedef zypp::Pattern::constPtr		ZyppPattern;
-typedef zypp::Language::constPtr	ZyppLanguage;
-inline ZyppPackage tryCastToZyppPkg (ZyppObject obj)
-	{ return zypp::dynamic_pointer_cast <const zypp::Package> (obj); }
-
 /**
  * A map to keep track of the EventDirector objects for
  * each zypp backend that is created.
@@ -113,28 +102,6 @@ inline ZyppPackage tryCastToZyppPkg (ZyppObject obj)
 static std::map<PkBackend *, EventDirector *> _eventDirectors;
 
 /**
- * Initialize Zypp (Factory method)
- */
-static zypp::ZYpp::Ptr
-get_zypp ()
-{
-	static gboolean initialized = FALSE;
-	zypp::ZYpp::Ptr zypp = NULL;
-
-	zypp = zypp::ZYppFactory::instance ().getZYpp ();
-	
-	// TODO: Make this threadsafe
-	if (initialized == FALSE) {
-		zypp::filesystem::Pathname pathname("/");
-		zypp->initializeTarget (pathname);
-
-		initialized = TRUE;
-	}
-
-	return zypp;
-}
-
-/**
  * backend_initialize:
  */
 static void
@@ -178,19 +145,24 @@ backend_get_description_thread (PkBackend *backend, gpointer data)
 	}
 	pk_backend_change_status (backend, PK_STATUS_ENUM_QUERY);
 
-	zypp::ZYpp::Ptr zypp;
-	zypp = get_zypp ();
-	//zypp::Resolvable::Kind kind = zypp::ResTraits<zypp::Package>::kind;
-
-	zypp::PoolItem item;
-	zypp::ResPool pool = zypp->pool ();
-	for (zypp::ResPool::byName_iterator it = pool.byNameBegin (pi->name);
-			it != pool.byNameEnd (pi->name); ++it) {
-		if (!item || it->status ().isInstalled ())
-			item = *it;
+	std::vector<zypp::PoolItem> *v;
+	v = zypp_get_packages_by_name ((const gchar *)pi->name);
+
+	zypp::ResObject::constPtr package;
+	for (std::vector<zypp::PoolItem>::iterator it = v->begin ();
+			it != v->end (); it++) {
+		zypp::ResObject::constPtr pkg = (*it);
+		const char *version = pkg->edition ().asString ().c_str ();
+fprintf (stderr, "\n\n *** comparing versions '%s' == '%s'", pi->version, version);
+		if (strcmp (pi->version, version) == 0) {
+			package = pkg;
+			break;
+		}
 	}
 
-	if (!item) {
+	delete (v);
+
+	if (package == NULL) {
 		pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "couldn't find package");
 		pk_package_id_free (pi);
 		g_free (d->package_id);
@@ -203,10 +175,10 @@ backend_get_description_thread (PkBackend *backend, gpointer data)
 				d->package_id,		// package_id
 				"unknown",		// const gchar *license
 				PK_GROUP_ENUM_OTHER,	// PkGroupEnum group
-				"FIXME: put package description here",	// const gchar *description
-				"FIXME: add package URL here",			// const gchar *url
-				0,			// gulong size
-				"FIXME: put package filelist here");			// const gchar *filelist
+				package->description ().c_str (),	// const gchar *description
+				"TODO: add package URL here",			// const gchar *url
+				(gulong)package->size(),			// gulong size
+				"TODO: put package filelist here");			// const gchar *filelist
 
 	pk_package_id_free (pi);
 	g_free (d->package_id);
@@ -410,7 +382,7 @@ backend_refresh_cache_thread (PkBackend *backend, gpointer data)
 
 		// skip changeable meda (DVDs and CDs).  Without doing this,
 		// the disc would be required to be physically present.
-		if (is_changeable_media (*repo.baseUrlsBegin ()) == true)
+		if (zypp_is_changeable_media (*repo.baseUrlsBegin ()) == true)
 			continue;
 
 		try {
diff --git a/backends/zypp/zypp-utils.cpp b/backends/zypp/zypp-utils.cpp
index aecd27e..4a0e8f7 100644
--- a/backends/zypp/zypp-utils.cpp
+++ b/backends/zypp/zypp-utils.cpp
@@ -3,14 +3,47 @@
 
 #include <stdlib.h>
 #include <glib.h>
+#include <zypp/ZYpp.h>
+#include <zypp/ZYppFactory.h>
 #include <zypp/RepoManager.h>
 #include <zypp/media/MediaManager.h>
 #include <zypp/Resolvable.h>
+#include <zypp/ResPool.h>
+#include <zypp/Repository.h>
+#include <zypp/RepoManager.h>
+#include <zypp/RepoInfo.h>
+#include <zypp/repo/RepoException.h>
+#include <zypp/parser/ParseException.h>
+#include <zypp/Pathname.h>
+#include <zypp/Patch.h>
+#include <zypp/Package.h>
 
 #include "zypp-utils.h"
 
+/**
+ * Initialize Zypp (Factory method)
+ */
+zypp::ZYpp::Ptr
+get_zypp ()
+{
+	static gboolean initialized = FALSE;
+	zypp::ZYpp::Ptr zypp = NULL;
+
+	zypp = zypp::ZYppFactory::instance ().getZYpp ();
+	
+	// TODO: Make this threadsafe
+	if (initialized == FALSE) {
+		zypp::filesystem::Pathname pathname("/");
+		zypp->initializeTarget (pathname);
+
+		initialized = TRUE;
+	}
+
+	return zypp;
+}
+
 gboolean
-is_changeable_media (const zypp::Url &url)
+zypp_is_changeable_media (const zypp::Url &url)
 {
 	gboolean is_cd = false;
 	try {
@@ -25,5 +58,57 @@ is_changeable_media (const zypp::Url &url)
 	return is_cd;
 }
 
+zypp::ResPool
+zypp_build_pool (gboolean include_local)
+{
+	zypp::ZYpp::Ptr zypp = get_zypp ();
+
+	if (include_local == TRUE) {
+		// Add local resolvables
+		zypp::Target_Ptr target = zypp->target ();
+		zypp->addResolvables (target->resolvables (), TRUE);
+	}
+
+	// Add resolvables from enabled repos
+	zypp::RepoManager manager;
+	std::list<zypp::RepoInfo> repos;
+	try {
+		repos = manager.knownRepositories ();
+		for (std::list<zypp::RepoInfo>::iterator it = repos.begin(); it != repos.end (); it++) {
+			zypp::RepoInfo repo (*it);
+
+			// skip disabled repos
+			if (repo.enabled () == false)
+				continue;
+
+			zypp::Repository repository = manager.createFromCache (repo);
+			zypp->addResolvables (repository.resolvables ());
+		}
+//	} catch (const zypp::repo::RepoNoAliasException &ex) {
+//	} catch (const zypp::repo::RepoNotCachedException &ex) {
+	} catch (const zypp::Exception &ex) {
+fprintf (stderr, "TODO: Handle exceptions: %s\n", ex.asUserString ().c_str ());
+	}
+
+	return zypp->pool ();
+}
+
+std::vector<zypp::PoolItem> *
+zypp_get_packages_by_name (const gchar *package_name)
+{
+	std::vector<zypp::PoolItem> *v = new std::vector<zypp::PoolItem> ();
+
+	zypp::ResPool pool = zypp_build_pool (FALSE);
+
+	std::string name (package_name);
+	for (zypp::ResPool::byName_iterator it = pool.byNameBegin (name);
+			it != pool.byNameEnd (name); it++) {
+		zypp::PoolItem item = (*it);
+		v->push_back (item);
+	}
+
+	return v;
+}
+
 #endif // _ZYPP_UTILS_H_
 
diff --git a/backends/zypp/zypp-utils.h b/backends/zypp/zypp-utils.h
index 4941019..47ee5d6 100644
--- a/backends/zypp/zypp-utils.h
+++ b/backends/zypp/zypp-utils.h
@@ -6,8 +6,37 @@
 #include <zypp/RepoManager.h>
 #include <zypp/media/MediaManager.h>
 #include <zypp/Resolvable.h>
+#include <zypp/ResPool.h>
 
-gboolean is_changeable_media (const zypp::Url &url);
+#include <list>
+
+// some typedefs and functions to shorten Zypp names
+typedef zypp::ResPoolProxy ZyppPool;
+//inline ZyppPool zyppPool() { return zypp::getZYpp()->poolProxy(); }
+typedef zypp::ui::Selectable::Ptr ZyppSelectable;
+typedef zypp::ui::Selectable*		ZyppSelectablePtr;
+typedef zypp::ResObject::constPtr	ZyppObject;
+typedef zypp::Package::constPtr		ZyppPackage;
+typedef zypp::Patch::constPtr		ZyppPatch;
+typedef zypp::Pattern::constPtr		ZyppPattern;
+typedef zypp::Language::constPtr	ZyppLanguage;
+//inline ZyppPackage tryCastToZyppPkg (ZyppObject obj)
+//	{ return zypp::dynamic_pointer_cast <const zypp::Package> (obj); }
+
+zypp::ZYpp::Ptr get_zypp ();
+
+gboolean zypp_is_changeable_media (const zypp::Url &url);
+
+/**
+ * Build and return a ResPool that contains all local resolvables
+ * and ones found in the enabled repositories.
+ */
+zypp::ResPool zypp_build_full_pool ();
+
+/**
+ * Returns a list of packages that match the specified package_name.
+ */
+std::vector<zypp::PoolItem> * zypp_get_packages_by_name (const gchar *package_name);
 
 #endif // _ZYPP_UTILS_H_
 
commit 81b673e649dcab705438303d15b9884149213f6c
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Nov 29 18:28:56 2007 +0000

     fix make check. note: the tests are now busted

diff --git a/src/pk-backend.c b/src/pk-backend.c
index d2882a4..1437811 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -1104,11 +1104,7 @@ pk_backend_finished (PkBackend *backend)
 	/* check we have not already finished */
 	if (backend->priv->finished == TRUE) {
 		pk_backend_message (backend, PK_MESSAGE_ENUM_DAEMON,
-				    "Backends cannot request Finished more than once!\n"
-				    "If you are using:\n"
-				    "* pk_backend_thread_helper\n"
-				    "   - You should _not_ use pk_backend_finished directly"
-				    "   - Return from the function like normal");
+				    "Backends cannot request Finished more than once!");
 		return FALSE;
 	}
 
@@ -2083,6 +2079,7 @@ static gboolean
 pk_backend_test_func_true (PkBackend *backend, gpointer data)
 {
 	g_usleep (1000*1000);
+	pk_backend_finished (backend);
 	return TRUE;
 }
 
@@ -2090,12 +2087,14 @@ static gboolean
 pk_backend_test_func_false (PkBackend *backend, gpointer data)
 {
 	g_usleep (1000*1000);
+	pk_backend_finished (backend);
 	return FALSE;
 }
 
 static gboolean
 pk_backend_test_func_immediate_false (PkBackend *backend, gpointer data)
 {
+	pk_backend_finished (backend);
 	return FALSE;
 }
 
@@ -2214,7 +2213,7 @@ libst_backend (LibSelfTest *test)
 	/************************************************************/
 	libst_title (test, "wait for a thread to return true");
 	g_timer_start (timer);
-	ret = pk_backend_thread_helper (backend, pk_backend_test_func_true, NULL);
+	ret = pk_backend_thread_create (backend, pk_backend_test_func_true, NULL);
 	if (ret == TRUE) {
 		libst_success (test, NULL);
 	} else {
@@ -2245,7 +2244,7 @@ libst_backend (LibSelfTest *test)
 	/************************************************************/
 	libst_title (test, "wait for a thread to return false");
 	g_timer_start (timer);
-	ret = pk_backend_thread_helper (backend, pk_backend_test_func_false, NULL);
+	ret = pk_backend_thread_create (backend, pk_backend_test_func_false, NULL);
 	if (ret == TRUE) {
 		libst_success (test, NULL);
 	} else {
@@ -2268,7 +2267,7 @@ libst_backend (LibSelfTest *test)
 	/************************************************************/
 	libst_title (test, "wait for a thread to return false (straight away)");
 	g_timer_start (timer);
-	ret = pk_backend_thread_helper (backend, pk_backend_test_func_immediate_false, NULL);
+	ret = pk_backend_thread_create (backend, pk_backend_test_func_immediate_false, NULL);
 	if (ret == TRUE) {
 		libst_success (test, NULL);
 	} else {
commit a5065179ef0551c28f268ac1cab4b715bf47abe4
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Nov 29 18:04:48 2007 +0000

    add a note about the dbus security file

diff --git a/src/pk-main.c b/src/pk-main.c
index c5fd1f9..6d45c64 100644
--- a/src/pk-main.c
+++ b/src/pk-main.c
@@ -75,7 +75,11 @@ pk_object_register (DBusGConnection *connection,
 		pk_warning ("RequestName failed!");
 		g_clear_error(error);
 		g_set_error(error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_DENIED,
-			    "Acquiring D-Bus name %s failed due to security policies on this machine", PK_DBUS_SERVICE);
+			    "Acquiring D-Bus name %s failed due to security policies on this machine\n"
+			    "This can happen for two reasons:\n"
+			    "* The correct user is not launching the executable (usually root)\n"
+			    "* The org.freedesktop.PackageKit.conf file is "
+			    "not installed in the system /etc/dbus-1/system.d directory\n", PK_DBUS_SERVICE);
 		return FALSE;
 	}
 
commit 39b6c01f396b050d128b7d426f8027fb577f7355
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Nov 29 17:56:19 2007 +0000

     check the user is root before we run packagekitd

diff --git a/src/run-pk.sh b/src/run-pk.sh
index 2e24c64..f2d7de2 100755
--- a/src/run-pk.sh
+++ b/src/run-pk.sh
@@ -1,5 +1,10 @@
 #!/bin/sh
 
+if [ "$USER" != "root" ]; then
+    echo "You are not running this script as root. Use sudo."
+    exit 1
+fi
+
 if [ "$1x" = "x" ]; then
     BACKEND=dummy
 else
commit 4cc78513f6117cb5b241b37184211d002530dfc7
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Nov 29 17:48:19 2007 +0000

    add a bugreport script

diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index 8080e92..40ab36e 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -5,3 +5,10 @@ endif
 bashcompletiondir = ${SYSCONFDIR}/bash_completion.d
 dist_bashcompletion_DATA = pk-completion.bash
 
+script_SCRIPTS =					\
+	packagekit-bugreport.sh
+
+EXTRA_DIST=$(script_SCRIPTS)
+
+scriptdir = $(bindir)
+
diff --git a/contrib/packagekit-bugreport.sh b/contrib/packagekit-bugreport.sh
new file mode 100755
index 0000000..ae7693b
--- /dev/null
+++ b/contrib/packagekit-bugreport.sh
@@ -0,0 +1,17 @@
+# Copyright (C) 2007 Richard Hughes <richard at hughsie.com>
+#
+# Licensed under the GNU General Public License Version 2
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+echo -n "Distro version:       "
+cat /etc/*-release | uniq
+
+echo -n "PackageKit version:   "
+pkcon --version
+
+echo "PackageKit Process Information:"
+ps aux --forest | grep packagekitd | grep -v grep
+
commit 9da22025283eb7183586032466cbe1ed115b4fe0
Author: Boyd Timothy <btimothy at gmail.com>
Date:   Wed Nov 28 16:45:50 2007 -0700

    Added pk_backend_finished () into a bunch of the zypp backend code so that when it errs out, the client will not just sit there.

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 596e28b..11da1c0 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -173,22 +173,34 @@ backend_get_description_thread (PkBackend *backend, gpointer data)
 		pk_package_id_free (pi);
 		g_free (d->package_id);
 		g_free (d);
+		pk_backend_finished (backend);
 		return FALSE;
 	}
 	pk_backend_change_status (backend, PK_STATUS_ENUM_QUERY);
 
-	// FIXME: Call libzypp here to get the "Selectable"
-	try
-	{
-		zypp::RepoManager manager;
-		//zypp::Repository repository(manager.createFromCach(repo));
+	zypp::ZYpp::Ptr zypp;
+	zypp = get_zypp ();
+	//zypp::Resolvable::Kind kind = zypp::ResTraits<zypp::Package>::kind;
+
+	zypp::PoolItem item;
+	zypp::ResPool pool = zypp->pool ();
+	for (zypp::ResPool::byName_iterator it = pool.byNameBegin (pi->name);
+			it != pool.byNameEnd (pi->name); ++it) {
+		if (!item || it->status ().isInstalled ())
+			item = *it;
 	}
-	catch ( const zypp::Exception &e)
-	{
+
+	if (!item) {
+		pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "couldn't find package");
+		pk_package_id_free (pi);
+		g_free (d->package_id);
+		g_free (d);
+		pk_backend_finished (backend);
+		return FALSE;
 	}
 
 	pk_backend_description (backend,
-				pi->name,		// package_id
+				d->package_id,		// package_id
 				"unknown",		// const gchar *license
 				PK_GROUP_ENUM_OTHER,	// PkGroupEnum group
 				"FIXME: put package description here",	// const gchar *description
@@ -235,6 +247,7 @@ backend_install_package_thread (PkBackend *backend, gpointer data)
                 pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id");
                 g_free (package_id);
 
+		pk_backend_finished (backend);
                 return FALSE;
         }
 
@@ -256,9 +269,14 @@ backend_install_package_thread (PkBackend *backend, gpointer data)
 	{
 		// TODO: Split the code up so it's not all just in one bit try/catch
 
-		// TODO: Fix up this code so we only iterate through enabled repositories
 		repos = manager.knownRepositories();
 		for (std::list <zypp::RepoInfo>::iterator it = repos.begin(); it != repos.end(); it++) {
+			zypp::RepoInfo repo (*it);
+
+			// skip disabled repos
+			if (repo.enabled () == false)
+				continue;
+
 			zypp::Repository repository = manager.createFromCache (*it);
 			zypp->addResolvables (repository.resolvables ());
 		}
@@ -304,6 +322,7 @@ backend_install_package_thread (PkBackend *backend, gpointer data)
 			pk_backend_error_code (backend, PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, "Couldn't resolve the package dependencies.");
 			g_free (package_id);
 			pk_package_id_free (pi);
+			pk_backend_finished (backend);
 			return FALSE;
 		}
 
@@ -325,12 +344,14 @@ printf ("Finished the installation.\n");
 		pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, ex.asUserString().c_str() );
 		g_free (package_id);
 		pk_package_id_free (pi);
+		pk_backend_finished (backend);
 		return FALSE;
 	} catch (const zypp::Exception &ex) {
 		//pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Error enumerating repositories");
 		pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString().c_str() );
 		g_free (package_id);
 		pk_package_id_free (pi);
+		pk_backend_finished (backend);
 		return FALSE;
 	}
 
@@ -351,8 +372,6 @@ backend_install_package (PkBackend *backend, const gchar *package_id)
 	//printf("package_id is %s\n", package_id);
 	gchar *package_to_install = g_strdup (package_id);
 	pk_backend_thread_create (backend, backend_install_package_thread, package_to_install);
-	//pk_backend_thread_create (backend, backend_install_package_thread, package_to_install);
-fprintf (stderr, "\n\n\n\n============== Returning from backend_install_package =============\n\n\n\n");
 }
 
 static gboolean
@@ -401,6 +420,7 @@ fprintf (stderr, "\n\n *** Refreshing metadata ***\n\n");
 				zypp::RepoManager::RefreshIfNeeded);
 		} catch (const zypp::Exception &ex) {
 			pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString ().c_str ());
+			pk_backend_finished (backend);
 			return FALSE;
 		}
 
@@ -416,6 +436,7 @@ fprintf (stderr, "\n\n *** Building cache ***\n\n");
 		} 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_finished (backend);
 			return FALSE;
 		}
 
@@ -426,6 +447,7 @@ fprintf (stderr, "\n\n *** Building cache ***\n\n");
 						i * percentage_increment);
 	}
 
+	pk_backend_finished (backend);
 	return TRUE;
 }
 
@@ -501,6 +523,7 @@ backend_resolve_thread (PkBackend *backend, gpointer data)
 	sqlite3 *db;
 	if (sqlite3_open("/var/cache/zypp/zypp.db", &db) != 0) {
 		pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Failed to open database");
+		pk_backend_finished (backend);
 		return FALSE;
 	}
 
@@ -510,6 +533,7 @@ backend_resolve_thread (PkBackend *backend, gpointer data)
 
 	if (sql_data->name == NULL) {
 		//did not get any matches
+		pk_backend_finished (backend);
 		return FALSE;
 	}
 	full_version = g_strconcat (sql_data->version, "-", sql_data->release, NULL);
commit 42160d322820ccd4f19bb5ce36a6858d1fc821e7
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Nov 28 22:43:39 2007 +0000

    only emit PK_BACKEND_CALLER_ACTIVE_CHANGED when we have disconnected - clients can never reconnect with the same connection

diff --git a/src/pk-backend.c b/src/pk-backend.c
index 8a494c9..d2882a4 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -1871,8 +1871,10 @@ pk_backend_is_caller_active (PkBackend *backend, gboolean *is_active)
 static void
 pk_backend_connection_changed_cb (LibGBus *libgbus, gboolean connected, PkBackend *backend)
 {
-	pk_debug ("client disconnected.... %i", connected);
-	g_signal_emit (backend, signals [PK_BACKEND_CALLER_ACTIVE_CHANGED], 0, FALSE);
+	if (connected == FALSE) {
+		pk_debug ("client disconnected....");
+		g_signal_emit (backend, signals [PK_BACKEND_CALLER_ACTIVE_CHANGED], 0, FALSE);
+	}
 }
 
 /**



More information about the PackageKit mailing list