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

Richard Hughes hughsient at kemper.freedesktop.org
Thu Jan 10 11:16:04 PST 2008


 backends/dummy/pk-backend-dummy.c |   21 ++++++--
 backends/ipkg/pk-backend-ipkg.c   |   95 +++++++++++++++++++++++++++++++++-----
 src/pk-backend.c                  |    7 ++
 3 files changed, 105 insertions(+), 18 deletions(-)

New commits:
commit 29e07f9150911e8404be8dd2c99165426c6485f4
Author: Thomas Wood <thomas at openedhand.com>
Date:   Thu Jan 10 18:18:41 2008 +0000

    ipkg: add backend_update_package function

diff --git a/backends/ipkg/pk-backend-ipkg.c b/backends/ipkg/pk-backend-ipkg.c
index 086038d..fed995d 100644
--- a/backends/ipkg/pk-backend-ipkg.c
+++ b/backends/ipkg/pk-backend-ipkg.c
@@ -30,6 +30,10 @@
 #define IPKG_LIB
 #include <libipkg.h>
 
+/* this is implemented in libipkg.a */
+int ipkg_upgrade_pkg(ipkg_conf_t *conf, pkg_t *old);
+
+
 enum filters {
 	PKG_INSTALLED = 1,
 	PKG_NOT_INSTALLED = 2,
@@ -560,6 +564,50 @@ backend_get_depends (PkBackend *backend, const gchar *package_id, gboolean recur
 	pk_backend_finished (backend);
 }
 
+/**
+ * backend_update_package:
+ */
+static gboolean
+backend_update_package_thread (PkBackend *backend, gchar *package_id)
+{
+	PkPackageId *pi;
+	pkg_t *pkg;
+	gint err = 0;
+
+	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");
+		err = -1;
+	} else {
+		/* TODO: determine if package is already latest? */
+		err = ipkg_upgrade_pkg (&global_conf, pkg);
+		if (err != 0)
+			ipkg_unknown_error (backend, err, "Update package");
+	}
+
+	g_free (package_id);
+	pk_package_id_free (pi);
+	pk_backend_finished (backend);
+	return (err != 0);
+}
+
+static void
+backend_update_package (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+
+	pk_backend_change_status (backend, PK_STATUS_ENUM_UPDATE);
+	pk_backend_no_percentage_updates (backend);
+
+	pk_backend_thread_create (backend,
+		(PkBackendThreadFunc) backend_update_package_thread,
+		g_strdup (package_id));
+}
+
+
 PK_BACKEND_OPTIONS (
 	"ipkg",					/* description */
 	"Thomas Wood <thomas at openedhand.com>",	/* author */
@@ -584,7 +632,7 @@ PK_BACKEND_OPTIONS (
 	NULL,					/* search_file */
 	NULL,					/* search_group */
 	backend_search_name,			/* search_name */
-	NULL,					/* update_package */
+	backend_update_package,			/* update_package */
 	backend_update_system,			/* update_system */
 	NULL,					/* get_repo_list */
 	NULL,					/* repo_enable */
commit 2215ae0617d41c8136f3a918764151045874f6c2
Author: Thomas Wood <thomas at openedhand.com>
Date:   Thu Jan 10 18:14:10 2008 +0000

    ipkg: free PkPackageId struct in get_depends if package not found

diff --git a/backends/ipkg/pk-backend-ipkg.c b/backends/ipkg/pk-backend-ipkg.c
index 1578dd3..086038d 100644
--- a/backends/ipkg/pk-backend-ipkg.c
+++ b/backends/ipkg/pk-backend-ipkg.c
@@ -498,7 +498,9 @@ backend_get_depends (PkBackend *backend, const gchar *package_id, gboolean recur
 
 	if (!pkg)
 	{
-		pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "Packge not found");
+		pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND,
+				"Package not found");
+		pk_package_id_free (pi);
 		pk_backend_finished (backend);
 		return;
 	}
commit 2fad8a256836d764e9f1a15e7ed10eccd91ec405
Author: Thomas Wood <thomas at openedhand.com>
Date:   Thu Jan 10 18:11:38 2008 +0000

    ipkg: fix debug reporting

diff --git a/backends/ipkg/pk-backend-ipkg.c b/backends/ipkg/pk-backend-ipkg.c
index d88be8d..1578dd3 100644
--- a/backends/ipkg/pk-backend-ipkg.c
+++ b/backends/ipkg/pk-backend-ipkg.c
@@ -50,7 +50,7 @@ static gchar *last_error;
 int
 ipkg_debug (ipkg_conf_t *conf, message_level_t level, char *msg)
 {
-	if (level != 0)
+	if (level != 1)
 		return 0;
 
 	/* print messages only if in verbose mode */
commit 5492cded007dddc905a64bc4887303b7e45e0bc2
Author: Thomas Wood <thomas at openedhand.com>
Date:   Thu Jan 10 15:15:06 2008 +0000

    ipkg: extract version requirements from depends information

diff --git a/backends/ipkg/pk-backend-ipkg.c b/backends/ipkg/pk-backend-ipkg.c
index 0aa86d6..d88be8d 100644
--- a/backends/ipkg/pk-backend-ipkg.c
+++ b/backends/ipkg/pk-backend-ipkg.c
@@ -486,6 +486,7 @@ backend_get_depends (PkBackend *backend, const gchar *package_id, gboolean recur
 	PkPackageId *pi;
 	pkg_t *pkg = NULL;
 	gint i;
+	GRegex *regex;
 
 	g_return_if_fail (backend != NULL);
 
@@ -502,28 +503,49 @@ backend_get_depends (PkBackend *backend, const gchar *package_id, gboolean recur
 		return;
 	}
 
+	/* compile a regex expression to parse depends_str package names */
+	regex = g_regex_new ("(.+) \\(([>=<]+) (.+)\\)", G_REGEX_OPTIMIZE, 0, NULL);
+
 	for (i = 0; i < pkg->depends_count; i++)
 	{
 		pkg_t *d_pkg = NULL;
 		pkg_vec_t *p_vec;
-		gchar *uid = NULL;
+		GMatchInfo *match_info = NULL;
+		gchar *uid = NULL, *pkg_name = NULL, *pkg_v = NULL, *pkg_req = NULL;
 		gint status;
 
 		/* find the package by name and select the package with the
 		 * latest 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 (!g_regex_match (regex, pkg->depends_str[i], 0, &match_info))
+		{
+			/* we couldn't parse the depends string */
+
+			/* match_info is always allocated, even if the match
+			 * failed */
+			g_match_info_free (match_info);
+			continue;
+		}
+
+		pkg_name = g_match_info_fetch (match_info, 1);
+		pkg_req = g_match_info_fetch (match_info, 2);
+		pkg_v = g_match_info_fetch (match_info, 3);
+		g_match_info_free (match_info);
+
+		p_vec = pkg_vec_fetch_by_name (&global_conf.pkg_hash, pkg_name);
+
 		if (!p_vec || p_vec->len < 1 || !p_vec->pkgs[0])
 			continue;
-		
+
 		d_pkg = ipkg_vec_find_latest (p_vec);
 
+		/* TODO: check the version requirements are satisfied */
+
+		g_free (pkg_name);
+		g_free (pkg_req);
+		g_free (pkg_v);
+
 		uid = g_strdup_printf ("%s;%s;%s;",
 			d_pkg->name, d_pkg->version, d_pkg->architecture);
 		if (d_pkg->state_status == SS_INSTALLED)
@@ -532,6 +554,7 @@ backend_get_depends (PkBackend *backend, const gchar *package_id, gboolean recur
 			status = PK_INFO_ENUM_AVAILABLE;
 		pk_backend_package (backend, status, uid, d_pkg->description);
 	}
+	g_regex_unref (regex);
 	pk_backend_finished (backend);
 }
 
commit c49171fa435791752e8eb93accb11af17a9f15d5
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Jan 9 23:30:45 2008 +0000

    convert back all the ;'s to newlines in the scripted backends

diff --git a/src/pk-backend.c b/src/pk-backend.c
index eb54690..d4e5a4b 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -352,6 +352,7 @@ pk_backend_parse_common_error (PkBackend *backend, const gchar *line)
 	guint size;
 	gint percentage;
 	gchar *command;
+	gchar *text;
 	PkErrorCodeEnum error_enum;
 	PkStatusEnum status_enum;
 	PkMessageEnum message_enum;
@@ -412,7 +413,11 @@ pk_backend_parse_common_error (PkBackend *backend, const gchar *line)
 			ret = FALSE;
 			goto out;
 		}
-		pk_backend_error_code (backend, error_enum, sections[2]);
+		/* convert back all the ;'s to newlines */
+		text = g_strdup (sections[2]);
+		g_strdelimit (text, ";", '\n');
+		pk_backend_error_code (backend, error_enum, text);
+		g_free (text);
 	} else if (pk_strequal (command, "requirerestart") == TRUE) {
 		if (size != 3) {
 			pk_warning ("invalid command '%s'", command);
commit 7778e8115252e8ec6747fad844951cc4f5205055
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Jan 9 19:47:39 2008 +0000

    be cleverer with the dummy backend and UpdateDetail

diff --git a/backends/dummy/pk-backend-dummy.c b/backends/dummy/pk-backend-dummy.c
index 1c62237..2701370 100644
--- a/backends/dummy/pk-backend-dummy.c
+++ b/backends/dummy/pk-backend-dummy.c
@@ -22,6 +22,7 @@
 #include <gmodule.h>
 #include <glib.h>
 #include <string.h>
+#include <pk-common.h>
 #include <pk-backend.h>
 
 static guint progress_percentage;
@@ -154,12 +155,20 @@ backend_get_update_detail (PkBackend *backend, const gchar *package_id)
 {
 	g_return_if_fail (backend != NULL);
 	pk_backend_change_status (backend, PK_STATUS_ENUM_QUERY);
-	pk_backend_update_detail (backend, "glib2;2.14.0;i386;fedora",
-				  "glib2;2.12.0;i386;fedora", "",
-				  "http://www.distro-update.org/page?moo;Bugfix release for PackageKit",
-				  "http://bgzilla.fd.org/result.php?#12344;Freedesktop Bugzilla #12344",
-				  "http://nvd.nist.gov/nvd.cfm?cvename=CVE-2007-3381;CVE-2007-3381",
-				  "system", "Update to newest upstream source");
+	if (pk_strequal (package_id, "powertop;1.8-1.fc8;i386;fedora") == TRUE) {
+		pk_backend_update_detail (backend, "powertop;1.8-1.fc8;i386;available",
+					  "powertop;1.7-1.fc8;i386;installed", "",
+					  "http://www.distro-update.org/page?moo;Bugfix release for powertop",
+					  "http://bgzilla.fd.org/result.php?#12344;Freedesktop Bugzilla #12344",
+					  "", "", "Update to newest upstream source");
+	} else {
+		pk_backend_update_detail (backend, "kernel;2.6.23-0.115.rc3.git1.fc8;i386;available",
+					  "kernel;2.6.22-0.105.rc3.git7.fc8;i386;installed", "",
+					  "http://www.distro-update.org/page?moo;Bugfix release for kernel",
+					  "http://bgzilla.fd.org/result.php?#12344;Freedesktop Bugzilla #12344",
+					  "http://nvd.nist.gov/nvd.cfm?cvename=CVE-2007-3381;CVE-2007-3381",
+					  "system", "Update to newest version");
+	}
 	pk_backend_finished (backend);
 }
 



More information about the PackageKit mailing list