[PackageKit-commit] packagekit: Branch 'master' - 20 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Thu Jun 25 09:32:41 PDT 2009
backends/apt.deprecated/aptBackend.py | 3
backends/apt.deprecated/pk-backend-apt.c | 2
backends/apt/aptBackend.py | 3
backends/apt/pk-backend-apt.c | 2
backends/conary/conaryBackend.py | 4
backends/conary/pk-backend-conary.c | 2
backends/pisi/pisiBackend.py | 3
backends/pisi/pk-backend-pisi.c | 2
backends/portage/pk-backend-portage.c | 56
backends/portage/portageBackend.py | 1679 ++++++++++++-----------
backends/smart/pk-backend-smart.c | 2
backends/smart/smartBackend.py | 3
backends/urpmi/pk-backend-urpmi.c | 2
backends/yum/pk-backend-yum.c | 2
backends/yum/yumBackend.py | 5
configure.ac | 33
contrib/Makefile.am | 4
contrib/PackageKit.spec.in | 17
contrib/browser-plugin/Makefile.am | 22
contrib/browser-plugin/sdk-new/npplat.h | 64
contrib/browser-plugin/sdk-new/pluginbase.h | 96 -
contrib/browser-plugin/sdk/np_entry.cpp | 320 ----
contrib/browser-plugin/sdk/npn_gate.cpp | 215 --
contrib/browser-plugin/sdk/npp_gate.cpp | 358 ----
contrib/browser-plugin/sdk/npplat.h | 100 -
contrib/browser-plugin/sdk/pluginbase.h | 20
contrib/browser-plugin/src/contents.cpp | 8
contrib/browser-plugin/src/plugin.cpp | 11
contrib/debuginfo-install/.gitignore | 5
contrib/debuginfo-install/Makefile.am | 35
contrib/debuginfo-install/egg-debug.c | 1
contrib/debuginfo-install/egg-debug.h | 1
contrib/debuginfo-install/pk-debuginfo-install.c | 414 +++++
lib/packagekit-glib/pk-enum.c | 2
lib/packagekit-glib/pk-enum.h | 2
lib/python/packagekit/backend.py | 5
src/org.freedesktop.PackageKit.Transaction.xml | 4
src/pk-transaction.c | 10
src/pk-transaction.h | 1
39 files changed, 1517 insertions(+), 2001 deletions(-)
New commits:
commit 8997120905a035dc9ddfa1c67d5a1217bc15b6f0
Author: Richard Hughes <richard at hughsie.com>
Date: Thu Jun 25 17:28:34 2009 +0100
Add debuginfo-install functionality as a contrib project
diff --git a/configure.ac b/configure.ac
index 144bbe1..8a19e96 100644
--- a/configure.ac
+++ b/configure.ac
@@ -439,6 +439,13 @@ AC_ARG_ENABLE(cron, AS_HELP_STRING([--enable-cron],[Build cron background functi
AM_CONDITIONAL(PK_BUILD_CRON, test $build_cron = "yes")
dnl ---------------------------------------------------------------------------
+dnl - Able to build debuginfo-install functionality
+dnl ---------------------------------------------------------------------------
+AC_ARG_ENABLE(debuginfo-install, AS_HELP_STRING([--enable-debuginfo-install],[Build debuginfo-install functionality]),
+ build_debuginfo_install=$enableval,build_debuginfo_install=yes)
+AM_CONDITIONAL(PK_BUILD_DEBUGINFO_INSTALL, test $build_debuginfo_install = "yes")
+
+dnl ---------------------------------------------------------------------------
dnl - Able to build pm-utils script functionality
dnl ---------------------------------------------------------------------------
AC_ARG_ENABLE(pm_utils, AS_HELP_STRING([--enable-pm-utils],[Build pm-utils script functionality]),
@@ -713,6 +720,7 @@ contrib/gtk-module/Makefile
contrib/yum-packagekit/Makefile
contrib/command-not-found/Makefile
contrib/cron/Makefile
+contrib/debuginfo-install/Makefile
contrib/pm-utils/Makefile
contrib/ruck/Makefile
contrib/ruck/src/Makefile
@@ -778,6 +786,7 @@ echo "
Pango module: ${build_gtk_module}
BASH Command not found: ${build_command_not_found}
Cron scripts: ${build_cron}
+ debuginfo-install: ${build_debuginfo_install}
pm-utils scripts: ${build_pm_utils}
RUCK client: ${build_ruck}
QT library: ${build_qt}
diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index e9f6ae0..6a2d883 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -28,6 +28,10 @@ if PK_BUILD_CRON
SUBDIRS += cron
endif
+if PK_BUILD_DEBUGINFO_INSTALL
+SUBDIRS += debuginfo-install
+endif
+
if PK_BUILD_PM_UTILS
SUBDIRS += pm-utils
endif
diff --git a/contrib/PackageKit.spec.in b/contrib/PackageKit.spec.in
index 7868534..8be4d5f 100644
--- a/contrib/PackageKit.spec.in
+++ b/contrib/PackageKit.spec.in
@@ -131,6 +131,14 @@ Requires: %{name} = %{version}-%{release}
%description cron
Crontab and utilities for running PackageKit as a cron job.
+%package debuginfo-install
+Summary: Facility to install debugging packages using PackageKit
+Group: System Environment/Base
+Requires: %{name} = %{version}-%{release}
+
+%description debuginfo-install
+Provides facility to install debugging packages using PackageKit.
+
%package glib-devel
Summary: GLib Libraries and headers for PackageKit
Group: Development/Libraries
@@ -352,6 +360,11 @@ update-mime-database %{_datadir}/mime &> /dev/null || :
%config %{_sysconfdir}/cron.daily/packagekit-background.cron
%config(noreplace) %{_sysconfdir}/sysconfig/packagekit-background
+%files debuginfo-install
+%defattr(-,root,root,-)
+%doc README AUTHORS NEWS COPYING
+%{_libexecdir}/pk-debuginfo-install
+
%files browser-plugin
%defattr(-,root,root,-)
%doc README AUTHORS NEWS COPYING
diff --git a/contrib/debuginfo-install/.gitignore b/contrib/debuginfo-install/.gitignore
new file mode 100644
index 0000000..53ecb7a
--- /dev/null
+++ b/contrib/debuginfo-install/.gitignore
@@ -0,0 +1,5 @@
+.deps
+.libs
+*.o
+pk-debuginfo-install
+
diff --git a/contrib/debuginfo-install/Makefile.am b/contrib/debuginfo-install/Makefile.am
new file mode 100644
index 0000000..00e6779
--- /dev/null
+++ b/contrib/debuginfo-install/Makefile.am
@@ -0,0 +1,35 @@
+## We require new-style dependency handling.
+AUTOMAKE_OPTIONS = 1.7
+
+INCLUDES = \
+ $(GLIB_CFLAGS) \
+ $(DBUS_CFLAGS) \
+ $(SQLITE_CFLAGS) \
+ -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
+ -DSYSCONFDIR=\""$(sysconfdir)"\" \
+ -DEGG_LOG_FILE=\""$(PK_LOG_DIR)/PackageKit"\" \
+ -DEGG_VERBOSE="\"PK_VERBOSE\"" \
+ -DEGG_LOGGING="\"PK_LOGGING\"" \
+ -DEGG_CONSOLE="\"PK_CONSOLE\"" \
+ -I$(top_srcdir)/lib
+
+PK_GLIB_LIBS = $(top_builddir)/lib/packagekit-glib/libpackagekit-glib.la
+
+libexec_PROGRAMS = pk-debuginfo-install
+
+pk_debuginfo_install_SOURCES = \
+ egg-debug.c \
+ egg-debug.h \
+ pk-debuginfo-install.c \
+ $(NULL)
+
+pk_debuginfo_install_LDADD = \
+ $(GLIB_LIBS) \
+ $(DBUS_LIBS) \
+ $(PK_GLIB_LIBS) \
+ $(NULL)
+
+pk_debuginfo_install_CFLAGS = \
+ $(WARNINGFLAGS_C) \
+ $(NULL)
+
diff --git a/contrib/debuginfo-install/egg-debug.c b/contrib/debuginfo-install/egg-debug.c
new file mode 120000
index 0000000..98fd102
--- /dev/null
+++ b/contrib/debuginfo-install/egg-debug.c
@@ -0,0 +1 @@
+../../src/egg-debug.c
\ No newline at end of file
diff --git a/contrib/debuginfo-install/egg-debug.h b/contrib/debuginfo-install/egg-debug.h
new file mode 120000
index 0000000..13de545
--- /dev/null
+++ b/contrib/debuginfo-install/egg-debug.h
@@ -0,0 +1 @@
+../../src/egg-debug.h
\ No newline at end of file
diff --git a/contrib/debuginfo-install/pk-debuginfo-install.c b/contrib/debuginfo-install/pk-debuginfo-install.c
new file mode 100644
index 0000000..32524fa
--- /dev/null
+++ b/contrib/debuginfo-install/pk-debuginfo-install.c
@@ -0,0 +1,414 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2009 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <string.h>
+#include <locale.h>
+#include <glib/gi18n.h>
+#include <packagekit-glib/packagekit.h>
+
+#include "egg-debug.h"
+
+/**
+ * pk_get_package_name_from_nevra:
+ **/
+static gchar *
+pk_get_package_name_from_nevra (const gchar *nevra)
+{
+ gchar *name = NULL;
+ gchar **split;
+ guint len;
+
+ /* hal-info-data-version-arch */
+ split = g_strsplit (nevra, "-", -1);
+ len = g_strv_length (split);
+
+ /* just the package name specified */
+ if (len == 1) {
+ name = g_strdup (split[0]);
+ goto out;
+ }
+
+ /* ignore the version */
+ g_free (split[len-2]);
+ split[len-2] = NULL;
+
+ /* ignore the arch */
+ g_free (split[len-1]);
+ split[len-1] = NULL;
+
+ /* join up name elements */
+ name = g_strjoinv ("-", split);
+out:
+ g_strfreev (split);
+ return name;
+}
+
+typedef struct {
+ GPtrArray *enabled;
+ GPtrArray *disabled;
+ PkClient *client;
+} PkPriv;
+
+/**
+ * repo_details_cb:
+ **/
+static void
+repo_details_cb (PkClient *client, const gchar *repo_id, const gchar *description, gboolean enabled, PkPriv *priv)
+{
+ if (enabled)
+ g_ptr_array_add (priv->enabled, g_strdup (repo_id));
+ else
+ g_ptr_array_add (priv->disabled, g_strdup (repo_id));
+}
+
+/**
+ * is_in_array:
+ **/
+static gboolean
+is_in_array (GPtrArray *array, const gchar *text)
+{
+ guint i;
+ gboolean ret = FALSE;
+ const gchar *possible;
+
+ /* compare each */
+ for (i=0; i<array->len; i++) {
+ possible = g_ptr_array_index (array, i);
+ if (g_strcmp0 (text, possible) == 0) {
+ ret = TRUE;
+ break;
+ }
+ }
+ return ret;
+}
+
+/**
+ * enable_repos:
+ **/
+static gboolean
+enable_repos (PkPriv *priv, GPtrArray *array, gboolean enable, GError **error)
+{
+ guint i;
+ gboolean ret = TRUE;
+ const gchar *repo_id;
+ GError *error_local = NULL;
+
+ /* enable all debuginfo repos we found */
+ for (i=0; i<array->len; i++) {
+ repo_id = g_ptr_array_index (array, i);
+
+ /* reset client */
+ ret = pk_client_reset (priv->client, &error_local);
+ if (!ret) {
+ *error = g_error_new (1, 0, "failed to reset: %s", error_local->message);
+ g_error_free (error_local);
+ goto out;
+ }
+
+ /* enable this repo */
+ ret = pk_client_repo_enable (priv->client, repo_id, enable, &error_local);
+ if (!ret) {
+ *error = g_error_new (1, 0, "failed to enable %s: %s", repo_id, error_local->message);
+ g_error_free (error_local);
+ goto out;
+ }
+ egg_warning ("setting %s: %i", repo_id, enable);
+ }
+out:
+ return ret;
+}
+
+/**
+ * install_packages:
+ **/
+static gboolean
+install_packages (PkPriv *priv, GPtrArray *array, GError **error)
+{
+ gboolean ret = TRUE;
+ gchar **package_ids;
+ GError *error_local = NULL;
+
+ /* mush back into a char** */
+ package_ids = pk_package_ids_from_array (array);
+
+ /* reset client */
+ ret = pk_client_reset (priv->client, &error_local);
+ if (!ret) {
+ *error = g_error_new (1, 0, "failed to reset: %s", error_local->message);
+ g_error_free (error_local);
+ goto out;
+ }
+
+ /* enable this repo */
+ ret = pk_client_install_packages (priv->client, TRUE, package_ids, &error_local);
+ if (!ret) {
+ *error = g_error_new (1, 0, "failed to install packages: %s", error_local->message);
+ g_error_free (error_local);
+ goto out;
+ }
+out:
+ g_strfreev (package_ids);
+ return ret;
+}
+
+/**
+ * resolve_to_id:
+ **/
+static gchar *
+resolve_to_id (PkPriv *priv, const gchar *package_name, GError **error)
+{
+ gboolean ret;
+ const PkPackageObj *obj;
+ const PkPackageId *id;
+ gchar *package_id = NULL;
+ PkPackageList *list = NULL;
+ GError *error_local = NULL;
+ gchar **names;
+ guint len;
+
+ /* resolve takes a char** */
+ names = g_strsplit (package_name, ";", -1);
+
+ /* reset client */
+ ret = pk_client_reset (priv->client, &error_local);
+ if (!ret) {
+ *error = g_error_new (1, 0, "failed to reset: %s", error_local->message);
+ g_error_free (error_local);
+ goto out;
+ }
+
+ /* resolve */
+ ret = pk_client_resolve (priv->client, pk_bitfield_from_enums (PK_FILTER_ENUM_NOT_INSTALLED, -1), names, &error_local);
+ if (!ret) {
+ *error = g_error_new (1, 0, "failed to resolve: %s", error_local->message);
+ g_error_free (error_local);
+ goto out;
+ }
+
+ /* check we only got one match */
+ list = pk_client_get_package_list (priv->client);
+ len = PK_OBJ_LIST(list)->len;
+ if (len == 0) {
+ *error = g_error_new (1, 0, "no package %s found", package_name);
+ goto out;
+ }
+ if (len > 1) {
+ *error = g_error_new (1, 0, "more than one package found for %s", package_name);
+ goto out;
+ }
+
+ /* get the package id */
+ obj = pk_package_list_get_obj (list, 0);
+ id = pk_package_obj_get_id(obj);
+ package_id = pk_package_id_to_string (id);
+out:
+ if (list != NULL)
+ g_object_unref (list);
+ g_strfreev (names);
+ return package_id;
+}
+
+/**
+ * main:
+ **/
+int
+main (int argc, char *argv[])
+{
+ gboolean ret;
+ GError *error = NULL;
+ GPtrArray *added_repos = NULL;
+ GPtrArray *package_ids_to_install = NULL;
+ guint i;
+ gchar *package_id;
+ gchar *name;
+ gchar *name_debuginfo;
+ gboolean verbose = FALSE;
+ GOptionContext *context;
+ const gchar *repo_id;
+ gchar *repo_id_debuginfo;
+ PkPriv _priv;
+ PkPriv *priv = &_priv;
+
+ const GOptionEntry options[] = {
+ { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
+ _("Show extra debugging information"), NULL },
+ { NULL}
+ };
+
+ memset (priv, 0, sizeof (PkPriv));
+
+ setlocale (LC_ALL, "");
+ bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
+ if (! g_thread_supported ())
+ g_thread_init (NULL);
+ g_type_init ();
+
+ context = g_option_context_new (NULL);
+ /* TRANSLATORS: tool that gets called when the command is not found */
+ g_option_context_set_summary (context, _("PackageKit Command Not Found"));
+ g_option_context_add_main_entries (context, options, NULL);
+ g_option_context_parse (context, &argc, &argv, NULL);
+ g_option_context_free (context);
+
+ egg_debug_init (verbose);
+
+ /* no input */
+ if (argv[1] == NULL) {
+ g_print ("specify packages to install\n");
+ goto out;
+ }
+
+ /* store as strings */
+ priv->enabled = g_ptr_array_new ();
+ priv->disabled = g_ptr_array_new ();
+ added_repos = g_ptr_array_new ();
+ package_ids_to_install = g_ptr_array_new ();
+
+ /* create #PkClient */
+ priv->client = pk_client_new ();
+ g_signal_connect (priv->client, "repo-detail", G_CALLBACK (repo_details_cb), priv);
+ pk_client_set_synchronous (priv->client, TRUE, NULL);
+ pk_client_set_use_buffer (priv->client, TRUE, NULL);
+
+ /* get all enabled repos */
+ g_print ("1. Getting sources list...");
+ ret = pk_client_get_repo_list (priv->client, PK_FILTER_ENUM_NONE, &error);
+ if (!ret) {
+ g_print ("failed to get repo list: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+ g_print ("OK. Found %i enabled and %i disabled sources.\n", priv->enabled->len, priv->disabled->len);
+
+ /* find all debuginfo repos for repos that are enabled */
+ g_print ("2. Finding debug sources...");
+ for (i=0; i<priv->enabled->len; i++) {
+
+ /* is already a -debuginfo */
+ repo_id = g_ptr_array_index (priv->enabled, i);
+ if (g_str_has_suffix (repo_id, "-debuginfo")) {
+ egg_debug ("already enabled: %s", repo_id);
+ continue;
+ }
+
+ /* has a debuginfo repo */
+ repo_id_debuginfo = g_strjoin ("-", repo_id, "debuginfo", NULL);
+ ret = is_in_array (priv->disabled, repo_id_debuginfo);
+ if (ret) {
+ /* add to list to change back at the end */
+ g_ptr_array_add (added_repos, g_strdup (repo_id_debuginfo));
+ } else {
+ egg_debug ("no debuginfo repo for %s", repo_id_debuginfo);
+ }
+
+ g_free (repo_id_debuginfo);
+ }
+ g_print ("OK. Found %i non-enabled debuginfo repos.\n", added_repos->len);
+
+ /* enable all debuginfo repos we found */
+ g_print ("3. Enabling debug sources...");
+ ret = enable_repos (priv, added_repos, TRUE, &error);
+ if (!ret) {
+ g_print ("failed to enable repos: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+ g_print ("OK. Enabled %i sources.\n", added_repos->len);
+
+//debuginfo-install bzip2-libs-1.0.5-5.fc11.i586 glib2-2.20.3-1.fc11.i586 libacl-2.2.47-4.fc11.i586 libarchive-2.6.2-1.fc11.i586 lzma-libs-4.32.7-2.fc11.i586 sqlite-3.6.12-3.fc11.i586 zlib-1.2.3-22.fc11.i586
+
+ /* parse arguments and resolve to packages */
+ g_print ("4. Finding debug packages...");
+ for (i=1; argv[i] != NULL; i++) {
+ name = pk_get_package_name_from_nevra (argv[i]);
+ name_debuginfo = g_strjoin ("-", name, "debuginfo", NULL);
+ egg_debug ("install %s [%s]", argv[i], name_debuginfo);
+
+ /* resolve name */
+ package_id = resolve_to_id (priv, name_debuginfo, &error);
+ if (package_id == NULL) {
+ g_print ("failed to map package name to an id: %s\n", error->message);
+ g_error_free (error);
+ /* don't quit, this is non-fatal */
+ error = NULL;
+ }
+
+ /* add to array to install */
+ if (package_id != NULL) {
+ egg_debug ("going to try to install: %s\n", package_id);
+ g_ptr_array_add (package_ids_to_install, g_strdup (package_id));
+ }
+
+ g_free (name);
+ g_free (name_debuginfo);
+ g_free (package_id);
+
+ }
+ g_print ("OK. Found %i packages.\n", package_ids_to_install->len);
+
+ /* install */
+ g_print ("5. Installing packages...");
+ ret = install_packages (priv, package_ids_to_install, &error);
+ if (!ret) {
+ g_print ("failed to install packages: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+ g_print ("OK.\n");
+
+out:
+
+ if (package_ids_to_install != NULL) {
+ g_ptr_array_foreach (package_ids_to_install, (GFunc) g_free, NULL);
+ g_ptr_array_free (package_ids_to_install, TRUE);
+ }
+ if (added_repos != NULL) {
+
+ g_print ("6. Disabling sources...");
+ /* disable all debuginfo repos we previously enabled */
+ ret = enable_repos (priv, added_repos, FALSE, &error);
+ if (!ret) {
+ g_print ("failed to enable repos: %s", error->message);
+ g_error_free (error);
+ }
+ g_print ("OK. Disabled %i sources.\n", added_repos->len);
+
+ g_ptr_array_foreach (added_repos, (GFunc) g_free, NULL);
+ g_ptr_array_free (added_repos, TRUE);
+ }
+ if (priv->enabled != NULL) {
+ g_ptr_array_foreach (priv->enabled, (GFunc) g_free, NULL);
+ g_ptr_array_free (priv->enabled, TRUE);
+ }
+ if (priv->disabled != NULL) {
+ g_ptr_array_foreach (priv->disabled, (GFunc) g_free, NULL);
+ g_ptr_array_free (priv->disabled, TRUE);
+ }
+ if (priv->client != NULL)
+ g_object_unref (priv->client);
+ return 0;
+}
+
commit 6851660159fcfa3440ee0007c41dcdfea7c9843d
Merge: a3333ef... d34a201...
Author: Richard Hughes <richard at hughsie.com>
Date: Thu Jun 25 16:47:34 2009 +0100
Merge branch 'master' of git+ssh://hughsie@git.packagekit.org/srv/git/PackageKit
commit d34a201b31a40904f20fcbf59a42194bd3e74dce
Author: Mounir Lamouri (volkmar) <mounir.lamouri at gmail.com>
Date: Thu Jun 25 18:01:22 2009 +0200
portage: FIX bug, was using default configuration instead of user's one for ACCEPT_KEFWORDS
diff --git a/backends/portage/portageBackend.py b/backends/portage/portageBackend.py
index f570a95..1d6ff76 100755
--- a/backends/portage/portageBackend.py
+++ b/backends/portage/portageBackend.py
@@ -328,7 +328,7 @@ class PackageKitPortageBackend(PackageKitBaseBackend, PackagekitPackage):
pkg_keywords, repo = portage.portdb.aux_get(cpv, ["KEYWORDS", "repository"])
pkg_keywords = pkg_keywords.split()
- sys_keywords = self.portage_settings.configdict["defaults"].get("ACCEPT_KEYWORDS").split()
+ sys_keywords = self.portage_settings.configdict["conf"].get("ACCEPT_KEYWORDS").split()
keywords = []
for x in sys_keywords:
commit 8792e50cade8a1a5ca43d4a32d725a9fba78d685
Author: Mounir Lamouri (volkmar) <mounir.lamouri at gmail.com>
Date: Thu Jun 25 17:26:45 2009 +0200
portage: add filter management for search-file and search-groups
diff --git a/backends/portage/portageBackend.py b/backends/portage/portageBackend.py
index a420416..f570a95 100755
--- a/backends/portage/portageBackend.py
+++ b/backends/portage/portageBackend.py
@@ -51,7 +51,9 @@ from itertools import izip
# names a package (an ebuild for portage)
# TODO:
-# print only found package or every ebuilds ?
+# FREE filter
+# NEWEST filter
+# ERRORS with messages ?
# Map Gentoo categories to the PackageKit group name space
SECTION_GROUP_MAP = {
@@ -257,6 +259,66 @@ class PackageKitPortageBackend(PackageKitBaseBackend, PackagekitPackage):
return True
return False
+ def get_all_cp(self, fltlist):
+ # NOTES:
+ # returns a list of cp _BUT_ if filter=installed, returns cpv
+ #
+ # FILTERS:
+ # - installed: ok
+ # - free: ok (should be done with cpv)
+ # - newest: ok (should be finished with cpv)
+
+ # if installed filter, return vardb.cpv_all
+ # it's a bit weird but with get_all_cpv(cp) return cpv, it could be ok
+ # TODO: ask zmedico
+ if FILTER_INSTALLED in fltlist:
+ return self.vardb.cpv_all()
+ else:
+ return portage.portdb.cp_all()
+
+ def get_all_cpv(self, cp, fltlist):
+ # NOTES:
+ # returns a list of cpv
+ # TODO: maybe improve filters management ?
+ #
+ # FILTERS:
+ # - installed: ok
+ # - free: TODO
+ # - newest: ok
+
+ cpv = []
+
+ # installed filter
+ if FILTER_INSTALLED in fltlist:
+ # special case : cp = cpv
+ cpv.append(cp)
+ elif FILTER_NOT_INSTALLED in fltlist:
+ for x in portage.portdb.match(cp):
+ if not self.is_installed(x):
+ cpv.append(x)
+ else:
+ cpv = portage.portdb.match(cp)
+
+ if len(cpv) == 0:
+ return []
+
+ # newest filter
+ if FILTER_NEWEST in fltlist:
+ if FILTER_INSTALLED in fltlist:
+ return cpv
+ elif FILTER_NOT_INSTALLED in fltlist:
+ return [cpv[-1]]
+ else:
+ if self.is_installed(cpv[-1]):
+ return [cpv[-1]]
+ else:
+ for x in cpv:
+ if self.is_installed(x):
+ return [x, cpv[-1]]
+ return [cpv[-1]]
+
+ return cpv
+
def cpv_to_id(self, cpv):
'''
Transform the cpv (portage) to a package id (packagekit)
@@ -796,11 +858,20 @@ class PackageKitPortageBackend(PackageKitBaseBackend, PackagekitPackage):
break
def search_file(self, filters, key):
- # TODO: manage filters, error if ~installed ?
+ # FILTERS:
+ # - ~installed is not accepted (error)
+ # - free: TODO
+ # - newest: as only installed, by himself
self.status(STATUS_QUERY)
self.allow_cancel(True)
self.percentage(None)
+ fltlist = filters.split(';')
+ if FILTER_NOT_INSTALLED in fltlist:
+ self.error(ERROR_CANNOT_GET_FILELIST,
+ "search-filelist isn't available with ~installed filter")
+ return
+
cpvlist = []
pkg_processed = 0.0
nb_pkg = float(len(self.vardb.cpv_all()))
@@ -813,7 +884,8 @@ class PackageKitPortageBackend(PackageKitBaseBackend, PackagekitPackage):
for cpv in self.vardb.cpv_all():
cat, pv = portage.catsplit(cpv)
db = portage.dblink(cat, pv, portage.settings["ROOT"],
- self.portage_settings, treetype="vartree", vartree=self.vardb)
+ self.portage_settings, treetype="vartree",
+ vartree=self.vardb)
contents = db.getcontents()
if not contents:
continue
@@ -832,14 +904,15 @@ class PackageKitPortageBackend(PackageKitBaseBackend, PackagekitPackage):
self.package(cpv)
def search_group(self, filters, group):
- # TODO: filters
self.status(STATUS_QUERY)
self.allow_cancel(True)
self.percentage(None)
- for cp in portage.portdb.cp_all():
+ fltlist = filters.split(';')
+
+ for cp in self.get_all_cp(fltlist):
if get_group(cp) == group:
- for cpv in portage.portdb.match(cp):
+ for cpv in self.get_all_cpv(cp, fltlist):
self.package(cpv)
def search_name(self, filters, key):
commit dd163ce77857560a212bf351c2fd3835a4bf0f51
Author: Mounir Lamouri (volkmar) <mounir.lamouri at gmail.com>
Date: Thu Jun 25 17:26:14 2009 +0200
Add errors when backend can't get filelist or can't get requires packages
diff --git a/lib/packagekit-glib/pk-enum.c b/lib/packagekit-glib/pk-enum.c
index 80bcd81..9d28b71 100644
--- a/lib/packagekit-glib/pk-enum.c
+++ b/lib/packagekit-glib/pk-enum.c
@@ -178,6 +178,8 @@ static const PkEnumMatch enum_error[] = {
{PK_ERROR_ENUM_UPDATE_NOT_FOUND, "update-not-found"},
{PK_ERROR_ENUM_CANNOT_INSTALL_REPO_UNSIGNED, "cannot-install-repo-unsigned"},
{PK_ERROR_ENUM_CANNOT_UPDATE_REPO_UNSIGNED, "cannot-update-repo-unsigned"},
+ {PK_ERROR_ENUM_CANNOT_GET_FILELIST, "cannot-get-filelist"},
+ {PK_ERROR_ENUM_CANNOT_GET_REQUIRES, "cannot-get-requires"},
{0, NULL}
};
diff --git a/lib/packagekit-glib/pk-enum.h b/lib/packagekit-glib/pk-enum.h
index f0cbf47..a437f53 100644
--- a/lib/packagekit-glib/pk-enum.h
+++ b/lib/packagekit-glib/pk-enum.h
@@ -293,6 +293,8 @@ typedef enum {
PK_ERROR_ENUM_UPDATE_NOT_FOUND,
PK_ERROR_ENUM_CANNOT_INSTALL_REPO_UNSIGNED,
PK_ERROR_ENUM_CANNOT_UPDATE_REPO_UNSIGNED,
+ PK_ERROR_ENUM_CANNOT_GET_FILELIST,
+ PK_ERROR_ENUM_CANNOT_GET_REQUIRES,
PK_ERROR_ENUM_UNKNOWN
} PkErrorCodeEnum;
commit a3333efed6c2ee76517a93084e8eb8be7f9b3d14
Author: Richard Hughes <richard at hughsie.com>
Date: Thu Jun 25 15:37:29 2009 +0100
yum: Fix up the logic in RepoEnable
diff --git a/backends/yum/yumBackend.py b/backends/yum/yumBackend.py
index bb6f105..8ab79f1 100755
--- a/backends/yum/yumBackend.py
+++ b/backends/yum/yumBackend.py
@@ -2253,7 +2253,7 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
self.status(STATUS_INFO)
try:
repo = self.yumbase.repos.getRepo(repoid)
- if enable:
+ if not enable:
if repo.isEnabled():
repo.disablePersistent()
else:
commit 6aee3cd3a4ba755a6234506fa82c782608950de9
Author: Mounir Lamouri (volkmar) <mounir.lamouri at gmail.com>
Date: Thu Jun 25 14:06:48 2009 +0200
portage: take a position for supported filters
diff --git a/backends/portage/pk-backend-portage.c b/backends/portage/pk-backend-portage.c
index 565178c..172a7aa 100644
--- a/backends/portage/pk-backend-portage.c
+++ b/backends/portage/pk-backend-portage.c
@@ -100,21 +100,18 @@ static PkBitfield
backend_get_filters (PkBackend *backend)
{
return pk_bitfield_from_enums (
- //PK_FILTER_ENUM_NONE,
PK_FILTER_ENUM_INSTALLED,
- //PK_FILTER_ENUM_DEVELOPMENT,
- //PK_FILTER_ENUM_GUI,
- //PK_FILTER_ENUM_FREE,
- //PK_FILTER_ENUM_VISIBLE,
- //PK_FILTER_ENUM_SUPPORTED,
- //PK_FILTER_ENUM_BASENAME,
+ PK_FILTER_ENUM_FREE,
PK_FILTER_ENUM_NEWEST,
- //PK_FILTER_ENUM_ARCH,
- //PK_FILTER_ENUM_SOURCE,
- //PK_FILTER_ENUM_COLLECTIONS,
- //PK_FILTER_ENUM_APPLICATION,
- //PK_FILTER_ENUM_UNKNOWN
-1);
+ /*
+ * These filters are candidate for further add:
+ * PK_FILTER_ENUM_GUI (need new PROPERTIES entry)
+ * PK_FILTER_ENUM_ARCH (need some work, see ML)
+ * PK_FILTER_ENUM_SOURCE (need some work/support, see ML)
+ * PK_FILTER_ENUM_COLLECTIONS (need new PROPERTIES entry)
+ * PK_FILTER_ENUM_APPLICATION (need new PROPERTIES entry)
+ */
}
/**
@@ -414,9 +411,9 @@ PK_BACKEND_OPTIONS (
backend_refresh_cache, /* refresh_cache */
backend_remove_packages, /* remove_packages */
backend_repo_enable, /* repo_enable */
- NULL, // TODO: probably not /* repo_set_data */
+ NULL, /* repo_set_data */
backend_resolve, /* resolve */
- NULL, // TODO: probably in a long time /* rollback */
+ NULL, /* rollback */
backend_search_details, /* search_details */
backend_search_file, /* search_file */
backend_search_group, /* search_group */
commit 2d3472acbeacebd3aed0b9462b6de7e57704ae6c
Author: Richard Hughes <richard at hughsie.com>
Date: Thu Jun 25 12:59:56 2009 +0100
Require new style xulrunner headers (breaks compile on F10, but simplifies code)
diff --git a/configure.ac b/configure.ac
index 22051ef..144bbe1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -366,14 +366,12 @@ if test x$enable_browser_plugin = xyes; then
AC_SUBST(PK_BROWSER_PLUGIN_LIBS)
if test $build_browser_plugin = "yes"; then
+ # check we have xulrunner headers
packagekit_save_CPPFLAGS="$CPPFLAGS"
packagekit_save_LDFLAGS="$LDFLAGS"
-
CPPFLAGS="$CPPFLAGS $PK_BROWSER_PLUGIN_CFLAGS"
LDFLAGS="$CPPFLAGS $PK_BROWSER_PLUGIN_LIBS"
-
- AC_CHECK_HEADER(npfunctions.h, xulrunner_plugin_new=yes, xulrunner_plugin_new=no)
-
+ AC_CHECK_HEADER(npfunctions.h, have_xulrunner_npfunctions=yes, have_xulrunner_npfunctions=no)
CPPFLAGS="$packagekit_save_CPPFLAGS"
LDFLAGS="$packagekit_save_LDFLAGS"
@@ -385,12 +383,16 @@ if test x$enable_browser_plugin = xyes; then
MOZILLA_PLUGIN_DIR="$LIBDIR/mozilla/plugins"
fi
AC_SUBST(MOZILLA_PLUGIN_DIR)
+
+ # not got headers
+ if test $have_xulrunner_npfunctions = "no"; then
+ build_browser_plugin=no
+ fi
fi
else
build_browser_plugin=no
fi
AM_CONDITIONAL(PK_BUILD_BROWSER_PLUGIN, test $build_browser_plugin = "yes")
-AM_CONDITIONAL(PK_XULRUNNER_PLUGIN_NEW, test $xulrunner_plugin_new = "yes")
dnl ---------------------------------------------------------------------------
dnl - Able to build gstreamer plugin
diff --git a/contrib/browser-plugin/Makefile.am b/contrib/browser-plugin/Makefile.am
index 1f563d8..535456c 100644
--- a/contrib/browser-plugin/Makefile.am
+++ b/contrib/browser-plugin/Makefile.am
@@ -6,37 +6,21 @@ packagekit_plugin_la_CPPFLAGS = \
$(PK_BROWSER_PLUGIN_CFLAGS) \
-DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
-DXP_UNIX \
+ -I$(srcdir)/sdk \
-I$(top_srcdir)/lib
-if PK_XULRUNNER_PLUGIN_NEW
-packagekit_plugin_la_CPPFLAGS += -I$(srcdir)/sdk-new
-else
-packagekit_plugin_la_CPPFLAGS += -I$(srcdir)/sdk
-endif
-
packagekit_plugin_la_LIBADD = \
$(PK_BROWSER_PLUGIN_LIBS) \
$(top_builddir)/lib/packagekit-glib/libpackagekit-glib.la
packagekit_plugin_la_SOURCES = \
+ sdk/npplat.h \
+ sdk/pluginbase.h \
src/contents.cpp \
src/contents.h \
src/plugin.cpp \
src/plugin.h
-if PK_XULRUNNER_PLUGIN_NEW
-packagekit_plugin_la_SOURCES += \
- sdk-new/npplat.h \
- sdk-new/pluginbase.h
-else
-packagekit_plugin_la_SOURCES += \
- sdk/np_entry.cpp \
- sdk/npn_gate.cpp \
- sdk/npp_gate.cpp \
- sdk/npplat.h \
- sdk/pluginbase.h
-endif
-
EXTRA_DIST = \
tests/test.html
diff --git a/contrib/browser-plugin/sdk-new/npplat.h b/contrib/browser-plugin/sdk-new/npplat.h
deleted file mode 100644
index d426a88..0000000
--- a/contrib/browser-plugin/sdk-new/npplat.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef npplat_h_
-#define npplat_h_
-
-#include "npapi.h"
-#include "npfunctions.h"
-
-#ifdef XP_WIN
-#include "windows.h"
-#endif
-
-#ifdef XP_UNIX
-#include <stdio.h>
-#endif
-
-#ifdef XP_MAC
-#include <Carbon/Carbon.h>
-#endif
-
-#ifndef HIBYTE
-#define HIBYTE(i) (i >> 8)
-#endif
-
-#ifndef LOBYTE
-#define LOBYTE(i) (i & 0xff)
-#endif
-
-#endif // npplat_h_
diff --git a/contrib/browser-plugin/sdk-new/pluginbase.h b/contrib/browser-plugin/sdk-new/pluginbase.h
deleted file mode 100644
index 1168bca..0000000
--- a/contrib/browser-plugin/sdk-new/pluginbase.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef pluginbase_h_
-#define pluginbase_h_
-
-#include "npplat.h"
-
-struct nsPluginCreateData
-{
- NPP instance;
- NPMIMEType type;
- uint16_t mode;
- int16_t argc;
- char** argn;
- char** argv;
- NPSavedData* saved;
-};
-
-class nsPluginInstanceBase
-{
-public:
- // these three methods must be implemented in the derived
- // class platform specific way
- virtual NPBool init(NPWindow* aWindow) = 0;
- virtual void shut() = 0;
- virtual NPBool isInitialized() = 0;
-
- // implement all or part of those methods in the derived
- // class as needed
- virtual NPError SetWindow(NPWindow* pNPWindow) { return NPERR_NO_ERROR; }
- virtual NPError NewStream(NPMIMEType type, NPStream* stream,
- NPBool seekable, uint16_t* stype) { return NPERR_NO_ERROR; }
- virtual NPError DestroyStream(NPStream *stream, NPError reason) { return NPERR_NO_ERROR; }
- virtual void StreamAsFile(NPStream* stream, const char* fname) { return; }
- virtual int32_t WriteReady(NPStream *stream) { return 0x0fffffff; }
- virtual int32_t Write(NPStream *stream, int32_t offset,
- int32_t len, void *buffer) { return len; }
- virtual void Print(NPPrint* printInfo) { return; }
- virtual uint16_t HandleEvent(void* event) { return 0; }
- virtual void URLNotify(const char* url, NPReason reason,
- void* notifyData) { return; }
- virtual NPError GetValue(NPPVariable variable, void *value) { return NPERR_NO_ERROR; }
- virtual NPError SetValue(NPNVariable variable, void *value) { return NPERR_NO_ERROR; }
-};
-
-// functions that should be implemented for each specific plugin
-
-// creation and destruction of the object of the derived class
-nsPluginInstanceBase * NS_NewPluginInstance(nsPluginCreateData * aCreateDataStruct);
-void NS_DestroyPluginInstance(nsPluginInstanceBase * aPlugin);
-
-// global plugin initialization and shutdown
-NPError NS_PluginInitialize();
-void NS_PluginShutdown();
-
-#ifdef XP_UNIX
-// global to get plugins name & description
-NPError NS_PluginGetValue(NPPVariable aVariable, void *aValue);
-#endif
-
-#endif // pluginbase_h_
diff --git a/contrib/browser-plugin/sdk/np_entry.cpp b/contrib/browser-plugin/sdk/np_entry.cpp
deleted file mode 100644
index 05323e9..0000000
--- a/contrib/browser-plugin/sdk/np_entry.cpp
+++ /dev/null
@@ -1,320 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-//////////////////////////////////////////////////////////////
-//
-// Main plugin entry point implementation -- exports from the
-// plugin library
-//
-#include "npplat.h"
-#include "pluginbase.h"
-
-NPNetscapeFuncs NPNFuncs;
-
-NPError OSCALL NP_Shutdown()
-{
- NS_PluginShutdown();
- return NPERR_NO_ERROR;
-}
-
-static NPError fillPluginFunctionTable(NPPluginFuncs* aNPPFuncs)
-{
- if(aNPPFuncs == NULL)
- return NPERR_INVALID_FUNCTABLE_ERROR;
-
- // Set up the plugin function table that Netscape will use to
- // call us. Netscape needs to know about our version and size
- // and have a UniversalProcPointer for every function we implement.
-
- aNPPFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
-#ifdef XP_MAC
- aNPPFuncs->newp = NewNPP_NewProc(Private_New);
- aNPPFuncs->destroy = NewNPP_DestroyProc(Private_Destroy);
- aNPPFuncs->setwindow = NewNPP_SetWindowProc(Private_SetWindow);
- aNPPFuncs->newstream = NewNPP_NewStreamProc(Private_NewStream);
- aNPPFuncs->destroystream = NewNPP_DestroyStreamProc(Private_DestroyStream);
- aNPPFuncs->asfile = NewNPP_StreamAsFileProc(Private_StreamAsFile);
- aNPPFuncs->writeready = NewNPP_WriteReadyProc(Private_WriteReady);
- aNPPFuncs->write = NewNPP_WriteProc(Private_Write);
- aNPPFuncs->print = NewNPP_PrintProc(Private_Print);
- aNPPFuncs->event = NewNPP_HandleEventProc(Private_HandleEvent);
- aNPPFuncs->urlnotify = NewNPP_URLNotifyProc(Private_URLNotify);
- aNPPFuncs->getvalue = NewNPP_GetValueProc(Private_GetValue);
- aNPPFuncs->setvalue = NewNPP_SetValueProc(Private_SetValue);
-#else
- aNPPFuncs->newp = NPP_New;
- aNPPFuncs->destroy = NPP_Destroy;
- aNPPFuncs->setwindow = NPP_SetWindow;
- aNPPFuncs->newstream = NPP_NewStream;
- aNPPFuncs->destroystream = NPP_DestroyStream;
- aNPPFuncs->asfile = NPP_StreamAsFile;
- aNPPFuncs->writeready = NPP_WriteReady;
- aNPPFuncs->write = NPP_Write;
- aNPPFuncs->print = NPP_Print;
- aNPPFuncs->event = NPP_HandleEvent;
- aNPPFuncs->urlnotify = NPP_URLNotify;
- aNPPFuncs->getvalue = NPP_GetValue;
- aNPPFuncs->setvalue = NPP_SetValue;
-#endif
-#ifdef OJI
- aNPPFuncs->javaClass = NULL;
-#endif
-
- return NPERR_NO_ERROR;
-}
-
-static NPError fillNetscapeFunctionTable(NPNetscapeFuncs* aNPNFuncs)
-{
- if(aNPNFuncs == NULL)
- return NPERR_INVALID_FUNCTABLE_ERROR;
-
- if(HIBYTE(aNPNFuncs->version) > NP_VERSION_MAJOR)
- return NPERR_INCOMPATIBLE_VERSION_ERROR;
-
- if(aNPNFuncs->size < sizeof(NPNetscapeFuncs))
- return NPERR_INVALID_FUNCTABLE_ERROR;
-
- NPNFuncs.size = aNPNFuncs->size;
- NPNFuncs.version = aNPNFuncs->version;
- NPNFuncs.geturlnotify = aNPNFuncs->geturlnotify;
- NPNFuncs.geturl = aNPNFuncs->geturl;
- NPNFuncs.posturlnotify = aNPNFuncs->posturlnotify;
- NPNFuncs.posturl = aNPNFuncs->posturl;
- NPNFuncs.requestread = aNPNFuncs->requestread;
- NPNFuncs.newstream = aNPNFuncs->newstream;
- NPNFuncs.write = aNPNFuncs->write;
- NPNFuncs.destroystream = aNPNFuncs->destroystream;
- NPNFuncs.status = aNPNFuncs->status;
- NPNFuncs.uagent = aNPNFuncs->uagent;
- NPNFuncs.memalloc = aNPNFuncs->memalloc;
- NPNFuncs.memfree = aNPNFuncs->memfree;
- NPNFuncs.memflush = aNPNFuncs->memflush;
- NPNFuncs.reloadplugins = aNPNFuncs->reloadplugins;
-#ifdef OJI
- NPNFuncs.getJavaEnv = aNPNFuncs->getJavaEnv;
- NPNFuncs.getJavaPeer = aNPNFuncs->getJavaPeer;
-#endif
- NPNFuncs.getvalue = aNPNFuncs->getvalue;
- NPNFuncs.setvalue = aNPNFuncs->setvalue;
- NPNFuncs.invalidaterect = aNPNFuncs->invalidaterect;
- NPNFuncs.invalidateregion = aNPNFuncs->invalidateregion;
- NPNFuncs.forceredraw = aNPNFuncs->forceredraw;
-
- return NPERR_NO_ERROR;
-}
-
-//
-// Some exports are different on different platforms
-//
-
-/**************************************************/
-/* */
-/* Windows */
-/* */
-/**************************************************/
-#ifdef XP_WIN
-
-NPError OSCALL NP_Initialize(NPNetscapeFuncs* aNPNFuncs)
-{
- NPError rv = fillNetscapeFunctionTable(aNPNFuncs);
- if(rv != NPERR_NO_ERROR)
- return rv;
-
- return NS_PluginInitialize();
-}
-
-NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* aNPPFuncs)
-{
- return fillPluginFunctionTable(aNPPFuncs);
-}
-
-#endif //XP_WIN
-
-/**************************************************/
-/* */
-/* Unix */
-/* */
-/**************************************************/
-#ifdef XP_UNIX
-
-NPError NP_Initialize(NPNetscapeFuncs* aNPNFuncs, NPPluginFuncs* aNPPFuncs)
-{
- NPError rv = fillNetscapeFunctionTable(aNPNFuncs);
- if(rv != NPERR_NO_ERROR)
- return rv;
-
- rv = fillPluginFunctionTable(aNPPFuncs);
- if(rv != NPERR_NO_ERROR)
- return rv;
-
- return NS_PluginInitialize();
-}
-
-char * NP_GetMIMEDescription(void)
-{
- return NPP_GetMIMEDescription();
-}
-
-NPError NP_GetValue(void *future, NPPVariable aVariable, void *aValue)
-{
- return NS_PluginGetValue(aVariable, aValue);
-}
-
-#endif //XP_UNIX
-
-/**************************************************/
-/* */
-/* Mac */
-/* */
-/**************************************************/
-#ifdef XP_MAC
-
-#if !TARGET_API_MAC_CARBON
-QDGlobals* gQDPtr; // Pointer to Netscape's QuickDraw globals
-#endif
-
-short gResFile; // Refnum of the plugin's resource file
-
-NPError Private_Initialize(void)
-{
- NPError rv = NS_PluginInitialize();
- return rv;
-}
-
-void Private_Shutdown(void)
-{
- NS_PluginShutdown();
- __destroy_global_chain();
-}
-
-void SetUpQD(void);
-
-void SetUpQD(void)
-{
- ProcessSerialNumber PSN;
- FSSpec myFSSpec;
- Str63 name;
- ProcessInfoRec infoRec;
- OSErr result = noErr;
- CFragConnectionID connID;
- Str255 errName;
-
- // Memorize the plugin¹s resource file refnum for later use.
- gResFile = CurResFile();
-
-#if !TARGET_API_MAC_CARBON
- // Ask the system if CFM is available.
- long response;
- OSErr err = Gestalt(gestaltCFMAttr, &response);
- Boolean hasCFM = BitTst(&response, 31-gestaltCFMPresent);
-
- if (hasCFM) {
- // GetProcessInformation takes a process serial number and
- // will give us back the name and FSSpec of the application.
- // See the Process Manager in IM.
- infoRec.processInfoLength = sizeof(ProcessInfoRec);
- infoRec.processName = name;
- infoRec.processAppSpec = &myFSSpec;
-
- PSN.highLongOfPSN = 0;
- PSN.lowLongOfPSN = kCurrentProcess;
-
- result = GetProcessInformation(&PSN, &infoRec);
- }
- else
- // If no CFM installed, assume it must be a 68K app.
- result = -1;
-
- if (result == noErr) {
- // Now that we know the app name and FSSpec, we can call GetDiskFragment
- // to get a connID to use in a subsequent call to FindSymbol (it will also
- // return the address of ³main² in app, which we ignore). If GetDiskFragment
- // returns an error, we assume the app must be 68K.
- Ptr mainAddr;
- result = GetDiskFragment(infoRec.processAppSpec, 0L, 0L, infoRec.processName,
- kReferenceCFrag, &connID, (Ptr*)&mainAddr, errName);
- }
-
- if (result == noErr) {
- // The app is a PPC code fragment, so call FindSymbol
- // to get the exported ³qd² symbol so we can access its
- // QuickDraw globals.
- CFragSymbolClass symClass;
- result = FindSymbol(connID, "\pqd", (Ptr*)&gQDPtr, &symClass);
- }
- else {
- // The app is 68K, so use its A5 to compute the address
- // of its QuickDraw globals.
- gQDPtr = (QDGlobals*)(*((long*)SetCurrentA5()) - (sizeof(QDGlobals) - sizeof(GrafPtr)));
- }
-#endif /* !TARGET_API_MAC_CARBON */
-}
-
-NPError main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, NPP_ShutdownUPP* unloadUpp);
-
-#if !TARGET_API_MAC_CARBON
-#pragma export on
-#if GENERATINGCFM
-RoutineDescriptor mainRD = BUILD_ROUTINE_DESCRIPTOR(uppNPP_MainEntryProcInfo, main);
-#endif
-#pragma export off
-#endif /* !TARGET_API_MAC_CARBON */
-
-
-NPError main(NPNetscapeFuncs* aNPNFuncs, NPPluginFuncs* aNPPFuncs, NPP_ShutdownUPP* aUnloadUpp)
-{
- NPError rv = NPERR_NO_ERROR;
-
- if (aUnloadUpp == NULL)
- rv = NPERR_INVALID_FUNCTABLE_ERROR;
-
- if (rv == NPERR_NO_ERROR)
- rv = fillNetscapeFunctionTable(aNPNFuncs);
-
- if (rv == NPERR_NO_ERROR) {
- // defer static constructors until the global functions are initialized.
- __InitCode__();
- rv = fillPluginFunctionTable(aNPPFuncs);
- }
-
- *aUnloadUpp = NewNPP_ShutdownProc(Private_Shutdown);
- SetUpQD();
- rv = Private_Initialize();
-
- return rv;
-}
-#endif //XP_MAC
diff --git a/contrib/browser-plugin/sdk/npn_gate.cpp b/contrib/browser-plugin/sdk/npn_gate.cpp
deleted file mode 100644
index f5caa32..0000000
--- a/contrib/browser-plugin/sdk/npn_gate.cpp
+++ /dev/null
@@ -1,215 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-
-////////////////////////////////////////////////////////////
-//
-// Implementation of Netscape entry points (NPN_*)
-//
-#include "npplat.h"
-
-extern NPNetscapeFuncs NPNFuncs;
-
-void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
-{
- *plugin_major = NP_VERSION_MAJOR;
- *plugin_minor = NP_VERSION_MINOR;
- *netscape_major = HIBYTE(NPNFuncs.version);
- *netscape_minor = LOBYTE(NPNFuncs.version);
-}
-
-NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void* notifyData)
-{
- int navMinorVers = NPNFuncs.version & 0xFF;
- NPError rv = NPERR_NO_ERROR;
-
- if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
- rv = CallNPN_GetURLNotifyProc(NPNFuncs.geturlnotify, instance, url, target, notifyData);
- else
- rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
-
- return rv;
-}
-
-NPError NPN_GetURL(NPP instance, const char *url, const char *target)
-{
- NPError rv = CallNPN_GetURLProc(NPNFuncs.geturl, instance, url, target);
- return rv;
-}
-
-NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData)
-{
- int navMinorVers = NPNFuncs.version & 0xFF;
- NPError rv = NPERR_NO_ERROR;
-
- if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
- rv = CallNPN_PostURLNotifyProc(NPNFuncs.posturlnotify, instance, url, window, len, buf, file, notifyData);
- else
- rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
-
- return rv;
-}
-
-NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file)
-{
- NPError rv = CallNPN_PostURLProc(NPNFuncs.posturl, instance, url, window, len, buf, file);
- return rv;
-}
-
-NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
-{
- NPError rv = CallNPN_RequestReadProc(NPNFuncs.requestread, stream, rangeList);
- return rv;
-}
-
-NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* target, NPStream** stream)
-{
- int navMinorVersion = NPNFuncs.version & 0xFF;
-
- NPError rv = NPERR_NO_ERROR;
-
- if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
- rv = CallNPN_NewStreamProc(NPNFuncs.newstream, instance, type, target, stream);
- else
- rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
-
- return rv;
-}
-
-int32 NPN_Write(NPP instance, NPStream *stream, int32 len, void *buffer)
-{
- int navMinorVersion = NPNFuncs.version & 0xFF;
- int32 rv = 0;
-
- if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
- rv = CallNPN_WriteProc(NPNFuncs.write, instance, stream, len, buffer);
- else
- rv = -1;
-
- return rv;
-}
-
-NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
-{
- int navMinorVersion = NPNFuncs.version & 0xFF;
- NPError rv = NPERR_NO_ERROR;
-
- if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
- rv = CallNPN_DestroyStreamProc(NPNFuncs.destroystream, instance, stream, reason);
- else
- rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
-
- return rv;
-}
-
-void NPN_Status(NPP instance, const char *message)
-{
- CallNPN_StatusProc(NPNFuncs.status, instance, message);
-}
-
-const char* NPN_UserAgent(NPP instance)
-{
- const char * rv = NULL;
- rv = CallNPN_UserAgentProc(NPNFuncs.uagent, instance);
- return rv;
-}
-
-void* NPN_MemAlloc(uint32 size)
-{
- void * rv = NULL;
- rv = CallNPN_MemAllocProc(NPNFuncs.memalloc, size);
- return rv;
-}
-
-void NPN_MemFree(void* ptr)
-{
- CallNPN_MemFreeProc(NPNFuncs.memfree, ptr);
-}
-
-uint32 NPN_MemFlush(uint32 size)
-{
- uint32 rv = CallNPN_MemFlushProc(NPNFuncs.memflush, size);
- return rv;
-}
-
-void NPN_ReloadPlugins(NPBool reloadPages)
-{
- CallNPN_ReloadPluginsProc(NPNFuncs.reloadplugins, reloadPages);
-}
-
-#ifdef OJI
-JRIEnv* NPN_GetJavaEnv(void)
-{
- JRIEnv * rv = NULL;
- rv = CallNPN_GetJavaEnvProc(NPNFuncs.getJavaEnv);
- return rv;
-}
-
-jref NPN_GetJavaPeer(NPP instance)
-{
- jref rv;
- rv = CallNPN_GetJavaPeerProc(NPNFuncs.getJavaPeer, instance);
- return rv;
-}
-#endif
-
-NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value)
-{
- NPError rv = CallNPN_GetValueProc(NPNFuncs.getvalue, instance, variable, value);
- return rv;
-}
-
-NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value)
-{
- NPError rv = CallNPN_SetValueProc(NPNFuncs.setvalue, instance, variable, value);
- return rv;
-}
-
-void NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
-{
- CallNPN_InvalidateRectProc(NPNFuncs.invalidaterect, instance, invalidRect);
-}
-
-void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
-{
- CallNPN_InvalidateRegionProc(NPNFuncs.invalidateregion, instance, invalidRegion);
-}
-
-void NPN_ForceRedraw(NPP instance)
-{
- CallNPN_ForceRedrawProc(NPNFuncs.forceredraw, instance);
-}
diff --git a/contrib/browser-plugin/sdk/npp_gate.cpp b/contrib/browser-plugin/sdk/npp_gate.cpp
deleted file mode 100644
index 3e22783..0000000
--- a/contrib/browser-plugin/sdk/npp_gate.cpp
+++ /dev/null
@@ -1,358 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-
-////////////////////////////////////////////////////////////
-//
-// Implementation of plugin entry points (NPP_*)
-//
-#include "pluginbase.h"
-
-// here the plugin creates a plugin instance object which
-// will be associated with this newly created NPP instance and
-// will do all the necessary job
-NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved)
-{
- if(instance == NULL)
- return NPERR_INVALID_INSTANCE_ERROR;
-
- NPError rv = NPERR_NO_ERROR;
-
- // create a new plugin instance object
- // initialization will be done when the associated window is ready
- nsPluginCreateData ds;
-
- ds.instance = instance;
- ds.type = pluginType;
- ds.mode = mode;
- ds.argc = argc;
- ds.argn = argn;
- ds.argv = argv;
- ds.saved = saved;
-
- nsPluginInstanceBase * plugin = NS_NewPluginInstance(&ds);
- if(plugin == NULL)
- return NPERR_OUT_OF_MEMORY_ERROR;
-
- // associate the plugin instance object with NPP instance
- instance->pdata = (void *)plugin;
- return rv;
-}
-
-// here is the place to clean up and destroy the nsPluginInstance object
-NPError NPP_Destroy (NPP instance, NPSavedData** save)
-{
- if(instance == NULL)
- return NPERR_INVALID_INSTANCE_ERROR;
-
- NPError rv = NPERR_NO_ERROR;
-
- nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
- if(plugin != NULL) {
- plugin->shut();
- NS_DestroyPluginInstance(plugin);
- }
- return rv;
-}
-
-// during this call we know when the plugin window is ready or
-// is about to be destroyed so we can do some gui specific
-// initialization and shutdown
-NPError NPP_SetWindow (NPP instance, NPWindow* pNPWindow)
-{
- if(instance == NULL)
- return NPERR_INVALID_INSTANCE_ERROR;
-
- NPError rv = NPERR_NO_ERROR;
-
- if(pNPWindow == NULL)
- return NPERR_GENERIC_ERROR;
-
- nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
-
- if(plugin == NULL)
- return NPERR_GENERIC_ERROR;
-
- // window just created
- if(!plugin->isInitialized() && (pNPWindow->window != NULL)) {
- if(!plugin->init(pNPWindow)) {
- NS_DestroyPluginInstance(plugin);
- return NPERR_MODULE_LOAD_FAILED_ERROR;
- }
- }
-
- // window goes away
- if((pNPWindow->window == NULL) && plugin->isInitialized())
- return plugin->SetWindow(pNPWindow);
-
- // window resized?
- if(plugin->isInitialized() && (pNPWindow->window != NULL))
- return plugin->SetWindow(pNPWindow);
-
- // this should not happen, nothing to do
- if((pNPWindow->window == NULL) && !plugin->isInitialized())
- return plugin->SetWindow(pNPWindow);
-
- return rv;
-}
-
-NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype)
-{
- if(instance == NULL)
- return NPERR_INVALID_INSTANCE_ERROR;
-
- nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
- if(plugin == NULL)
- return NPERR_GENERIC_ERROR;
-
- NPError rv = plugin->NewStream(type, stream, seekable, stype);
- return rv;
-}
-
-int32 NPP_WriteReady (NPP instance, NPStream *stream)
-{
- if(instance == NULL)
- return 0x0fffffff;
-
- nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
- if(plugin == NULL)
- return 0x0fffffff;
-
- int32 rv = plugin->WriteReady(stream);
- return rv;
-}
-
-int32 NPP_Write (NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer)
-{
- if(instance == NULL)
- return len;
-
- nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
- if(plugin == NULL)
- return len;
-
- int32 rv = plugin->Write(stream, offset, len, buffer);
- return rv;
-}
-
-NPError NPP_DestroyStream (NPP instance, NPStream *stream, NPError reason)
-{
- if(instance == NULL)
- return NPERR_INVALID_INSTANCE_ERROR;
-
- nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
- if(plugin == NULL)
- return NPERR_GENERIC_ERROR;
-
- NPError rv = plugin->DestroyStream(stream, reason);
- return rv;
-}
-
-void NPP_StreamAsFile (NPP instance, NPStream* stream, const char* fname)
-{
- if(instance == NULL)
- return;
-
- nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
- if(plugin == NULL)
- return;
-
- plugin->StreamAsFile(stream, fname);
-}
-
-void NPP_Print (NPP instance, NPPrint* printInfo)
-{
- if(instance == NULL)
- return;
-
- nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
- if(plugin == NULL)
- return;
-
- plugin->Print(printInfo);
-}
-
-void NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
-{
- if(instance == NULL)
- return;
-
- nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
- if(plugin == NULL)
- return;
-
- plugin->URLNotify(url, reason, notifyData);
-}
-
-NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value)
-{
- if(instance == NULL)
- return NPERR_INVALID_INSTANCE_ERROR;
-
- nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
- if(plugin == NULL)
- return NPERR_GENERIC_ERROR;
-
- NPError rv = plugin->GetValue(variable, value);
- return rv;
-}
-
-NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value)
-{
- if(instance == NULL)
- return NPERR_INVALID_INSTANCE_ERROR;
-
- nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
- if(plugin == NULL)
- return NPERR_GENERIC_ERROR;
-
- NPError rv = plugin->SetValue(variable, value);
- return rv;
-}
-
-int16 NPP_HandleEvent(NPP instance, void* event)
-{
- if(instance == NULL)
- return 0;
-
- nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
- if(plugin == NULL)
- return 0;
-
- uint16 rv = plugin->HandleEvent(event);
- return rv;
-}
-
-#ifdef OJI
-jref NPP_GetJavaClass (void)
-{
- return NULL;
-}
-#endif
-
-/**************************************************/
-/* */
-/* Mac */
-/* */
-/**************************************************/
-
-// Mac needs these wrappers, see npplat.h for more info
-
-#ifdef XP_MAC
-
-NPError Private_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved)
-{
- NPError rv = NPP_New(pluginType, instance, mode, argc, argn, argv, saved);
- return rv;
-}
-
-NPError Private_Destroy(NPP instance, NPSavedData** save)
-{
- NPError rv = NPP_Destroy(instance, save);
- return rv;
-}
-
-NPError Private_SetWindow(NPP instance, NPWindow* window)
-{
- NPError rv = NPP_SetWindow(instance, window);
- return rv;
-}
-
-NPError Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype)
-{
- NPError rv = NPP_NewStream(instance, type, stream, seekable, stype);
- return rv;
-}
-
-int32 Private_WriteReady(NPP instance, NPStream* stream)
-{
- int32 rv = NPP_WriteReady(instance, stream);
- return rv;
-}
-
-int32 Private_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer)
-{
- int32 rv = NPP_Write(instance, stream, offset, len, buffer);
- return rv;
-}
-
-void Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
-{
- NPP_StreamAsFile(instance, stream, fname);
-}
-
-
-NPError Private_DestroyStream(NPP instance, NPStream* stream, NPError reason)
-{
- NPError rv = NPP_DestroyStream(instance, stream, reason);
- return rv;
-}
-
-int16 Private_HandleEvent(NPP instance, void* event)
-{
- int16 rv = NPP_HandleEvent(instance, event);
- return rv;
-}
-
-void Private_Print(NPP instance, NPPrint* platformPrint)
-{
- NPP_Print(instance, platformPrint);
-}
-
-void Private_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
-{
- NPP_URLNotify(instance, url, reason, notifyData);
-}
-
-jref Private_GetJavaClass(void)
-{
- return NULL;
-}
-
-NPError Private_GetValue(NPP instance, NPPVariable variable, void *result)
-{
- NPError rv = NPP_GetValue(instance, variable, result);
- return rv;
-}
-
-NPError Private_SetValue(NPP instance, NPNVariable variable, void *value)
-{
- NPError rv = NPP_SetValue(instance, variable, value);
- return rv;
-}
-
-#endif //XP_MAC
diff --git a/contrib/browser-plugin/sdk/npplat.h b/contrib/browser-plugin/sdk/npplat.h
index 637ac36..d426a88 100644
--- a/contrib/browser-plugin/sdk/npplat.h
+++ b/contrib/browser-plugin/sdk/npplat.h
@@ -35,110 +35,24 @@
*
* ***** END LICENSE BLOCK ***** */
-#ifndef _NPPLAT_H_
-#define _NPPLAT_H_
+#ifndef npplat_h_
+#define npplat_h_
#include "npapi.h"
-#include "npupp.h"
+#include "npfunctions.h"
-/**************************************************/
-/* */
-/* Windows */
-/* */
-/**************************************************/
#ifdef XP_WIN
#include "windows.h"
-#endif //XP_WIN
+#endif
-/**************************************************/
-/* */
-/* Unix */
-/* */
-/**************************************************/
#ifdef XP_UNIX
#include <stdio.h>
-#endif //XP_UNIX
-
-/**************************************************/
-/* */
-/* Mac */
-/* */
-/**************************************************/
-#ifdef XP_MAC
-
-#include <Processes.h>
-#include <Gestalt.h>
-#include <CodeFragments.h>
-#include <Timer.h>
-#include <Resources.h>
-#include <ToolUtils.h>
-
-#include "jri.h"
-
-// The Mixed Mode procInfos defined in npupp.h assume Think C-
-// style calling conventions. These conventions are used by
-// Metrowerks with the exception of pointer return types, which
-// in Metrowerks 68K are returned in A0, instead of the standard
-// D0. Thus, since NPN_MemAlloc and NPN_UserAgent return pointers,
-// Mixed Mode will return the values to a 68K plugin in D0, but
-// a 68K plugin compiled by Metrowerks will expect the result in
-// A0. The following pragma forces Metrowerks to use D0 instead.
-//
-#ifdef __MWERKS__
-#ifndef powerc
-#pragma pointers_in_D0
-#endif
#endif
-#ifdef __MWERKS__
-#ifndef powerc
-#pragma pointers_in_A0
-#endif
+#ifdef XP_MAC
+#include <Carbon/Carbon.h>
#endif
-// The following fix for static initializers (which fixes a preious
-// incompatibility with some parts of PowerPlant, was submitted by
-// Jan Ulbrich.
-#ifdef __MWERKS__
- #ifdef __cplusplus
- extern "C" {
- #endif
- #ifndef powerc
- extern void __InitCode__(void);
- #else
- extern void __sinit(void);
- #define __InitCode__ __sinit
- #endif
- extern void __destroy_global_chain(void);
- #ifdef __cplusplus
- }
- #endif // __cplusplus
-#endif // __MWERKS__
-
-// Wrapper functions for all calls from Netscape to the plugin.
-// These functions let the plugin developer just create the APIs
-// as documented and defined in npapi.h, without needing to
-// install those functions in the function table or worry about
-// setting up globals for 68K plugins.
-NPError Private_Initialize(void);
-void Private_Shutdown(void);
-NPError Private_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved);
-NPError Private_Destroy(NPP instance, NPSavedData** save);
-NPError Private_SetWindow(NPP instance, NPWindow* window);
-NPError Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype);
-NPError Private_DestroyStream(NPP instance, NPStream* stream, NPError reason);
-int32 Private_WriteReady(NPP instance, NPStream* stream);
-int32 Private_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer);
-void Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname);
-void Private_Print(NPP instance, NPPrint* platformPrint);
-int16 Private_HandleEvent(NPP instance, void* event);
-void Private_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData);
-jref Private_GetJavaClass(void);
-NPError Private_GetValue(NPP instance, NPPVariable variable, void *result);
-NPError Private_SetValue(NPP instance, NPNVariable variable, void *value);
-
-#endif //XP_MAC
-
#ifndef HIBYTE
#define HIBYTE(i) (i >> 8)
#endif
@@ -147,4 +61,4 @@ NPError Private_SetValue(NPP instance, NPNVariable variable, void *value);
#define LOBYTE(i) (i & 0xff)
#endif
-#endif //_NPPLAT_H_
+#endif // npplat_h_
diff --git a/contrib/browser-plugin/sdk/pluginbase.h b/contrib/browser-plugin/sdk/pluginbase.h
index b7e3327..1168bca 100644
--- a/contrib/browser-plugin/sdk/pluginbase.h
+++ b/contrib/browser-plugin/sdk/pluginbase.h
@@ -35,8 +35,8 @@
*
* ***** END LICENSE BLOCK ***** */
-#ifndef __PLUGININSTANCEBASE_H__
-#define __PLUGININSTANCEBASE_H__
+#ifndef pluginbase_h_
+#define pluginbase_h_
#include "npplat.h"
@@ -44,8 +44,8 @@ struct nsPluginCreateData
{
NPP instance;
NPMIMEType type;
- uint16 mode;
- int16 argc;
+ uint16_t mode;
+ int16_t argc;
char** argn;
char** argv;
NPSavedData* saved;
@@ -64,14 +64,14 @@ public:
// class as needed
virtual NPError SetWindow(NPWindow* pNPWindow) { return NPERR_NO_ERROR; }
virtual NPError NewStream(NPMIMEType type, NPStream* stream,
- NPBool seekable, uint16* stype) { return NPERR_NO_ERROR; }
+ NPBool seekable, uint16_t* stype) { return NPERR_NO_ERROR; }
virtual NPError DestroyStream(NPStream *stream, NPError reason) { return NPERR_NO_ERROR; }
virtual void StreamAsFile(NPStream* stream, const char* fname) { return; }
- virtual int32 WriteReady(NPStream *stream) { return 0x0fffffff; }
- virtual int32 Write(NPStream *stream, int32 offset,
- int32 len, void *buffer) { return len; }
+ virtual int32_t WriteReady(NPStream *stream) { return 0x0fffffff; }
+ virtual int32_t Write(NPStream *stream, int32_t offset,
+ int32_t len, void *buffer) { return len; }
virtual void Print(NPPrint* printInfo) { return; }
- virtual uint16 HandleEvent(void* event) { return 0; }
+ virtual uint16_t HandleEvent(void* event) { return 0; }
virtual void URLNotify(const char* url, NPReason reason,
void* notifyData) { return; }
virtual NPError GetValue(NPPVariable variable, void *value) { return NPERR_NO_ERROR; }
@@ -93,4 +93,4 @@ void NS_PluginShutdown();
NPError NS_PluginGetValue(NPPVariable aVariable, void *aValue);
#endif
-#endif // __PLUGININSTANCEBASE_H__
+#endif // pluginbase_h_
commit 1c13c765c7ea6d6b8d5c434cd53bcd350974e49c
Author: Richard Hughes <richard at hughsie.com>
Date: Thu Jun 25 12:22:23 2009 +0100
Depend on gtk2+ >= 2.14.0 for the browser plugin
diff --git a/configure.ac b/configure.ac
index 53fdcc8..22051ef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -354,12 +354,17 @@ dnl ---------------------------------------------------------------------------
AC_ARG_ENABLE(browser_plugin, AS_HELP_STRING([--enable-browser-plugin],[Build browser plugin functionality]),
enable_browser_plugin=$enableval,enable_browser_plugin=yes)
if test x$enable_browser_plugin = xyes; then
- PKG_CHECK_MODULES(PK_BROWSER_PLUGIN, mozilla-plugin gio-unix-2.0 cairo pango gtk+-2.0 dbus-glib-1,
- build_browser_plugin=yes, build_browser_plugin=no)
+ PKG_CHECK_MODULES(PK_BROWSER_PLUGIN, \
+ mozilla-plugin \
+ gio-unix-2.0 \
+ cairo \
+ pango \
+ gtk+-2.0 >= 2.14.0 \
+ dbus-glib-1,
+ build_browser_plugin=yes, build_browser_plugin=no)
AC_SUBST(PK_BROWSER_PLUGIN_CFLAGS)
AC_SUBST(PK_BROWSER_PLUGIN_LIBS)
if test $build_browser_plugin = "yes"; then
- # Check if we have GdkAppLaunchContext (new in GTK+-2.14)
packagekit_save_CPPFLAGS="$CPPFLAGS"
packagekit_save_LDFLAGS="$LDFLAGS"
@@ -367,7 +372,6 @@ if test x$enable_browser_plugin = xyes; then
CPPFLAGS="$CPPFLAGS $PK_BROWSER_PLUGIN_CFLAGS"
LDFLAGS="$CPPFLAGS $PK_BROWSER_PLUGIN_LIBS"
- AC_CHECK_FUNCS(gdk_app_launch_context_new)
AC_CHECK_HEADER(npfunctions.h, xulrunner_plugin_new=yes, xulrunner_plugin_new=no)
CPPFLAGS="$packagekit_save_CPPFLAGS"
diff --git a/contrib/browser-plugin/src/contents.cpp b/contrib/browser-plugin/src/contents.cpp
index a30f3e1..3de2b4a 100644
--- a/contrib/browser-plugin/src/contents.cpp
+++ b/contrib/browser-plugin/src/contents.cpp
@@ -648,9 +648,7 @@ void
PkpContents::runApplication (Time time)
{
GError *error = NULL;
-#ifdef HAVE_GDK_APP_LAUNCH_CONTEXT_NEW
GdkAppLaunchContext *context;
-#endif
if (mAppInfo == 0) {
g_warning("Didn't find application to launch");
@@ -660,22 +658,16 @@ PkpContents::runApplication (Time time)
if (time == 0)
time = get_server_timestamp();
-#ifdef HAVE_GDK_APP_LAUNCH_CONTEXT_NEW
context = gdk_app_launch_context_new();
gdk_app_launch_context_set_timestamp(context, time);
if (!g_app_info_launch(mAppInfo, NULL, G_APP_LAUNCH_CONTEXT (context), &error)) {
-#else
- if (!g_app_info_launch(mAppInfo, NULL, NULL, &error)) {
-#endif
g_warning("%s\n", error->message);
g_clear_error(&error);
return;
}
-#ifdef HAVE_GDK_APP_LAUNCH_CONTEXT_NEW
if (context != NULL)
g_object_unref(context);
-#endif
}
void
commit 2af53a2dfd3568503178518fb37e04defd348c92
Author: Richard Hughes <richard at hughsie.com>
Date: Thu Jun 25 12:04:39 2009 +0100
Make the PackageKit plugin available to firefox
diff --git a/contrib/browser-plugin/src/plugin.cpp b/contrib/browser-plugin/src/plugin.cpp
index 565e8b3..e0aef5b 100644
--- a/contrib/browser-plugin/src/plugin.cpp
+++ b/contrib/browser-plugin/src/plugin.cpp
@@ -50,12 +50,11 @@
#include "plugin.h"
-#define MIME_TYPES_HANDLED "application/x-packagekit-plugin"
-#define PLUGIN_NAME "Plugin for Installing Applications"
-#define MIME_TYPES_DESCRIPTION MIME_TYPES_HANDLED":bsc:"PLUGIN_NAME
-#define PLUGIN_DESCRIPTION PLUGIN_NAME
+#define MIME_TYPES_DESCRIPTION "application/x-packagekit-plugin:bsc:PackageKit Plugin"
+#define PLUGIN_NAME "PackageKit"
+#define PLUGIN_DESCRIPTION "Plugin for Installing Applications"
-char* NPP_GetMIMEDescription(void)
+char* NP_GetMIMEDescription(void)
{
return (char *)(MIME_TYPES_DESCRIPTION);
}
@@ -80,7 +79,7 @@ make_module_resident()
Dl_info info;
/* Get the (absolute) filename of this module */
- if (!dladdr((void *)NPP_GetMIMEDescription, &info)) {
+ if (!dladdr((void *)NP_GetMIMEDescription, &info)) {
g_warning("Can't find filename for module");
return;
}
commit 0241b2292ea0aa47a01f9716ebef9cf3ba11dcd7
Merge: ac54e30... 6aee3cd...
Author: Richard Hughes <richard at hughsie.com>
Date: Thu Jun 25 11:19:26 2009 +0100
Merge branch 'master' of git+ssh://hughsie@git.packagekit.org/srv/git/PackageKit
commit ac54e30f6fb394e059b490a56a6ad27b458762a6
Author: Richard Hughes <richard at hughsie.com>
Date: Thu Jun 25 10:06:47 2009 +0100
Fix up the refresh_cache force parameter passing in the other backends
diff --git a/backends/apt.deprecated/pk-backend-apt.c b/backends/apt.deprecated/pk-backend-apt.c
index 6206d9a..7b57637 100644
--- a/backends/apt.deprecated/pk-backend-apt.c
+++ b/backends/apt.deprecated/pk-backend-apt.c
@@ -155,7 +155,7 @@ backend_refresh_cache (PkBackend *backend, gboolean force)
return;
}
- pk_backend_spawn_helper (spawn, "aptBackend.py", "refresh-cache", NULL);
+ pk_backend_spawn_helper (spawn, "aptBackend.py", "refresh-cache", pk_backend_bool_to_text (force), NULL);
}
/**
diff --git a/backends/apt/pk-backend-apt.c b/backends/apt/pk-backend-apt.c
index 59b6c68..4f2f50d 100644
--- a/backends/apt/pk-backend-apt.c
+++ b/backends/apt/pk-backend-apt.c
@@ -255,7 +255,7 @@ backend_install_signature (PkBackend *backend, PkSigTypeEnum type,
static void
backend_refresh_cache (PkBackend *backend, gboolean force)
{
- pk_backend_spawn_helper (spawn, "aptBackend.py", "refresh-cache", NULL);
+ pk_backend_spawn_helper (spawn, "aptBackend.py", "refresh-cache", pk_backend_bool_to_text (force), NULL);
}
/**
diff --git a/backends/conary/pk-backend-conary.c b/backends/conary/pk-backend-conary.c
index 628a47c..5ac87ac 100644
--- a/backends/conary/pk-backend-conary.c
+++ b/backends/conary/pk-backend-conary.c
@@ -186,7 +186,7 @@ backend_refresh_cache (PkBackend *backend, gboolean force)
return;
}
- pk_backend_spawn_helper (spawn, "conaryBackend.py", "refresh-cache", NULL);
+ pk_backend_spawn_helper (spawn, "conaryBackend.py", "refresh-cache", pk_backend_bool_to_text (force), NULL);
}
/**
diff --git a/backends/pisi/pk-backend-pisi.c b/backends/pisi/pk-backend-pisi.c
index 5802838..8717fae 100644
--- a/backends/pisi/pk-backend-pisi.c
+++ b/backends/pisi/pk-backend-pisi.c
@@ -215,7 +215,7 @@ backend_refresh_cache (PkBackend *backend, gboolean force)
return;
}
- pk_backend_spawn_helper (spawn, "pisiBackend.py", "refresh-cache", NULL);
+ pk_backend_spawn_helper (spawn, "pisiBackend.py", "refresh-cache", pk_backend_bool_to_text (force), NULL);
}
/**
diff --git a/backends/portage/pk-backend-portage.c b/backends/portage/pk-backend-portage.c
index 565178c..129972c 100644
--- a/backends/portage/pk-backend-portage.c
+++ b/backends/portage/pk-backend-portage.c
@@ -229,7 +229,7 @@ backend_refresh_cache (PkBackend *backend, gboolean force)
return;
}
- pk_backend_spawn_helper (spawn, BACKEND_FILE, "refresh-cache", pk_backend_bool_to_text(force), NULL);
+ pk_backend_spawn_helper (spawn, BACKEND_FILE, "refresh-cache", pk_backend_bool_to_text (force), NULL);
}
/**
diff --git a/backends/smart/pk-backend-smart.c b/backends/smart/pk-backend-smart.c
index f199c4b..e19e62a 100644
--- a/backends/smart/pk-backend-smart.c
+++ b/backends/smart/pk-backend-smart.c
@@ -285,7 +285,7 @@ backend_refresh_cache (PkBackend *backend, gboolean force)
return;
}
- pk_backend_spawn_helper (spawn, BACKEND("refresh-cache"), NULL);
+ pk_backend_spawn_helper (spawn, BACKEND("refresh-cache"), pk_backend_bool_to_text (force), NULL);
}
/**
diff --git a/backends/urpmi/pk-backend-urpmi.c b/backends/urpmi/pk-backend-urpmi.c
index 08008b3..5bdc8f8 100644
--- a/backends/urpmi/pk-backend-urpmi.c
+++ b/backends/urpmi/pk-backend-urpmi.c
@@ -187,7 +187,7 @@ backend_refresh_cache (PkBackend *backend, gboolean force)
return;
}
- pk_backend_spawn_helper (spawn, "urpmi-dispatched-backend.pl", "refresh-cache", NULL);
+ pk_backend_spawn_helper (spawn, "urpmi-dispatched-backend.pl", "refresh-cache", pk_backend_bool_to_text (force), NULL);
}
/**
diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c
index 0a4b678..7006147 100644
--- a/backends/yum/pk-backend-yum.c
+++ b/backends/yum/pk-backend-yum.c
@@ -311,7 +311,7 @@ backend_refresh_cache (PkBackend *backend, gboolean force)
return;
}
- pk_backend_spawn_helper (spawn, "yumBackend.py", "refresh-cache", NULL);
+ pk_backend_spawn_helper (spawn, "yumBackend.py", "refresh-cache", pk_backend_bool_to_text (force), NULL);
}
/**
commit 1b13e553f8270e20ee9c67e7785de869b9223a99
Author: Richard Hughes <richard at hughsie.com>
Date: Thu Jun 25 09:57:20 2009 +0100
Bump two versions in the Fedora spec file
diff --git a/contrib/PackageKit.spec.in b/contrib/PackageKit.spec.in
index 4303eb9..7868534 100644
--- a/contrib/PackageKit.spec.in
+++ b/contrib/PackageKit.spec.in
@@ -1,6 +1,6 @@
%define glib2_version 2.16.1
-%define dbus_version 0.90
-%define dbus_glib_version 0.70
+%define dbus_version 1.1.1
+%define dbus_glib_version 0.74
%define polkit_version 0.92
%define libnm_glib_version 0.6.4
%define alphatag #ALPHATAG#
commit 20ea4f25071e5c0bd617a95bdfead6568091212c
Author: Mounir Lamouri (volkmar) <mounir.lamouri at gmail.com>
Date: Wed Jun 24 23:39:42 2009 +0200
portage: make pylint happy (mostly indentation issues)
diff --git a/backends/portage/portageBackend.py b/backends/portage/portageBackend.py
index 15c8695..a420416 100755
--- a/backends/portage/portageBackend.py
+++ b/backends/portage/portageBackend.py
@@ -1,4 +1,5 @@
#!/usr/bin/python
+# vim:set shiftwidth=4 tabstop=4 expandtab:
#
# Copyright (C) 2009 Mounir Lamouri (volkmar) <mounir.lamouri at gmail.com>
#
@@ -47,864 +48,864 @@ from itertools import izip
#
# Naming convention:
# cpv: category package version, the standard representation of what packagekit
-# names a package (an ebuild for portage)
+# names a package (an ebuild for portage)
# TODO:
# print only found package or every ebuilds ?
# Map Gentoo categories to the PackageKit group name space
SECTION_GROUP_MAP = {
- "app-accessibility" : GROUP_ACCESSIBILITY,
- "app-admin" : GROUP_ADMIN_TOOLS,
- "app-antivirus" : GROUP_OTHER, #TODO
- "app-arch" : GROUP_OTHER,
- "app-backup" : GROUP_OTHER,
- "app-benchmarks" : GROUP_OTHER,
- "app-cdr" : GROUP_OTHER,
- "app-crypt" : GROUP_OTHER,
- "app-dicts" : GROUP_OTHER,
- "app-doc" : GROUP_OTHER,
- "app-editors" : GROUP_OTHER,
- "app-emacs" : GROUP_OTHER,
- "app-emulation" : GROUP_OTHER,
- "app-forensics" : GROUP_OTHER,
- "app-i18n" : GROUP_OTHER,
- "app-laptop" : GROUP_OTHER,
- "app-misc" : GROUP_OTHER,
- "app-mobilephone" : GROUP_OTHER,
- "app-office" : GROUP_OFFICE,
- "app-pda" : GROUP_OTHER,
- "app-portage" : GROUP_OTHER,
- "app-shells" : GROUP_OTHER,
- "app-text" : GROUP_OTHER,
- "app-vim" : GROUP_OTHER,
- "app-xemacs" : GROUP_OTHER,
- "dev-ada" : GROUP_OTHER,
- "dev-cpp" : GROUP_OTHER,
- "dev-db" : GROUP_OTHER,
- "dev-dotnet" : GROUP_OTHER,
- "dev-embedded" : GROUP_OTHER,
- "dev-games" : GROUP_OTHER,
- "dev-haskell" : GROUP_OTHER,
- "dev-java" : GROUP_OTHER,
- "dev-lang" : GROUP_OTHER,
- "dev-libs" : GROUP_OTHER,
- "dev-lisp" : GROUP_OTHER,
- "dev-ml" : GROUP_OTHER,
- "dev-perl" : GROUP_OTHER,
- "dev-php" : GROUP_OTHER,
- "dev-php5" : GROUP_OTHER,
- "dev-python" : GROUP_OTHER,
- "dev-ruby" : GROUP_OTHER,
- "dev-scheme" : GROUP_OTHER,
- "dev-tcltk" : GROUP_OTHER,
- "dev-tex" : GROUP_OTHER,
- "dev-texlive" : GROUP_OTHER,
- "dev-tinyos" : GROUP_OTHER,
- "dev-util" : GROUP_OTHER,
- "games-action" : GROUP_GAMES, # DONE from there
- "games-arcade" : GROUP_GAMES,
- "games-board" : GROUP_GAMES,
- "games-emulation" : GROUP_GAMES,
- "games-engines" : GROUP_GAMES,
- "games-fps" : GROUP_GAMES,
- "games-kids" : GROUP_GAMES,
- "games-misc" : GROUP_GAMES,
- "games-mud" : GROUP_GAMES,
- "games-puzzle" : GROUP_GAMES,
- "games-roguelike" : GROUP_GAMES,
- "games-rpg" : GROUP_GAMES,
- "games-server" : GROUP_GAMES,
- "games-simulation" : GROUP_GAMES,
- "games-sports" : GROUP_GAMES,
- "games-strategy" : GROUP_GAMES,
- "games-util" : GROUP_GAMES,
- "gnome-base" : GROUP_DESKTOP_GNOME,
- "gnome-extra" : GROUP_DESKTOP_GNOME,
- "gnustep-apps" : GROUP_OTHER, # TODO: from there
- "gnustep-base" : GROUP_OTHER,
- "gnustep-libs" : GROUP_OTHER,
- "gpe-base" : GROUP_OTHER,
- "gpe-utils" : GROUP_OTHER,
- "java-virtuals" : GROUP_OTHER,
- "kde-base" : GROUP_DESKTOP_KDE, # DONE from there
- "kde-misc" : GROUP_DESKTOP_KDE,
- "lxde-base" : GROUP_DESKTOP_OTHER,
- "mail-client" : GROUP_COMMUNICATION, # TODO: or GROUP_INTERNET ?
- "mail-filter" : GROUP_OTHER, # TODO: from there
- "mail-mta" : GROUP_OTHER,
- "media-fonts" : GROUP_FONTS, # DONE (only this one)
- "media-gfx" : GROUP_OTHER,
- "media-libs" : GROUP_OTHER,
- "media-plugins" : GROUP_OTHER,
- "media-radio" : GROUP_OTHER,
- "media-sound" : GROUP_OTHER,
- "media-tv" : GROUP_OTHER,
- "media-video" : GROUP_OTHER,
- "metadata" : GROUP_OTHER,
- "net-analyzer" : GROUP_OTHER,
- "net-dialup" : GROUP_OTHER,
- "net-dns" : GROUP_OTHER,
- "net-firewall" : GROUP_OTHER,
- "net-fs" : GROUP_OTHER,
- "net-ftp" : GROUP_OTHER,
- "net-im" : GROUP_OTHER,
- "net-irc" : GROUP_OTHER,
- "net-libs" : GROUP_OTHER,
- "net-mail" : GROUP_OTHER,
- "net-misc" : GROUP_OTHER,
- "net-nds" : GROUP_OTHER,
- "net-news" : GROUP_OTHER,
- "net-nntp" : GROUP_OTHER,
- "net-p2p" : GROUP_OTHER,
- "net-print" : GROUP_OTHER,
- "net-proxy" : GROUP_OTHER,
- "net-voip" : GROUP_OTHER,
- "net-wireless" : GROUP_OTHER,
- "net-zope" : GROUP_OTHER,
- "perl-core" : GROUP_OTHER,
- "profiles" : GROUP_OTHER,
- "rox-base" : GROUP_OTHER,
- "rox-extra" : GROUP_OTHER,
- "sci-astronomy" : GROUP_SCIENCE, # DONE from there
- "sci-biology" : GROUP_SCIENCE,
- "sci-calculators" : GROUP_SCIENCE,
- "sci-chemistry" : GROUP_SCIENCE,
- "sci-electronics" : GROUP_SCIENCE,
- "sci-geosciences" : GROUP_SCIENCE,
- "sci-libs" : GROUP_SCIENCE,
- "sci-mathematics" : GROUP_SCIENCE,
- "sci-misc" : GROUP_SCIENCE,
- "sci-physics" : GROUP_SCIENCE,
- "sci-visualization" : GROUP_SCIENCE,
- "sec-policy" : GROUP_OTHER, # TODO: from there
- "sys-apps" : GROUP_OTHER,
- "sys-auth" : GROUP_OTHER,
- "sys-block" : GROUP_OTHER,
- "sys-boot" : GROUP_OTHER,
- "sys-cluster" : GROUP_OTHER,
- "sys-devel" : GROUP_OTHER,
- "sys-freebsd" : GROUP_OTHER,
- "sys-fs" : GROUP_OTHER,
- "sys-kernel" : GROUP_OTHER,
- "sys-libs" : GROUP_OTHER,
- "sys-power" : GROUP_OTHER,
- "sys-process" : GROUP_OTHER,
- "virtual" : GROUP_OTHER,
- "www-apache" : GROUP_OTHER,
- "www-apps" : GROUP_OTHER,
- "www-client" : GROUP_OTHER,
- "www-misc" : GROUP_OTHER,
- "www-plugins" : GROUP_OTHER,
- "www-servers" : GROUP_OTHER,
- "x11-apps" : GROUP_OTHER,
- "x11-base" : GROUP_OTHER,
- "x11-drivers" : GROUP_OTHER,
- "x11-libs" : GROUP_OTHER,
- "x11-misc" : GROUP_OTHER,
- "x11-plugins" : GROUP_OTHER,
- "x11-proto" : GROUP_OTHER,
- "x11-terms" : GROUP_OTHER,
- "x11-themes" : GROUP_OTHER,
- "x11-wm" : GROUP_OTHER,
- "xfce-base" : GROUP_DESKTOP_XFCE, # DONE from there
- "xfce-extra" : GROUP_DESKTOP_XFCE
+ "app-accessibility" : GROUP_ACCESSIBILITY,
+ "app-admin" : GROUP_ADMIN_TOOLS,
+ "app-antivirus" : GROUP_OTHER, #TODO
+ "app-arch" : GROUP_OTHER,
+ "app-backup" : GROUP_OTHER,
+ "app-benchmarks" : GROUP_OTHER,
+ "app-cdr" : GROUP_OTHER,
+ "app-crypt" : GROUP_OTHER,
+ "app-dicts" : GROUP_OTHER,
+ "app-doc" : GROUP_OTHER,
+ "app-editors" : GROUP_OTHER,
+ "app-emacs" : GROUP_OTHER,
+ "app-emulation" : GROUP_OTHER,
+ "app-forensics" : GROUP_OTHER,
+ "app-i18n" : GROUP_OTHER,
+ "app-laptop" : GROUP_OTHER,
+ "app-misc" : GROUP_OTHER,
+ "app-mobilephone" : GROUP_OTHER,
+ "app-office" : GROUP_OFFICE,
+ "app-pda" : GROUP_OTHER,
+ "app-portage" : GROUP_OTHER,
+ "app-shells" : GROUP_OTHER,
+ "app-text" : GROUP_OTHER,
+ "app-vim" : GROUP_OTHER,
+ "app-xemacs" : GROUP_OTHER,
+ "dev-ada" : GROUP_OTHER,
+ "dev-cpp" : GROUP_OTHER,
+ "dev-db" : GROUP_OTHER,
+ "dev-dotnet" : GROUP_OTHER,
+ "dev-embedded" : GROUP_OTHER,
+ "dev-games" : GROUP_OTHER,
+ "dev-haskell" : GROUP_OTHER,
+ "dev-java" : GROUP_OTHER,
+ "dev-lang" : GROUP_OTHER,
+ "dev-libs" : GROUP_OTHER,
+ "dev-lisp" : GROUP_OTHER,
+ "dev-ml" : GROUP_OTHER,
+ "dev-perl" : GROUP_OTHER,
+ "dev-php" : GROUP_OTHER,
+ "dev-php5" : GROUP_OTHER,
+ "dev-python" : GROUP_OTHER,
+ "dev-ruby" : GROUP_OTHER,
+ "dev-scheme" : GROUP_OTHER,
+ "dev-tcltk" : GROUP_OTHER,
+ "dev-tex" : GROUP_OTHER,
+ "dev-texlive" : GROUP_OTHER,
+ "dev-tinyos" : GROUP_OTHER,
+ "dev-util" : GROUP_OTHER,
+ "games-action" : GROUP_GAMES, # DONE from there
+ "games-arcade" : GROUP_GAMES,
+ "games-board" : GROUP_GAMES,
+ "games-emulation" : GROUP_GAMES,
+ "games-engines" : GROUP_GAMES,
+ "games-fps" : GROUP_GAMES,
+ "games-kids" : GROUP_GAMES,
+ "games-misc" : GROUP_GAMES,
+ "games-mud" : GROUP_GAMES,
+ "games-puzzle" : GROUP_GAMES,
+ "games-roguelike" : GROUP_GAMES,
+ "games-rpg" : GROUP_GAMES,
+ "games-server" : GROUP_GAMES,
+ "games-simulation" : GROUP_GAMES,
+ "games-sports" : GROUP_GAMES,
+ "games-strategy" : GROUP_GAMES,
+ "games-util" : GROUP_GAMES,
+ "gnome-base" : GROUP_DESKTOP_GNOME,
+ "gnome-extra" : GROUP_DESKTOP_GNOME,
+ "gnustep-apps" : GROUP_OTHER, # TODO: from there
+ "gnustep-base" : GROUP_OTHER,
+ "gnustep-libs" : GROUP_OTHER,
+ "gpe-base" : GROUP_OTHER,
+ "gpe-utils" : GROUP_OTHER,
+ "java-virtuals" : GROUP_OTHER,
+ "kde-base" : GROUP_DESKTOP_KDE, # DONE from there
+ "kde-misc" : GROUP_DESKTOP_KDE,
+ "lxde-base" : GROUP_DESKTOP_OTHER,
+ "mail-client" : GROUP_COMMUNICATION, # TODO: or GROUP_INTERNET ?
+ "mail-filter" : GROUP_OTHER, # TODO: from there
+ "mail-mta" : GROUP_OTHER,
+ "media-fonts" : GROUP_FONTS, # DONE (only this one)
+ "media-gfx" : GROUP_OTHER,
+ "media-libs" : GROUP_OTHER,
+ "media-plugins" : GROUP_OTHER,
+ "media-radio" : GROUP_OTHER,
+ "media-sound" : GROUP_OTHER,
+ "media-tv" : GROUP_OTHER,
+ "media-video" : GROUP_OTHER,
+ "metadata" : GROUP_OTHER,
+ "net-analyzer" : GROUP_OTHER,
+ "net-dialup" : GROUP_OTHER,
+ "net-dns" : GROUP_OTHER,
+ "net-firewall" : GROUP_OTHER,
+ "net-fs" : GROUP_OTHER,
+ "net-ftp" : GROUP_OTHER,
+ "net-im" : GROUP_OTHER,
+ "net-irc" : GROUP_OTHER,
+ "net-libs" : GROUP_OTHER,
+ "net-mail" : GROUP_OTHER,
+ "net-misc" : GROUP_OTHER,
+ "net-nds" : GROUP_OTHER,
+ "net-news" : GROUP_OTHER,
+ "net-nntp" : GROUP_OTHER,
+ "net-p2p" : GROUP_OTHER,
+ "net-print" : GROUP_OTHER,
+ "net-proxy" : GROUP_OTHER,
+ "net-voip" : GROUP_OTHER,
+ "net-wireless" : GROUP_OTHER,
+ "net-zope" : GROUP_OTHER,
+ "perl-core" : GROUP_OTHER,
+ "profiles" : GROUP_OTHER,
+ "rox-base" : GROUP_OTHER,
+ "rox-extra" : GROUP_OTHER,
+ "sci-astronomy" : GROUP_SCIENCE, # DONE from there
+ "sci-biology" : GROUP_SCIENCE,
+ "sci-calculators" : GROUP_SCIENCE,
+ "sci-chemistry" : GROUP_SCIENCE,
+ "sci-electronics" : GROUP_SCIENCE,
+ "sci-geosciences" : GROUP_SCIENCE,
+ "sci-libs" : GROUP_SCIENCE,
+ "sci-mathematics" : GROUP_SCIENCE,
+ "sci-misc" : GROUP_SCIENCE,
+ "sci-physics" : GROUP_SCIENCE,
+ "sci-visualization" : GROUP_SCIENCE,
+ "sec-policy" : GROUP_OTHER, # TODO: from there
+ "sys-apps" : GROUP_OTHER,
+ "sys-auth" : GROUP_OTHER,
+ "sys-block" : GROUP_OTHER,
+ "sys-boot" : GROUP_OTHER,
+ "sys-cluster" : GROUP_OTHER,
+ "sys-devel" : GROUP_OTHER,
+ "sys-freebsd" : GROUP_OTHER,
+ "sys-fs" : GROUP_OTHER,
+ "sys-kernel" : GROUP_OTHER,
+ "sys-libs" : GROUP_OTHER,
+ "sys-power" : GROUP_OTHER,
+ "sys-process" : GROUP_OTHER,
+ "virtual" : GROUP_OTHER,
+ "www-apache" : GROUP_OTHER,
+ "www-apps" : GROUP_OTHER,
+ "www-client" : GROUP_OTHER,
+ "www-misc" : GROUP_OTHER,
+ "www-plugins" : GROUP_OTHER,
+ "www-servers" : GROUP_OTHER,
+ "x11-apps" : GROUP_OTHER,
+ "x11-base" : GROUP_OTHER,
+ "x11-drivers" : GROUP_OTHER,
+ "x11-libs" : GROUP_OTHER,
+ "x11-misc" : GROUP_OTHER,
+ "x11-plugins" : GROUP_OTHER,
+ "x11-proto" : GROUP_OTHER,
+ "x11-terms" : GROUP_OTHER,
+ "x11-themes" : GROUP_OTHER,
+ "x11-wm" : GROUP_OTHER,
+ "xfce-base" : GROUP_DESKTOP_XFCE, # DONE from there
+ "xfce-extra" : GROUP_DESKTOP_XFCE
}
def sigquit(signum, frame):
- sys.exit(1)
+ sys.exit(1)
def id_to_cpv(pkgid):
- '''
- Transform the package id (packagekit) to a cpv (portage)
- '''
- # TODO: raise error if ret[0] doesn't contain a '/'
- ret = split_package_id(pkgid)
+ '''
+ Transform the package id (packagekit) to a cpv (portage)
+ '''
+ # TODO: raise error if ret[0] doesn't contain a '/'
+ ret = split_package_id(pkgid)
- if len(ret) < 4:
- raise "id_to_cpv: package id not valid"
+ if len(ret) < 4:
+ raise "id_to_cpv: package id not valid"
- return ret[0] + "-" + ret[1]
+ return ret[0] + "-" + ret[1]
# TODO: move to class ?
def get_group(cp):
- ''' Return the group of the package
- Argument could be cp or cpv. '''
- cat = portage.catsplit(cp)[0]
- if SECTION_GROUP_MAP.has_key(cat):
- return SECTION_GROUP_MAP[cat]
+ ''' Return the group of the package
+ Argument could be cp or cpv. '''
+ cat = portage.catsplit(cp)[0]
+ if SECTION_GROUP_MAP.has_key(cat):
+ return SECTION_GROUP_MAP[cat]
- return GROUP_UNKNOWN
+ return GROUP_UNKNOWN
class PackageKitPortageBackend(PackageKitBaseBackend, PackagekitPackage):
- def __init__(self, args, lock=True):
- signal.signal(signal.SIGQUIT, sigquit)
- PackageKitBaseBackend.__init__(self, args)
-
- self.portage_settings = portage.config()
- self.vardb = portage.db[portage.settings["ROOT"]]["vartree"].dbapi
- #self.portdb = portage.db[portage.settings["ROOT"]]["porttree"].dbapi
-
- if lock:
- self.doLock()
-
- def is_installed(self, cpv):
- if self.vardb.cpv_exists(cpv):
- return True
- return False
-
- def cpv_to_id(self, cpv):
- '''
- Transform the cpv (portage) to a package id (packagekit)
- '''
- # TODO: manage SLOTS !
- package, version, rev = portage.pkgsplit(cpv)
- pkg_keywords, repo = portage.portdb.aux_get(cpv, ["KEYWORDS", "repository"])
-
- pkg_keywords = pkg_keywords.split()
- sys_keywords = self.portage_settings.configdict["defaults"].get("ACCEPT_KEYWORDS").split()
- keywords = []
-
- for x in sys_keywords:
- if x in pkg_keywords:
- keywords.append(x)
-
- # if no keywords, check in package.keywords
- if not keywords:
- for _, keys in self.portage_settings.pkeywordsdict.get(portage.dep_getkey(cpv)).iteritems():
- for x in keys:
- keywords.append(x)
-
- if not keywords:
- keywords.append("no keywords")
- self.message(MESSAGE_UNKNOWN, "No keywords have been found for %s" % cpv)
-
- # don't want to see -r0
- if rev != "r0":
- version = version + "-" + rev
-
- # if installed, repo should be 'installed', packagekit rule
- if self.is_installed(cpv):
- repo = "installed"
-
- return get_package_id(package, version, ' '.join(keywords), repo)
-
- def package(self, cpv, info=None):
- desc = portage.portdb.aux_get(cpv, ["DESCRIPTION"])
- if not info:
- if self.is_installed(cpv):
- info = INFO_INSTALLED
- else:
- info = INFO_AVAILABLE
- PackageKitBaseBackend.package(self, self.cpv_to_id(cpv), info, desc[0])
-
- def get_depends(self, filters, pkgids, recursive):
- # TODO: manage filters
- # TODO: optimize by using vardb for installed packages ?
- self.status(STATUS_INFO)
- self.allow_cancel(True)
- self.percentage(None)
-
- for pkgid in pkgids:
- cpv = id_to_cpv(pkgid)
-
- # is cpv valid
- if not portage.portdb.cpv_exists(cpv):
- # self.warning ? self.error ?
- self.message(MESSAGE_COULD_NOT_FIND_PACKAGE,
- "Could not find the package %s" % pkgid)
- continue
-
- myopts = {}
- if recursive:
- myopts.pop("--emptytree", None)
- myopts["--emptytree"] = True
- spinner = ""
- settings, trees, mtimedb = _emerge.load_emerge_config()
- myparams = _emerge.create_depgraph_params(myopts, "")
- spinner = _emerge.stdout_spinner()
- depgraph = _emerge.depgraph(settings, trees, myopts, myparams, spinner)
- retval, fav = depgraph.select_files(["="+cpv])
- if not retval:
- self.error(ERROR_INTERNAL_ERROR, "Wasn't able to get dependency graph")
- continue
-
- if recursive:
- # printing the whole tree
- pkgs = depgraph.altlist(reversed=1)
- for pkg in pkgs:
- if pkg[2] != cpv:
- self.package(pkg[2])
- else: # !recursive
- # only printing child of the root node
- # actually, we have "=cpv" -> "cpv" -> children
- root_node = depgraph.digraph.root_nodes()[0] # =cpv
- root_node = depgraph.digraph.child_nodes(root_node)[0] # cpv
- children = depgraph.digraph.child_nodes(root_node)
- for child in children:
- self.package(child[2])
-
- def get_details(self, pkgs):
- self.status(STATUS_INFO)
- self.allow_cancel(True)
- self.percentage(None)
-
- for pkg in pkgs:
- cpv = id_to_cpv(pkg)
-
- # is cpv valid
- if not portage.portdb.cpv_exists(cpv):
- # self.warning ? self.error ?
- self.message(MESSAGE_COULD_NOT_FIND_PACKAGE,
- "Could not find the package %s" % pkg)
- continue
-
- homepage, desc, license = portage.portdb.aux_get(cpv,
- ["HOMEPAGE", "DESCRIPTION", "LICENSE"])
-
- # size should be prompted only if not installed
- size = 0
- if not self.is_installed(cpv):
- ebuild = portage.portdb.findname(cpv)
- if ebuild:
- dir = os.path.dirname(ebuild)
- manifest = portage.manifest.Manifest(dir, portage.settings["DISTDIR"])
- uris = portage.portdb.getFetchMap(cpv)
- size = manifest.getDistfilesSize(uris)
-
- self.details(self.cpv_to_id(cpv), license, get_group(cpv),
- desc, homepage, size)
-
- def get_files(self, pkgids):
- self.status(STATUS_INFO)
- self.allow_cancel(True)
- self.percentage(None)
-
- for pkgid in pkgids:
- cpv = id_to_cpv(pkgid)
-
- # is cpv valid
- if not portage.portdb.cpv_exists(cpv):
- self.error(ERROR_PACKAGE_NOT_FOUND,
- "Package %s was not found" % pkgid)
- continue
-
- if not self.vardb.cpv_exists(cpv):
- self.error(ERROR_PACKAGE_NOT_INSTALLED,
- "Package %s is not installed" % pkgid)
- continue
-
- cat, pv = portage.catsplit(cpv)
- db = portage.dblink(cat, pv, portage.settings["ROOT"],
- self.portage_settings, treetype="vartree", vartree=self.vardb)
- files = db.getcontents().keys()
- files = sorted(files)
- files = ";".join(files)
-
- self.files(pkgid, files)
-
- def get_packages(self, filters):
- # TODO: filters
- self.status(STATUS_QUERY)
- self.allow_cancel(True)
- self.percentage(None)
-
- for cp in portage.portdb.cp_all():
- for cpv in portage.portdb.match(cp):
- self.package(cpv)
-
- def get_repo_list(self, filters):
- # TODO: filters
- # TODO: not official
- # TODO: not supported (via filters ?)
- self.status(STATUS_INFO)
- self.allow_cancel(True)
- self.percentage(None)
-
- layman_db = layman.db.RemoteDB(layman.config.Config())
- for o in layman_db.overlays.keys():
- self.repo_detail(o, layman_db.overlays[o].description, True)
-
- def get_requires(self, filters, pkgs, recursive):
- # TODO: filters
- # TODO: recursive not implemented
- # TODO: usefulness ? use cases
- # TODO: work only on installed packages
- self.status(STATUS_RUNNING)
- self.allow_cancel(True)
- self.percentage(None)
-
- myopts = {}
- spinner = ""
- favorites = []
- settings, trees, mtimedb = _emerge.load_emerge_config()
- spinner = _emerge.stdout_spinner()
- rootconfig = _emerge.RootConfig(self.portage_settings, trees["/"],
- portage._sets.load_default_config(self.portage_settings, trees["/"]))
-
- for pkg in pkgs:
- cpv = id_to_cpv(pkg)
-
- # is cpv installed
- # TODO: keep error msg ?
- if not self.vardb.match(cpv):
- self.error(ERROR_PACKAGE_NOT_INSTALLED,
- "Package %s is not installed" % pkg)
- continue
-
- required_set_names = ("system", "world")
- required_sets = {}
-
- args_set = portage._sets.base.InternalPackageSet()
- args_set.update(["="+cpv]) # parameters is converted to atom
- # or use portage.dep_expand
-
- if not args_set:
- self.error(ERROR_INTERNAL_ERROR, "Was not able to generate atoms")
- continue
-
- depgraph = _emerge.depgraph(settings, trees, myopts,
- _emerge.create_depgraph_params(myopts, "remove"), spinner)
- vardb = depgraph.trees["/"]["vartree"].dbapi
-
- for s in required_set_names:
- required_sets[s] = portage._sets.base.InternalPackageSet(
- initial_atoms=rootconfig.setconfig.getSetAtoms(s))
-
- # TODO: error/warning if world = null or system = null ?
-
- # TODO: not sure it's needed. for deselect in emerge...
- required_sets["world"].clear()
- for pkg in vardb:
- spinner.update()
- try:
- if args_set.findAtomForPackage(pkg) is None:
- required_sets["world"].add("=" + pkg.cpv)
- except portage.exception.InvalidDependString, e:
- required_sets["world"].add("=" + pkg.cpv)
-
- set_args = {}
- for s, pkg_set in required_sets.iteritems():
- set_atom = portage._sets.SETPREFIX + s
- set_arg = _emerge.SetArg(arg=set_atom, set=pkg_set,
- root_config=depgraph.roots[portage.settings["ROOT"]])
- set_args[s] = set_arg
- for atom in set_arg.set:
- depgraph._dep_stack.append(
- _emerge.Dependency(atom=atom, root=portage.settings["ROOT"],
- parent=set_arg))
- depgraph.digraph.add(set_arg, None)
-
- if not depgraph._complete_graph():
- self.error(ERROR_INTERNAL_ERROR, "Error when generating depgraph")
- continue
-
- def cmp_pkg_cpv(pkg1, pkg2):
- if pkg1.cpv > pkg2.cpv:
- return 1
- elif pkg1.cpv == pkg2.cpv:
- return 0
- else:
- return -1
-
- for pkg in sorted(vardb,
- key=portage.util.cmp_sort_key(cmp_pkg_cpv)):
- arg_atom = None
- try:
- arg_atom = args_set.findAtomForPackage(pkg)
- except portage.exception.InvalidDependString:
- continue
-
- if arg_atom and pkg in depgraph.digraph:
- parents = depgraph.digraph.parent_nodes(pkg)
- for node in parents:
- self.package(node[2])
-
- self.percentage(100)
-
- def get_update_detail(self, pkgs):
- # TODO: a lot of informations are missing
-
- self.status(STATUS_INFO)
- self.allow_cancel(True)
- self.percentage(None)
-
- for pkg in pkgs:
- updates = []
- obsoletes = ""
- vendor_url = ""
- bugzilla_url = ""
- cve_url = ""
-
- cpv = id_to_cpv(pkg)
-
- if not portage.portdb.cpv_exists(cpv):
- self.message(MESSAGE_COULD_NOT_FIND_PACKAGE, "could not find %s" % pkg)
-
- for cpv in self.vardb.match(portage.pkgsplit(cpv)[0]):
- updates.append(cpv)
- updates = "&".join(updates)
-
- # temporarily set vendor_url = homepage
- homepage = portage.portdb.aux_get(cpv, ["HOMEPAGE"])[0]
- vendor_url = homepage
-
- self.update_detail(pkg, updates, obsoletes, vendor_url, bugzilla_url,
- cve_url, "none", "No update text", "No ChangeLog",
- UPDATE_STATE_STABLE, None, None)
-
- def get_updates(self, filters):
- # NOTES:
- # portage prefer not to update _ALL_ packages so we will only list updated
- # packages in world or system
-
- # TODO: filters ?
- # TODO: INFO
- self.status(STATUS_INFO)
- self.allow_cancel(True)
- self.percentage(None)
-
- # best way to get that ?
- settings, trees, mtimedb = _emerge.load_emerge_config()
- rootconfig = _emerge.RootConfig(self.portage_settings, trees["/"],
- portage._sets.load_default_config(self.portage_settings, trees["/"]))
-
- cp_to_check = []
-
- # get system and world sets
- for s in ("system", "world"):
- set = portage._sets.base.InternalPackageSet(
- initial_atoms=rootconfig.setconfig.getSetAtoms(s))
- for cp in set:
- cp_to_check.append(cp)
-
- # check if bestmatch is installed
- for cp in cp_to_check:
- best_cpv = portage.portdb.xmatch("bestmatch-visible", cp)
- if not self.vardb.cpv_exists(best_cpv):
- self.package(best_cpv, INFO_NORMAL)
-
- def install_packages(self, only_trusted, pkgs):
- self.status(STATUS_RUNNING)
- self.allow_cancel(True) # TODO: sure ?
- self.percentage(None)
-
- # FIXME: use only_trusted
-
- for pkg in pkgs:
- # check for installed is not mandatory as there are a lot of reason
- # to re-install a package (USE/{LD,C}FLAGS change for example) (or live)
- # TODO: keep a final position
- cpv = id_to_cpv(pkg)
-
- # is cpv valid
- if not portage.portdb.cpv_exists(cpv):
- self.error(ERROR_PACKAGE_NOT_FOUND, "Package %s was not found" % pkg)
- continue
-
- # inits
- myopts = {} # TODO: --nodepends ?
- spinner = ""
- favorites = []
- settings, trees, mtimedb = _emerge.load_emerge_config()
- myparams = _emerge.create_depgraph_params(myopts, "")
- spinner = _emerge.stdout_spinner()
-
- depgraph = _emerge.depgraph(settings, trees, myopts, myparams, spinner)
- retval, favorites = depgraph.select_files(["="+cpv])
- if not retval:
- self.error(ERROR_INTERNAL_ERROR, "Wasn't able to get dependency graph")
- continue
-
- if "resume" in mtimedb and \
- "mergelist" in mtimedb["resume"] and \
- len(mtimedb["resume"]["mergelist"]) > 1:
- mtimedb["resume_backup"] = mtimedb["resume"]
- del mtimedb["resume"]
- mtimedb.commit()
-
- mtimedb["resume"]={}
- mtimedb["resume"]["myopts"] = myopts.copy()
- mtimedb["resume"]["favorites"] = [str(x) for x in favorites]
-
- # TODO: check for writing access before calling merge ?
-
- mergetask = _emerge.Scheduler(settings, trees, mtimedb,
- myopts, spinner, depgraph.altlist(),
- favorites, depgraph.schedulerGraph())
- mergetask.merge()
-
- def refresh_cache(self, force):
- # TODO: use force ?
- self.status(STATUS_REFRESH_CACHE)
- self.allow_cancel(True)
- self.percentage(None)
-
- myopts = {} # TODO: --quiet ?
- myopts.pop("--quiet", None)
- myopts["--quiet"] = True
- settings, trees, mtimedb = _emerge.load_emerge_config()
- spinner = _emerge.stdout_spinner()
- try:
- _emerge.action_sync(settings, trees, mtimedb, myopts, "")
- finally:
- self.percentage(100)
-
- def remove_packages(self, allowdep, pkgs):
- # can't use allowdep: never removing dep
- # TODO: filters ?
- self.status(STATUS_RUNNING)
- self.allow_cancel(True)
- self.percentage(None)
-
- for pkg in pkgs:
- cpv = id_to_cpv(pkg)
-
- # is cpv valid
- if not portage.portdb.cpv_exists(cpv):
- self.error(ERROR_PACKAGE_NOT_FOUND, "Package %s was not found" % pkg)
- continue
-
- # is package installed
- if not self.vardb.match(cpv):
- self.error(ERROR_PACKAGE_NOT_INSTALLED,
- "Package %s is not installed" % pkg)
- continue
-
- myopts = {} # TODO: --nodepends ?
- spinner = ""
- favorites = []
- settings, trees, mtimedb = _emerge.load_emerge_config()
- spinner = _emerge.stdout_spinner()
- rootconfig = _emerge.RootConfig(self.portage_settings, trees["/"],
- portage._sets.load_default_config(self.portage_settings, trees["/"])
- )
-
- if "resume" in mtimedb and \
- "mergelist" in mtimedb["resume"] and \
- len(mtimedb["resume"]["mergelist"]) > 1:
- mtimedb["resume_backup"] = mtimedb["resume"]
- del mtimedb["resume"]
- mtimedb.commit()
-
- mtimedb["resume"]={}
- mtimedb["resume"]["myopts"] = myopts.copy()
- mtimedb["resume"]["favorites"] = [str(x) for x in favorites]
-
- db_keys = list(portage.portdb._aux_cache_keys)
- metadata = izip(db_keys, portage.portdb.aux_get(cpv, db_keys))
- package = _emerge.Package(
- type_name="ebuild",
- built=True,
- installed=True,
- root_config=rootconfig,
- cpv=cpv,
- metadata=metadata,
- operation="uninstall")
-
- mergetask = _emerge.Scheduler(settings,
- trees, mtimedb, myopts, spinner, [package], favorites, package)
- mergetask.merge()
-
- def repo_enable(self, repoid, enable):
- self.status(STATUS_INFO)
- self.allow_cancel(True)
- self.percentage(None)
-
- # get installed and available dbs
- installed_layman_db = layman.db.DB(layman.config.Config())
- available_layman_db = layman.db.RemoteDB(layman.config.Config())
-
- # disabling (removing) a db
- if not enable:
- if not repoid in installed_layman_db.overlays.keys():
- self.error(ERROR_REPO_NOT_FOUND, "Repository %s was not found" %repoid)
- return
-
- overlay = installed_layman_db.select(repoid)
-
- if not overlay:
- self.error(ERROR_REPO_NOT_FOUND, "Repository %s was not found" %repoid)
- return
-
- try:
- installed_layman_db.delete(overlay)
- except Exception, e:
- self.error(ERROR_INTERNAL_ERROR,
- "Failed to disable repository " + repoid + " : " + str(e))
- return
-
- # enabling (adding) a db
- if enable:
- if not repoid in available_layman_db.overlays.keys():
- self.error(ERROR_REPO_NOT_FOUND, "Repository %s was not found" %repoid)
- return
-
- overlay = available_layman_db.select(repoid)
-
- if not overlay:
- self.error(ERROR_REPO_NOT_FOUND, "Repository %s was not found" %repoid)
- return
-
- try:
- installed_layman_db.add(overlay, True)
- except Exception, e:
- self.error(ERROR_INTERNAL_ERROR,
- "Failed to disable repository " + repoid + " : " + str(e))
- return
-
- def resolve(self, filters, pkgs):
- # TODO: filters
- self.status(STATUS_QUERY)
- self.allow_cancel(True)
- self.percentage(None)
-
- for pkg in pkgs:
- # TODO: be case sensitive ?
- searchre = re.compile(pkg, re.IGNORECASE)
-
- # TODO: optim with filter = installed
- for cp in portage.portdb.cp_all():
- if searchre.search(cp):
- #print self.vardb.dep_bestmatch(cp)
- self.package(portage.portdb.xmatch("bestmatch-visible", cp))
-
- def search_details(self, filters, key):
- # TODO: add keywords when they will be available
- # TODO: filters
- # TODO: split keys
- # TODO: PERFORMANCE !
- self.status(STATUS_QUERY)
- self.allow_cancel(True)
- self.percentage(None)
-
- searchre = re.compile(key, re.IGNORECASE)
- cpvlist = []
-
- for cp in portage.portdb.cp_all():
- # TODO: baaad, we are working on _every_ cpv :-/
- for cpv in portage.portdb.match(cp): #TODO: cp_list(cp) ?
- infos = portage.portdb.aux_get(cpv,
- ["HOMEPAGE","DESCRIPTION","repository"]) # LICENSE ?
- for x in infos:
- if searchre.search(x):
- self.package(cpv)
- break
-
- def search_file(self, filters, key):
- # TODO: manage filters, error if ~installed ?
- self.status(STATUS_QUERY)
- self.allow_cancel(True)
- self.percentage(None)
-
- cpvlist = []
- pkg_processed = 0.0
- nb_pkg = float(len(self.vardb.cpv_all()))
- is_full_path = True
-
- if key[0] != "/":
- is_full_path = False
- searchre = re.compile("/" + key + "$", re.IGNORECASE)
-
- for cpv in self.vardb.cpv_all():
- cat, pv = portage.catsplit(cpv)
- db = portage.dblink(cat, pv, portage.settings["ROOT"],
- self.portage_settings, treetype="vartree", vartree=self.vardb)
- contents = db.getcontents()
- if not contents:
- continue
- for file in contents.keys():
- if (is_full_path and key == file) \
- or (not is_full_path and searchre.search(file)):
- cpvlist.append(cpv)
- break
-
- pkg_processed+=100.0 # instead of +=1 and *100, doing +=100
- self.percentage(pkg_processed/nb_pkg)
-
- self.percentage(100)
-
- for cpv in cpvlist:
- self.package(cpv)
-
- def search_group(self, filters, group):
- # TODO: filters
- self.status(STATUS_QUERY)
- self.allow_cancel(True)
- self.percentage(None)
-
- for cp in portage.portdb.cp_all():
- if get_group(cp) == group:
- for cpv in portage.portdb.match(cp):
- self.package(cpv)
-
- def search_name(self, filters, key):
- # TODO: manage filters
- # TODO: collections ?
- self.status(STATUS_QUERY)
- self.allow_cancel(True)
- self.percentage(None)
-
- searchre = re.compile(key, re.IGNORECASE)
-
- for cp in portage.portdb.cp_all():
- if searchre.search(cp):
- for cpv in portage.portdb.match(cp): #TODO: cp_list(cp) ?
- self.package(cpv)
-
- def update_packages(self, pkgs):
- # TODO: add some checks ?
- self.install_packages("false", pkgs)
-
- def update_system(self, only_trusted):
- # TODO: only_trusted
- self.status(STATUS_RUNNING)
- self.allow_cancel(True)
- self.percentage(None)
-
- # inits
- myopts = {}
- myopts.pop("--deep", None)
- myopts.pop("--newuse", None)
- myopts.pop("--update", None)
- myopts["--deep"] = True
- myopts["--newuse"] = True
- myopts["--update"] = True
-
- spinner = ""
- favorites = []
- settings, trees, mtimedb = _emerge.load_emerge_config()
- myparams = _emerge.create_depgraph_params(myopts, "")
- spinner = _emerge.stdout_spinner()
-
- depgraph = _emerge.depgraph(settings, trees, myopts, myparams, spinner)
- retval, favorites = depgraph.select_files(["system", "world"])
- if not retval:
- self.error(ERROR_INTERNAL_ERROR, "Wasn't able to get dependency graph")
- return
-
- if "resume" in mtimedb and \
- "mergelist" in mtimedb["resume"] and \
- len(mtimedb["resume"]["mergelist"]) > 1:
- mtimedb["resume_backup"] = mtimedb["resume"]
- del mtimedb["resume"]
- mtimedb.commit()
-
- mtimedb["resume"]={}
- mtimedb["resume"]["myopts"] = myopts.copy()
- mtimedb["resume"]["favorites"] = [str(x) for x in favorites]
-
- mergetask = _emerge.Scheduler(settings, trees, mtimedb,
- myopts, spinner, depgraph.altlist(),
- favorites, depgraph.schedulerGraph())
- mergetask.merge()
+ def __init__(self, args, lock=True):
+ signal.signal(signal.SIGQUIT, sigquit)
+ PackageKitBaseBackend.__init__(self, args)
+
+ self.portage_settings = portage.config()
+ self.vardb = portage.db[portage.settings["ROOT"]]["vartree"].dbapi
+ #self.portdb = portage.db[portage.settings["ROOT"]]["porttree"].dbapi
+
+ if lock:
+ self.doLock()
+
+ def is_installed(self, cpv):
+ if self.vardb.cpv_exists(cpv):
+ return True
+ return False
+
+ def cpv_to_id(self, cpv):
+ '''
+ Transform the cpv (portage) to a package id (packagekit)
+ '''
+ # TODO: manage SLOTS !
+ package, version, rev = portage.pkgsplit(cpv)
+ pkg_keywords, repo = portage.portdb.aux_get(cpv, ["KEYWORDS", "repository"])
+
+ pkg_keywords = pkg_keywords.split()
+ sys_keywords = self.portage_settings.configdict["defaults"].get("ACCEPT_KEYWORDS").split()
+ keywords = []
+
+ for x in sys_keywords:
+ if x in pkg_keywords:
+ keywords.append(x)
+
+ # if no keywords, check in package.keywords
+ if not keywords:
+ for _, keys in self.portage_settings.pkeywordsdict.get(portage.dep_getkey(cpv)).iteritems():
+ for x in keys:
+ keywords.append(x)
+
+ if not keywords:
+ keywords.append("no keywords")
+ self.message(MESSAGE_UNKNOWN, "No keywords have been found for %s" % cpv)
+
+ # don't want to see -r0
+ if rev != "r0":
+ version = version + "-" + rev
+
+ # if installed, repo should be 'installed', packagekit rule
+ if self.is_installed(cpv):
+ repo = "installed"
+
+ return get_package_id(package, version, ' '.join(keywords), repo)
+
+ def package(self, cpv, info=None):
+ desc = portage.portdb.aux_get(cpv, ["DESCRIPTION"])
+ if not info:
+ if self.is_installed(cpv):
+ info = INFO_INSTALLED
+ else:
+ info = INFO_AVAILABLE
+ PackageKitBaseBackend.package(self, self.cpv_to_id(cpv), info, desc[0])
+
+ def get_depends(self, filters, pkgids, recursive):
+ # TODO: manage filters
+ # TODO: optimize by using vardb for installed packages ?
+ self.status(STATUS_INFO)
+ self.allow_cancel(True)
+ self.percentage(None)
+
+ for pkgid in pkgids:
+ cpv = id_to_cpv(pkgid)
+
+ # is cpv valid
+ if not portage.portdb.cpv_exists(cpv):
+ # self.warning ? self.error ?
+ self.message(MESSAGE_COULD_NOT_FIND_PACKAGE,
+ "Could not find the package %s" % pkgid)
+ continue
+
+ myopts = {}
+ if recursive:
+ myopts.pop("--emptytree", None)
+ myopts["--emptytree"] = True
+ spinner = ""
+ settings, trees, mtimedb = _emerge.load_emerge_config()
+ myparams = _emerge.create_depgraph_params(myopts, "")
+ spinner = _emerge.stdout_spinner()
+ depgraph = _emerge.depgraph(settings, trees, myopts, myparams, spinner)
+ retval, fav = depgraph.select_files(["="+cpv])
+ if not retval:
+ self.error(ERROR_INTERNAL_ERROR, "Wasn't able to get dependency graph")
+ continue
+
+ if recursive:
+ # printing the whole tree
+ pkgs = depgraph.altlist(reversed=1)
+ for pkg in pkgs:
+ if pkg[2] != cpv:
+ self.package(pkg[2])
+ else: # !recursive
+ # only printing child of the root node
+ # actually, we have "=cpv" -> "cpv" -> children
+ root_node = depgraph.digraph.root_nodes()[0] # =cpv
+ root_node = depgraph.digraph.child_nodes(root_node)[0] # cpv
+ children = depgraph.digraph.child_nodes(root_node)
+ for child in children:
+ self.package(child[2])
+
+ def get_details(self, pkgs):
+ self.status(STATUS_INFO)
+ self.allow_cancel(True)
+ self.percentage(None)
+
+ for pkg in pkgs:
+ cpv = id_to_cpv(pkg)
+
+ # is cpv valid
+ if not portage.portdb.cpv_exists(cpv):
+ # self.warning ? self.error ?
+ self.message(MESSAGE_COULD_NOT_FIND_PACKAGE,
+ "Could not find the package %s" % pkg)
+ continue
+
+ homepage, desc, license = portage.portdb.aux_get(cpv,
+ ["HOMEPAGE", "DESCRIPTION", "LICENSE"])
+
+ # size should be prompted only if not installed
+ size = 0
+ if not self.is_installed(cpv):
+ ebuild = portage.portdb.findname(cpv)
+ if ebuild:
+ dir = os.path.dirname(ebuild)
+ manifest = portage.manifest.Manifest(dir, portage.settings["DISTDIR"])
+ uris = portage.portdb.getFetchMap(cpv)
+ size = manifest.getDistfilesSize(uris)
+
+ self.details(self.cpv_to_id(cpv), license, get_group(cpv),
+ desc, homepage, size)
+
+ def get_files(self, pkgids):
+ self.status(STATUS_INFO)
+ self.allow_cancel(True)
+ self.percentage(None)
+
+ for pkgid in pkgids:
+ cpv = id_to_cpv(pkgid)
+
+ # is cpv valid
+ if not portage.portdb.cpv_exists(cpv):
+ self.error(ERROR_PACKAGE_NOT_FOUND,
+ "Package %s was not found" % pkgid)
+ continue
+
+ if not self.vardb.cpv_exists(cpv):
+ self.error(ERROR_PACKAGE_NOT_INSTALLED,
+ "Package %s is not installed" % pkgid)
+ continue
+
+ cat, pv = portage.catsplit(cpv)
+ db = portage.dblink(cat, pv, portage.settings["ROOT"],
+ self.portage_settings, treetype="vartree", vartree=self.vardb)
+ files = db.getcontents().keys()
+ files = sorted(files)
+ files = ";".join(files)
+
+ self.files(pkgid, files)
+
+ def get_packages(self, filters):
+ # TODO: filters
+ self.status(STATUS_QUERY)
+ self.allow_cancel(True)
+ self.percentage(None)
+
+ for cp in portage.portdb.cp_all():
+ for cpv in portage.portdb.match(cp):
+ self.package(cpv)
+
+ def get_repo_list(self, filters):
+ # TODO: filters
+ # TODO: not official
+ # TODO: not supported (via filters ?)
+ self.status(STATUS_INFO)
+ self.allow_cancel(True)
+ self.percentage(None)
+
+ layman_db = layman.db.RemoteDB(layman.config.Config())
+ for o in layman_db.overlays.keys():
+ self.repo_detail(o, layman_db.overlays[o].description, True)
+
+ def get_requires(self, filters, pkgs, recursive):
+ # TODO: filters
+ # TODO: recursive not implemented
+ # TODO: usefulness ? use cases
+ # TODO: work only on installed packages
+ self.status(STATUS_RUNNING)
+ self.allow_cancel(True)
+ self.percentage(None)
+
+ myopts = {}
+ spinner = ""
+ favorites = []
+ settings, trees, mtimedb = _emerge.load_emerge_config()
+ spinner = _emerge.stdout_spinner()
+ rootconfig = _emerge.RootConfig(self.portage_settings, trees["/"],
+ portage._sets.load_default_config(self.portage_settings, trees["/"]))
+
+ for pkg in pkgs:
+ cpv = id_to_cpv(pkg)
+
+ # is cpv installed
+ # TODO: keep error msg ?
+ if not self.vardb.match(cpv):
+ self.error(ERROR_PACKAGE_NOT_INSTALLED,
+ "Package %s is not installed" % pkg)
+ continue
+
+ required_set_names = ("system", "world")
+ required_sets = {}
+
+ args_set = portage._sets.base.InternalPackageSet()
+ args_set.update(["="+cpv]) # parameters is converted to atom
+ # or use portage.dep_expand
+
+ if not args_set:
+ self.error(ERROR_INTERNAL_ERROR, "Was not able to generate atoms")
+ continue
+
+ depgraph = _emerge.depgraph(settings, trees, myopts,
+ _emerge.create_depgraph_params(myopts, "remove"), spinner)
+ vardb = depgraph.trees["/"]["vartree"].dbapi
+
+ for s in required_set_names:
+ required_sets[s] = portage._sets.base.InternalPackageSet(
+ initial_atoms=rootconfig.setconfig.getSetAtoms(s))
+
+ # TODO: error/warning if world = null or system = null ?
+
+ # TODO: not sure it's needed. for deselect in emerge...
+ required_sets["world"].clear()
+ for pkg in vardb:
+ spinner.update()
+ try:
+ if args_set.findAtomForPackage(pkg) is None:
+ required_sets["world"].add("=" + pkg.cpv)
+ except portage.exception.InvalidDependString, e:
+ required_sets["world"].add("=" + pkg.cpv)
+
+ set_args = {}
+ for s, pkg_set in required_sets.iteritems():
+ set_atom = portage._sets.SETPREFIX + s
+ set_arg = _emerge.SetArg(arg=set_atom, set=pkg_set,
+ root_config=depgraph.roots[portage.settings["ROOT"]])
+ set_args[s] = set_arg
+ for atom in set_arg.set:
+ depgraph._dep_stack.append(
+ _emerge.Dependency(atom=atom, root=portage.settings["ROOT"],
+ parent=set_arg))
+ depgraph.digraph.add(set_arg, None)
+
+ if not depgraph._complete_graph():
+ self.error(ERROR_INTERNAL_ERROR, "Error when generating depgraph")
+ continue
+
+ def cmp_pkg_cpv(pkg1, pkg2):
+ if pkg1.cpv > pkg2.cpv:
+ return 1
+ elif pkg1.cpv == pkg2.cpv:
+ return 0
+ else:
+ return -1
+
+ for pkg in sorted(vardb,
+ key=portage.util.cmp_sort_key(cmp_pkg_cpv)):
+ arg_atom = None
+ try:
+ arg_atom = args_set.findAtomForPackage(pkg)
+ except portage.exception.InvalidDependString:
+ continue
+
+ if arg_atom and pkg in depgraph.digraph:
+ parents = depgraph.digraph.parent_nodes(pkg)
+ for node in parents:
+ self.package(node[2])
+
+ self.percentage(100)
+
+ def get_update_detail(self, pkgs):
+ # TODO: a lot of informations are missing
+
+ self.status(STATUS_INFO)
+ self.allow_cancel(True)
+ self.percentage(None)
+
+ for pkg in pkgs:
+ updates = []
+ obsoletes = ""
+ vendor_url = ""
+ bugzilla_url = ""
+ cve_url = ""
+
+ cpv = id_to_cpv(pkg)
+
+ if not portage.portdb.cpv_exists(cpv):
+ self.message(MESSAGE_COULD_NOT_FIND_PACKAGE, "could not find %s" % pkg)
+
+ for cpv in self.vardb.match(portage.pkgsplit(cpv)[0]):
+ updates.append(cpv)
+ updates = "&".join(updates)
+
+ # temporarily set vendor_url = homepage
+ homepage = portage.portdb.aux_get(cpv, ["HOMEPAGE"])[0]
+ vendor_url = homepage
+
+ self.update_detail(pkg, updates, obsoletes, vendor_url, bugzilla_url,
+ cve_url, "none", "No update text", "No ChangeLog",
+ UPDATE_STATE_STABLE, None, None)
+
+ def get_updates(self, filters):
+ # NOTES:
+ # portage prefer not to update _ALL_ packages so we will only list updated
+ # packages in world or system
+
+ # TODO: filters ?
+ # TODO: INFO
+ self.status(STATUS_INFO)
+ self.allow_cancel(True)
+ self.percentage(None)
+
+ # best way to get that ?
+ settings, trees, mtimedb = _emerge.load_emerge_config()
+ rootconfig = _emerge.RootConfig(self.portage_settings, trees["/"],
+ portage._sets.load_default_config(self.portage_settings, trees["/"]))
+
+ cp_to_check = []
+
+ # get system and world sets
+ for s in ("system", "world"):
+ set = portage._sets.base.InternalPackageSet(
+ initial_atoms=rootconfig.setconfig.getSetAtoms(s))
+ for cp in set:
+ cp_to_check.append(cp)
+
+ # check if bestmatch is installed
+ for cp in cp_to_check:
+ best_cpv = portage.portdb.xmatch("bestmatch-visible", cp)
+ if not self.vardb.cpv_exists(best_cpv):
+ self.package(best_cpv, INFO_NORMAL)
+
+ def install_packages(self, only_trusted, pkgs):
+ self.status(STATUS_RUNNING)
+ self.allow_cancel(True) # TODO: sure ?
+ self.percentage(None)
+
+ # FIXME: use only_trusted
+
+ for pkg in pkgs:
+ # check for installed is not mandatory as there are a lot of reason
+ # to re-install a package (USE/{LD,C}FLAGS change for example) (or live)
+ # TODO: keep a final position
+ cpv = id_to_cpv(pkg)
+
+ # is cpv valid
+ if not portage.portdb.cpv_exists(cpv):
+ self.error(ERROR_PACKAGE_NOT_FOUND, "Package %s was not found" % pkg)
+ continue
+
+ # inits
+ myopts = {} # TODO: --nodepends ?
+ spinner = ""
+ favorites = []
+ settings, trees, mtimedb = _emerge.load_emerge_config()
+ myparams = _emerge.create_depgraph_params(myopts, "")
+ spinner = _emerge.stdout_spinner()
+
+ depgraph = _emerge.depgraph(settings, trees, myopts, myparams, spinner)
+ retval, favorites = depgraph.select_files(["="+cpv])
+ if not retval:
+ self.error(ERROR_INTERNAL_ERROR, "Wasn't able to get dependency graph")
+ continue
+
+ if "resume" in mtimedb and \
+ "mergelist" in mtimedb["resume"] and \
+ len(mtimedb["resume"]["mergelist"]) > 1:
+ mtimedb["resume_backup"] = mtimedb["resume"]
+ del mtimedb["resume"]
+ mtimedb.commit()
+
+ mtimedb["resume"] = {}
+ mtimedb["resume"]["myopts"] = myopts.copy()
+ mtimedb["resume"]["favorites"] = [str(x) for x in favorites]
+
+ # TODO: check for writing access before calling merge ?
+
+ mergetask = _emerge.Scheduler(settings, trees, mtimedb,
+ myopts, spinner, depgraph.altlist(),
+ favorites, depgraph.schedulerGraph())
+ mergetask.merge()
+
+ def refresh_cache(self, force):
+ # TODO: use force ?
+ self.status(STATUS_REFRESH_CACHE)
+ self.allow_cancel(True)
+ self.percentage(None)
+
+ myopts = {} # TODO: --quiet ?
+ myopts.pop("--quiet", None)
+ myopts["--quiet"] = True
+ settings, trees, mtimedb = _emerge.load_emerge_config()
+ spinner = _emerge.stdout_spinner()
+ try:
+ _emerge.action_sync(settings, trees, mtimedb, myopts, "")
+ finally:
+ self.percentage(100)
+
+ def remove_packages(self, allowdep, pkgs):
+ # can't use allowdep: never removing dep
+ # TODO: filters ?
+ self.status(STATUS_RUNNING)
+ self.allow_cancel(True)
+ self.percentage(None)
+
+ for pkg in pkgs:
+ cpv = id_to_cpv(pkg)
+
+ # is cpv valid
+ if not portage.portdb.cpv_exists(cpv):
+ self.error(ERROR_PACKAGE_NOT_FOUND, "Package %s was not found" % pkg)
+ continue
+
+ # is package installed
+ if not self.vardb.match(cpv):
+ self.error(ERROR_PACKAGE_NOT_INSTALLED,
+ "Package %s is not installed" % pkg)
+ continue
+
+ myopts = {} # TODO: --nodepends ?
+ spinner = ""
+ favorites = []
+ settings, trees, mtimedb = _emerge.load_emerge_config()
+ spinner = _emerge.stdout_spinner()
+ rootconfig = _emerge.RootConfig(self.portage_settings, trees["/"],
+ portage._sets.load_default_config(self.portage_settings, trees["/"])
+ )
+
+ if "resume" in mtimedb and \
+ "mergelist" in mtimedb["resume"] and \
+ len(mtimedb["resume"]["mergelist"]) > 1:
+ mtimedb["resume_backup"] = mtimedb["resume"]
+ del mtimedb["resume"]
+ mtimedb.commit()
+
+ mtimedb["resume"] = {}
+ mtimedb["resume"]["myopts"] = myopts.copy()
+ mtimedb["resume"]["favorites"] = [str(x) for x in favorites]
+
+ db_keys = list(portage.portdb._aux_cache_keys)
+ metadata = izip(db_keys, portage.portdb.aux_get(cpv, db_keys))
+ package = _emerge.Package(
+ type_name="ebuild",
+ built=True,
+ installed=True,
+ root_config=rootconfig,
+ cpv=cpv,
+ metadata=metadata,
+ operation="uninstall")
+
+ mergetask = _emerge.Scheduler(settings,
+ trees, mtimedb, myopts, spinner, [package], favorites, package)
+ mergetask.merge()
+
+ def repo_enable(self, repoid, enable):
+ self.status(STATUS_INFO)
+ self.allow_cancel(True)
+ self.percentage(None)
+
+ # get installed and available dbs
+ installed_layman_db = layman.db.DB(layman.config.Config())
+ available_layman_db = layman.db.RemoteDB(layman.config.Config())
+
+ # disabling (removing) a db
+ if not enable:
+ if not repoid in installed_layman_db.overlays.keys():
+ self.error(ERROR_REPO_NOT_FOUND, "Repository %s was not found" %repoid)
+ return
+
+ overlay = installed_layman_db.select(repoid)
+
+ if not overlay:
+ self.error(ERROR_REPO_NOT_FOUND, "Repository %s was not found" %repoid)
+ return
+
+ try:
+ installed_layman_db.delete(overlay)
+ except Exception, e:
+ self.error(ERROR_INTERNAL_ERROR,
+ "Failed to disable repository " + repoid + " : " + str(e))
+ return
+
+ # enabling (adding) a db
+ if enable:
+ if not repoid in available_layman_db.overlays.keys():
+ self.error(ERROR_REPO_NOT_FOUND, "Repository %s was not found" %repoid)
+ return
+
+ overlay = available_layman_db.select(repoid)
+
+ if not overlay:
+ self.error(ERROR_REPO_NOT_FOUND, "Repository %s was not found" %repoid)
+ return
+
+ try:
+ installed_layman_db.add(overlay, True)
+ except Exception, e:
+ self.error(ERROR_INTERNAL_ERROR,
+ "Failed to disable repository " + repoid + " : " + str(e))
+ return
+
+ def resolve(self, filters, pkgs):
+ # TODO: filters
+ self.status(STATUS_QUERY)
+ self.allow_cancel(True)
+ self.percentage(None)
+
+ for pkg in pkgs:
+ # TODO: be case sensitive ?
+ searchre = re.compile(pkg, re.IGNORECASE)
+
+ # TODO: optim with filter = installed
+ for cp in portage.portdb.cp_all():
+ if searchre.search(cp):
+ #print self.vardb.dep_bestmatch(cp)
+ self.package(portage.portdb.xmatch("bestmatch-visible", cp))
+
+ def search_details(self, filters, key):
+ # TODO: add keywords when they will be available
+ # TODO: filters
+ # TODO: split keys
+ # TODO: PERFORMANCE !
+ self.status(STATUS_QUERY)
+ self.allow_cancel(True)
+ self.percentage(None)
+
+ searchre = re.compile(key, re.IGNORECASE)
+ cpvlist = []
+
+ for cp in portage.portdb.cp_all():
+ # TODO: baaad, we are working on _every_ cpv :-/
+ for cpv in portage.portdb.match(cp): #TODO: cp_list(cp) ?
+ infos = portage.portdb.aux_get(cpv,
+ ["HOMEPAGE","DESCRIPTION","repository"]) # LICENSE ?
+ for x in infos:
+ if searchre.search(x):
+ self.package(cpv)
+ break
+
+ def search_file(self, filters, key):
+ # TODO: manage filters, error if ~installed ?
+ self.status(STATUS_QUERY)
+ self.allow_cancel(True)
+ self.percentage(None)
+
+ cpvlist = []
+ pkg_processed = 0.0
+ nb_pkg = float(len(self.vardb.cpv_all()))
+ is_full_path = True
+
+ if key[0] != "/":
+ is_full_path = False
+ searchre = re.compile("/" + key + "$", re.IGNORECASE)
+
+ for cpv in self.vardb.cpv_all():
+ cat, pv = portage.catsplit(cpv)
+ db = portage.dblink(cat, pv, portage.settings["ROOT"],
+ self.portage_settings, treetype="vartree", vartree=self.vardb)
+ contents = db.getcontents()
+ if not contents:
+ continue
+ for file in contents.keys():
+ if (is_full_path and key == file) \
+ or (not is_full_path and searchre.search(file)):
+ cpvlist.append(cpv)
+ break
+
+ pkg_processed += 100.0 # instead of +=1 and *100, doing +=100
+ self.percentage(pkg_processed/nb_pkg)
+
+ self.percentage(100)
+
+ for cpv in cpvlist:
+ self.package(cpv)
+
+ def search_group(self, filters, group):
+ # TODO: filters
+ self.status(STATUS_QUERY)
+ self.allow_cancel(True)
+ self.percentage(None)
+
+ for cp in portage.portdb.cp_all():
+ if get_group(cp) == group:
+ for cpv in portage.portdb.match(cp):
+ self.package(cpv)
+
+ def search_name(self, filters, key):
+ # TODO: manage filters
+ # TODO: collections ?
+ self.status(STATUS_QUERY)
+ self.allow_cancel(True)
+ self.percentage(None)
+
+ searchre = re.compile(key, re.IGNORECASE)
+
+ for cp in portage.portdb.cp_all():
+ if searchre.search(cp):
+ for cpv in portage.portdb.match(cp): #TODO: cp_list(cp) ?
+ self.package(cpv)
+
+ def update_packages(self, only_trusted, pkgs):
+ # TODO: add some checks ?
+ self.install_packages(only_trusted, pkgs)
+
+ def update_system(self, only_trusted):
+ # TODO: only_trusted
+ self.status(STATUS_RUNNING)
+ self.allow_cancel(True)
+ self.percentage(None)
+
+ # inits
+ myopts = {}
+ myopts.pop("--deep", None)
+ myopts.pop("--newuse", None)
+ myopts.pop("--update", None)
+ myopts["--deep"] = True
+ myopts["--newuse"] = True
+ myopts["--update"] = True
+
+ spinner = ""
+ favorites = []
+ settings, trees, mtimedb = _emerge.load_emerge_config()
+ myparams = _emerge.create_depgraph_params(myopts, "")
+ spinner = _emerge.stdout_spinner()
+
+ depgraph = _emerge.depgraph(settings, trees, myopts, myparams, spinner)
+ retval, favorites = depgraph.select_files(["system", "world"])
+ if not retval:
+ self.error(ERROR_INTERNAL_ERROR, "Wasn't able to get dependency graph")
+ return
+
+ if "resume" in mtimedb and \
+ "mergelist" in mtimedb["resume"] and \
+ len(mtimedb["resume"]["mergelist"]) > 1:
+ mtimedb["resume_backup"] = mtimedb["resume"]
+ del mtimedb["resume"]
+ mtimedb.commit()
+
+ mtimedb["resume"] = {}
+ mtimedb["resume"]["myopts"] = myopts.copy()
+ mtimedb["resume"]["favorites"] = [str(x) for x in favorites]
+
+ mergetask = _emerge.Scheduler(settings, trees, mtimedb,
+ myopts, spinner, depgraph.altlist(),
+ favorites, depgraph.schedulerGraph())
+ mergetask.merge()
def main():
- backend = PackageKitPortageBackend("") #'', lock=True)
- backend.dispatcher(sys.argv[1:])
+ backend = PackageKitPortageBackend("") #'', lock=True)
+ backend.dispatcher(sys.argv[1:])
if __name__ == "__main__":
- main()
+ main()
commit df7001a106f5ea63d0e19dc5aaeeb6711872e1ee
Author: Mounir Lamouri (volkmar) <mounir.lamouri at gmail.com>
Date: Wed Jun 24 13:00:47 2009 +0200
pk-transaction checks if the given path in search-file is valid
diff --git a/src/pk-transaction.c b/src/pk-transaction.c
index 8286544..512cfa5 100644
--- a/src/pk-transaction.c
+++ b/src/pk-transaction.c
@@ -223,6 +223,7 @@ pk_transaction_error_get_type (void)
ENUM_ENTRY (PK_TRANSACTION_ERROR_REFUSED_BY_POLICY, "RefusedByPolicy"),
ENUM_ENTRY (PK_TRANSACTION_ERROR_PACKAGE_ID_INVALID, "PackageIdInvalid"),
ENUM_ENTRY (PK_TRANSACTION_ERROR_SEARCH_INVALID, "SearchInvalid"),
+ ENUM_ENTRY (PK_TRANSACTION_ERROR_SEARCH_PATH_INVALID, "SearchPathInvalid"),
ENUM_ENTRY (PK_TRANSACTION_ERROR_FILTER_INVALID, "FilterInvalid"),
ENUM_ENTRY (PK_TRANSACTION_ERROR_INPUT_INVALID, "InputInvalid"),
ENUM_ENTRY (PK_TRANSACTION_ERROR_INVALID_STATE, "InvalidState"),
@@ -3619,6 +3620,15 @@ pk_transaction_search_file (PkTransaction *transaction, const gchar *filter,
return;
}
+ /* when not an absolute path, disallow slashes in search */
+ if (search[0] != '/' && strstr (search, "/") != NULL) {
+ error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_SEARCH_PATH_INVALID,
+ "Invalid search path");
+ pk_transaction_release_tid (transaction);
+ pk_transaction_dbus_return_error (context, error);
+ return;
+ }
+
/* check the filter */
ret = pk_transaction_filter_check (filter, &error);
if (!ret) {
diff --git a/src/pk-transaction.h b/src/pk-transaction.h
index 8ac5a69..086f793 100644
--- a/src/pk-transaction.h
+++ b/src/pk-transaction.h
@@ -64,6 +64,7 @@ typedef enum
PK_TRANSACTION_ERROR_REFUSED_BY_POLICY,
PK_TRANSACTION_ERROR_PACKAGE_ID_INVALID,
PK_TRANSACTION_ERROR_SEARCH_INVALID,
+ PK_TRANSACTION_ERROR_SEARCH_PATH_INVALID,
PK_TRANSACTION_ERROR_FILTER_INVALID,
PK_TRANSACTION_ERROR_INPUT_INVALID,
PK_TRANSACTION_ERROR_INVALID_STATE,
commit 70d97ad9f1b2f9956a8b1a7806362d304dcef5bc
Author: Mounir Lamouri (volkmar) <mounir.lamouri at gmail.com>
Date: Wed Jun 24 00:46:18 2009 +0200
portage: let search-file accept filename or fully qualified path and filename
diff --git a/backends/portage/portageBackend.py b/backends/portage/portageBackend.py
index 7fd6cd7..15c8695 100755
--- a/backends/portage/portageBackend.py
+++ b/backends/portage/portageBackend.py
@@ -796,15 +796,18 @@ class PackageKitPortageBackend(PackageKitBaseBackend, PackagekitPackage):
def search_file(self, filters, key):
# TODO: manage filters, error if ~installed ?
- # TODO: keep exact path or change to exact name ?
self.status(STATUS_QUERY)
self.allow_cancel(True)
self.percentage(None)
- searchre = re.compile(key, re.IGNORECASE)
cpvlist = []
pkg_processed = 0.0
nb_pkg = float(len(self.vardb.cpv_all()))
+ is_full_path = True
+
+ if key[0] != "/":
+ is_full_path = False
+ searchre = re.compile("/" + key + "$", re.IGNORECASE)
for cpv in self.vardb.cpv_all():
cat, pv = portage.catsplit(cpv)
@@ -814,7 +817,8 @@ class PackageKitPortageBackend(PackageKitBaseBackend, PackagekitPackage):
if not contents:
continue
for file in contents.keys():
- if searchre.match(file):
+ if (is_full_path and key == file) \
+ or (not is_full_path and searchre.search(file)):
cpvlist.append(cpv)
break
commit 6cb78a1fcaba0ad1aa91321155d3e9c22c46ea42
Author: Mounir Lamouri (volkmar) <mounir.lamouri at gmail.com>
Date: Tue Jun 23 22:04:39 2009 +0200
Specify search-file use cases (entire path or filename)
diff --git a/src/org.freedesktop.PackageKit.Transaction.xml b/src/org.freedesktop.PackageKit.Transaction.xml
index 961e231..b83f69a 100644
--- a/src/org.freedesktop.PackageKit.Transaction.xml
+++ b/src/org.freedesktop.PackageKit.Transaction.xml
@@ -1079,7 +1079,9 @@
<doc:doc>
<doc:summary>
<doc:para>
- A single local path on the system
+ A filename or fully qualified path and filename on the system.
+ If the search term begins with a <doc:tt>/</doc:tt> it will be assumed the entire path has been given and only packages that contain this exact path and filename will be returned.
+ If the search term does not start with <doc:tt>/</doc:tt> then it should be treated as a single filename, which can be in any directory.
</doc:para>
</doc:summary>
</doc:doc>
commit c234c386f81b2c265464c768c475b9adeecd4cdf
Author: Mounir Lamouri (volkmar) <mounir.lamouri at gmail.com>
Date: Tue Jun 23 17:18:57 2009 +0200
add force parameter to refresh-cache function in python backends
diff --git a/backends/apt.deprecated/aptBackend.py b/backends/apt.deprecated/aptBackend.py
index 525d79e..2f79238 100644
--- a/backends/apt.deprecated/aptBackend.py
+++ b/backends/apt.deprecated/aptBackend.py
@@ -259,10 +259,11 @@ class PackageKitAptBackend(PackageKitBaseBackend):
self.error(ERROR_NOT_SUPPORTED,
"This function is not implemented in this backend")
- def refresh_cache(self):
+ def refresh_cache(self, force):
'''
Implement the {backend}-refresh_cache functionality
'''
+ # TODO: use force ?
self.status(STATUS_REFRESH_CACHE)
try:
res = self._apt_cache.update(PackageKitProgress(self))
diff --git a/backends/apt/aptBackend.py b/backends/apt/aptBackend.py
index 843f22c..df01c52 100755
--- a/backends/apt/aptBackend.py
+++ b/backends/apt/aptBackend.py
@@ -1190,10 +1190,11 @@ class PackageKitAptBackend(PackageKitBaseBackend):
self.percentage(100)
@unlock_cache_afterwards
- def refresh_cache(self):
+ def refresh_cache(self, force):
"""
Implement the {backend}-refresh_cache functionality
"""
+ # TODO: use force ?
pklog.info("Refresh cache")
if not self._lock_cache(): return
self.status(STATUS_REFRESH_CACHE)
diff --git a/backends/conary/conaryBackend.py b/backends/conary/conaryBackend.py
index ec9099b..9574e1f 100755
--- a/backends/conary/conaryBackend.py
+++ b/backends/conary/conaryBackend.py
@@ -559,7 +559,9 @@ class PackageKitConaryBackend(PackageKitBaseBackend):
self.client.setUpdateCallback(self.callback )
# @ExceptionHandler
- def refresh_cache(self):
+ def refresh_cache(self, force):
+ # TODO: use force ?
+
#log.debug("refresh-cache command ")
# self.percentage()
diff --git a/backends/pisi/pisiBackend.py b/backends/pisi/pisiBackend.py
index 503d016..6bcc787 100755
--- a/backends/pisi/pisiBackend.py
+++ b/backends/pisi/pisiBackend.py
@@ -281,8 +281,9 @@ class PackageKitPisiBackend(PackageKitBaseBackend, PackagekitPackage):
else:
self.error(ERROR_PACKAGE_NOT_INSTALLED, "Package is already installed")
- def refresh_cache(self):
+ def refresh_cache(self, force):
""" Updates repository indexes """
+ # TODO: use force ?
self.allow_cancel(False)
self.percentage(0)
self.status(STATUS_REFRESH_CACHE)
diff --git a/backends/portage/pk-backend-portage.c b/backends/portage/pk-backend-portage.c
index 2e50894..565178c 100644
--- a/backends/portage/pk-backend-portage.c
+++ b/backends/portage/pk-backend-portage.c
@@ -229,8 +229,7 @@ backend_refresh_cache (PkBackend *backend, gboolean force)
return;
}
- /* TODO: force ? */
- pk_backend_spawn_helper (spawn, BACKEND_FILE, "refresh-cache", /*pk_backend_bool_to_text(force),*/ NULL);
+ pk_backend_spawn_helper (spawn, BACKEND_FILE, "refresh-cache", pk_backend_bool_to_text(force), NULL);
}
/**
diff --git a/backends/portage/portageBackend.py b/backends/portage/portageBackend.py
index 30c0d0d..7fd6cd7 100755
--- a/backends/portage/portageBackend.py
+++ b/backends/portage/portageBackend.py
@@ -637,7 +637,8 @@ class PackageKitPortageBackend(PackageKitBaseBackend, PackagekitPackage):
favorites, depgraph.schedulerGraph())
mergetask.merge()
- def refresh_cache(self):
+ def refresh_cache(self, force):
+ # TODO: use force ?
self.status(STATUS_REFRESH_CACHE)
self.allow_cancel(True)
self.percentage(None)
diff --git a/backends/smart/smartBackend.py b/backends/smart/smartBackend.py
index c990243..1b09b60 100755
--- a/backends/smart/smartBackend.py
+++ b/backends/smart/smartBackend.py
@@ -543,7 +543,8 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self._post_process_package_list(filters)
self._show_package_list()
- def refresh_cache(self):
+ def refresh_cache(self, force):
+ # TODO: use force ?
self.status(STATUS_REFRESH_CACHE)
self.allow_cancel(True)
self.ctrl.rebuildSysConfChannels()
diff --git a/backends/yum/yumBackend.py b/backends/yum/yumBackend.py
index 2eddac3..bb6f105 100755
--- a/backends/yum/yumBackend.py
+++ b/backends/yum/yumBackend.py
@@ -1375,10 +1375,11 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
self.error(ERROR_NO_PACKAGES_TO_UPDATE, "Nothing to do", exit=False)
return
- def refresh_cache(self):
+ def refresh_cache(self, force):
'''
Implement the {backend}-refresh_cache functionality
'''
+ # TODO: use force ?
self.allow_cancel(True)
self.percentage(0)
self.status(STATUS_REFRESH_CACHE)
diff --git a/lib/python/packagekit/backend.py b/lib/python/packagekit/backend.py
index f98ca05..c0e9bed 100644
--- a/lib/python/packagekit/backend.py
+++ b/lib/python/packagekit/backend.py
@@ -352,7 +352,7 @@ class PackageKitBaseBackend:
'''
self.error(ERROR_NOT_SUPPORTED, "This function is not implemented in this backend", exit=False)
- def refresh_cache(self):
+ def refresh_cache(self, force):
'''
Implement the {backend}-refresh_cache functionality
Needed to be implemented in a sub class
@@ -561,7 +561,8 @@ class PackageKitBaseBackend:
self.install_signature(sigtype, key_id, package_id)
self.finished()
elif cmd == 'refresh-cache':
- self.refresh_cache()
+ force = _text_to_bool(args[0])
+ self.refresh_cache(force)
self.finished()
elif cmd == 'remove-packages':
allowdeps = args[0]
commit 2b26bf5091d3a59c162cb9fe17bdbebdf8b513b6
Author: Mounir Lamouri (volkmar) <mounir.lamouri at gmail.com>
Date: Tue Jun 23 01:40:15 2009 +0200
portage: add percentage to search-files and change search method to match exact path
diff --git a/backends/portage/portageBackend.py b/backends/portage/portageBackend.py
index e5a5ce9..30c0d0d 100755
--- a/backends/portage/portageBackend.py
+++ b/backends/portage/portageBackend.py
@@ -795,13 +795,15 @@ class PackageKitPortageBackend(PackageKitBaseBackend, PackagekitPackage):
def search_file(self, filters, key):
# TODO: manage filters, error if ~installed ?
- # TODO: search for exact file name
+ # TODO: keep exact path or change to exact name ?
self.status(STATUS_QUERY)
self.allow_cancel(True)
self.percentage(None)
searchre = re.compile(key, re.IGNORECASE)
cpvlist = []
+ pkg_processed = 0.0
+ nb_pkg = float(len(self.vardb.cpv_all()))
for cpv in self.vardb.cpv_all():
cat, pv = portage.catsplit(cpv)
@@ -811,10 +813,15 @@ class PackageKitPortageBackend(PackageKitBaseBackend, PackagekitPackage):
if not contents:
continue
for file in contents.keys():
- if searchre.search(file):
+ if searchre.match(file):
cpvlist.append(cpv)
break
+ pkg_processed+=100.0 # instead of +=1 and *100, doing +=100
+ self.percentage(pkg_processed/nb_pkg)
+
+ self.percentage(100)
+
for cpv in cpvlist:
self.package(cpv)
commit 593965c8133e6817b90207ae9a1e5bb79f42d147
Author: Mounir Lamouri (volkmar) <mounir.lamouri at gmail.com>
Date: Tue Jun 23 00:52:44 2009 +0200
portage: add repo-list and repo-enable functions with layman api
diff --git a/backends/portage/pk-backend-portage.c b/backends/portage/pk-backend-portage.c
index c663ece..2e50894 100644
--- a/backends/portage/pk-backend-portage.c
+++ b/backends/portage/pk-backend-portage.c
@@ -248,6 +248,15 @@ backend_remove_packages (PkBackend *backend, gchar **package_ids, gboolean allow
}
/**
+ * pk_backend_repo_enable:
+ */
+static void
+backend_repo_enable (PkBackend *backend, const gchar *rid, gboolean enabled)
+{
+ pk_backend_spawn_helper (spawn, BACKEND_FILE, "repo-enable", rid, pk_backend_bool_to_text (enabled), NULL);
+}
+
+/**
* pk_backend_resolve:
*/
static void
@@ -343,6 +352,19 @@ backend_get_packages (PkBackend *backend, PkBitfield filters)
}
/**
+ * pk_backend_get_repo_list:
+ */
+static void
+backend_get_repo_list (PkBackend *backend, PkBitfield filters)
+{
+ gchar *filters_text;
+
+ filters_text = pk_filter_bitfield_to_text (filters);
+ pk_backend_spawn_helper (spawn, BACKEND_FILE, "get-repo-list", filters_text, NULL);
+ g_free (filters_text);
+}
+
+/**
* backend_get_requires:
*/
static void
@@ -383,16 +405,16 @@ PK_BACKEND_OPTIONS (
NULL, /* get_distro_upgrades */
backend_get_files, /* get_files */
backend_get_packages, /* get_packages */
- NULL, // TODO /* get_repo_list */
+ backend_get_repo_list, /* get_repo_list */
backend_get_requires, /* get_requires */
- backend_get_update_detail, // TODO /* get_update_detail */
+ backend_get_update_detail, /* get_update_detail */
backend_get_updates, /* get_updates */
NULL, /* install_files */
backend_install_packages, /* install_packages */
NULL, /* install_signature */
backend_refresh_cache, /* refresh_cache */
backend_remove_packages, /* remove_packages */
- NULL, // TODO: choose /* repo_enable */
+ backend_repo_enable, /* repo_enable */
NULL, // TODO: probably not /* repo_set_data */
backend_resolve, /* resolve */
NULL, // TODO: probably in a long time /* rollback */
diff --git a/backends/portage/portageBackend.py b/backends/portage/portageBackend.py
index 9733faf..e5a5ce9 100755
--- a/backends/portage/portageBackend.py
+++ b/backends/portage/portageBackend.py
@@ -28,6 +28,10 @@ from packagekit.package import PackagekitPackage
import portage
import _emerge
+# layman imports
+import layman.db
+import layman.config
+
# misc imports
import sys
import signal
@@ -412,6 +416,18 @@ class PackageKitPortageBackend(PackageKitBaseBackend, PackagekitPackage):
for cpv in portage.portdb.match(cp):
self.package(cpv)
+ def get_repo_list(self, filters):
+ # TODO: filters
+ # TODO: not official
+ # TODO: not supported (via filters ?)
+ self.status(STATUS_INFO)
+ self.allow_cancel(True)
+ self.percentage(None)
+
+ layman_db = layman.db.RemoteDB(layman.config.Config())
+ for o in layman_db.overlays.keys():
+ self.repo_detail(o, layman_db.overlays[o].description, True)
+
def get_requires(self, filters, pkgs, recursive):
# TODO: filters
# TODO: recursive not implemented
@@ -692,6 +708,53 @@ class PackageKitPortageBackend(PackageKitBaseBackend, PackagekitPackage):
trees, mtimedb, myopts, spinner, [package], favorites, package)
mergetask.merge()
+ def repo_enable(self, repoid, enable):
+ self.status(STATUS_INFO)
+ self.allow_cancel(True)
+ self.percentage(None)
+
+ # get installed and available dbs
+ installed_layman_db = layman.db.DB(layman.config.Config())
+ available_layman_db = layman.db.RemoteDB(layman.config.Config())
+
+ # disabling (removing) a db
+ if not enable:
+ if not repoid in installed_layman_db.overlays.keys():
+ self.error(ERROR_REPO_NOT_FOUND, "Repository %s was not found" %repoid)
+ return
+
+ overlay = installed_layman_db.select(repoid)
+
+ if not overlay:
+ self.error(ERROR_REPO_NOT_FOUND, "Repository %s was not found" %repoid)
+ return
+
+ try:
+ installed_layman_db.delete(overlay)
+ except Exception, e:
+ self.error(ERROR_INTERNAL_ERROR,
+ "Failed to disable repository " + repoid + " : " + str(e))
+ return
+
+ # enabling (adding) a db
+ if enable:
+ if not repoid in available_layman_db.overlays.keys():
+ self.error(ERROR_REPO_NOT_FOUND, "Repository %s was not found" %repoid)
+ return
+
+ overlay = available_layman_db.select(repoid)
+
+ if not overlay:
+ self.error(ERROR_REPO_NOT_FOUND, "Repository %s was not found" %repoid)
+ return
+
+ try:
+ installed_layman_db.add(overlay, True)
+ except Exception, e:
+ self.error(ERROR_INTERNAL_ERROR,
+ "Failed to disable repository " + repoid + " : " + str(e))
+ return
+
def resolve(self, filters, pkgs):
# TODO: filters
self.status(STATUS_QUERY)
More information about the PackageKit-commit
mailing list