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

Richard Hughes hughsient at kemper.freedesktop.org
Wed Jan 9 11:16:02 PST 2008


 backends/ipkg/pk-backend-ipkg.c |  145 ++++++++++++++++++++++++++++++++++++----
 1 file changed, 133 insertions(+), 12 deletions(-)

New commits:
commit 45751d756910daad6165d2ebf5d56ebb6478724c
Author: Thomas Wood <thomas at openedhand.com>
Date:   Wed Jan 9 17:34:36 2008 +0000

    ipkg: improve get_depends by returning packages with the highest available version number

diff --git a/backends/ipkg/pk-backend-ipkg.c b/backends/ipkg/pk-backend-ipkg.c
index a3957c3..0aa86d6 100644
--- a/backends/ipkg/pk-backend-ipkg.c
+++ b/backends/ipkg/pk-backend-ipkg.c
@@ -112,6 +112,50 @@ ipkg_is_devel_pkg (pkg_t *pkg)
   return FALSE;
 }
 
+/**
+ * ipkg_vec_find_latest:
+ *
+ * search a pkg_vec for the latest version of a package
+ */
+
+static pkg_t*
+ipkg_vec_find_latest_helper (pkg_vec_t *vec, pkg_t *pkg)
+{
+	gint i;
+	for (i = 0; i < vec->len; i++)
+	{
+		/* if the version found is newer, return it */
+		if (pkg_compare_versions (pkg, vec->pkgs[i]) > 0)
+			return vec->pkgs[i];
+	}
+	/* return NULL if there is no package newer than pkg */
+	return NULL;
+}
+
+static pkg_t*
+ipkg_vec_find_latest (pkg_vec_t *vec)
+{
+	gint i;
+	pkg_t *tmp, *ret;
+
+	if (vec->len < 1)
+		return NULL;
+	if (vec->len == 1)
+		return vec->pkgs[0];
+
+	ret = tmp = vec->pkgs[0];
+
+	for (i = 0; i < vec->len; i++)
+	{
+		tmp = ipkg_vec_find_latest_helper (vec, ret);
+		if (!tmp)
+			return ret;
+		else
+			ret = tmp;
+	}
+	return NULL;
+}
+
 
 /**
  * parse_filter:
@@ -465,22 +509,20 @@ backend_get_depends (PkBackend *backend, const gchar *package_id, gboolean recur
 		gchar *uid = NULL;
 		gint status;
 
-		/* find the package by name if we don't have a version
-		 * specified, and pick the first available package TODO: pick
-		 * the package with the newest version
+		/* find the package by name and select the package with the
+		 * latest version number
 		 *
-		 * this currently fails if the depends string includes a version
-		 * constraint, e.g. "libz1 (>= 1.2.3)".  TODO: parse the depends
-		 * string for version number
+		 * this currently fails if the package name includes a version
+		 * constraint, e.g. "libz1 (>= 1.2.3)".
+		 * TODO: parse the depends string for version number
 		 */
 
 		p_vec = pkg_vec_fetch_by_name (&global_conf.pkg_hash,
 		    pkg->depends_str[i]);
-
 		if (!p_vec || p_vec->len < 1 || !p_vec->pkgs[0])
 			continue;
 		
-		d_pkg = p_vec->pkgs[0];
+		d_pkg = ipkg_vec_find_latest (p_vec);
 
 		uid = g_strdup_printf ("%s;%s;%s;",
 			d_pkg->name, d_pkg->version, d_pkg->architecture);
commit 433142494c82a62a260915bf323b6b13fb418c3d
Author: Thomas Wood <thomas at openedhand.com>
Date:   Wed Jan 9 15:20:30 2008 +0000

    ipkg: improve devel filter

diff --git a/backends/ipkg/pk-backend-ipkg.c b/backends/ipkg/pk-backend-ipkg.c
index 2886ff9..a3957c3 100644
--- a/backends/ipkg/pk-backend-ipkg.c
+++ b/backends/ipkg/pk-backend-ipkg.c
@@ -93,6 +93,27 @@ ipkg_is_gui_pkg (pkg_t *pkg)
 }
 
 /**
+ * ipkg_is_devel_pkg:
+ *
+ * check an ipkg package to determine if it is a development package
+ */
+static gboolean
+ipkg_is_devel_pkg (pkg_t *pkg)
+{
+  if (g_strrstr (pkg->name, "-dev"))
+      return TRUE;
+
+  if (g_strrstr (pkg->name, "-dbg"))
+      return TRUE;
+
+  if (g_strrstr (pkg->section, "devel"))
+      return TRUE;
+
+  return FALSE;
+}
+
+
+/**
  * parse_filter:
  */
 static int
@@ -257,9 +278,9 @@ backend_search_name_thread (PkBackend *backend, gchar *params[2])
 		pkg = available->pkgs[i];
 		if (!g_strrstr (pkg->name, search))
 			continue;
-		if ((filter & PKG_DEVEL) && !g_strrstr (pkg->name, "-dev"))
+		if ((filter & PKG_DEVEL) && !ipkg_is_devel_pkg (pkg))
 			continue;
-		if ((filter & PKG_NOT_DEVEL) && g_strrstr (pkg->name, "-dev"))
+		if ((filter & PKG_NOT_DEVEL) && ipkg_is_devel_pkg (pkg))
 			continue;
 		if ((filter & PKG_GUI) && !ipkg_is_gui_pkg (pkg))
 			continue;
commit 81153712e45c5fd3ed08d61ca8c9024130ae0bf7
Author: Thomas Wood <thomas at openedhand.com>
Date:   Wed Jan 9 13:26:17 2008 +0000

    ipkg: add preliminary backend_get_depends function

diff --git a/backends/ipkg/pk-backend-ipkg.c b/backends/ipkg/pk-backend-ipkg.c
index 5881a9b..2886ff9 100644
--- a/backends/ipkg/pk-backend-ipkg.c
+++ b/backends/ipkg/pk-backend-ipkg.c
@@ -411,7 +411,66 @@ backend_update_system (PkBackend *backend)
 		NULL);
 }
 
+/**
+ * backend_get_depends:
+ */
+static void
+backend_get_depends (PkBackend *backend, const gchar *package_id, gboolean recursive)
+{
+	/* TODO: revursive is ignored */
+	PkPackageId *pi;
+	pkg_t *pkg = NULL;
+	gint i;
+
+	g_return_if_fail (backend != NULL);
+
+	pk_backend_change_status (backend, PK_STATUS_ENUM_QUERY);
+	pk_backend_no_percentage_updates (backend);
+
+	pi = pk_package_id_new_from_string (package_id);
+	pkg = pkg_hash_fetch_by_name_version (&global_conf.pkg_hash, pi->name, pi->version);
+
+	if (!pkg)
+	{
+		pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "Packge not found");
+		pk_backend_finished (backend);
+		return;
+	}
+
+	for (i = 0; i < pkg->depends_count; i++)
+	{
+		pkg_t *d_pkg = NULL;
+		pkg_vec_t *p_vec;
+		gchar *uid = NULL;
+		gint status;
+
+		/* find the package by name if we don't have a version
+		 * specified, and pick the first available package TODO: pick
+		 * the package with the newest version
+		 *
+		 * this currently fails if the depends string includes a version
+		 * constraint, e.g. "libz1 (>= 1.2.3)".  TODO: parse the depends
+		 * string for version number
+		 */
+
+		p_vec = pkg_vec_fetch_by_name (&global_conf.pkg_hash,
+		    pkg->depends_str[i]);
+
+		if (!p_vec || p_vec->len < 1 || !p_vec->pkgs[0])
+			continue;
+		
+		d_pkg = p_vec->pkgs[0];
 
+		uid = g_strdup_printf ("%s;%s;%s;",
+			d_pkg->name, d_pkg->version, d_pkg->architecture);
+		if (d_pkg->state_status == SS_INSTALLED)
+			status = PK_INFO_ENUM_INSTALLED;
+		else
+			status = PK_INFO_ENUM_AVAILABLE;
+		pk_backend_package (backend, status, uid, d_pkg->description);
+	}
+	pk_backend_finished (backend);
+}
 
 PK_BACKEND_OPTIONS (
 	"ipkg",					/* description */
@@ -421,7 +480,7 @@ PK_BACKEND_OPTIONS (
 	NULL,					/* get_groups */
 	backend_get_filters,			/* get_filters */
 	NULL,					/* cancel */
-	NULL,					/* get_depends */
+	backend_get_depends,			/* get_depends */
 	backend_get_description,		/* get_description */
 	NULL,					/* get_files */
 	NULL,					/* get_requires */
commit 44ed07f81769f66fd25814372ab3145188711d24
Author: Thomas Wood <thomas at openedhand.com>
Date:   Wed Jan 9 13:14:47 2008 +0000

    ipkg: fix package status in backend_search_name_thread

diff --git a/backends/ipkg/pk-backend-ipkg.c b/backends/ipkg/pk-backend-ipkg.c
index e9617ac..5881a9b 100644
--- a/backends/ipkg/pk-backend-ipkg.c
+++ b/backends/ipkg/pk-backend-ipkg.c
@@ -252,6 +252,8 @@ backend_search_name_thread (PkBackend *backend, gchar *params[2])
 	pkg_hash_fetch_available (&global_conf.pkg_hash, available);
 	for (i=0; i < available->len; i++) {
 		char *uid;
+		gint status;
+
 		pkg = available->pkgs[i];
 		if (!g_strrstr (pkg->name, search))
 			continue;
@@ -271,7 +273,12 @@ backend_search_name_thread (PkBackend *backend, gchar *params[2])
 		uid = g_strdup_printf ("%s;%s;%s;",
 			pkg->name, pkg->version, pkg->architecture);
 
-		pk_backend_package (backend, PK_INFO_ENUM_AVAILABLE, uid,pkg->description);
+		if (pkg->state_status == SS_INSTALLED)
+			status = PK_INFO_ENUM_INSTALLED;
+		else
+			status = PK_INFO_ENUM_AVAILABLE;
+
+		pk_backend_package (backend, status, uid,pkg->description);
 	}
 
 	pkg_vec_free(available);
commit 00942be11dfe498bff7335e488520ee017bae7d4
Author: Thomas Wood <thomas at openedhand.com>
Date:   Wed Jan 9 09:52:39 2008 +0000

    ipkg: remove redundant code from backend_install_package_thread

diff --git a/backends/ipkg/pk-backend-ipkg.c b/backends/ipkg/pk-backend-ipkg.c
index d7882ed..e9617ac 100644
--- a/backends/ipkg/pk-backend-ipkg.c
+++ b/backends/ipkg/pk-backend-ipkg.c
@@ -311,14 +311,6 @@ backend_install_package_thread (PkBackend *backend, gchar *package_id)
 
 	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;
-
-	/* ITS4: ignore, we've set this to something sane in backend_initalize */
-	if (!getenv ("PATH"))
-		setenv ("PATH", "", 1);
-
 	err = ipkg_packages_install (&args, pi->name);
 	if (err != 0)
 		ipkg_unknown_error (backend, err, "Install");



More information about the PackageKit mailing list