[packagekit] packagekit: Branch 'master' - 7 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Wed Jan 16 13:25:56 PST 2008
backends/ipkg/pk-backend-ipkg.c | 120 ++++++++++++++++++++++++++++++++++---
backends/yum/helpers/yumBackend.py | 36 ++++++-----
configure.ac | 7 ++
src/pk-backend.c | 13 +++-
src/pk-conf.c | 12 ++-
5 files changed, 158 insertions(+), 30 deletions(-)
New commits:
commit 26a6858d7651c19fc64bf01c7ed56d40888e3e84
Author: Thomas Wood <thomas at openedhand.com>
Date: Wed Jan 16 16:20:09 2008 +0000
ipkg: implement initial get_updates function
diff --git a/backends/ipkg/pk-backend-ipkg.c b/backends/ipkg/pk-backend-ipkg.c
index 4e87ad4..ae8b861 100644
--- a/backends/ipkg/pk-backend-ipkg.c
+++ b/backends/ipkg/pk-backend-ipkg.c
@@ -661,6 +661,65 @@ backend_update_package (PkBackend *backend, const gchar *package_id)
g_strdup (package_id));
}
+/**
+ * backend_get_updates:
+ */
+
+static gboolean
+backend_get_updates_thread (PkBackend *backend, gpointer data)
+{
+ pkg_vec_t *installed;
+ gint i;
+
+
+ installed = pkg_vec_alloc();
+
+ pkg_hash_fetch_all_installed (&global_conf.pkg_hash, installed);
+
+ for (i=0; i < installed->len; i++) {
+
+ gchar *uid;
+ pkg_t *pkg, *best_pkg;
+ gint status;
+
+ pkg = installed->pkgs[i];
+ best_pkg = pkg_hash_fetch_best_installation_candidate_by_name (&global_conf, pkg->name);
+
+ /* couldn't find an install candidate?! */
+ if (!best_pkg)
+ continue;
+
+ /* check to see if the best candidate is actually newer */
+ if (pkg_compare_versions (best_pkg, pkg) <= 0)
+ continue;
+
+ uid = g_strdup_printf ("%s;%s;%s;",
+ pkg->name, pkg->version, pkg->architecture);
+
+ 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);
+ }
+ pk_backend_finished (backend);
+ return TRUE;
+}
+
+static void
+backend_get_updates (PkBackend *backend)
+{
+ 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_get_updates_thread,
+ NULL);
+}
+
PK_BACKEND_OPTIONS (
"ipkg", /* description */
@@ -675,7 +734,7 @@ PK_BACKEND_OPTIONS (
NULL, /* get_files */
NULL, /* get_requires */
NULL, /* get_update_detail */
- NULL, /* get_updates */
+ backend_get_updates, /* get_updates */
backend_install_package, /* install_package */
NULL, /* install_file */
backend_refresh_cache, /* refresh_cache */
commit b91de20dcb0633f358c7c716496cd0f1194070ce
Author: Thomas Wood <thomas at openedhand.com>
Date: Wed Jan 16 11:59:22 2008 +0000
ipkg: move get_depends function into a thread
diff --git a/backends/ipkg/pk-backend-ipkg.c b/backends/ipkg/pk-backend-ipkg.c
index edf2ffa..4e87ad4 100644
--- a/backends/ipkg/pk-backend-ipkg.c
+++ b/backends/ipkg/pk-backend-ipkg.c
@@ -504,20 +504,15 @@ backend_update_system (PkBackend *backend)
/**
* backend_get_depends:
*/
-static void
-backend_get_depends (PkBackend *backend, const gchar *package_id, gboolean recursive)
+
+static gboolean
+backend_get_depends_thread (PkBackend *backend, gchar *package_id)
{
- /* TODO: revursive is ignored */
PkPackageId *pi;
pkg_t *pkg = NULL;
gint i;
GRegex *regex;
- 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);
if (!pi->name || !pi->version)
@@ -526,7 +521,7 @@ backend_get_depends (PkBackend *backend, const gchar *package_id, gboolean recur
"Package not found");
pk_package_id_free (pi);
pk_backend_finished (backend);
- return;
+ return FALSE;
}
pkg = pkg_hash_fetch_by_name_version (&global_conf.pkg_hash, pi->name, pi->version);
@@ -537,7 +532,7 @@ backend_get_depends (PkBackend *backend, const gchar *package_id, gboolean recur
"Package not found");
pk_package_id_free (pi);
pk_backend_finished (backend);
- return;
+ return FALSE;
}
/* compile a regex expression to parse depends_str package names */
@@ -591,8 +586,26 @@ 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);
+ g_free (package_id);
+
+ return TRUE;
+}
+
+static void
+backend_get_depends (PkBackend *backend, const gchar *package_id, gboolean recursive)
+{
+ /* TODO: revursive is ignored */
+ g_return_if_fail (backend != NULL);
+
+ pk_backend_change_status (backend, PK_STATUS_ENUM_QUERY);
+ pk_backend_no_percentage_updates (backend);
+
+ pk_backend_thread_create (backend,
+ (PkBackendThreadFunc) backend_get_depends_thread,
+ g_strdup (package_id));
}
/**
commit 81b5b406dabe3093d86bee4638160f0c44c72289
Merge: 5339803... c1985af...
Author: Thomas Wood <thomas at openedhand.com>
Date: Tue Jan 15 15:10:16 2008 +0000
Merge branch 'master' of git+ssh://thos@git.packagekit.org/srv/git/PackageKit
commit 5339803950ccac286a0b35cfca9f02b71bc9c2c6
Author: Thomas Wood <thomas at openedhand.com>
Date: Tue Jan 15 09:17:40 2008 +0000
ipkg: protect against NULL user input
diff --git a/backends/ipkg/pk-backend-ipkg.c b/backends/ipkg/pk-backend-ipkg.c
index 28610bf..edf2ffa 100644
--- a/backends/ipkg/pk-backend-ipkg.c
+++ b/backends/ipkg/pk-backend-ipkg.c
@@ -258,6 +258,16 @@ backend_get_description_thread (PkBackend *backend, gchar *package_id)
pkg_t *pkg;
PkPackageId *pi;
pi = pk_package_id_new_from_string (package_id);
+
+ if (!pi->name || !pi->version)
+ {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND,
+ "Package not found");
+ pk_package_id_free (pi);
+ pk_backend_finished (backend);
+ return FALSE;
+ }
+
pkg = pkg_hash_fetch_by_name_version (&global_conf.pkg_hash, pi->name, pi->version);
pk_backend_description (backend, pi->name,
@@ -509,6 +519,16 @@ backend_get_depends (PkBackend *backend, const gchar *package_id, gboolean recur
pk_backend_no_percentage_updates (backend);
pi = pk_package_id_new_from_string (package_id);
+
+ if (!pi->name || !pi->version)
+ {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND,
+ "Package not found");
+ pk_package_id_free (pi);
+ pk_backend_finished (backend);
+ return;
+ }
+
pkg = pkg_hash_fetch_by_name_version (&global_conf.pkg_hash, pi->name, pi->version);
if (!pkg)
@@ -586,6 +606,16 @@ backend_update_package_thread (PkBackend *backend, gchar *package_id)
gint err = 0;
pi = pk_package_id_new_from_string (package_id);
+
+ if (!pi->name || !pi->version)
+ {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND,
+ "Package not found");
+ pk_package_id_free (pi);
+ pk_backend_finished (backend);
+ return FALSE;
+ }
+
pkg = pkg_hash_fetch_by_name_version (&global_conf.pkg_hash, pi->name, pi->version);
if (!pkg) {
commit c1985af0190118e0bd7128f25b4eb57aa0b8ddc1
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Jan 14 19:04:56 2008 +0000
only look for helpers and the config file in a local root if we have configured with --enable-local to make people less uneasy with .. path globbing
diff --git a/configure.ac b/configure.ac
index 9e4a5f1..999e61f 100755
--- a/configure.ac
+++ b/configure.ac
@@ -142,12 +142,18 @@ dnl ---------------------------------------------------------------------------
AC_ARG_ENABLE(tests, AS_HELP_STRING([--enable-tests],[enable unit test code]),enable_tests=$enableval,enable_tests=$USE_MAINTAINER_MODE)
AC_ARG_ENABLE(gcov, AS_HELP_STRING([--enable-gcov],[compile with coverage profiling instrumentation (gcc only)]),enable_gcov=$enableval,enable_gcov=no)
AC_ARG_ENABLE(gprof, AS_HELP_STRING([--enable-gprof],[compile with gprof support (gcc only)]),enable_gprof=$enableval,enable_gprof=no)
+AC_ARG_ENABLE(local, AS_HELP_STRING([--enable-local],[enable running in local checkout]),enable_tests=$enableval,enable_tests=$USE_MAINTAINER_MODE)
AM_CONDITIONAL(PK_BUILD_TESTS, test x$enable_tests = xyes)
if test x$enable_tests = xyes; then
AC_DEFINE(PK_BUILD_TESTS,1,[Build test code])
fi
+AM_CONDITIONAL(PK_BUILD_LOCAL, test x$enable_local = xyes)
+if test x$enable_local = xyes; then
+ AC_DEFINE(PK_BUILD_LOCAL,1,[Build local code])
+fi
+
if test x$enable_gcov = xyes; then
## so that config.h changes when you toggle gcov support
AC_DEFINE_UNQUOTED(PK_BUILD_GCOV, 1, [Defined if gcov is enabled to force a rebuild due to config.h changing])
@@ -522,6 +528,7 @@ echo "
compiler: ${CC}
cflags: ${CFLAGS}
Building unit tests: ${enable_tests}
+ Able to run locally: ${enable_local}
GCC coverage profiling: ${enable_gcov}
GCC time profiling: ${enable_gprof}
Default backend: ${with_default_backend}
diff --git a/src/pk-backend.c b/src/pk-backend.c
index d4e5a4b..ca9316b 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -134,11 +134,17 @@ pk_backend_build_library_path (PkBackend *backend)
g_return_val_if_fail (backend != NULL, NULL);
filename = g_strdup_printf ("libpk_backend_%s.so", backend->priv->name);
+#if PK_BUILD_LOCAL
+ /* prefer the local version */
path = g_build_filename ("..", "backends", backend->priv->name, ".libs", filename, NULL);
if (g_file_test (path, G_FILE_TEST_EXISTS) == FALSE) {
+ pk_debug ("local backend not found '%s'", path);
g_free (path);
path = g_build_filename (LIBDIR, "packagekit-backend", filename, NULL);
}
+#else
+ path = g_build_filename (LIBDIR, "packagekit-backend", filename, NULL);
+#endif
g_free (filename);
pk_debug ("dlopening '%s'", path);
@@ -601,12 +607,17 @@ pk_backend_spawn_helper_internal (PkBackend *backend, const gchar *script, const
gchar *filename;
gchar *command;
- /* build script */
+#if PK_BUILD_LOCAL
+ /* prefer the local version */
filename = g_build_filename ("..", "backends", backend->priv->name, "helpers", script, NULL);
if (g_file_test (filename, G_FILE_TEST_EXISTS) == FALSE) {
+ pk_debug ("local helper not found '%s'", filename);
g_free (filename);
filename = g_build_filename (DATADIR, "PackageKit", "helpers", backend->priv->name, script, NULL);
}
+#else
+ filename = g_build_filename (DATADIR, "PackageKit", "helpers", backend->priv->name, script, NULL);
+#endif
pk_debug ("using spawn filename %s", filename);
if (argument != NULL) {
diff --git a/src/pk-conf.c b/src/pk-conf.c
index 89ac2b1..94d0fce 100644
--- a/src/pk-conf.c
+++ b/src/pk-conf.c
@@ -123,15 +123,19 @@ pk_conf_init (PkConf *conf)
conf->priv = PK_CONF_GET_PRIVATE (conf);
+#if PK_BUILD_LOCAL
/* try a local path first */
path = g_build_filename ("..", "etc", "PackageKit.conf", NULL);
if (g_file_test (path, G_FILE_TEST_EXISTS) == FALSE) {
- pk_debug ("config file not found '%s'", path);
+ pk_debug ("local config file not found '%s'", path);
g_free (path);
path = g_build_filename (SYSCONFDIR, "PackageKit", "PackageKit.conf", NULL);
- if (g_file_test (path, G_FILE_TEST_EXISTS) == FALSE) {
- pk_error ("config file not found '%s'", path);
- }
+ }
+#else
+ path = g_build_filename (SYSCONFDIR, "PackageKit", "PackageKit.conf", NULL);
+#endif
+ if (g_file_test (path, G_FILE_TEST_EXISTS) == FALSE) {
+ pk_error ("config file not found '%s'", path);
}
pk_debug ("using config file '%s'", path);
conf->priv->keyfile = g_key_file_new ();
commit d76d9842b644e3a8d07d48c6207a58edbf3ef9f9
Author: Tim Lauridsen <tim at naboo.local>
Date: Sun Jan 13 15:14:05 2008 +0100
yum: catch RepoError in get-updates and submit ERROR_NO_CACHE to frontend
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 66b02b8..2b8aa26 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -1008,16 +1008,20 @@ class PackageKitYumBackend(PackageKitBaseBackend):
self.allow_interrupt(True)
self.percentage(None)
self.status(STATUS_INFO)
- ygl = self.yumbase.doPackageLists(pkgnarrow='updates')
- md = self.updateMetadata
- for pkg in ygl.updates:
- # Get info about package in updates info
- notice = md.get_notice((pkg.name, pkg.version, pkg.release))
- if notice:
- status = self._get_status(notice)
- self._show_package(pkg,status)
- else:
- self._show_package(pkg,INFO_NORMAL)
+ try:
+ ygl = self.yumbase.doPackageLists(pkgnarrow='updates')
+ md = self.updateMetadata
+ for pkg in ygl.updates:
+ # Get info about package in updates info
+ notice = md.get_notice((pkg.name, pkg.version, pkg.release))
+ if notice:
+ status = self._get_status(notice)
+ self._show_package(pkg,status)
+ else:
+ self._show_package(pkg,INFO_NORMAL)
+ except yum.Errors.RepoError,e:
+ self.error(ERROR_NO_CACHE,"Yum cache is invalid")
+
def repo_enable(self, repoid, enable):
'''
commit a60ffbbfb3cd5401999fa7e2d92cdc97538fb2f7
Author: Tim Lauridsen <tim at naboo.local>
Date: Sun Jan 13 13:54:59 2008 +0100
yum: make Yum Traceback send the right values to the frontend
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index e7bebcb..66b02b8 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -894,11 +894,11 @@ class PackageKitYumBackend(PackageKitBaseBackend):
callback = ProcessTransPackageKitCallback(self)
self.yumbase.processTransaction(callback=callback,
rpmDisplay=rpmDisplay)
- except yum.Errors.YumDownloadError, msgs:
- retmsg = "Error in Download;" +";".join(msgs)
+ except yum.Errors.YumDownloadError, ye:
+ retmsg = "Error in Download;" +";".join(ye.value)
self.error(ERROR_PACKAGE_DOWNLOAD_FAILED,retmsg)
- except yum.Errors.YumGPGCheckError, msgs:
- retmsg = "Error in Package Signatures;" +";".join(msgs)
+ except yum.Errors.YumGPGCheckError, ye:
+ retmsg = "Error in Package Signatures;" +";".join(ye.value)
self.error(ERROR_INTERNAL_ERROR,retmsg)
except GPGKeyNotImported, e:
keyData = self.yumbase.missingGPGKey
@@ -918,8 +918,8 @@ class PackageKitYumBackend(PackageKitBaseBackend):
keyData['timestamp'],
'GPG')
self.error(ERROR_SIGNATURE_NOT_IMPORTED,"GPG key not imported.")
- except yum.Errors.YumBaseError, msgs:
- retmsg = "Error in Transaction Processing;" +";".join(msgs)
+ except yum.Errors.YumBaseError, ye:
+ retmsg = "Error in Transaction Processing;" +";".join(ye.value)
self.error(ERROR_TRANSACTION_ERROR,retmsg)
def remove(self, allowdep, package):
More information about the PackageKit
mailing list