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

Richard Hughes hughsient at kemper.freedesktop.org
Mon Jan 7 10:15:28 PST 2008


 backends/ipkg/pk-backend-ipkg.c  |  148 ++++++++++++++++++++++++++++++++-------
 docs/html/img/author-lmacken.png |binary
 docs/html/pk-authors.html        |   20 +++++
 3 files changed, 145 insertions(+), 23 deletions(-)

New commits:
commit 9c1e0763a32ac980ce22eb3704b72b950c5e72ba
Author: Thomas Wood <thomas at openedhand.com>
Date:   Mon Jan 7 17:09:59 2008 +0000

    Add my details to the authors page

diff --git a/docs/html/pk-authors.html b/docs/html/pk-authors.html
index e40084d..01b2012 100644
--- a/docs/html/pk-authors.html
+++ b/docs/html/pk-authors.html
@@ -207,6 +207,26 @@
  </td>
 </tr>
 
+<tr>
+ <td>
+  <img src="img/author-unknown.png" alt="[img]"/><!-- image should be 120px wide -->
+ </td>
+ <td>
+  <h2>Thomas Wood</h2>
+  <p>
+  Thomas is a software engineer at <a
+  href="http://www.openedhand.com">OpenedHand</a> and is working on the Ipkg
+  backend for <a href="http://www.openmoko.org">OpenMoko</a>. He takes no
+  responsibility for the quality of Ipkg itself and hopes using PackageKit will
+  allow a smooth transition to an alternative package management system in the
+  future.
+  </p>
+  <p>
+   <b>Responsible for: ipkg backend</b>
+  </p>
+ </td>
+</tr>
+
 </table>
 
 <p>Back to the <a href="index.html">main page</a></p>
commit 7d6bd0f2208bd9ffcc47cb1697c3d1fd34cf2bfb
Author: Thomas Wood <thomas at openedhand.com>
Date:   Mon Jan 7 16:34:57 2008 +0000

    ipkg: use threads for refresh cache and get description functions

diff --git a/backends/ipkg/pk-backend-ipkg.c b/backends/ipkg/pk-backend-ipkg.c
index 1a27961..a19e327 100644
--- a/backends/ipkg/pk-backend-ipkg.c
+++ b/backends/ipkg/pk-backend-ipkg.c
@@ -81,25 +81,53 @@ backend_destroy (PkBackend *backend)
 	args_deinit (&args);
 }
 
+
+static gboolean
+backend_get_description_thread (PkBackend *backend, gchar *package_id)
+{
+	pkg_t *pkg;
+	PkPackageId *pi;
+	pi = pk_package_id_new_from_string (package_id);
+	pkg = pkg_hash_fetch_by_name_version (&global_conf.pkg_hash, pi->name, pi->version);
+
+	pk_backend_description (backend, pi->name,
+	    "unknown", PK_GROUP_ENUM_OTHER, pkg->description, pkg->url, 0, NULL);
+
+	g_free (package_id);
+	pk_backend_finished (backend);
+	return TRUE;
+}
+
 /**
  * backend_get_description:
  */
 static void
 backend_get_description (PkBackend *backend, const gchar *package_id)
 {
-	pkg_t *pkg;
-	PkPackageId *pi;
 	g_return_if_fail (backend != NULL);
 
 	pk_backend_change_status (backend, PK_STATUS_ENUM_QUERY);
+	pk_backend_thread_create (backend,
+		(PkBackendThreadFunc) backend_get_description_thread,
+		g_strdup (package_id));
+}
 
-	pi = pk_package_id_new_from_string (package_id);
-	pkg = pkg_hash_fetch_by_name_version (&global_conf.pkg_hash, pi->name, pi->version);
+static gboolean
+backend_refresh_cache_thread (PkBackend *backend, gpointer data)
+{
+	int ret;
 
-	pk_backend_description (backend, pi->name,
-	    "unknown", PK_GROUP_ENUM_OTHER, pkg->description, pkg->url, 0, NULL);
+	/* set up debug if in verbose mode */
+	if (pk_debug_enabled ())
+		ipkg_cb_message = ipkg_debug;
 
+	ret = ipkg_lists_update (&args);
+	if (ret) {
+		pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "update failed");
+	}
 	pk_backend_finished (backend);
+
+	return (ret == 0);
 }
 
 /**
@@ -108,19 +136,15 @@ backend_get_description (PkBackend *backend, const gchar *package_id)
 static void
 backend_refresh_cache (PkBackend *backend, gboolean force)
 {
-	int ret;
 	g_return_if_fail (backend != NULL);
 
 	pk_backend_change_status (backend, PK_STATUS_ENUM_REFRESH_CACHE);
 	pk_backend_no_percentage_updates (backend);
 
-	ipkg_cb_message = ipkg_debug;
 
-	ret = ipkg_lists_update (&args);
-	if (ret) {
-		pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "update failed");
-	}
-	pk_backend_finished (backend);
+	pk_backend_thread_create (backend,
+		(PkBackendThreadFunc) backend_refresh_cache_thread,
+		NULL);
 }
 
 /**
commit 6631895f3732667a8a1d6f48f3101b0a971f82a8
Author: Thomas Wood <thomas at openedhand.com>
Date:   Mon Jan 7 16:15:44 2008 +0000

    ipkg: Use a define to set offline_root if required

diff --git a/backends/ipkg/pk-backend-ipkg.c b/backends/ipkg/pk-backend-ipkg.c
index e2e0106..1a27961 100644
--- a/backends/ipkg/pk-backend-ipkg.c
+++ b/backends/ipkg/pk-backend-ipkg.c
@@ -59,10 +59,8 @@ backend_initalize (PkBackend *backend)
 
 	args_init (&args);
 
-#if 0
-	/* testing only */
-	args.offline_root = "/home/thomas/chroots/openmoko/";
-	args.noaction = 0;
+#ifdef IPKG_OFFLINE_ROOT
+	args.offline_root = IPKG_OFFLINE_ROOT;
 #endif
 
 	err = ipkg_conf_init (&global_conf, &args);
commit c7c3e73b8483d6e6198713dcd869f129ddf6316d
Author: Thomas Wood <thomas at openedhand.com>
Date:   Mon Jan 7 15:49:17 2008 +0000

    Ensure status is always set in ipkg backend functions

diff --git a/backends/ipkg/pk-backend-ipkg.c b/backends/ipkg/pk-backend-ipkg.c
index 7b6df2b..e2e0106 100644
--- a/backends/ipkg/pk-backend-ipkg.c
+++ b/backends/ipkg/pk-backend-ipkg.c
@@ -93,6 +93,8 @@ backend_get_description (PkBackend *backend, const gchar *package_id)
 	PkPackageId *pi;
 	g_return_if_fail (backend != NULL);
 
+	pk_backend_change_status (backend, PK_STATUS_ENUM_QUERY);
+
 	pi = pk_package_id_new_from_string (package_id);
 	pkg = pkg_hash_fetch_by_name_version (&global_conf.pkg_hash, pi->name, pi->version);
 
@@ -110,6 +112,8 @@ backend_refresh_cache (PkBackend *backend, gboolean force)
 {
 	int ret;
 	g_return_if_fail (backend != NULL);
+
+	pk_backend_change_status (backend, PK_STATUS_ENUM_REFRESH_CACHE);
 	pk_backend_no_percentage_updates (backend);
 
 	ipkg_cb_message = ipkg_debug;
@@ -135,9 +139,6 @@ backend_search_name_thread (PkBackend *backend, gchar *search)
 
 	ipkg_cb_message = ipkg_debug;
 
-	pk_backend_change_status (backend, PK_STATUS_ENUM_QUERY);
-	pk_backend_no_percentage_updates (backend);
-
 	available = pkg_vec_alloc();
 	pkg_hash_fetch_available (&global_conf.pkg_hash, available);
 	for (i=0; i < available->len; i++) {
@@ -164,6 +165,9 @@ backend_search_name (PkBackend *backend, const gchar *filter, const gchar *searc
 	g_return_if_fail (backend != NULL);
 	char *foo = g_strdup (search);
 
+	pk_backend_change_status (backend, PK_STATUS_ENUM_QUERY);
+	pk_backend_no_percentage_updates (backend);
+
 	pk_backend_thread_create (backend,(PkBackendThreadFunc) backend_search_name_thread, foo);
 }
 
@@ -199,6 +203,7 @@ backend_install_package (PkBackend *backend, const gchar *package_id)
 {
 	g_return_if_fail (backend != NULL);
 
+	pk_backend_change_status (backend, PK_STATUS_ENUM_INSTALL);
 	pk_backend_no_percentage_updates (backend);
 	pk_backend_thread_create (backend,
 		(PkBackendThreadFunc) backend_install_package_thread,
@@ -228,6 +233,7 @@ static void
 backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean allow_deps)
 {
 	g_return_if_fail (backend != NULL);
+	pk_backend_change_status (backend, PK_STATUS_ENUM_REMOVE);
 	pk_backend_no_percentage_updates (backend);
 	/* TODO: allow_deps is currently ignored */
 	pk_backend_thread_create (backend,
commit 3576c33707851a2fe247e2432434e1794a8a70c7
Author: Thomas Wood <thomas at openedhand.com>
Date:   Mon Jan 7 15:46:41 2008 +0000

    Clean up some memory management in the ipkg backend

diff --git a/backends/ipkg/pk-backend-ipkg.c b/backends/ipkg/pk-backend-ipkg.c
index 27a75fe..7b6df2b 100644
--- a/backends/ipkg/pk-backend-ipkg.c
+++ b/backends/ipkg/pk-backend-ipkg.c
@@ -69,7 +69,6 @@ backend_initalize (PkBackend *backend)
 	if (err) {
 		pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "init failed");
 	}
-	args_deinit (&args);
 }
 
 /**
@@ -79,8 +78,9 @@ static void
 backend_destroy (PkBackend *backend)
 {
 	g_return_if_fail (backend != NULL);
-	/* this appears to be freed elsewhere ... */
+	/* this appears to (sometimes) be freed elsewhere ... */
 	/* ipkg_conf_deinit (&global_conf); */
+	args_deinit (&args);
 }
 
 /**
@@ -189,6 +189,7 @@ backend_install_package_thread (PkBackend *backend, gchar *package_id)
 		pk_backend_error_code (backend, PK_ERROR_ENUM_UNKNOWN, "Install failed");
 
 	g_free (package_id);
+	pk_package_id_free (pi);
 	pk_backend_finished (backend);
 	return (err == 0);
 }
commit 21fe02a809f03f027ecad4226987640d6d29f16c
Author: Thomas Wood <thomas at openedhand.com>
Date:   Mon Jan 7 15:16:50 2008 +0000

    Implement remove package function in ipkg backend

diff --git a/backends/ipkg/pk-backend-ipkg.c b/backends/ipkg/pk-backend-ipkg.c
index 9eaa365..27a75fe 100644
--- a/backends/ipkg/pk-backend-ipkg.c
+++ b/backends/ipkg/pk-backend-ipkg.c
@@ -204,6 +204,37 @@ backend_install_package (PkBackend *backend, const gchar *package_id)
 		g_strdup (package_id));
 }
 
+static gboolean
+backend_remove_package_thread (PkBackend *backend, gchar *package_id)
+{
+	PkPackageId *pi;
+	gint err;
+
+	pi = pk_package_id_new_from_string (package_id);
+
+	err = ipkg_packages_remove (&args, pi->name, 0);
+	/* TODO: improve error reporting */
+	if (err != 0)
+		pk_backend_error_code (backend, PK_ERROR_ENUM_UNKNOWN, "Install failed");
+
+	g_free (package_id);
+	pk_package_id_free (pi);
+	pk_backend_finished (backend);
+	return (err == 0);
+}
+
+static void
+backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean allow_deps)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_no_percentage_updates (backend);
+	/* TODO: allow_deps is currently ignored */
+	pk_backend_thread_create (backend,
+		(PkBackendThreadFunc) backend_remove_package_thread,
+		g_strdup (package_id));
+
+}
+
 PK_BACKEND_OPTIONS (
 	"ipkg",					/* description */
 	"Thomas Wood <thomas at openedhand.com>",	/* author */
@@ -221,7 +252,7 @@ PK_BACKEND_OPTIONS (
 	backend_install_package,		/* install_package */
 	NULL,					/* install_file */
 	backend_refresh_cache,			/* refresh_cache */
-	NULL,					/* remove_package */
+	backend_remove_package,			/* remove_package */
 	NULL,					/* resolve */
 	NULL,					/* rollback */
 	NULL,					/* search_details */
commit f8b66d3e2b52064f98027c3e7d7238398b29a970
Merge: a3846be... 1dd4866...
Author: Thomas Wood <thomas at openedhand.com>
Date:   Mon Jan 7 14:25:56 2008 +0000

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

commit a3846be6107bd6433de3fb1bef59cc4b79ed70bc
Author: Thomas Wood <thomas at openedhand.com>
Date:   Mon Jan 7 14:24:16 2008 +0000

    Implement install package in ipkg backend

diff --git a/backends/ipkg/pk-backend-ipkg.c b/backends/ipkg/pk-backend-ipkg.c
index 4d5af12..9eaa365 100644
--- a/backends/ipkg/pk-backend-ipkg.c
+++ b/backends/ipkg/pk-backend-ipkg.c
@@ -24,6 +24,7 @@
 #include <glib.h>
 #include <string.h>
 #include <pk-backend.h>
+#include <pk-debug.h>
 
 
 #define IPKG_LIB
@@ -33,6 +34,9 @@
 static ipkg_conf_t global_conf;
 static args_t args;
 
+/* Ipkg message callback function */
+extern ipkg_message_callback ipkg_cb_message;
+
 int
 ipkg_debug (ipkg_conf_t *conf, message_level_t level, char *msg)
 {
@@ -58,7 +62,7 @@ backend_initalize (PkBackend *backend)
 #if 0
 	/* testing only */
 	args.offline_root = "/home/thomas/chroots/openmoko/";
-	args.noaction = 1;
+	args.noaction = 0;
 #endif
 
 	err = ipkg_conf_init (&global_conf, &args);
@@ -74,8 +78,9 @@ backend_initalize (PkBackend *backend)
 static void
 backend_destroy (PkBackend *backend)
 {
-	ipkg_conf_deinit (&global_conf);
 	g_return_if_fail (backend != NULL);
+	/* this appears to be freed elsewhere ... */
+	/* ipkg_conf_deinit (&global_conf); */
 }
 
 /**
@@ -162,6 +167,42 @@ backend_search_name (PkBackend *backend, const gchar *filter, const gchar *searc
 	pk_backend_thread_create (backend,(PkBackendThreadFunc) backend_search_name_thread, foo);
 }
 
+static gboolean
+backend_install_package_thread (PkBackend *backend, gchar *package_id)
+{
+	PkPackageId *pi;
+	gint err;
+
+	pi = pk_package_id_new_from_string (package_id);
+
+	/* set up debug if in verbose mode */
+	if (pk_debug_enabled ())
+		ipkg_cb_message = ipkg_debug;
+
+	/* libipkg requires PATH env variable to be present, otherwise it
+	 * segfaults */
+	if (!getenv ("PATH"))
+		setenv ("PATH", "", 1);
+
+	err = ipkg_packages_install (&args, pi->name);
+	if (err != 0)
+		pk_backend_error_code (backend, PK_ERROR_ENUM_UNKNOWN, "Install failed");
+
+	g_free (package_id);
+	pk_backend_finished (backend);
+	return (err == 0);
+}
+
+static void
+backend_install_package (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+
+	pk_backend_no_percentage_updates (backend);
+	pk_backend_thread_create (backend,
+		(PkBackendThreadFunc) backend_install_package_thread,
+		g_strdup (package_id));
+}
 
 PK_BACKEND_OPTIONS (
 	"ipkg",					/* description */
@@ -177,7 +218,7 @@ PK_BACKEND_OPTIONS (
 	NULL,					/* get_requires */
 	NULL,					/* get_update_detail */
 	NULL,					/* get_updates */
-	NULL,					/* install_package */
+	backend_install_package,		/* install_package */
 	NULL,					/* install_file */
 	backend_refresh_cache,			/* refresh_cache */
 	NULL,					/* remove_package */
commit 1dd4866e2b678ba14ce2114988aeaf7d1e8ca934
Author: Luke Macken <lmacken at redhat.com>
Date:   Mon Jan 7 00:57:57 2008 -0500

    Add author image and details for lmacken

diff --git a/docs/html/img/author-lmacken.png b/docs/html/img/author-lmacken.png
new file mode 100644
index 0000000..832fa8a
Binary files /dev/null and b/docs/html/img/author-lmacken.png differ
commit d347e6b020346ba8d089152413531a1e2748f075
Merge: dbe13ad... 431cb7d...
Author: Thomas Wood <thomas at openedhand.com>
Date:   Fri Jan 4 14:54:27 2008 +0000

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

commit dbe13ada0d3086a93fefcd3bd7531edcdb1c4060
Author: Thomas Wood <thomas at openedhand.com>
Date:   Fri Jan 4 12:38:51 2008 +0000

    Comment out testing only code

diff --git a/backends/ipkg/pk-backend-ipkg.c b/backends/ipkg/pk-backend-ipkg.c
index 78ac977..4d5af12 100644
--- a/backends/ipkg/pk-backend-ipkg.c
+++ b/backends/ipkg/pk-backend-ipkg.c
@@ -55,10 +55,11 @@ backend_initalize (PkBackend *backend)
 
 	args_init (&args);
 
+#if 0
 	/* testing only */
 	args.offline_root = "/home/thomas/chroots/openmoko/";
 	args.noaction = 1;
-
+#endif
 
 	err = ipkg_conf_init (&global_conf, &args);
 	if (err) {



More information about the PackageKit mailing list