diff options
author | Daniel Nicoletti <dantti85-pk@yahoo.com.br> | 2011-05-01 23:49:37 -0300 |
---|---|---|
committer | Daniel Nicoletti <dantti85-pk@yahoo.com.br> | 2011-05-01 23:49:37 -0300 |
commit | 9ba55e479e1d1b251aaa443b9304fef2b1374e74 (patch) | |
tree | 38d33928286b4b2a850bd4af79bfd0cd53f8cb60 | |
parent | 03d8d9c3fcc619ddf4950111990b69069a12c074 (diff) | |
parent | 12137903a3b088c0b4dca6860393eef22686986e (diff) |
Merge branch 'master' of gitorious.org:packagekit/packagekit
76 files changed, 10462 insertions, 6738 deletions
diff --git a/backends/Makefile.am b/backends/Makefile.am index 3d539504e..ba378df20 100644 --- a/backends/Makefile.am +++ b/backends/Makefile.am @@ -32,10 +32,6 @@ if BACKEND_TYPE_OPKG SUBDIRS += opkg endif -if BACKEND_TYPE_PACMAN -SUBDIRS += pacman -endif - if BACKEND_TYPE_RAZOR SUBDIRS += razor endif diff --git a/backends/alpm/Makefile.am b/backends/alpm/Makefile.am index 15749dc70..a664b2c05 100644 --- a/backends/alpm/Makefile.am +++ b/backends/alpm/Makefile.am @@ -1,10 +1,54 @@ -INCLUDES = \ - -DG_LOG_DOMAIN=\"PackageKit-Alpm\" +PK_BACKEND_CONFIG_FILE = $(confdir)/pacman.conf +PK_BACKEND_GROUP_FILE = $(confdir)/groups.list +PK_BACKEND_REPO_FILE = $(confdir)/repos.list + +PK_BACKEND_DEFAULT_PATH = "/bin:/usr/bin:/sbin:/usr/sbin" +PK_BACKEND_DEFAULT_ROOT = "/" +PK_BACKEND_DEFAULT_DBPATH = $(localstatedir)/lib/pacman +PK_BACKEND_DEFAULT_CACHEDIR = $(localstatedir)/cache/pacman/pkg +PK_BACKEND_DEFAULT_LOGFILE = $(localstatedir)/log/pacman.log + +ALPM_CACHE_PATH = $(localstatedir)/lib/pacman/sync +ALPM_PACKAGE_URL = "http://www.archlinux.org/packages/%s/%s/%s/" + +DEFS = -DPK_BACKEND_CONFIG_FILE=\"$(PK_BACKEND_CONFIG_FILE)\" \ + -DPK_BACKEND_GROUP_FILE=\"$(PK_BACKEND_GROUP_FILE)\" \ + -DPK_BACKEND_REPO_FILE=\"$(PK_BACKEND_REPO_FILE)\" \ + -DPK_BACKEND_DEFAULT_PATH=\"$(PK_BACKEND_DEFAULT_PATH)\" \ + -DPK_BACKEND_DEFAULT_ROOT=\"$(PK_BACKEND_DEFAULT_ROOT)\" \ + -DPK_BACKEND_DEFAULT_DBPATH=\"$(PK_BACKEND_DEFAULT_DBPATH)\" \ + -DPK_BACKEND_DEFAULT_CACHEDIR=\"$(PK_BACKEND_DEFAULT_CACHEDIR)\" \ + -DPK_BACKEND_DEFAULT_LOGFILE=\"$(PK_BACKEND_DEFAULT_LOGFILE)\" \ + -DALPM_CACHE_PATH=\"$(ALPM_CACHE_PATH)\" \ + -DALPM_PACKAGE_URL=\"$(ALPM_PACKAGE_URL)\" \ + -DG_LOG_DOMAIN=\"PackageKit-alpm\" + +confdir = $(PK_CONF_DIR)/alpm.d +conf_DATA = groups.list \ + pacman.conf \ + repos.list plugindir = $(PK_PLUGIN_DIR) plugin_LTLIBRARIES = libpk_backend_alpm.la -libpk_backend_alpm_la_SOURCES = pk-backend-alpm.c -libpk_backend_alpm_la_LIBADD = $(PK_PLUGIN_LIBS) -lalpm -libpk_backend_alpm_la_LDFLAGS = -module -avoid-version -libpk_backend_alpm_la_CFLAGS = $(PK_PLUGIN_CFLAGS) $(WARNINGFLAGS_C) +libpk_backend_alpm_la_SOURCES = pk-backend-alpm.c \ + pk-backend-config.c \ + pk-backend-databases.c \ + pk-backend-depends.c \ + pk-backend-error.c \ + pk-backend-groups.c \ + pk-backend-install.c \ + pk-backend-packages.c \ + pk-backend-remove.c \ + pk-backend-search.c \ + pk-backend-sync.c \ + pk-backend-transaction.c \ + pk-backend-update.c +libpk_backend_alpm_la_LIBADD = $(PK_PLUGIN_LIBS) \ + -lalpm +libpk_backend_alpm_la_LDFLAGS = -module \ + -avoid-version +libpk_backend_alpm_la_CFLAGS = $(PK_PLUGIN_CFLAGS) \ + $(WARNINGFLAGS_C) + +EXTRA_DIST = $(conf_DATA) $(libpk_backend_alpm_la_SOURCES:.c=.h) diff --git a/backends/alpm/TODO b/backends/alpm/TODO deleted file mode 100644 index 04a827f59..000000000 --- a/backends/alpm/TODO +++ /dev/null @@ -1,4 +0,0 @@ - -* Fix cache refreshing. Currently throws 'unexpected error' -* Improve error handling by using macros. Currently 50% is very similiar error handling code. -* Handle transaction progress and events in the callback functions. diff --git a/backends/pacman/groups.list b/backends/alpm/groups.list index b2c02aede..b2c02aede 100644 --- a/backends/pacman/groups.list +++ b/backends/alpm/groups.list diff --git a/backends/pacman/pacman.conf b/backends/alpm/pacman.conf index 40b8e4a90..8fdef09a5 100644 --- a/backends/pacman/pacman.conf +++ b/backends/alpm/pacman.conf @@ -1,4 +1,4 @@ -# PackageKit configuration for the pacman backend +# PackageKit configuration for the alpm backend # See the pacman.conf(5) manpage for option and repository directives. [options] diff --git a/backends/alpm/pk-backend-alpm.c b/backends/alpm/pk-backend-alpm.c index 5513d8d21..00773297a 100644 --- a/backends/alpm/pk-backend-alpm.c +++ b/backends/alpm/pk-backend-alpm.c @@ -1,7 +1,8 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- * * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> - * Copyright (C) 2008, 2009 Valeriy Lyasotskiy <onestep@ukr.net> + * Copyright (C) 2008-2010 Valeriy Lyasotskiy <onestep@ukr.net> + * Copyright (C) 2010-2011 Jonathan Conder <jonno.conder@gmail.com> * * Licensed under the GNU General Public License Version 2 * @@ -20,1678 +21,361 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define _GNU_SOURCE +#include <config.h> +#include <glib/gstdio.h> +#include <sys/utsname.h> -#define ALPM_CONFIG_PATH "/etc/pacman.conf" +#include "pk-backend-alpm.h" +#include "pk-backend-databases.h" +#include "pk-backend-error.h" +#include "pk-backend-groups.h" -#define ALPM_ROOT "/" -#define ALPM_DBPATH "/var/lib/pacman" -#define ALPM_CACHEDIR "/var/cache/pacman/pkg" -#define ALPM_LOGFILE "/var/log/pacman.log" +PkBackend *backend = NULL; +GCancellable *cancellable = NULL; +static GStaticMutex mutex = G_STATIC_MUTEX_INIT; -#define ALPM_PKG_EXT ".pkg.tar.gz" -#define ALPM_LOCAL_DB_ALIAS "installed" +pmdb_t *localdb = NULL; -#define ALPM_PROGRESS_UPDATE_INTERVAL 400 +gchar *xfercmd = NULL; +alpm_list_t *holdpkgs = NULL; +alpm_list_t *syncfirsts = NULL; -#include <gmodule.h> -#include <glib.h> -#include <string.h> -#include <pk-backend.h> - -#include <alpm.h> -#include <alpm_list.h> - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <ctype.h> - -PkBackend *backend_instance = NULL; - -GHashTable *group_map; - -alpm_list_t *syncfirst = NULL; -alpm_list_t *holdpkg = NULL; - -alpm_list_t *downloaded_files = NULL; -gchar *current_file = NULL; - -off_t trans_xfered; -off_t trans_total; - -int trans_subprogress; - -typedef enum { - PK_ALPM_SEARCH_TYPE_NULL, - PK_ALPM_SEARCH_TYPE_RESOLVE, - PK_ALPM_SEARCH_TYPE_NAME, - PK_ALPM_SEARCH_TYPE_DETAILS, - PK_ALPM_SEARCH_TYPE_GROUP, - PK_ALPM_SEARCH_TYPE_PROVIDES -} PkAlpmSearchType; - -static int -pkg_cmp (pmpkg_t *pkg1, pmpkg_t *pkg2) { - int comparison; - /* check for no package */ - if (pkg1 == NULL) - return -1; - if (pkg2 == NULL) - return 1; - /* compare package names */ - comparison = g_strcmp0 (alpm_pkg_get_name (pkg1), alpm_pkg_get_name (pkg2)); - if (comparison != 0) - return comparison; - /* compare package versions */ - comparison = alpm_pkg_vercmp (alpm_pkg_get_version (pkg1), alpm_pkg_get_version (pkg2)); - if (comparison != 0) - return comparison; - /* packages are equal */ - return 0; -} - -/* temporary commented to not produce compilation errors :) */ -/* -static gboolean -pkg_equal (pmpkg_t *p1, pmpkg_t *p2) -{ - if (g_strcmp0 (alpm_pkg_get_name (p1), alpm_pkg_get_name (p2)) != 0) - return FALSE; - if (g_strcmp0 (alpm_pkg_get_version (p1), alpm_pkg_get_version (p2)) != 0) - return FALSE; - return TRUE; -} -*/ - -static gboolean -pkg_equals_to (pmpkg_t *pkg, const gchar *name, const gchar *version) -{ - if (pkg == NULL) - return FALSE; - if (g_strcmp0 (alpm_pkg_get_name (pkg), name) != 0) - return FALSE; - if (version != NULL) - if (g_strcmp0 (alpm_pkg_get_version (pkg), version) != 0) - return FALSE; - return TRUE; -} - -static gchar * -pkg_to_package_id_str (pmpkg_t *pkg, const gchar *repo) -{ - gchar *arch = (gchar *) alpm_pkg_get_arch (pkg); - if (arch == NULL) - arch = (gchar *) "unknown"; - - return pk_package_id_build (alpm_pkg_get_name (pkg), alpm_pkg_get_version (pkg), arch, repo); -} - -static pmpkg_t * -pkg_from_package_id (const gchar *package_id) -{ - pmdb_t *repo = NULL; - pmpkg_t *result; - gchar **package_id_data = pk_package_id_split (package_id); - - /* do all this fancy stuff */ - if (g_strcmp0 (ALPM_LOCAL_DB_ALIAS, package_id_data[PK_PACKAGE_ID_DATA]) == 0) - repo = alpm_option_get_localdb (); - else { - alpm_list_t *iterator; - for (iterator = alpm_option_get_syncdbs (); iterator; iterator = alpm_list_next (iterator)) { - repo = alpm_list_getdata (iterator); - if (g_strcmp0 (alpm_db_get_name (repo), package_id_data[PK_PACKAGE_ID_DATA]) == 0) - break; - } - } - - if (repo != NULL) { - pmpkg_t *pkg = alpm_db_get_pkg (repo, package_id_data[PK_PACKAGE_ID_NAME]); - if (pkg_equals_to (pkg, package_id_data[PK_PACKAGE_ID_NAME], package_id_data[PK_PACKAGE_ID_VERSION])) - result = pkg; - else - result = NULL; - } else - result = NULL; - - g_strfreev (package_id_data); - - return result; -} - -static void -emit_package (PkBackend *backend, pmpkg_t *pkg, const gchar *repo, PkInfoEnum info) -{ - gchar *package_id_str; - - g_debug ("alpm: emitting package with name %s", alpm_pkg_get_name (pkg)); - - package_id_str = pkg_to_package_id_str (pkg, repo); - pk_backend_package (backend, info, package_id_str, alpm_pkg_get_desc (pkg)); - g_free (package_id_str); -} - -static void -cb_trans_evt (pmtransevt_t event, void *data1, void *data2) -{ - gchar **package_ids; - - /* TODO: add more code here */ - switch (event) { - case PM_TRANS_EVT_REMOVE_START: - pk_backend_set_allow_cancel (backend_instance, FALSE); - - /* reset transaction subprogress */ - trans_subprogress = -1; - - emit_package (backend_instance, data1, ALPM_LOCAL_DB_ALIAS, PK_INFO_ENUM_REMOVING); - break; - case PM_TRANS_EVT_ADD_START: - pk_backend_set_allow_cancel (backend_instance, FALSE); - - /* reset transaction subprogress */ - trans_subprogress = -1; - - pk_backend_set_status (backend_instance, PK_STATUS_ENUM_INSTALL); - - package_ids = pk_backend_get_strv (backend_instance, "package_ids"); - if (package_ids != NULL) { - unsigned int iterator; - - /* search for package in package_ids */ - gchar *package_id_needle = pkg_to_package_id_str (data1, ""); - - g_debug ("needle is %s", package_id_needle); - for (iterator = 0; iterator < g_strv_length (package_ids); ++iterator) - if (strstr (package_ids[iterator], package_id_needle) != NULL) { - pk_backend_package (backend_instance, PK_INFO_ENUM_INSTALLING, package_ids[iterator], alpm_pkg_get_desc (data1)); - break; - } - - g_free (package_id_needle); - } else - /* we are installing a local file */ - emit_package (backend_instance, data1, "local", PK_INFO_ENUM_INSTALLING); - - break; - case PM_TRANS_EVT_UPGRADE_START: - pk_backend_set_allow_cancel (backend_instance, FALSE); - - /* reset transaction subprogress */ - trans_subprogress = -1; - - emit_package (backend_instance, data1, ALPM_LOCAL_DB_ALIAS, PK_INFO_ENUM_UPDATING); - break; - default: g_debug ("alpm: event %i happened", event); - } -} - -static void -cb_trans_conv (pmtransconv_t conv, void *data1, void *data2, void *data3, int *response) -{ - /* TODO: check if some code needs to be placed there */ -} - -static void -cb_trans_progress (pmtransprog_t event, const char *pkgname, int percent, int howmany, int current) +gchar * +pk_backend_get_description (PkBackend *self) { - if (trans_subprogress != percent) { - /* avoid duplicates */ - trans_subprogress = percent; + g_return_val_if_fail (self != NULL, NULL); - if (event == PM_TRANS_PROGRESS_ADD_START || event == PM_TRANS_PROGRESS_UPGRADE_START || event == PM_TRANS_PROGRESS_REMOVE_START) { - int trans_percent; - - g_debug ("alpm: transaction percentage for %s is %i", pkgname, percent); - trans_percent = (int) ((float) ((current - 1) * 100 + percent)) / ((float) (howmany * 100)) * 100; - pk_backend_set_sub_percentage ((PkBackend *) backend_instance, percent); - pk_backend_set_percentage ((PkBackend *) backend_instance, trans_percent); - } - } + return g_strdup ("alpm"); } -static void -cb_dl_progress (const char *filename, off_t file_xfered, off_t file_total) +gchar * +pk_backend_get_author (PkBackend *self) { - int file_percent; - int trans_percent; - - if (g_str_has_suffix (filename, ALPM_PKG_EXT)) { - if (g_strcmp0 (filename, current_file) != 0) { - alpm_list_t *repos; - alpm_list_t *packages; - pmpkg_t *current_pkg = NULL; - const gchar *repo_name = NULL; - - g_free (current_file); - current_file = g_strdup (filename); - - /* iterate repos */ - for (repos = alpm_option_get_syncdbs (); current_pkg == NULL && repos; repos = alpm_list_next (repos)) { - pmdb_t *db = alpm_list_getdata (repos); - - /* iterate pkgs */ - for (packages = alpm_db_get_pkgcache (db); current_pkg == NULL && packages; packages = alpm_list_next (packages)) { - pmpkg_t *pkg = alpm_list_getdata (packages); - - /* compare package information with file name */ - gchar *needle = g_strjoin ("-", alpm_pkg_get_name (pkg), alpm_pkg_get_version (pkg), NULL); - if (needle != NULL && strcmp (needle, "") != 0) - g_debug ("matching %s with %s", filename, needle); - if (g_str_has_prefix (filename, needle)) { - current_pkg = pkg; - repo_name = alpm_db_get_name (db); - } - g_free (needle); - } - } - - if (current_pkg != NULL) - emit_package (backend_instance, current_pkg, repo_name, PK_INFO_ENUM_DOWNLOADING); - } - } + g_return_val_if_fail (self != NULL, NULL); - file_percent = (int) ((float) file_xfered) / ((float) file_total) * 100; - trans_percent = (int) ((float) (trans_xfered + file_xfered)) / ((float) trans_total) * 100; - pk_backend_set_sub_percentage ((PkBackend *) backend_instance, file_percent); - pk_backend_set_percentage ((PkBackend *) backend_instance, trans_percent); - - if (file_xfered == file_total) { - downloaded_files = alpm_list_add (downloaded_files, g_strdup (filename)); - trans_xfered = trans_xfered + file_total; - } + return g_strdup ("Jonathan Conder <jonno.conder@gmail.com>"); } -static void -cb_dl_total (off_t total) -{ - trans_total = total; - /* zero total size means that download is finished, so clear trans_xfered */ - if (total == 0) - trans_xfered = 0; -} - -/** - * strtrim: - * Trim whitespaces and newlines from a string - */ -static char * -strtrim (char *str) -{ - char *pch = str; - - if (str == NULL || *str == '\0') - /* string is empty, so we're done. */ - return (str); - - while (isspace (*pch)) - pch++; - - if (pch != str) - memmove (str, pch, (strlen (pch) + 1)); - - /* check if there wasn't anything but whitespace in the string. */ - if (*str == '\0') - return (str); - - pch = (str + (strlen (str) - 1)); - - while (isspace (*pch)) - pch--; - - *++pch = '\0'; - - return (str); -} - -/** - * _strnadd: - * Helper function for strreplace - */ -static void -_strnadd (char **str, const char *append, unsigned int count) -{ - if (*str) - *str = realloc (*str, strlen (*str) + count + 1); - else - *str = calloc (sizeof (char), count + 1); - - strncat (*str, append, count); -} - -/** - * strreplace: - * Replace all occurences of 'needle' with 'replace' in 'str', returning - * a new string (must be free'd) - */ -static char * -strreplace (const char *str, const char *needle, const char *replace) -{ - const char *p, *q; - char *newstr = NULL; - unsigned int needlesz = strlen (needle), replacesz = strlen (replace); - - p = q = str; - - while (1) { - q = strstr (p, needle); - if (!q) { - /* not found */ - if (*p) /* add the rest of 'p' */ - _strnadd (&newstr, p, strlen (p)); - - break; - } else { /* found match */ - if (q > p) /* add chars between this occurance and last occurance, if any */ - _strnadd (&newstr, p, q - p); - - _strnadd (&newstr, replace, replacesz); - p = q + needlesz; - } - } - - return newstr; -} - -/** - * set_repeating_option: - * Add repeating options such as NoExtract, NoUpgrade, etc to alpm settings. - * @param ptr a pointer to the start of the multiple options - * @param option the string (friendly) name of the option, used for messages - * @param optionfunc a function pointer to an alpm_option_add_* function - */ -static void -set_repeating_option (const char *ptr, const char *option, void (*optionfunc) (const char*)) -{ - char *p = (char*) ptr; - char *q; - - while ((q = strchr (p, ' '))) { - *q = '\0'; - (*optionfunc) (p); - g_debug ("config: %s: %s", option, p); - p = q; - p++; - } - (*optionfunc) (p); - g_debug ("config: %s: %s", option, p); -} - -/** - * option_add_syncfirst: - * Add package name to SyncFirst list - * @param name name of the package to be added - */ -static void -option_add_syncfirst (const char *name) { - syncfirst = alpm_list_add (syncfirst, strdup (name)); -} - -/** - * option_add_holdpkg: - * Add package name to HoldPkg list - * @param name name of the package to be added - */ -static void -option_add_holdpkg (const char *name) { - holdpkg = alpm_list_add (holdpkg, strdup (name)); -} - -/** - * parse_config: - * Parse config file and set all the needed options - * Based heavily on the pacman source code - * @param file full name of config file - * @param givensection section to start from - * @param givendb db to start from - */ -static int -parse_config (const char *file, const char *givensection, pmdb_t * const givendb) -{ - FILE *fp = NULL; - char line[PATH_MAX + 1]; - int linenum = 0; - char *ptr, *section = NULL; - pmdb_t *db = NULL; - - /* set default options */ - alpm_option_set_root (ALPM_ROOT); - alpm_option_set_dbpath (ALPM_DBPATH); - alpm_option_add_cachedir (ALPM_CACHEDIR); - alpm_option_set_logfile (ALPM_LOGFILE); - - fp = fopen (file, "r"); - if (fp == NULL) { - g_error ("config file %s could not be read", file); - return 1; - } - - /* if we are passed a section, use it as our starting point */ - if (givensection != NULL) - section = strdup (givensection); - - /* if we are passed a db, use it as our starting point */ - if (givendb != NULL) - db = givendb; - - while (fgets (line, PATH_MAX, fp)) { - linenum++; - strtrim (line); - - if (strlen (line) == 0 || line[0] == '#') - continue; - - if ((ptr = strchr (line, '#'))) - *ptr = '\0'; - - if (line[0] == '[' && line[strlen (line) - 1] == ']') { - /* new config section, skip the '[' */ - ptr = line; - ptr++; - if (section) - free (section); - - section = strdup (ptr); - section[strlen (section) - 1] = '\0'; - g_debug ("config: new section '%s'", section); - if (!strlen (section)) { - g_debug ("config file %s, line %d: bad section name", file, linenum); - return 1; - } - - /* if we are not looking at the options section, register a db */ - if (g_strcmp0 (section, "options") != 0) - db = alpm_db_register_sync (section); - } else { - /* directive */ - char *key; - key = line; - ptr = line; - /* strsep modifies the 'line' string: 'key \0 ptr' */ - strsep (&ptr, "="); - strtrim (key); - strtrim (ptr); - - if (key == NULL) { - g_error ("config file %s, line %d: syntax error in config file - missing key.", file, linenum); - return 1; - } - if (section == NULL) { - g_error ("config file %s, line %d: all directives must belong to a section.", file, linenum); - return 1; - } - - if (ptr == NULL && g_strcmp0 (section, "options") == 0) { - /* directives without settings, all in [options] */ - if (g_strcmp0 (key, "UseSyslog") == 0) { - alpm_option_set_usesyslog (1); - g_debug ("config: usesyslog"); - } else if (g_strcmp0 (key, "UseDelta") == 0) { - alpm_option_set_usedelta (1); - g_debug ("config: usedelta"); - } else if (g_strcmp0 (key, "ILoveCandy") != 0 && g_strcmp0 (key, "ShowSize") != 0 && g_strcmp0 (key, "TotalDownload") != 0 && g_strcmp0 (key, "NoPassiveFTP") != 0) { - g_warning ("config file %s, line %d: directive '%s' not recognized.", file, linenum, key); - } - } else { - /* directives with settings */ - if (g_strcmp0 (key, "Include") == 0) { - g_debug ("config: including %s", ptr); - parse_config (ptr, section, db); - /* Ignore include failures... assume non-critical */ - } else if (g_strcmp0 (section, "options") == 0) { - if (g_strcmp0 (key, "NoUpgrade") == 0) { - set_repeating_option (ptr, "NoUpgrade", alpm_option_add_noupgrade); - } else if (g_strcmp0 (key, "NoExtract") == 0) { - set_repeating_option (ptr, "NoExtract", alpm_option_add_noextract); - } else if (g_strcmp0 (key, "IgnorePkg") == 0) { - set_repeating_option (ptr, "IgnorePkg", alpm_option_add_ignorepkg); - } else if (g_strcmp0 (key, "IgnoreGroup") == 0) { - set_repeating_option (ptr, "IgnoreGroup", alpm_option_add_ignoregrp); - } else if (g_strcmp0 (key, "HoldPkg") == 0) { - set_repeating_option (ptr, "HoldPkg", option_add_holdpkg); - } else if (g_strcmp0 (key, "SyncFirst") == 0) { - set_repeating_option (ptr, "SyncFirst", option_add_syncfirst); - } else if (g_strcmp0 (key, "DBPath") == 0) { - alpm_option_set_dbpath (ptr); - } else if (g_strcmp0 (key, "CacheDir") == 0) { - if (alpm_option_add_cachedir (ptr) != 0) { - g_error ("problem adding cachedir '%s' (%s)", ptr, alpm_strerrorlast ()); - return 1; - } - g_debug ("config: cachedir: %s", ptr); - } else if (g_strcmp0 (key, "RootDir") == 0) { - alpm_option_set_root (ptr); - g_debug ("config: rootdir: %s", ptr); - } else if (g_strcmp0 (key, "LogFile") == 0) { - alpm_option_set_logfile (ptr); - g_debug ("config: logfile: %s", ptr); - } else if (g_strcmp0 (key, "XferCommand") != 0 && g_strcmp0 (key, "CleanMethod") != 0) { - g_warning ("config file %s, line %d: directive '%s' not recognized.", file, linenum, key); - } - } else if (g_strcmp0 (key, "Server") == 0) { - /* let's attempt a replacement for the current repo */ - char *server = strreplace (ptr, "$repo", section); - - if (alpm_db_setserver (db, server) != 0) { - /* pm_errno is set by alpm_db_setserver */ - g_error ("config file %s, line %d: could not add server URL to database (%s).", file, linenum, alpm_strerrorlast ()); - free (server); - return 1; - } - free (server); - } else { - g_warning ("config file %s, line %d: directive '%s' not recognized.", file, linenum, key); - } - } - } - } - - fclose (fp); - if (section) - free (section); - - g_debug ("config: finished parsing %s", file); - return 0; -} - -/** - * backend_initialize: - */ -static void -backend_initialize (PkBackend *backend) -{ - /* initialize backend_instance for use in callback functions */ - backend_instance = backend; - - g_debug ("alpm: initializing backend"); - - if (alpm_initialize () == -1) { - pk_backend_error_code (backend, PK_ERROR_ENUM_FAILED_INITIALIZATION, "Failed to initialize package manager"); - g_debug ("alpm: %s", alpm_strerror (pm_errno)); - return; - } - - /* read options from config file */ - if (parse_config (ALPM_CONFIG_PATH, NULL, NULL) != 0) { - pk_backend_error_code (backend, PK_ERROR_ENUM_FAILED_CONFIG_PARSING, "Failed to parse config file"); - alpm_release (); - return; - } - - if (alpm_db_register_local () == NULL) { - pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_AVAILABLE, "Failed to load local database"); - g_debug ("alpm: %s", alpm_strerror (pm_errno)); - alpm_release (); - return; - } - - alpm_option_set_dlcb (cb_dl_progress); - alpm_option_set_totaldlcb (cb_dl_total); - - /* fill in group mapping */ - group_map = g_hash_table_new (g_str_hash, g_str_equal); - g_hash_table_insert (group_map, (gchar *) "gnome", (gchar *) "desktop-gnome"); - g_hash_table_insert (group_map, (gchar *) "gnome-extra", (gchar *) "desktop-gnome"); - g_hash_table_insert (group_map, (gchar *) "compiz-gnome", (gchar *) "desktop-gnome"); - g_hash_table_insert (group_map, (gchar *) "kde", (gchar *) "desktop-kde"); - g_hash_table_insert (group_map, (gchar *) "compiz-kde", (gchar *) "desktop-kde"); - g_hash_table_insert (group_map, (gchar *) "compiz-fusion-kde", (gchar *) "desktop-kde"); - g_hash_table_insert (group_map, (gchar *) "lxde", (gchar *) "desktop-other"); - g_hash_table_insert (group_map, (gchar *) "rox-desktop", (gchar *) "desktop-other"); - g_hash_table_insert (group_map, (gchar *) "e17-cvs", (gchar *) "desktop-other"); - g_hash_table_insert (group_map, (gchar *) "e17-extra-cvs", (gchar *) "desktop-other"); - g_hash_table_insert (group_map, (gchar *) "e17-libs-cvs", (gchar *) "desktop-other"); - g_hash_table_insert (group_map, (gchar *) "xfce4", (gchar *) "desktop-xfce"); - g_hash_table_insert (group_map, (gchar *) "xfce4-goodies", (gchar *) "desktop-xfce"); - g_hash_table_insert (group_map, (gchar *) "bmp-io-plugins", (gchar *) "multimedia"); - g_hash_table_insert (group_map, (gchar *) "bmp-plugins", (gchar *) "multimedia"); - g_hash_table_insert (group_map, (gchar *) "bmp-visualization-plugins", (gchar *) "multimedia"); - g_hash_table_insert (group_map, (gchar *) "gstreamer0.10-plugins", (gchar *) "multimedia"); - g_hash_table_insert (group_map, (gchar *) "ladspa-plugins", (gchar *) "multimedia"); - g_hash_table_insert (group_map, (gchar *) "pvr", (gchar *) "multimedia"); - g_hash_table_insert (group_map, (gchar *) "mythtv-extras", (gchar *) "multimedia"); - g_hash_table_insert (group_map, (gchar *) "xmms-effect-plugins", (gchar *) "multimedia"); - g_hash_table_insert (group_map, (gchar *) "xmms-io-plugins", (gchar *) "multimedia"); - g_hash_table_insert (group_map, (gchar *) "xmms-plugins", (gchar *) "multimedia"); - g_hash_table_insert (group_map, (gchar *) "base-devel", (gchar *) "programming"); - g_hash_table_insert (group_map, (gchar *) "texlive-lang", (gchar *) "publishing"); - g_hash_table_insert (group_map, (gchar *) "texlive-lang-doc", (gchar *) "publishing"); - g_hash_table_insert (group_map, (gchar *) "texlive-most", (gchar *) "publishing"); - g_hash_table_insert (group_map, (gchar *) "texlive-most-doc", (gchar *) "publishing"); - g_hash_table_insert (group_map, (gchar *) "texlive-most-svn", (gchar *) "publishing"); - g_hash_table_insert (group_map, (gchar *) "base", (gchar *) "system"); - - g_debug ("alpm: ready to go"); -} - -/** - * backend_destroy: - */ -static void -backend_destroy (PkBackend *backend) -{ - g_hash_table_destroy (group_map); - - if (alpm_release () == -1) { - pk_backend_error_code (backend, PK_ERROR_ENUM_FAILED_FINALISE, "Failed to release package manager"); - g_debug ("alpm: %s", alpm_strerror (pm_errno)); - } -} - -/** - * backend_get_groups: - */ -static PkBitfield -backend_get_groups (PkBackend *backend) -{ - return pk_bitfield_from_enums ( - PK_GROUP_ENUM_DESKTOP_GNOME, - PK_GROUP_ENUM_DESKTOP_KDE, - PK_GROUP_ENUM_DESKTOP_OTHER, - PK_GROUP_ENUM_DESKTOP_XFCE, - PK_GROUP_ENUM_MULTIMEDIA, - PK_GROUP_ENUM_OTHER, - PK_GROUP_ENUM_PROGRAMMING, - PK_GROUP_ENUM_PUBLISHING, - PK_GROUP_ENUM_SYSTEM, - -1); -} - -/** - * backend_get_filters: - */ -static PkBitfield -backend_get_filters (PkBackend *backend) -{ - return pk_bitfield_from_enums (PK_FILTER_ENUM_INSTALLED, -1); -} - -/** - * backend_get_mime_types: - */ -static gchar * -backend_get_mime_types (PkBackend *backend) -{ - return g_strdup ("application/x-compressed-tar"); -} - -/** - * backend_cancel: - **/ -static void -backend_cancel (PkBackend *backend) -{ - pk_backend_set_status (backend, PK_STATUS_ENUM_CANCEL); -} - -/** - * backend_download_packages_thread: - */ static gboolean -backend_download_packages_thread (PkBackend *backend) +pk_backend_spawn (PkBackend *self, const gchar *command) { - gchar **package_ids = pk_backend_get_strv (backend, "package_ids"); - const gchar *directory = pk_backend_get_string (backend, "directory"); - unsigned int iterator; - alpm_list_t *list_iterator; - alpm_list_t *cachedirs = NULL; - alpm_list_t *data = NULL; - - g_debug ("alpm: downloading packages to %s", directory); - - /* old cachedirs list automatically gets freed in alpm, so make a copy */ - for (list_iterator = alpm_option_get_cachedirs (); list_iterator; list_iterator = alpm_list_next (list_iterator)) - cachedirs = alpm_list_add (cachedirs, g_strdup (alpm_list_getdata (list_iterator))); - /* set new download destination */ - alpm_option_set_cachedirs (NULL); - alpm_option_add_cachedir (directory); - - /* create a new transaction */ - if (alpm_trans_init (PM_TRANS_FLAG_NODEPS | PM_TRANS_FLAG_DOWNLOADONLY, cb_trans_evt, cb_trans_conv, cb_trans_progress) != 0) { - pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerrorlast ()); - pk_backend_finished (backend); - return FALSE; - } + int status; + GError *error = NULL; - /* add targets to the transaction */ - for (iterator = 0; iterator < g_strv_length (package_ids); ++iterator) { - gchar **package_id_data = pk_package_id_split (package_ids[iterator]); - - if (alpm_sync_target (package_id_data[PK_PACKAGE_ID_NAME]) != 0) { - pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerrorlast ()); - alpm_trans_release (); - pk_backend_finished (backend); - return FALSE; - } + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (command != NULL, FALSE); - g_strfreev (package_id_data); + if (!g_spawn_command_line_sync (command, NULL, NULL, &status, &error)) { + g_warning ("could not spawn command: %s", error->message); + g_error_free (error); + return FALSE; } - /* prepare and commit transaction */ - if (alpm_trans_prepare (&data) != 0 || alpm_trans_commit (&data) != 0) { - pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerrorlast ()); - alpm_trans_release (); - pk_backend_finished (backend); + if (WIFEXITED (status) == 0) { + g_warning ("command did not execute correctly"); return FALSE; } - alpm_trans_release (); - - /* emit downloaded packages */ - for (list_iterator = downloaded_files; list_iterator; list_iterator = alpm_list_next (list_iterator)) { - gchar *package_id = NULL; - gchar *filename; - - /* TODO: optimize this? split-then-join isn't good */ - for (iterator = 0; package_id == NULL && iterator < g_strv_length (package_ids); ++iterator) { - gchar **package_id_data = pk_package_id_split (package_ids[iterator]); - gchar *needle = g_strjoin ("-", package_id_data[PK_PACKAGE_ID_NAME], package_id_data[PK_PACKAGE_ID_VERSION], NULL); - - if (needle != NULL && strcmp (needle, "") != 0) - g_debug ("matching %s with %s", (char *) alpm_list_getdata (list_iterator), needle); - if (g_str_has_prefix ((char *) alpm_list_getdata (list_iterator), needle)) - package_id = package_ids[iterator]; - - g_free (needle); - g_strfreev (package_id_data); - } - - filename = g_build_filename (directory, alpm_list_getdata (list_iterator), NULL); - pk_backend_files (backend, package_id, filename); - g_free (filename); - - /* clean up list data */ - g_free (alpm_list_getdata (list_iterator)); + if (WEXITSTATUS (status) != EXIT_SUCCESS) { + gint code = WEXITSTATUS (status); + g_warning ("command returned error code %d", code); + return FALSE; } - alpm_list_free (downloaded_files); - /* return cachedirs back */ - alpm_option_set_cachedirs (cachedirs); - - pk_backend_finished (backend); return TRUE; } -/** - * backend_download_packages: - */ -static void -backend_download_packages (PkBackend *backend, gchar **package_ids, const gchar *directory) -{ - pk_backend_set_status (backend, PK_STATUS_ENUM_DOWNLOAD); - pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID); - - pk_backend_thread_create (backend, backend_download_packages_thread); -} - -/** - * backend_get_depends: - */ -static void -backend_get_depends (PkBackend *backend, PkBitfield filters, gchar **package_ids, gboolean recursive) +gint +pk_backend_fetchcb (const gchar *url, const gchar *path, gint force) { - unsigned int iterator; + GRegex *xo, *xi; + gchar *oldpwd, *basename, *file, *part; + gchar *tempcmd = NULL, *finalcmd = NULL; + gint result = 0; - pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); - pk_backend_set_allow_cancel (backend, FALSE); + g_return_val_if_fail (url != NULL, -1); + g_return_val_if_fail (path != NULL, -1); + g_return_val_if_fail (xfercmd != NULL, -1); + g_return_val_if_fail (backend != NULL, -1); - for (iterator = 0; iterator < g_strv_length (package_ids); ++iterator) { - alpm_list_t *list_iterator; - - pmpkg_t *pkg = pkg_from_package_id (package_ids[iterator]); - if (pkg == NULL) { - pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, alpm_strerrorlast ()); - pk_backend_finished (backend); - return; - } - - for (list_iterator = alpm_pkg_get_depends (pkg); list_iterator; list_iterator = alpm_list_next (list_iterator)) { - pmdepend_t *dep = alpm_list_getdata (list_iterator); - pmpkg_t *dep_pkg; - gboolean found = FALSE; - - if (!pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED)) { - /* search in sync dbs */ - alpm_list_t *db_iterator; - for (db_iterator = alpm_option_get_syncdbs (); found == FALSE && db_iterator; db_iterator = alpm_list_next (db_iterator)) { - pmdb_t *syncdb = alpm_list_getdata (db_iterator); - - g_debug ("alpm: searching for %s in %s", alpm_dep_get_name (dep), alpm_db_get_name (syncdb)); - - dep_pkg = alpm_db_get_pkg (syncdb, alpm_dep_get_name (dep)); - if (dep_pkg && alpm_depcmp (dep_pkg, dep) && pkg_cmp (dep_pkg, alpm_db_get_pkg (alpm_option_get_localdb (), alpm_dep_get_name (dep))) != 0) { - found = TRUE; - emit_package (backend, dep_pkg, alpm_db_get_name (syncdb), PK_INFO_ENUM_AVAILABLE); - } - } - } - - if (!pk_bitfield_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED)) { - g_debug ("alpm: searching for %s in local db", alpm_dep_get_name (dep)); - - /* search in local db */ - dep_pkg = alpm_db_get_pkg (alpm_option_get_localdb (), alpm_dep_get_name (dep)); - if (dep_pkg && alpm_depcmp (dep_pkg, dep)) { - found = TRUE; - emit_package (backend, dep_pkg, ALPM_LOCAL_DB_ALIAS, PK_INFO_ENUM_INSTALLED); - } - } - } + oldpwd = g_get_current_dir (); + if (g_chdir (path) < 0) { + g_warning ("could not find or read directory %s", path); + g_free (oldpwd); + return -1; } - pk_backend_finished (backend); -} - -/** - * backend_get_details: - */ -static void -backend_get_details (PkBackend *backend, gchar **package_ids) -{ - unsigned int iterator; - - pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); - pk_backend_set_allow_cancel (backend, FALSE); - - for (iterator = 0; iterator < g_strv_length (package_ids); ++iterator) { - alpm_list_t *licenses_list; - GString *licenses_str; - gchar *licenses; - - pmpkg_t *pkg = pkg_from_package_id (package_ids[iterator]); - if (pkg == NULL) { - pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, alpm_strerrorlast ()); - pk_backend_finished (backend); - return; - } - - licenses_list = alpm_pkg_get_licenses (pkg); - if (licenses_list == NULL) - licenses_str = g_string_new ("unknown"); - else { - alpm_list_t *list_iterator; - - licenses_str = g_string_new (""); - for (list_iterator = licenses_list; list_iterator; list_iterator = alpm_list_next (list_iterator)) { - if (list_iterator != licenses_list) - g_string_append (licenses_str, ", "); - g_string_append (licenses_str, (char *) alpm_list_getdata (list_iterator)); - } - } - - /* get licenses_str content to licenses array */ - licenses = g_string_free (licenses_str, FALSE); + xo = g_regex_new ("%o", 0, 0, NULL); + xi = g_regex_new ("%u", 0, 0, NULL); - /* return details */ - pk_backend_details (backend, package_ids[iterator], licenses, PK_GROUP_ENUM_OTHER, alpm_pkg_get_desc (pkg), alpm_pkg_get_url (pkg), alpm_pkg_get_size (pkg)); + basename = g_path_get_basename (url); + file = g_strconcat (path, basename, NULL); + part = g_strconcat (file, ".part", NULL); - /* free licenses array as we no longer need it */ - g_free (licenses); + if (force != 0 && g_file_test (part, G_FILE_TEST_EXISTS)) { + g_unlink (part); } - - pk_backend_finished (backend); -} - -/** - * backend_get_files: - */ -static void -backend_get_files (PkBackend *backend, gchar **package_ids) -{ - unsigned int iterator; - - pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); - pk_backend_set_allow_cancel (backend, FALSE); - - for (iterator = 0; iterator < g_strv_length (package_ids); ++iterator) { - alpm_list_t *files_list; - GString *files_str; - gchar *files; - - pmpkg_t *pkg = pkg_from_package_id (package_ids[iterator]); - if (pkg == NULL) { - pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, alpm_strerrorlast ()); - pk_backend_finished (backend); - return; - } - - files_list = alpm_pkg_get_files (pkg); - files_str = g_string_new (""); - if (files_list != NULL) { - alpm_list_t *list_iterator; - - for (list_iterator = files_list; list_iterator; list_iterator = alpm_list_next (list_iterator)) { - if (list_iterator != files_list) - g_string_append (files_str, ";"); - g_string_append (files_str, alpm_option_get_root ()); - g_string_append (files_str, (char *) alpm_list_getdata (list_iterator)); - } - } - files = g_string_free (files_str, FALSE); - - pk_backend_files (backend, package_ids[iterator], files); + if (force != 0 && g_file_test (file, G_FILE_TEST_EXISTS)) { + g_unlink (file); } - pk_backend_finished (backend); -} - -static void -backend_search (PkBackend *backend, pmdb_t *repo, const gchar *needle, PkAlpmSearchType search_type) { - /* package cache */ - alpm_list_t *pkg_cache; - - /* utility variables */ - alpm_list_t *iterator; - const gchar *repo_name; - PkInfoEnum info; - gboolean match; - gboolean repo_is_local; - - if (repo == alpm_option_get_localdb ()) { - repo_name = ALPM_LOCAL_DB_ALIAS; - info = PK_INFO_ENUM_INSTALLED; - repo_is_local = TRUE; - } else { - repo_name = alpm_db_get_name (repo); - info = PK_INFO_ENUM_AVAILABLE; - repo_is_local = FALSE; + tempcmd = g_regex_replace_literal (xo, xfercmd, -1, 0, part, 0, NULL); + if (tempcmd == NULL) { + result = -1; + goto out; } - /* get package cache for specified repo */ - pkg_cache = alpm_db_get_pkgcache (repo); - - /* iterate package cache */ - for (iterator = pkg_cache; iterator; iterator = alpm_list_next (iterator)) { - pmpkg_t *pkg = alpm_list_getdata (iterator); - - switch (search_type) { - alpm_list_t *provides; - alpm_list_t *groups; - - case PK_ALPM_SEARCH_TYPE_NULL: - match = TRUE; - break; - case PK_ALPM_SEARCH_TYPE_RESOLVE: - match = g_strcmp0 (alpm_pkg_get_name (pkg), needle) == 0; - break; - case PK_ALPM_SEARCH_TYPE_NAME: - match = strstr (alpm_pkg_get_name (pkg), needle) != NULL; - break; - case PK_ALPM_SEARCH_TYPE_DETAILS: - /* workaround for buggy packages with no description */ - if (alpm_pkg_get_desc (pkg) == NULL) - match = FALSE; - else - /* TODO: strcasestr is a non-standard extension, replace it? */ - match = strcasestr (alpm_pkg_get_desc (pkg), needle) != NULL; - break; - case PK_ALPM_SEARCH_TYPE_GROUP: - match = FALSE; - /* iterate groups */ - for (groups = alpm_pkg_get_groups (pkg); groups && !match; groups = alpm_list_next (groups)) { - gchar *group = (gchar *) g_hash_table_lookup (group_map, (char *) alpm_list_getdata (groups)); - if (group == NULL) - group = (gchar *) "other"; - match = (g_strcmp0 (group, needle) == 0); - } - break; - case PK_ALPM_SEARCH_TYPE_PROVIDES: - match = FALSE; - /* iterate provides */ - for (provides = alpm_pkg_get_provides (pkg); provides && !match; provides = alpm_list_next (provides)) - match = (g_strcmp0 (needle, alpm_list_getdata (provides)) == 0); - break; - default: - match = FALSE; - } + finalcmd = g_regex_replace_literal (xi, tempcmd, -1, 0, url, 0, NULL); + if (finalcmd == NULL) { + result = -1; + goto out; + } - if (match && (repo_is_local || pkg_cmp (pkg, alpm_db_get_pkg (alpm_option_get_localdb (), alpm_pkg_get_name (pkg))) != 0)) { - /* we found what we wanted */ - emit_package (backend, pkg, repo_name, info); + if (!pk_backend_spawn (backend, finalcmd)) { + result = -1; + goto out; + } else if (g_strrstr (xfercmd, "%o") != NULL) { + /* using .part filename */ + if (g_rename (part, file) < 0) { + g_warning ("could not rename %s", part); + result = -1; + goto out; } } -} -/** - * backend_search_values: - */ -static void -backend_search_values (PkBackend *backend, pmdb_t *repo, gchar **values, PkAlpmSearchType search_type) { - unsigned int iterator; +out: + g_free (finalcmd); + g_free (tempcmd); - for (iterator = 0; iterator < g_strv_length (values); ++iterator) - backend_search (backend, repo, values[iterator], search_type); -} - -/** - * backend_get_packages_thread: - */ -static gboolean -backend_get_packages_thread (PkBackend *backend) -{ - PkBitfield filters = pk_backend_get_uint (backend, "filters"); - - gboolean search_installed = pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED); - gboolean search_not_installed = pk_bitfield_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED); + g_free (part); + g_free (file); + g_free (basename); - if (!search_not_installed) { - /* search in local db */ - backend_search (backend, alpm_option_get_localdb (), NULL, PK_ALPM_SEARCH_TYPE_NULL); - } - - if (!search_installed) { - /* search in sync repos */ - alpm_list_t *repos; - /* iterate repos */ - for (repos = alpm_option_get_syncdbs (); repos; repos = alpm_list_next (repos)) - backend_search (backend, alpm_list_getdata (repos), NULL, PK_ALPM_SEARCH_TYPE_NULL); - } + g_regex_unref (xi); + g_regex_unref (xo); - pk_backend_finished (backend); - return TRUE; -} + g_chdir (oldpwd); + g_free (oldpwd); -/** - * backend_get_packages: - */ -static void -backend_get_packages (PkBackend *backend, PkBitfield filters) -{ - pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); - pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID); - - pk_backend_thread_create (backend, backend_get_packages_thread); + return result; } -/** - * backend_get_repo_list: - */ static void -backend_get_repo_list (PkBackend *backend, PkBitfield filters) +pk_backend_logcb (pmloglevel_t level, const gchar *format, va_list args) { - alpm_list_t *list_iterator; - - pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); + gchar *output; - /* iterate on repo list */ - for (list_iterator = alpm_option_get_syncdbs (); list_iterator; list_iterator = alpm_list_next (list_iterator)) { - pmdb_t *db = alpm_list_getdata (list_iterator); + g_return_if_fail (backend != NULL); - pk_backend_repo_detail (backend, alpm_db_get_name (db), alpm_db_get_name (db), TRUE); + if (format != NULL && format[0] != '\0') { + output = g_strdup_vprintf (format, args); + } else { + return; } - pk_backend_finished (backend); -} - -/** - * backend_get_update_detail: - */ -static void -backend_get_update_detail (PkBackend *backend, gchar **package_ids) -{ - unsigned int iterator; - - pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); - pk_backend_set_allow_cancel (backend, FALSE); - - for (iterator = 0; iterator < g_strv_length (package_ids); ++iterator) { - /* TODO: add changelog code here */ - gchar **package_id_data = pk_package_id_split (package_ids[iterator]); - - pmpkg_t *installed_pkg = alpm_db_get_pkg (alpm_option_get_localdb (), package_id_data[PK_PACKAGE_ID_NAME]); + /* report important output to PackageKit */ + switch (level) { + case PM_LOG_DEBUG: + case PM_LOG_FUNCTION: + g_debug ("%s", output); + break; - gchar *installed_package_id = installed_pkg ? pkg_to_package_id_str (installed_pkg, ALPM_LOCAL_DB_ALIAS) : NULL; - pk_backend_update_detail (backend, package_ids[iterator], installed_package_id, "", "", "", "", PK_RESTART_ENUM_NONE, - installed_pkg ? "Update to latest available version" : "Install as a dependency for another update", - NULL, PK_UPDATE_STATE_ENUM_UNKNOWN, NULL, NULL); - g_free (installed_package_id); + case PM_LOG_WARNING: + g_warning ("%s", output); + pk_backend_output (backend, output); + break; - g_strfreev (package_id_data); + default: + g_warning ("%s", output); + break; } - pk_backend_finished (backend); + g_free (output); } -/** - * backend_get_updates: - */ -static void -backend_get_updates (PkBackend *backend, PkBitfield filters) +static gboolean +pk_backend_initialize_alpm (PkBackend *self, GError **error) { - alpm_list_t *list_iterator; - - pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); - pk_backend_set_allow_cancel (backend, FALSE); - - /* iterate through list of installed packages to find update for each */ - for (list_iterator = alpm_db_get_pkgcache (alpm_option_get_localdb ()); list_iterator; list_iterator = alpm_list_next (list_iterator)) { - alpm_list_t *db_iterator; - - pmpkg_t *pkg = alpm_list_getdata (list_iterator); + struct utsname un; + gchar *user_agent; - for (db_iterator = alpm_option_get_syncdbs (); db_iterator; db_iterator = alpm_list_next (db_iterator)) { - pmdb_t *db = alpm_list_getdata (db_iterator); - pmpkg_t *repo_pkg = alpm_db_get_pkg (db, alpm_pkg_get_name (pkg)); + g_return_val_if_fail (self != NULL, FALSE); - if (repo_pkg != NULL && alpm_pkg_vercmp (alpm_pkg_get_version (pkg), alpm_pkg_get_version (repo_pkg)) < 0) { - gchar *package_id_str = pkg_to_package_id_str (repo_pkg, alpm_db_get_name (db)); - pk_backend_package (backend, PK_INFO_ENUM_NORMAL, package_id_str, alpm_pkg_get_desc (repo_pkg)); - g_free (package_id_str); + /* PATH might have been nuked by D-Bus */ + g_setenv ("PATH", PK_BACKEND_DEFAULT_PATH, FALSE); - break; - } - } - } - - pk_backend_finished (backend); -} + uname (&un); + user_agent = g_strdup_printf ("%s/%s (%s %s) libalpm/%s", + PACKAGE_TARNAME, PACKAGE_VERSION, + un.sysname, un.machine, alpm_version ()); + g_setenv ("HTTP_USER_AGENT", user_agent, FALSE); + g_free (user_agent); -/** - * backend_install_files_thread: - */ -static gboolean -backend_install_files_thread (PkBackend *backend) -{ - unsigned int iterator; - alpm_list_t *data = NULL; - - gchar **full_paths = pk_backend_get_strv (backend, "full_paths"); - - /* create a new transaction */ - if (alpm_trans_init (0, cb_trans_evt, cb_trans_conv, cb_trans_progress) != 0) { - pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerrorlast ()); - pk_backend_finished (backend); + g_debug ("initializing"); + if (alpm_initialize () < 0) { + g_set_error_literal (error, ALPM_ERROR, pm_errno, + alpm_strerrorlast ()); return FALSE; } - /* add targets to the transaction */ - for (iterator = 0; iterator < g_strv_length (full_paths); ++iterator) { - if (alpm_add_target (full_paths[iterator]) != 0) { - pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerrorlast ()); - alpm_trans_release (); - pk_backend_finished (backend); - return FALSE; - } else - g_debug ("alpm: %s added to transaction queue", full_paths[iterator]); - } - - /* prepare and commit transaction */ - if (alpm_trans_prepare (&data) != 0 || alpm_trans_commit (&data) != 0) { - pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerrorlast ()); - alpm_trans_release (); - pk_backend_finished (backend); - return FALSE; + backend = self; + localdb = alpm_option_get_localdb (); + if (localdb == NULL) { + g_set_error (error, ALPM_ERROR, pm_errno, "[%s]: %s", "local", + alpm_strerrorlast ()); } - alpm_trans_release (); + /* set some sane defaults */ + alpm_option_set_logcb (pk_backend_logcb); + alpm_option_set_root (PK_BACKEND_DEFAULT_ROOT); + alpm_option_set_dbpath (PK_BACKEND_DEFAULT_DBPATH); + alpm_option_set_logfile (PK_BACKEND_DEFAULT_LOGFILE); - pk_backend_finished (backend); return TRUE; } -/** - * backend_install_files: - */ static void -backend_install_files (PkBackend *backend, gboolean only_trusted, gchar **full_paths) -{ - pk_backend_set_status (backend, PK_STATUS_ENUM_INSTALL); - pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID); - - pk_backend_thread_create (backend, backend_install_files_thread); -} - -/** - * backend_install_packages_thread: - */ -static gboolean -backend_install_packages_thread (PkBackend *backend) +pk_backend_destroy_alpm (PkBackend *self) { - unsigned int iterator; - alpm_list_t *data = NULL; - - /* FIXME: support only_trusted */ - gchar **package_ids = pk_backend_get_strv (backend, "package_ids"); - - /* create a new transaction */ - if (alpm_trans_init (0, cb_trans_evt, cb_trans_conv, cb_trans_progress) != 0) { - pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerrorlast ()); - pk_backend_finished (backend); - return FALSE; - } - - /* add targets to the transaction */ - for (iterator = 0; iterator < g_strv_length (package_ids); ++iterator) { - gchar **package_id_data = pk_package_id_split (package_ids[iterator]); + g_return_if_fail (self != NULL); - if (alpm_sync_target (package_id_data[PK_PACKAGE_ID_NAME]) != 0) { - pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerrorlast ()); + if (backend != NULL) { + if (alpm_trans_get_flags () != -1) { alpm_trans_release (); - pk_backend_finished (backend); - return FALSE; } - - g_strfreev (package_id_data); - } - - /* prepare and commit transaction */ - if (alpm_trans_prepare (&data) != 0 || alpm_trans_commit (&data) != 0) { - pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerrorlast ()); - alpm_trans_release (); - pk_backend_finished (backend); - return FALSE; + alpm_release (); + backend = NULL; } - alpm_trans_release (); - - pk_backend_finished (backend); - return TRUE; -} - -/** - * backend_install_packages: - */ -static void -backend_install_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids) -{ - pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID); - - pk_backend_thread_create (backend, backend_install_packages_thread); + FREELIST (syncfirsts); + FREELIST (holdpkgs); + g_free (xfercmd); } -/** - * backend_refresh_cache_thread: - */ -static gboolean -backend_refresh_cache_thread (PkBackend *backend) +void +pk_backend_initialize (PkBackend *self) { - alpm_list_t *list_iterator; + GError *error = NULL; - if (alpm_trans_init (PM_TRANS_FLAG_NOSCRIPTLET, cb_trans_evt, cb_trans_conv, cb_trans_progress) != 0) { - pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerrorlast ()); - pk_backend_finished (backend); - return FALSE; - } + g_return_if_fail (self != NULL); - for (list_iterator = alpm_option_get_syncdbs (); list_iterator; list_iterator = alpm_list_next (list_iterator)) { - pmdb_t *db = (pmdb_t *) alpm_list_getdata (list_iterator); - if (alpm_db_update (FALSE, db) == -1) { - pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerrorlast ()); - pk_backend_finished (backend); - return FALSE; - } + if (!pk_backend_initialize_alpm (self, &error) || + !pk_backend_initialize_databases (self, &error) || + !pk_backend_initialize_groups (self, &error)) { + g_error ("%s", error->message); + g_error_free (error); } - - alpm_trans_release (); - - pk_backend_finished (backend); - return TRUE; } -/** - * backend_refresh_cache: - */ -static void -backend_refresh_cache (PkBackend *backend, gboolean force) +void +pk_backend_destroy (PkBackend *self) { - if (!pk_backend_is_online (backend)) { - pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Can not refresh cache in offline mode"); - pk_backend_finished (backend); - return; - } - - pk_backend_set_status (backend, PK_STATUS_ENUM_REFRESH_CACHE); - pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID); + g_return_if_fail (self != NULL); - pk_backend_thread_create (backend, backend_refresh_cache_thread); + pk_backend_destroy_groups (self); + pk_backend_destroy_databases (self); + pk_backend_destroy_alpm (self); } -/** - * backend_remove_packages_thread: - */ -static gboolean -backend_remove_packages_thread (PkBackend *backend) +PkBitfield +pk_backend_get_filters (PkBackend *self) { - unsigned int iterator; - alpm_list_t *list_iterator = NULL; - alpm_list_t *data = NULL; - gchar *holdpkgs = NULL; - - gchar **package_ids = pk_backend_get_strv (backend, "package_ids"); - gboolean allow_deps = pk_backend_get_bool (backend, "allow_deps"); - gboolean autoremove = pk_backend_get_bool (backend, "autoremove"); - - pmtransflag_t flags = 0; - if (allow_deps) - flags |= PM_TRANS_FLAG_CASCADE; - if (autoremove) - flags |= PM_TRANS_FLAG_RECURSE; - - /* create a new transaction */ - if (alpm_trans_init (flags, cb_trans_evt, cb_trans_conv, cb_trans_progress) != 0) { - pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerrorlast ()); - pk_backend_finished (backend); - return FALSE; - } - - /* add targets to the transaction */ - for (iterator = 0; iterator < g_strv_length (package_ids); ++iterator) { - gchar **package_id_data = pk_package_id_split (package_ids[iterator]); - - if (alpm_remove_target (package_id_data[PK_PACKAGE_ID_NAME]) != 0) { - pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerrorlast ()); - alpm_trans_release (); - pk_backend_finished (backend); - return FALSE; - } - - g_strfreev (package_id_data); - } - - /* prepare transaction */ - if (alpm_trans_prepare (&data) != 0) { - pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerrorlast ()); - alpm_trans_release (); - pk_backend_finished (backend); - return FALSE; - } + g_return_val_if_fail (self != NULL, 0); - /* search for HoldPkg's in target list */ - for (list_iterator = alpm_trans_get_remove (); list_iterator; list_iterator = alpm_list_next (list_iterator)) { - pmpkg_t *pkg = alpm_list_getdata (list_iterator); - const gchar *pkgname = alpm_pkg_get_name (pkg); - - if (alpm_list_find_str (holdpkg, pkgname) != NULL) { - if (holdpkgs == NULL) - holdpkgs = g_strdup (pkgname); - else { - gchar *new_holdpkgs = g_strdup_printf ("%s, %s", holdpkgs, pkgname); - g_free (holdpkgs); - holdpkgs = new_holdpkgs; - } - } - } - - /* pacman just asks for confirmation, but here we fail to be safe */ - if (holdpkgs != NULL) { - pk_backend_error_code (backend, PK_ERROR_ENUM_CANNOT_REMOVE_SYSTEM_PACKAGE, "The following packages are designated HoldPkg: %s", holdpkgs); - free (holdpkgs); - alpm_trans_release (); - pk_backend_finished (backend); - return FALSE; - } - - /* commit transaction */ - if (alpm_trans_commit (&data) != 0) { - pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerrorlast ()); - alpm_trans_release (); - pk_backend_finished (backend); - return FALSE; - } - - alpm_trans_release (); - - pk_backend_finished (backend); - return TRUE; + return pk_bitfield_from_enums (PK_FILTER_ENUM_INSTALLED, -1); } -/** - * backend_remove_packages: - */ -static void -backend_remove_packages (PkBackend *backend, gchar **package_ids, gboolean allow_deps, gboolean autoremove) +gchar * +pk_backend_get_mime_types (PkBackend *self) { - pk_backend_set_status (backend, PK_STATUS_ENUM_REMOVE); - pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID); + g_return_val_if_fail (self != NULL, NULL); - pk_backend_thread_create (backend, backend_remove_packages_thread); + /* packages currently use .pkg.tar.gz and .pkg.tar.xz */ + return g_strdup ("application/x-compressed-tar;" + "application/x-xz-compressed-tar"); } -/** - * backend_resolve_thread: - */ -static gboolean -backend_resolve_thread (PkBackend *backend) +void +pk_backend_run (PkBackend *self, PkStatusEnum status, PkBackendThreadFunc func) { - unsigned int iterator; - - gchar **package_ids = pk_backend_get_strv (backend, "package_ids"); - PkBitfield filters = pk_backend_get_uint (backend, "filters"); - - gboolean search_installed = pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED); - gboolean search_not_installed = pk_bitfield_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED); - - for (iterator = 0; iterator < g_strv_length (package_ids); ++iterator) { - if (pk_package_id_check (package_ids[iterator])) { - /* skip all the db iterations and so on - we already know everything */ - pmpkg_t *pkg = pkg_from_package_id (package_ids[iterator]); - - if (pkg != NULL) { - gchar **package_id_data = pk_package_id_split (package_ids[iterator]); - - if (!search_not_installed && g_strcmp0 (package_id_data[PK_PACKAGE_ID_DATA], ALPM_LOCAL_DB_ALIAS) == 0) - emit_package (backend, pkg, ALPM_LOCAL_DB_ALIAS, PK_INFO_ENUM_INSTALLED); - - if (!search_installed && g_strcmp0 (package_id_data[PK_PACKAGE_ID_DATA], ALPM_LOCAL_DB_ALIAS) != 0) - emit_package (backend, pkg, package_id_data[PK_PACKAGE_ID_DATA], PK_INFO_ENUM_INSTALLED); - - g_strfreev (package_id_data); - } - } else { - /* good old way with backend_search */ - /* TODO: check, is it still needed? */ - if (!search_not_installed) { - /* search in local db */ - backend_search (backend, alpm_option_get_localdb (), package_ids[iterator], PK_ALPM_SEARCH_TYPE_RESOLVE); - } - - if (!search_installed) { - /* search in sync repos */ - alpm_list_t *repos; - /* iterate repos */ - for (repos = alpm_option_get_syncdbs (); repos; repos = alpm_list_next (repos)) - backend_search (backend, alpm_list_getdata (repos), package_ids[iterator], PK_ALPM_SEARCH_TYPE_RESOLVE); - } - } + g_return_if_fail (self != NULL); + g_return_if_fail (func != NULL); + + g_static_mutex_lock (&mutex); + + if (cancellable != NULL) { + g_warning ("cancellable was not NULL"); + g_object_unref (cancellable); } + cancellable = g_cancellable_new (); - pk_backend_finished (backend); - return TRUE; -} + g_static_mutex_unlock (&mutex); -/** - * backend_resolve: - */ -static void -backend_resolve (PkBackend *backend, PkBitfield filters, gchar **package_ids) -{ - pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); - pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID); + pk_backend_set_allow_cancel (self, TRUE); - pk_backend_thread_create (backend, backend_resolve_thread); + pk_backend_set_status (self, status); + pk_backend_thread_create (self, func); } -/** - * backend_search_thread: - */ -static gboolean -backend_search_thread (PkBackend *backend) +void +pk_backend_cancel (PkBackend *self) { - gchar **values = pk_backend_get_strv (backend, "values"); - PkBitfield filters = pk_backend_get_uint (backend, "filters"); - PkAlpmSearchType search_type = pk_backend_get_uint (backend, "search-type"); - - gboolean search_installed = pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED); - gboolean search_not_installed = pk_bitfield_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED); + g_return_if_fail (self != NULL); - if (!search_not_installed) { - /* search in local db */ - backend_search_values (backend, alpm_option_get_localdb (), values, search_type); - } + g_static_mutex_lock (&mutex); - if (!search_installed) { - /* search in sync repos */ - alpm_list_t *repos; - /* iterate repos */ - for (repos = alpm_option_get_syncdbs (); repos; repos = alpm_list_next (repos)) - backend_search_values (backend, alpm_list_getdata (repos), values, search_type); + if (cancellable != NULL) { + g_cancellable_cancel (cancellable); } - pk_backend_finished (backend); - return TRUE; + g_static_mutex_unlock (&mutex); } -/** - * backend_search_details: - */ -static void -backend_search_details (PkBackend *backend, PkBitfield filters, gchar **values) +gboolean +pk_backend_cancelled (PkBackend *self) { - pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); - pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID); - pk_backend_set_uint (backend, "search-type", PK_ALPM_SEARCH_TYPE_DETAILS); - pk_backend_set_strv (backend, "values", values); + gboolean cancelled; - pk_backend_thread_create (backend, backend_search_thread); -} + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (cancellable != NULL, FALSE); -/** - * backend_search_groups: - */ -static void -backend_search_groups (PkBackend *backend, PkBitfield filters, gchar **values) -{ - pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); - pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID); - pk_backend_set_uint (backend, "search-type", PK_ALPM_SEARCH_TYPE_GROUP); - pk_backend_set_strv (backend, "values", values); + g_static_mutex_lock (&mutex); - pk_backend_thread_create (backend, backend_search_thread); -} + cancelled = g_cancellable_is_cancelled (cancellable); -/** - * backend_search_names: - */ -static void -backend_search_names (PkBackend *backend, PkBitfield filters, gchar **values) -{ - pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); - pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID); - pk_backend_set_uint (backend, "search-type", PK_ALPM_SEARCH_TYPE_NAME); - pk_backend_set_strv (backend, "values", values); + g_static_mutex_unlock (&mutex); - pk_backend_thread_create (backend, backend_search_thread); + return cancelled; } -/** - * backend_update_packages: - */ -static void -backend_update_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids) +gboolean +pk_backend_finish (PkBackend *self, GError *error) { - pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID); + gboolean cancelled = FALSE; - pk_backend_thread_create (backend, backend_install_packages_thread); -} + g_return_val_if_fail (self != NULL, FALSE); -/** - * backend_update_system_thread: - */ -static gboolean -backend_update_system_thread (PkBackend *backend) -{ - alpm_list_t *data = NULL; - - /* FIXME: support only_trusted */ + pk_backend_set_allow_cancel (self, FALSE); - /* create a new transaction */ - if (alpm_trans_init (0, cb_trans_evt, cb_trans_conv, cb_trans_progress) != 0) { - pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerrorlast ()); - pk_backend_finished (backend); - return FALSE; - } + g_static_mutex_lock (&mutex); - /* set action, prepare and commit transaction */ - if (alpm_sync_sysupgrade (FALSE) != 0 || alpm_trans_prepare (&data) != 0 || alpm_trans_commit (&data) != 0) { - pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerrorlast ()); - alpm_trans_release (); - pk_backend_finished (backend); - return FALSE; + if (cancellable != NULL) { + cancelled = g_cancellable_is_cancelled (cancellable); + g_object_unref (cancellable); + cancellable = NULL; } - alpm_trans_release (); + g_static_mutex_unlock (&mutex); - pk_backend_finished (backend); - return TRUE; -} - -/** - * backend_update_system: - */ -static void -backend_update_system (PkBackend *backend, gboolean only_trusted) -{ - pk_backend_thread_create (backend, backend_update_system_thread); -} + if (error != NULL) { + pk_backend_error (self, error); + g_error_free (error); + } -/** - * backend_what_provides: - */ -static void -backend_what_provides (PkBackend *backend, PkBitfield filters, PkProvidesEnum provides, gchar **values) -{ - pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); - pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID); - pk_backend_set_uint (backend, "search-type", PK_ALPM_SEARCH_TYPE_PROVIDES); - pk_backend_set_strv (backend, "values", values); + if (cancelled) { + pk_backend_set_status (self, PK_STATUS_ENUM_CANCEL); + } - pk_backend_thread_create (backend, backend_search_thread); + pk_backend_thread_finished (self); + return (error == NULL); } - -/* FIXME: port this away from PK_BACKEND_OPTIONS */ -PK_BACKEND_OPTIONS ( - "alpm", /* description */ - "Valeriy Lyasotskiy <onestep@ukr.net>", /* author */ - backend_initialize, /* initialize */ - backend_destroy, /* destroy */ - backend_get_groups, /* get_groups */ - backend_get_filters, /* get_filters */ - NULL, /* get_roles */ - backend_get_mime_types, /* get_mime_types */ - backend_cancel, /* cancel */ - backend_download_packages, /* download_packages */ - NULL, /* get_categories */ - backend_get_depends, /* get_depends */ - backend_get_details, /* get_details */ - NULL, /* get_distro_upgrades */ - backend_get_files, /* get_files */ - backend_get_packages, /* get_packages */ - backend_get_repo_list, /* get_repo_list */ - NULL, /* get_requires */ - backend_get_update_detail, /* get_update_detail */ - backend_get_updates, /* get_updates */ - backend_install_files, /* install_files */ - backend_install_packages, /* install_packages */ - NULL, /* install_signature */ - backend_refresh_cache, /* refresh_cache */ - backend_remove_packages, /* remove_packages */ - NULL, /* repo_enable */ - NULL, /* repo_set_data */ - backend_resolve, /* resolve */ - NULL, /* rollback */ - backend_search_details, /* search_details */ - NULL, /* search_files */ - backend_search_groups, /* search_groups */ - backend_search_names, /* search_names */ - backend_update_packages, /* update_packages */ - backend_update_system, /* update_system */ - backend_what_provides, /* what_provides */ - NULL, /* simulate_install_files */ - NULL, /* simulate_install_packages */ - NULL, /* simulate_remove_packages */ - NULL, /* simulate_update_packages */ - NULL, /* upgrade_system */ - NULL, /* transaction_start */ - NULL /* transaction_stop */ -); diff --git a/backends/pacman/backend-pacman.h b/backends/alpm/pk-backend-alpm.h index 0d7b89b68..23a27244f 100644 --- a/backends/pacman/backend-pacman.h +++ b/backends/alpm/pk-backend-alpm.h @@ -1,8 +1,8 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- * * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> - * Copyright (C) 2008, 2009 Valeriy Lyasotskiy <onestep@ukr.net> - * Copyright (C) 2010 Jonathan Conder <j@skurvy.no-ip.org> + * Copyright (C) 2008-2010 Valeriy Lyasotskiy <onestep@ukr.net> + * Copyright (C) 2010-2011 Jonathan Conder <jonno.conder@gmail.com> * * Licensed under the GNU General Public License Version 2 * @@ -21,15 +21,27 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include <alpm.h> #include <gio/gio.h> -#include <pacman.h> #include <pk-backend.h> -extern PacmanManager *pacman; -extern GCancellable *cancellable; +extern PkBackend *backend; +extern GCancellable *cancellable; -void backend_run (PkBackend *backend, - PkStatusEnum status, - PkBackendThreadFunc func); -gboolean backend_cancelled (PkBackend *backend); -void backend_finished (PkBackend *backend); +extern pmdb_t *localdb; + +extern gchar *xfercmd; +extern alpm_list_t *holdpkgs; +extern alpm_list_t *syncfirsts; + +gint pk_backend_fetchcb (const gchar *url, const gchar *path, + gint force); + +void pk_backend_run (PkBackend *self, PkStatusEnum status, + PkBackendThreadFunc func); + +void pk_backend_cancel (PkBackend *self); + +gboolean pk_backend_cancelled (PkBackend *self); + +gboolean pk_backend_finish (PkBackend *self, GError *error); diff --git a/backends/alpm/pk-backend-config.c b/backends/alpm/pk-backend-config.c new file mode 100644 index 000000000..21a4c541c --- /dev/null +++ b/backends/alpm/pk-backend-config.c @@ -0,0 +1,775 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> + * Copyright (C) 2008-2010 Valeriy Lyasotskiy <onestep@ukr.net> + * Copyright (C) 2010-2011 Jonathan Conder <jonno.conder@gmail.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include <alpm.h> +#include <glob.h> +#include <string.h> +#include <sys/utsname.h> + +#include "pk-backend-alpm.h" +#include "pk-backend-config.h" +#include "pk-backend-error.h" + +typedef struct { + gboolean checkspace, ilovecandy, showsize, totaldl, usedelta, usesyslog; + + gchar *arch, *cleanmethod, *dbpath, *logfile, *root, *xfercmd; + + alpm_list_t *cachedirs, *holdpkgs, *ignoregrps, *ignorepkgs, + *noextracts, *noupgrades, *syncfirsts; + + alpm_list_t *repos; + GHashTable *servers; + GRegex *xrepo, *xarch; +} PkBackendConfig; + +static PkBackendConfig * +pk_backend_config_new (void) +{ + PkBackendConfig *config = g_new0 (PkBackendConfig, 1); + config->servers = g_hash_table_new_full (g_str_hash, g_str_equal, + g_free, NULL); + config->xrepo = g_regex_new ("\\$repo", 0, 0, NULL); + config->xarch = g_regex_new ("\\$arch", 0, 0, NULL); + return config; +} + +static void +pk_backend_config_list_free (alpm_list_t *list) +{ + alpm_list_free_inner (list, g_free); + alpm_list_free (list); +} + +static gboolean +pk_backend_config_servers_free (gpointer repo, gpointer list, gpointer data) +{ + pk_backend_config_list_free ((alpm_list_t *) list); + return TRUE; +} + +static void +pk_backend_config_free (PkBackendConfig *config) +{ + g_return_if_fail (config != NULL); + + g_free (config->arch); + g_free (config->cleanmethod); + g_free (config->dbpath); + g_free (config->logfile); + g_free (config->root); + g_free (config->xfercmd); + + FREELIST (config->cachedirs); + FREELIST (config->holdpkgs); + FREELIST (config->ignoregrps); + FREELIST (config->ignorepkgs); + FREELIST (config->noextracts); + FREELIST (config->noupgrades); + FREELIST (config->syncfirsts); + + pk_backend_config_list_free (config->repos); + g_hash_table_foreach_remove (config->servers, + pk_backend_config_servers_free, NULL); + g_hash_table_unref (config->servers); + g_regex_unref (config->xrepo); + g_regex_unref (config->xarch); +} + +static void +pk_backend_config_set_checkspace (PkBackendConfig *config) +{ + g_return_if_fail (config != NULL); + + config->checkspace = TRUE; +} + +static void +pk_backend_config_set_ilovecandy (PkBackendConfig *config) +{ + g_return_if_fail (config != NULL); + + config->ilovecandy = TRUE; +} + +static void +pk_backend_config_set_showsize (PkBackendConfig *config) +{ + g_return_if_fail (config != NULL); + + config->showsize = TRUE; +} + +static void +pk_backend_config_set_totaldl (PkBackendConfig *config) +{ + g_return_if_fail (config != NULL); + + config->totaldl = TRUE; +} + +static void +pk_backend_config_set_usedelta (PkBackendConfig *config) +{ + g_return_if_fail (config != NULL); + + config->usedelta = TRUE; +} + +static void +pk_backend_config_set_usesyslog (PkBackendConfig *config) +{ + g_return_if_fail (config != NULL); + + config->usesyslog = TRUE; +} + +typedef struct { + const gchar *name; + void (*func) (PkBackendConfig *config); +} PkBackendConfigBoolean; + +/* keep this in alphabetical order */ +static const PkBackendConfigBoolean pk_backend_config_boolean_options[] = { + { "CheckSpace", pk_backend_config_set_checkspace }, + { "ILoveCandy", pk_backend_config_set_ilovecandy }, + { "ShowSize", pk_backend_config_set_showsize }, + { "TotalDownload", pk_backend_config_set_totaldl }, + { "UseDelta", pk_backend_config_set_usedelta }, + { "UseSyslog", pk_backend_config_set_usesyslog }, + { NULL, NULL } +}; + +static gboolean +pk_backend_config_set_boolean (PkBackendConfig *config, const gchar *option) +{ + gsize i; + + g_return_val_if_fail (config != NULL, FALSE); + g_return_val_if_fail (option != NULL, FALSE); + + for (i = 0;; ++i) { + const gchar *name = pk_backend_config_boolean_options[i].name; + gint cmp = g_strcmp0 (option, name); + + if (name == NULL || cmp < 0) { + return FALSE; + } else if (cmp == 0) { + pk_backend_config_boolean_options[i].func (config); + return TRUE; + } + } +} + +static void +pk_backend_config_add_cachedir (PkBackendConfig *config, const gchar *path) +{ + gsize length; + gchar *cachedir; + + g_return_if_fail (config != NULL); + g_return_if_fail (path != NULL); + + /* allocate normally */ + length = strlen (path) + 1; + cachedir = malloc (length * sizeof (gchar)); + g_strlcpy (cachedir, path, length); + config->cachedirs = alpm_list_add (config->cachedirs, cachedir); +} + +static void +pk_backend_config_set_arch (PkBackendConfig *config, const gchar *arch) +{ + g_return_if_fail (config != NULL); + g_return_if_fail (arch != NULL); + + g_free (config->arch); + if (g_strcmp0 (arch, "auto") == 0) { + struct utsname un; + uname (&un); + config->arch = g_strdup (un.machine); + } else { + config->arch = g_strdup (arch); + } +} + +static void +pk_backend_config_set_cleanmethod (PkBackendConfig *config, const gchar *method) +{ + g_return_if_fail (config != NULL); + g_return_if_fail (method != NULL); + + g_free (config->cleanmethod); + config->cleanmethod = g_strdup (method); +} + +static void +pk_backend_config_set_dbpath (PkBackendConfig *config, const gchar *path) +{ + g_return_if_fail (config != NULL); + g_return_if_fail (path != NULL); + + g_free (config->dbpath); + config->dbpath = g_strdup (path); +} + +static void +pk_backend_config_set_logfile (PkBackendConfig *config, const gchar *filename) +{ + g_return_if_fail (config != NULL); + g_return_if_fail (filename != NULL); + + g_free (config->logfile); + config->logfile = g_strdup (filename); +} + +static void +pk_backend_config_set_root (PkBackendConfig *config, const gchar *path) +{ + g_return_if_fail (config != NULL); + g_return_if_fail (path != NULL); + + g_free (config->root); + config->root = g_strdup (path); +} + +static void +pk_backend_config_set_xfercmd (PkBackendConfig *config, const gchar *command) +{ + g_return_if_fail (config != NULL); + g_return_if_fail (command != NULL); + + g_free (config->xfercmd); + config->xfercmd = g_strdup (command); +} + +typedef struct { + const gchar *name; + void (*func) (PkBackendConfig *config, const gchar *s); +} PkBackendConfigString; + +/* keep this in alphabetical order */ +static const PkBackendConfigString pk_backend_config_string_options[] = { + { "Architecture", pk_backend_config_set_arch }, + { "CacheDir", pk_backend_config_add_cachedir }, + { "CleanMethod", pk_backend_config_set_cleanmethod }, + { "DBPath", pk_backend_config_set_dbpath }, + { "LogFile", pk_backend_config_set_logfile }, + { "RootDir", pk_backend_config_set_root }, + { "XferCommand", pk_backend_config_set_xfercmd }, + { NULL, NULL } +}; + +static gboolean +pk_backend_config_set_string (PkBackendConfig *config, const gchar *option, + const gchar *s) +{ + gsize i; + + g_return_val_if_fail (config != NULL, FALSE); + g_return_val_if_fail (option != NULL, FALSE); + g_return_val_if_fail (s != NULL, FALSE); + + for (i = 0;; ++i) { + const gchar *name = pk_backend_config_string_options[i].name; + gint cmp = g_strcmp0 (option, name); + + if (name == NULL || cmp < 0) { + return FALSE; + } else if (cmp == 0) { + pk_backend_config_string_options[i].func (config, s); + return TRUE; + } + } +} + +static void +pk_backend_config_add_holdpkg (PkBackendConfig *config, gchar *package) +{ + g_return_if_fail (config != NULL); + g_return_if_fail (package != NULL); + + config->holdpkgs = alpm_list_add (config->holdpkgs, package); +} + +static void +pk_backend_config_add_ignoregrp (PkBackendConfig *config, gchar *group) +{ + g_return_if_fail (config != NULL); + g_return_if_fail (group != NULL); + + config->ignoregrps = alpm_list_add (config->ignoregrps, group); +} + +static void +pk_backend_config_add_ignorepkg (PkBackendConfig *config, gchar *package) +{ + g_return_if_fail (config != NULL); + g_return_if_fail (package != NULL); + + config->ignorepkgs = alpm_list_add (config->ignorepkgs, package); +} + +static void +pk_backend_config_add_noextract (PkBackendConfig *config, gchar *filename) +{ + g_return_if_fail (config != NULL); + g_return_if_fail (filename != NULL); + + config->noextracts = alpm_list_add (config->noextracts, filename); +} + +static void +pk_backend_config_add_noupgrade (PkBackendConfig *config, gchar *filename) +{ + g_return_if_fail (config != NULL); + g_return_if_fail (filename != NULL); + + config->noupgrades = alpm_list_add (config->noupgrades, filename); +} + +static void +pk_backend_config_add_syncfirst (PkBackendConfig *config, gchar *package) +{ + g_return_if_fail (config != NULL); + g_return_if_fail (package != NULL); + + config->syncfirsts = alpm_list_add (config->syncfirsts, package); +} + +typedef struct { + const gchar *name; + void (*func) (PkBackendConfig *config, gchar *value); +} PkBackendConfigList; + +/* keep this in alphabetical order */ +static const PkBackendConfigList pk_backend_config_list_options[] = { + { "HoldPkg", pk_backend_config_add_holdpkg }, + { "IgnoreGroup", pk_backend_config_add_ignoregrp }, + { "IgnorePkg", pk_backend_config_add_ignorepkg }, + { "NoExtract", pk_backend_config_add_noextract }, + { "NoUpgrade", pk_backend_config_add_noupgrade }, + { "SyncFirst", pk_backend_config_add_syncfirst }, + { NULL, NULL } +}; + +static void +pk_backend_config_list_add (PkBackendConfig *config, gsize option, + const gchar *list) +{ + gchar *str; + + for (str = strchr (list, ' '); str != NULL; str = strchr (list, ' ')) { + /* allocate normally */ + gchar *value = malloc ((++str - list) * sizeof (gchar)); + g_strlcpy (value, list, str - list); + pk_backend_config_list_options[option].func (config, value); + list = str; + } + pk_backend_config_list_options[option].func (config, strdup (list)); +} + +static gboolean +pk_backend_config_set_list (PkBackendConfig *config, const gchar *option, + const gchar *list) +{ + gsize i; + + g_return_val_if_fail (config != NULL, FALSE); + g_return_val_if_fail (option != NULL, FALSE); + g_return_val_if_fail (list != NULL, FALSE); + + for (i = 0;; ++i) { + const gchar *name = pk_backend_config_list_options[i].name; + gint cmp = g_strcmp0 (option, name); + + if (name == NULL || cmp < 0) { + return FALSE; + } else if (cmp == 0) { + pk_backend_config_list_add (config, i, list); + return TRUE; + } + } +} + +static void +pk_backend_config_add_repo (PkBackendConfig *config, const gchar *repo) +{ + g_return_if_fail (config != NULL); + g_return_if_fail (repo != NULL); + + if (alpm_list_find_str (config->repos, repo) == NULL) { + config->repos = alpm_list_add (config->repos, g_strdup (repo)); + } +} + +static gboolean +pk_backend_config_repo_add_server (PkBackendConfig *config, const gchar *repo, + const gchar *value, GError **e) +{ + alpm_list_t *list; + gchar *url; + + g_return_val_if_fail (config != NULL, FALSE); + g_return_val_if_fail (repo != NULL, FALSE); + g_return_val_if_fail (alpm_list_find_str (config->repos, repo) != NULL, + FALSE); + g_return_val_if_fail (value != NULL, FALSE); + + url = g_regex_replace_literal (config->xrepo, value, -1, 0, repo, 0, e); + if (url == NULL) { + return FALSE; + } + + if (config->arch != NULL) { + gchar *temp = url; + url = g_regex_replace_literal (config->xarch, temp, -1, 0, + config->arch, 0, e); + g_free (temp); + + if (url == NULL) { + return FALSE; + } + } else if (strstr (url, "$arch") != NULL) { + g_set_error (e, ALPM_ERROR, PM_ERR_CONFIG_INVALID, + "url contained $arch, which is not set"); + } + + list = (alpm_list_t *) g_hash_table_lookup (config->servers, repo); + list = alpm_list_add (list, url); + g_hash_table_insert (config->servers, g_strdup (repo), list); + + return TRUE; +} + +static gboolean +pk_backend_config_parse (PkBackendConfig *config, const gchar *filename, + gchar *section, GError **error) +{ + GFile *file; + GFileInputStream *is; + GDataInputStream *input; + + gchar *key, *str, *line = NULL; + guint num = 1; + + GError *e = NULL; + + g_return_val_if_fail (config != NULL, FALSE); + g_return_val_if_fail (filename != NULL, FALSE); + + file = g_file_new_for_path (filename); + is = g_file_read (file, NULL, &e); + + if (is == NULL) { + g_propagate_error (error, e); + g_object_unref (file); + return FALSE; + } + + input = g_data_input_stream_new (G_INPUT_STREAM (is)); + section = g_strdup (section); + + for (;; g_free (line), ++num) { + line = g_data_input_stream_read_line (input, NULL, NULL, &e); + + if (line != NULL) { + g_strstrip (line); + } else { + break; + } + + /* skip empty lines */ + if (*line == '\0' || *line == '#') { + continue; + } + + /* remove trailing comments */ + for (str = line; *str != '\0' && *str != '#'; ++str); + *str-- = '\0'; + + /* change sections */ + if (*line == '[' && *str == ']') { + *str = '\0'; + str = line + 1; + + if (*str == '\0') { + g_set_error (&e, ALPM_ERROR, + PM_ERR_CONFIG_INVALID, + "empty section name"); + break; + } + + g_free (section); + section = g_strdup (str); + + if (g_strcmp0 (section, "options") != 0) { + pk_backend_config_add_repo (config, section); + } + + continue; + } + + /* parse a directive */ + if (section == NULL) { + g_set_error (&e, ALPM_ERROR, PM_ERR_CONFIG_INVALID, + "directive must belong to a section"); + break; + } + + str = line; + key = strsep (&str, "="); + g_strchomp (key); + if (str != NULL) { + g_strchug (str); + } + + if (str == NULL) { + /* set a boolean directive */ + if (g_strcmp0 (section, "options") == 0 && + pk_backend_config_set_boolean (config, key)) { + continue; + } + /* report error below */ + } else if (g_strcmp0 (key, "Include") == 0) { + gsize i; + glob_t match = { 0 }; + + /* ignore globbing errors */ + if (glob (str, GLOB_NOCHECK, NULL, &match) != 0) { + continue; + } + + /* parse the files that matched */ + for (i = 0; i < match.gl_pathc; ++i) { + if (!pk_backend_config_parse (config, + match.gl_pathv[i], + section, &e)) { + break; + } + } + + globfree (&match); + if (e != NULL) { + break; + } else { + continue; + } + } else if (g_strcmp0 (section, "options") == 0) { + /* set a string or list directive */ + if (pk_backend_config_set_string (config, key, str) || + pk_backend_config_set_list (config, key, str)) { + continue; + } + /* report error below */ + } else if (g_strcmp0 (key, "Server") == 0) { + if (!pk_backend_config_repo_add_server (config, section, + str, &e)) { + break; + } else { + continue; + } + } + + /* report errors from above */ + g_set_error (&e, ALPM_ERROR, PM_ERR_CONFIG_INVALID, + "unrecognised directive '%s'", key); + break; + } + + g_free (section); + + g_object_unref (input); + g_object_unref (is); + g_object_unref (file); + + if (e != NULL) { + g_propagate_prefixed_error (error, e, "%s:%u", filename, num); + return FALSE; + } else { + return TRUE; + } +} + +static gboolean +pk_backend_config_configure_paths (PkBackendConfig *config, GError **error) +{ + g_return_val_if_fail (config != NULL, FALSE); + + if (config->root == NULL) { + config->root = g_strdup (PK_BACKEND_DEFAULT_ROOT); + } + + if (alpm_option_set_root (config->root) < 0) { + g_set_error (error, ALPM_ERROR, pm_errno, "RootDir: %s", + alpm_strerrorlast ()); + return FALSE; + } + + if (config->dbpath == NULL) { + config->dbpath = g_strconcat (alpm_option_get_root (), + PK_BACKEND_DEFAULT_DBPATH + 1, + NULL); + } + + if (alpm_option_set_dbpath (config->dbpath) < 0) { + g_set_error (error, ALPM_ERROR, pm_errno, "DBPath: %s", + alpm_strerrorlast ()); + return FALSE; + } + + if (config->logfile == NULL) { + config->logfile = g_strconcat (alpm_option_get_root (), + PK_BACKEND_DEFAULT_LOGFILE + 1, + NULL); + } + + alpm_option_set_logfile (config->logfile); + + if (config->cachedirs == NULL) { + gchar *path = g_strconcat (alpm_option_get_root (), + PK_BACKEND_DEFAULT_CACHEDIR + 1, + NULL); + config->cachedirs = alpm_list_add (NULL, path); + } + + /* alpm takes ownership */ + alpm_option_set_cachedirs (config->cachedirs); + config->cachedirs = NULL; + + return TRUE; +} + +static gboolean +pk_backend_config_configure_repos (PkBackendConfig *config, GError **error) +{ + const alpm_list_t *i; + + g_return_val_if_fail (config != NULL, FALSE); + + for (i = alpm_option_get_syncdbs (); i != NULL; i = i->next) { + if (alpm_db_unregister (i->data) < 0) { + g_set_error_literal (error, ALPM_ERROR, pm_errno, + alpm_strerrorlast ()); + return FALSE; + } + } + + for (i = config->repos; i != NULL; i = i->next) { + const gchar *key; + gpointer value; + pmdb_t *db; + alpm_list_t *j; + + key = (const gchar *) i->data; + value = g_hash_table_lookup (config->servers, key); + + db = alpm_db_register_sync (key); + if (db == NULL) { + g_set_error (error, ALPM_ERROR, pm_errno, "[%s]: %s", + key, alpm_strerrorlast ()); + return FALSE; + } + + for (j = (alpm_list_t *) value; j != NULL; j = j->next) { + alpm_db_setserver (db, (const gchar *) j->data); + } + } + + return TRUE; +} + +static gboolean +pk_backend_config_configure_alpm (PkBackendConfig *config, GError **error) +{ + g_return_val_if_fail (config != NULL, FALSE); + + if (!pk_backend_config_configure_paths (config, error)) { + return FALSE; + } + + alpm_option_set_checkspace (config->checkspace); + alpm_option_set_usedelta (config->usedelta); + alpm_option_set_usesyslog (config->usesyslog); + alpm_option_set_arch (config->arch); + + /* backend takes ownership */ + g_free (xfercmd); + xfercmd = config->xfercmd; + config->xfercmd = NULL; + + if (xfercmd != NULL) { + alpm_option_set_fetchcb (pk_backend_fetchcb); + } else { + alpm_option_set_fetchcb (NULL); + } + + /* backend takes ownership */ + FREELIST (holdpkgs); + holdpkgs = config->holdpkgs; + config->holdpkgs = NULL; + + /* backend takes ownership */ + FREELIST (syncfirsts); + syncfirsts = config->syncfirsts; + config->syncfirsts = NULL; + + /* alpm takes ownership */ + alpm_option_set_ignoregrps (config->ignoregrps); + config->ignoregrps = NULL; + + /* alpm takes ownership */ + alpm_option_set_ignorepkgs (config->ignorepkgs); + config->ignorepkgs = NULL; + + /* alpm takes ownership */ + alpm_option_set_noextracts (config->noextracts); + config->noextracts = NULL; + + /* alpm takes ownership */ + alpm_option_set_noupgrades (config->noupgrades); + config->noupgrades = NULL; + + if (!pk_backend_config_configure_repos (config, error)) { + return FALSE; + } + + return TRUE; +} + +gboolean +pk_backend_configure (const gchar *filename, GError **error) +{ + PkBackendConfig *config; + gboolean result; + + g_return_val_if_fail (filename != NULL, FALSE); + + config = pk_backend_config_new (); + + result = pk_backend_config_parse (config, filename, NULL, error) && + pk_backend_config_configure_alpm (config, error); + + pk_backend_config_free (config); + return result; +} diff --git a/backends/pacman/backend-error.h b/backends/alpm/pk-backend-config.h index 2be80218a..cb8b8dcf1 100644 --- a/backends/pacman/backend-error.h +++ b/backends/alpm/pk-backend-config.h @@ -1,8 +1,8 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- * * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> - * Copyright (C) 2008, 2009 Valeriy Lyasotskiy <onestep@ukr.net> - * Copyright (C) 2010 Jonathan Conder <j@skurvy.no-ip.org> + * Copyright (C) 2008-2010 Valeriy Lyasotskiy <onestep@ukr.net> + * Copyright (C) 2010-2011 Jonathan Conder <jonno.conder@gmail.com> * * Licensed under the GNU General Public License Version 2 * @@ -21,9 +21,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include <pk-backend.h> +#include <glib.h> -void backend_error (PkBackend *backend, - GError *error); -void backend_message (PkBackend *backend, - const gchar *message); +gboolean pk_backend_configure (const gchar *filename, GError **error); diff --git a/backends/alpm/pk-backend-databases.c b/backends/alpm/pk-backend-databases.c new file mode 100644 index 000000000..f6ab06e3d --- /dev/null +++ b/backends/alpm/pk-backend-databases.c @@ -0,0 +1,346 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> + * Copyright (C) 2008-2010 Valeriy Lyasotskiy <onestep@ukr.net> + * Copyright (C) 2010-2011 Jonathan Conder <jonno.conder@gmail.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "pk-backend-alpm.h" +#include "pk-backend-config.h" +#include "pk-backend-databases.h" +#include "pk-backend-error.h" + +static GHashTable *disabled = NULL; + +static GHashTable * +disabled_repos_new (GError **error) +{ + GHashTable *table; + GFile *file; + + GFileInputStream *is; + GDataInputStream *input; + + GError *e = NULL; + + g_debug ("reading disabled repos from %s", PK_BACKEND_REPO_FILE); + file = g_file_new_for_path (PK_BACKEND_REPO_FILE); + is = g_file_read (file, NULL, &e); + + if (is == NULL) { + g_object_unref (file); + g_propagate_error (error, e); + return NULL; + } + + table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); + input = g_data_input_stream_new (G_INPUT_STREAM (is)); + + /* read disabled repos line by line, ignoring comments */ + while (TRUE) { + gchar *line; + + line = g_data_input_stream_read_line (input, NULL, NULL, &e); + + if (line != NULL) { + g_strstrip (line); + } else { + break; + } + + if (*line == '\0' || *line == '#') { + g_free (line); + continue; + } + + g_hash_table_insert (table, line, GINT_TO_POINTER (1)); + } + + g_object_unref (input); + g_object_unref (is); + g_object_unref (file); + + if (e != NULL) { + g_hash_table_unref (table); + g_propagate_error (error, e); + return NULL; + } else { + return table; + } +} + +static void +disabled_repos_free (GHashTable *table) +{ + GHashTableIter iter; + GFile *file; + + GFileOutputStream *os; + GDataOutputStream *output; + + const gchar *line; + + g_return_if_fail (table != NULL); + + g_debug ("storing disabled repos in %s", PK_BACKEND_REPO_FILE); + file = g_file_new_for_path (PK_BACKEND_REPO_FILE); + os = g_file_replace (file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, NULL); + + if (os == NULL) { + g_object_unref (file); + g_hash_table_unref (table); + return; + } + + g_hash_table_iter_init (&iter, table); + output = g_data_output_stream_new (G_OUTPUT_STREAM (os)); + + /* write all disabled repos line by line */ + while (g_hash_table_iter_next (&iter, (gpointer *) &line, NULL) && + g_data_output_stream_put_string (output, line, NULL, NULL) && + g_data_output_stream_put_byte (output, '\n', NULL, NULL)); + + g_object_unref (output); + g_object_unref (os); + g_object_unref (file); + + g_hash_table_unref (table); +} + +static gboolean +disabled_repos_configure (GHashTable *table, GError **error) +{ + const alpm_list_t *i; + + g_debug ("reading config from %s", PK_BACKEND_CONFIG_FILE); + + /* read configuration from pacman.conf file */ + if (!pk_backend_configure (PK_BACKEND_CONFIG_FILE, error)) { + return FALSE; + } + + /* disable disabled repos */ + for (i = alpm_option_get_syncdbs (); i != NULL;) { + pmdb_t *db = (pmdb_t *) i->data; + const gchar *repo = alpm_db_get_name (db); + + if (g_hash_table_lookup (table, repo) == NULL) { + /* repo is not disabled */ + i = i->next; + continue; + } + + if (alpm_db_unregister (db) < 0) { + g_set_error (error, ALPM_ERROR, pm_errno, "[%s]: %s", + repo, alpm_strerrorlast ()); + return FALSE; + } + + /* start again because the list gets invalidated */ + i = alpm_option_get_syncdbs (); + } + + return TRUE; +} + +gboolean +pk_backend_initialize_databases (PkBackend *self, GError **error) +{ + g_return_val_if_fail (self != NULL, FALSE); + + disabled = disabled_repos_new (error); + if (disabled == NULL) { + return FALSE; + } + + if (!disabled_repos_configure (disabled, error)) { + return FALSE; + } + + return TRUE; +} + +void +pk_backend_destroy_databases (PkBackend *self) +{ + g_return_if_fail (self != NULL); + + if (disabled != NULL) { + disabled_repos_free (disabled); + } +} + +static gboolean +pk_backend_repo_info (PkBackend *self, const gchar *repo, gboolean enabled) +{ + gchar *description; + gboolean result; + + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (repo != NULL, FALSE); + + description = g_strdup_printf ("[%s]", repo); + result = pk_backend_repo_detail (self, repo, description, enabled); + g_free (description); + + return result; +} + +static gboolean +pk_backend_get_repo_list_thread (PkBackend *self) +{ + const alpm_list_t *i; + GHashTableIter iter; + gpointer key, value; + + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (disabled != NULL, FALSE); + + /* emit enabled repos */ + for (i = alpm_option_get_syncdbs (); i != NULL; i = i->next) { + pmdb_t *db = (pmdb_t *) i->data; + const gchar *repo = alpm_db_get_name (db); + + if (pk_backend_cancelled (self)) { + goto out; + } else { + pk_backend_repo_info (self, repo, TRUE); + } + } + + /* emit disabled repos */ + g_hash_table_iter_init (&iter, disabled); + while (g_hash_table_iter_next (&iter, &key, &value)) { + const gchar *repo = (const gchar *) key; + + if (pk_backend_cancelled (self)) { + goto out; + } else { + pk_backend_repo_info (self, repo, FALSE); + } + } + +out: + return pk_backend_finish (self, NULL); +} + +void +pk_backend_get_repo_list (PkBackend *self, PkBitfield filters) +{ + g_return_if_fail (self != NULL); + + pk_backend_run (self, PK_STATUS_ENUM_QUERY, + pk_backend_get_repo_list_thread); +} + +static gboolean +pk_backend_repo_enable_thread (PkBackend *self) +{ + const gchar *repo; + + GError *error = NULL; + + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (disabled != NULL, FALSE); + + repo = pk_backend_get_string (self, "repo_id"); + + g_return_val_if_fail (repo != NULL, FALSE); + + if (g_hash_table_remove (disabled, repo)) { + /* reload configuration to preserve ordering */ + if (disabled_repos_configure (disabled, &error)) { + pk_backend_repo_list_changed (self); + } + } else { + int code = PM_ERR_DB_NOT_NULL; + g_set_error (&error, ALPM_ERROR, code, "[%s]: %s", + repo, alpm_strerror (code)); + } + + if (error != NULL) { + pk_backend_error (self, error); + g_error_free (error); + } + + pk_backend_thread_finished (self); + return (error == NULL); +} + +static gboolean +pk_backend_repo_disable_thread (PkBackend *self) +{ + const alpm_list_t *i; + const gchar *repo; + + GError *error = NULL; + + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (disabled != NULL, FALSE); + + repo = pk_backend_get_string (self, "repo_id"); + + g_return_val_if_fail (repo != NULL, FALSE); + + for (i = alpm_option_get_syncdbs (); i != NULL; i = i->next) { + pmdb_t *db = (pmdb_t *) i->data; + const gchar *name = alpm_db_get_name (db); + + if (g_strcmp0 (repo, name) == 0) { + if (alpm_db_unregister (db) < 0) { + g_set_error (&error, ALPM_ERROR, pm_errno, + "[%s]: %s", repo, + alpm_strerrorlast ()); + } else { + g_hash_table_insert (disabled, g_strdup (repo), + GINT_TO_POINTER (1)); + } + break; + } + } + + if (i == NULL) { + int code = PM_ERR_DB_NULL; + g_set_error (&error, ALPM_ERROR, code, "[%s]: %s", repo, + alpm_strerror (code)); + } + + if (error != NULL) { + pk_backend_error (self, error); + g_error_free (error); + } + + pk_backend_thread_finished (self); + return (error == NULL); +} + +void +pk_backend_repo_enable (PkBackend *self, const gchar *repo_id, gboolean enabled) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (repo_id != NULL); + + pk_backend_set_status (self, PK_STATUS_ENUM_QUERY); + + if (enabled) { + pk_backend_thread_create (self, pk_backend_repo_enable_thread); + } else { + pk_backend_thread_create (self, pk_backend_repo_disable_thread); + } +} diff --git a/backends/pacman/backend-update.h b/backends/alpm/pk-backend-databases.h index 2a8bf02cf..f9eb2f950 100644 --- a/backends/pacman/backend-update.h +++ b/backends/alpm/pk-backend-databases.h @@ -1,8 +1,8 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- * * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> - * Copyright (C) 2008, 2009 Valeriy Lyasotskiy <onestep@ukr.net> - * Copyright (C) 2010 Jonathan Conder <j@skurvy.no-ip.org> + * Copyright (C) 2008-2010 Valeriy Lyasotskiy <onestep@ukr.net> + * Copyright (C) 2010-2011 Jonathan Conder <jonno.conder@gmail.com> * * Licensed under the GNU General Public License Version 2 * @@ -21,11 +21,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include <alpm.h> #include <pk-backend.h> -void backend_get_update_detail (PkBackend *backend, - gchar **package_ids); -void backend_get_updates (PkBackend *backend, - PkBitfield filters); -void backend_refresh_cache (PkBackend *backend, - gboolean force); +gboolean pk_backend_initialize_databases (PkBackend *self, + GError **error); + +void pk_backend_destroy_databases (PkBackend *self); diff --git a/backends/alpm/pk-backend-depends.c b/backends/alpm/pk-backend-depends.c new file mode 100644 index 000000000..8bb8567f1 --- /dev/null +++ b/backends/alpm/pk-backend-depends.c @@ -0,0 +1,269 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> + * Copyright (C) 2008-2010 Valeriy Lyasotskiy <onestep@ukr.net> + * Copyright (C) 2010-2011 Jonathan Conder <jonno.conder@gmail.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include <alpm.h> +#include <pk-backend.h> + +#include "pk-backend-alpm.h" +#include "pk-backend-depends.h" +#include "pk-backend-error.h" +#include "pk-backend-packages.h" + +static pmpkg_t * +alpm_list_find_pkg (const alpm_list_t *pkgs, const gchar *name) +{ + g_return_val_if_fail (name != NULL, NULL); + + for (; pkgs != NULL; pkgs = pkgs->next) { + if (g_strcmp0 (name, alpm_pkg_get_name (pkgs->data)) == 0) { + return pkgs->data; + } + } + + return NULL; +} + +static alpm_list_t * +pk_backend_find_provider (PkBackend *self, alpm_list_t *pkgs, + const gchar *depend, GError **error) +{ + PkBitfield filters; + gboolean recursive, skip_local, skip_remote; + + pmpkg_t *provider; + alpm_list_t *pkgcache, *syncdbs; + + g_return_val_if_fail (self != NULL, pkgs); + g_return_val_if_fail (depend != NULL, pkgs); + g_return_val_if_fail (localdb != NULL, pkgs); + + recursive = pk_backend_get_bool (self, "recursive"); + filters = pk_backend_get_uint (self, "filters"); + skip_local = pk_bitfield_contain (filters, + PK_FILTER_ENUM_NOT_INSTALLED); + skip_remote = pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED); + + if (alpm_find_satisfier (pkgs, depend) != NULL) { + return pkgs; + } + + /* look for local dependencies */ + pkgcache = alpm_db_get_pkgcache (localdb); + provider = alpm_find_satisfier (pkgcache, depend); + + if (provider != NULL) { + if (!skip_local) { + pk_backend_pkg (self, provider, PK_INFO_ENUM_INSTALLED); + /* assume later dependencies will also be local */ + if (recursive) { + pkgs = alpm_list_add (pkgs, provider); + } + } + + return pkgs; + } + + /* look for remote dependencies */ + syncdbs = alpm_option_get_syncdbs (); + provider = alpm_find_dbs_satisfier (syncdbs, depend); + + if (provider != NULL) { + if (!skip_remote) { + pk_backend_pkg (self, provider, PK_INFO_ENUM_AVAILABLE); + } + /* keep looking for local dependencies */ + if (recursive) { + pkgs = alpm_list_add (pkgs, provider); + } + } else { + int code = PM_ERR_UNSATISFIED_DEPS; + g_set_error (error, ALPM_ERROR, code, "%s: %s", depend, + alpm_strerror (code)); + } + + return pkgs; +} + +static alpm_list_t * +pk_backend_find_requirer (PkBackend *self, alpm_list_t *pkgs, const gchar *name, + GError **error) +{ + pmpkg_t *requirer; + + g_return_val_if_fail (self != NULL, pkgs); + g_return_val_if_fail (name != NULL, pkgs); + g_return_val_if_fail (localdb != NULL, pkgs); + + if (alpm_list_find_pkg (pkgs, name) != NULL) { + return pkgs; + } + + /* look for local requirers */ + requirer = alpm_db_get_pkg (localdb, name); + + if (requirer != NULL) { + pk_backend_pkg (self, requirer, PK_INFO_ENUM_INSTALLED); + if (pk_backend_get_bool (self, "recursive")) { + pkgs = alpm_list_add (pkgs, requirer); + } + } else { + int code = PM_ERR_PKG_NOT_FOUND; + g_set_error (error, ALPM_ERROR, code, "%s: %s", name, + alpm_strerror (code)); + } + + return pkgs; +} + +static gboolean +pk_backend_get_depends_thread (PkBackend *self) +{ + gchar **packages; + alpm_list_t *i, *pkgs = NULL; + GError *error = NULL; + + g_return_val_if_fail (self != NULL, FALSE); + + packages = pk_backend_get_strv (self, "package_ids"); + + g_return_val_if_fail (packages != NULL, FALSE); + + /* construct an initial package list */ + for (; *packages != NULL; ++packages) { + pmpkg_t *pkg; + + if (pk_backend_cancelled (self)) { + break; + } + + pkg = pk_backend_find_pkg (self, *packages, &error); + if (pkg == NULL) { + break; + } + + pkgs = alpm_list_add (pkgs, pkg); + } + + /* package list might be modified along the way but that is ok */ + for (i = pkgs; i != NULL; i = i->next) { + const alpm_list_t *depends; + + if (pk_backend_cancelled (self) || error != NULL) { + break; + } + + depends = alpm_pkg_get_depends (i->data); + for (; depends != NULL; depends = depends->next) { + gchar *depend; + + if (pk_backend_cancelled (self) || error != NULL) { + break; + } + + depend = alpm_dep_compute_string (depends->data); + pkgs = pk_backend_find_provider (self, pkgs, depend, + &error); + g_free (depend); + } + } + + alpm_list_free (pkgs); + return pk_backend_finish (self, NULL); +} + +static gboolean +pk_backend_get_requires_thread (PkBackend *self) +{ + gchar **packages; + alpm_list_t *i, *pkgs = NULL; + GError *error = NULL; + + g_return_val_if_fail (self != NULL, FALSE); + + packages = pk_backend_get_strv (self, "package_ids"); + + g_return_val_if_fail (packages != NULL, FALSE); + + /* construct an initial package list */ + for (; *packages != NULL; ++packages) { + pmpkg_t *pkg; + + if (pk_backend_cancelled (self)) { + break; + } + + pkg = pk_backend_find_pkg (self, *packages, &error); + if (pkg == NULL) { + break; + } + + pkgs = alpm_list_add (pkgs, pkg); + } + + /* package list might be modified along the way but that is ok */ + for (i = pkgs; i != NULL; i = i->next) { + alpm_list_t *requiredby; + + if (pk_backend_cancelled (self) || error != NULL) { + break; + } + + requiredby = alpm_pkg_compute_requiredby (i->data); + for (; requiredby != NULL; requiredby = requiredby->next) { + if (pk_backend_cancelled (self) || error != NULL) { + break; + } + + pkgs = pk_backend_find_requirer (self, pkgs, + requiredby->data, + &error); + } + + FREELIST (requiredby); + } + + alpm_list_free (pkgs); + return pk_backend_finish (self, error); +} + +void +pk_backend_get_depends (PkBackend *self, PkBitfield filters, + gchar **package_ids, gboolean recursive) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (package_ids != NULL); + + pk_backend_run (self, PK_STATUS_ENUM_QUERY, + pk_backend_get_depends_thread); +} + +void +pk_backend_get_requires (PkBackend *self, PkBitfield filters, + gchar **package_ids, gboolean recursive) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (package_ids != NULL); + + pk_backend_run (self, PK_STATUS_ENUM_QUERY, + pk_backend_get_requires_thread); +} diff --git a/backends/alpm/pk-backend-depends.h b/backends/alpm/pk-backend-depends.h new file mode 100644 index 000000000..368965a01 --- /dev/null +++ b/backends/alpm/pk-backend-depends.h @@ -0,0 +1,22 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> + * Copyright (C) 2008-2010 Valeriy Lyasotskiy <onestep@ukr.net> + * Copyright (C) 2010-2011 Jonathan Conder <jonno.conder@gmail.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ diff --git a/backends/alpm/pk-backend-error.c b/backends/alpm/pk-backend-error.c new file mode 100644 index 000000000..63831750f --- /dev/null +++ b/backends/alpm/pk-backend-error.c @@ -0,0 +1,203 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> + * Copyright (C) 2008-2010 Valeriy Lyasotskiy <onestep@ukr.net> + * Copyright (C) 2010-2011 Jonathan Conder <jonno.conder@gmail.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include <alpm.h> + +#include "pk-backend-error.h" + +static void +pk_backend_output_locked (PkBackend *self) +{ + gchar *output; + + g_return_if_fail (self != NULL); + + output = g_strdup_printf ("If you are certain no other package manager " + "is running, you can remove %s\n", + alpm_option_get_lockfile ()); + pk_backend_output (self, output); + g_free (output); +} + +void +pk_backend_error (PkBackend *self, GError *error) +{ + PkErrorEnum code = PK_ERROR_ENUM_UNKNOWN; + + g_return_if_fail (self != NULL); + g_return_if_fail (error != NULL); + + if (error->domain == ALPM_ERROR) { + switch (error->code) { + case PM_ERR_MEMORY: + case PM_ERR_SYSTEM: + code = PK_ERROR_ENUM_OOM; + break; + + case PM_ERR_BADPERMS: + code = PK_ERROR_ENUM_NOT_AUTHORIZED; + break; + + case PM_ERR_NOT_A_FILE: + case PM_ERR_NOT_A_DIR: + code = PK_ERROR_ENUM_FILE_NOT_FOUND; + break; + + case PM_ERR_WRONG_ARGS: + case PM_ERR_HANDLE_NULL: + case PM_ERR_DB_NULL: + case PM_ERR_TRANS_NULL: + case PM_ERR_TRANS_NOT_INITIALIZED: + case PM_ERR_TRANS_NOT_PREPARED: + case PM_ERR_TRANS_NOT_LOCKED: + case PM_ERR_INVALID_REGEX: + code = PK_ERROR_ENUM_INTERNAL_ERROR; + break; + + case PM_ERR_DISK_SPACE: + code = PK_ERROR_ENUM_NO_SPACE_ON_DEVICE; + break; + + case PM_ERR_HANDLE_NOT_NULL: + case PM_ERR_DB_NOT_NULL: + case PM_ERR_TRANS_NOT_NULL: + code = PK_ERROR_ENUM_FAILED_INITIALIZATION; + break; + + case PM_ERR_HANDLE_LOCK: + code = PK_ERROR_ENUM_CANNOT_GET_LOCK; + pk_backend_output_locked (self); + break; + + case PM_ERR_DB_OPEN: + case PM_ERR_DB_NOT_FOUND: + case PM_ERR_PKG_REPO_NOT_FOUND: + code = PK_ERROR_ENUM_REPO_NOT_FOUND; + break; + + case PM_ERR_DB_CREATE: + code = PK_ERROR_ENUM_CANNOT_WRITE_REPO_CONFIG; + break; + + case PM_ERR_DB_VERSION: + case PM_ERR_DB_REMOVE: + code = PK_ERROR_ENUM_REPO_CONFIGURATION_ERROR; + break; + + case PM_ERR_DB_WRITE: + code = PK_ERROR_ENUM_REPO_NOT_AVAILABLE; + break; + + case PM_ERR_SERVER_BAD_URL: + code = PK_ERROR_ENUM_REPO_CONFIGURATION_ERROR; + break; + + case PM_ERR_SERVER_NONE: + code = PK_ERROR_ENUM_NO_MORE_MIRRORS_TO_TRY; + break; + + case PM_ERR_TRANS_DUP_TARGET: + case PM_ERR_TRANS_ABORT: + code = PK_ERROR_ENUM_TRANSACTION_ERROR; + break; + + case PM_ERR_TRANS_TYPE: + code = PK_ERROR_ENUM_CANNOT_CANCEL; + break; + + case PM_ERR_PKG_NOT_FOUND: + code = PK_ERROR_ENUM_PACKAGE_NOT_FOUND; + break; + + case PM_ERR_PKG_IGNORED: + code = PK_ERROR_ENUM_PACKAGE_INSTALL_BLOCKED; + break; + + case PM_ERR_PKG_INVALID: + case PM_ERR_PKG_OPEN: + case PM_ERR_PKG_INVALID_NAME: + case PM_ERR_DLT_INVALID: + code = PK_ERROR_ENUM_INVALID_PACKAGE_FILE; + break; + + case PM_ERR_PKG_CANT_REMOVE: + code = PK_ERROR_ENUM_PACKAGE_FAILED_TO_REMOVE; + break; + + case PM_ERR_PKG_INVALID_ARCH: + code = PK_ERROR_ENUM_INCOMPATIBLE_ARCHITECTURE; + break; + + case PM_ERR_DLT_PATCHFAILED: + code = PK_ERROR_ENUM_PACKAGE_FAILED_TO_BUILD; + break; + + case PM_ERR_UNSATISFIED_DEPS: + code = PK_ERROR_ENUM_DEP_RESOLUTION_FAILED; + break; + + case PM_ERR_CONFLICTING_DEPS: + code = PK_ERROR_ENUM_PACKAGE_CONFLICTS; + break; + + case PM_ERR_FILE_CONFLICTS: + code = PK_ERROR_ENUM_FILE_CONFLICTS; + break; + + case PM_ERR_RETRIEVE: + case PM_ERR_LIBFETCH: + case PM_ERR_EXTERNAL_DOWNLOAD: + code = PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED; + break; + + case PM_ERR_LIBARCHIVE: + code = PK_ERROR_ENUM_LOCAL_INSTALL_FAILED; + break; + + case PM_ERR_CONFIG_INVALID: + code = PK_ERROR_ENUM_CANNOT_REMOVE_SYSTEM_PACKAGE; + break; + + case PM_ERR_PKG_HELD: + code = PK_ERROR_ENUM_CANNOT_REMOVE_SYSTEM_PACKAGE; + break; + } + } + + pk_backend_error_code (self, code, "%s", error->message); +} + +void +pk_backend_output (PkBackend *self, const gchar *output) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (output != NULL); + + pk_backend_message (self, PK_MESSAGE_ENUM_UNKNOWN, "%s", output); +} + +GQuark +alpm_error_quark (void) +{ + return g_quark_from_static_string ("alpm-error-quark"); +} diff --git a/backends/alpm/pk-backend-error.h b/backends/alpm/pk-backend-error.h new file mode 100644 index 000000000..b01b06d10 --- /dev/null +++ b/backends/alpm/pk-backend-error.h @@ -0,0 +1,37 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> + * Copyright (C) 2008-2010 Valeriy Lyasotskiy <onestep@ukr.net> + * Copyright (C) 2010-2011 Jonathan Conder <jonno.conder@gmail.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include <pk-backend.h> + +#define ALPM_ERROR (alpm_error_quark ()) + +enum { + PM_ERR_CONFIG_INVALID = 0x10000, + PM_ERR_PKG_HELD +}; + +void pk_backend_error (PkBackend *self, GError *error); + +void pk_backend_output (PkBackend *self, const gchar *output); + +GQuark alpm_error_quark (void); diff --git a/backends/pacman/backend-groups.c b/backends/alpm/pk-backend-groups.c index 95ebce61f..59e304dc2 100644 --- a/backends/pacman/backend-groups.c +++ b/backends/alpm/pk-backend-groups.c @@ -1,8 +1,8 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- * * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> - * Copyright (C) 2008, 2009 Valeriy Lyasotskiy <onestep@ukr.net> - * Copyright (C) 2010 Jonathan Conder <j@skurvy.no-ip.org> + * Copyright (C) 2008-2010 Valeriy Lyasotskiy <onestep@ukr.net> + * Copyright (C) 2010-2011 Jonathan Conder <jonno.conder@gmail.com> * * Licensed under the GNU General Public License Version 2 * @@ -21,12 +21,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include <string.h> #include <gio/gio.h> -#include "backend-error.h" -#include "backend-groups.h" +#include <string.h> + +#include "pk-backend-groups.h" -static GHashTable *group_map = NULL; +static GHashTable *grps = NULL; static PkBitfield groups = 0; static GHashTable * @@ -35,36 +35,43 @@ group_map_new (GError **error) GHashTable *map; GFile *file; - GFileInputStream *file_stream; - GDataInputStream *data_stream; + GFileInputStream *is; + GDataInputStream *input; - gchar *key, *value; GError *e = NULL; - g_debug ("pacman: reading groups from %s", PACMAN_GROUP_LIST); - file = g_file_new_for_path (PACMAN_GROUP_LIST); - file_stream = g_file_read (file, NULL, &e); + g_debug ("reading group map from %s", PK_BACKEND_GROUP_FILE); + file = g_file_new_for_path (PK_BACKEND_GROUP_FILE); + is = g_file_read (file, NULL, &e); - if (file_stream == NULL) { + if (is == NULL) { g_object_unref (file); g_propagate_error (error, e); return NULL; } map = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - data_stream = g_data_input_stream_new (G_INPUT_STREAM (file_stream)); + input = g_data_input_stream_new (G_INPUT_STREAM (is)); /* read groups line by line, ignoring comments */ - while ((value = g_data_input_stream_read_line (data_stream, NULL, NULL, &e)) != NULL) { + while (TRUE) { PkGroupEnum group; + gchar *key, *value; + + value = g_data_input_stream_read_line (input, NULL, NULL, &e); + + if (value != NULL) { + g_strstrip (value); + } else { + break; + } - g_strstrip (value); if (*value == '\0' || *value == '#') { g_free (value); continue; } - /* line format: alpm-group (space|tab)+ packagekit-group */ + /* line format: grp (space|tab)+ group */ key = strsep (&value, " "); g_strchomp (key); @@ -78,14 +85,14 @@ group_map_new (GError **error) } if (group != PK_GROUP_ENUM_UNKNOWN) { - /* use replace because key and value are allocated together */ + /* key and value are allocated together */ g_hash_table_replace (map, key, value); pk_bitfield_add (groups, group); } } - g_object_unref (data_stream); - g_object_unref (file_stream); + g_object_unref (input); + g_object_unref (is); g_object_unref (file); if (e != NULL) { @@ -98,39 +105,37 @@ group_map_new (GError **error) } gboolean -backend_initialize_groups (PkBackend *backend, GError **error) +pk_backend_initialize_groups (PkBackend *self, GError **error) { - g_return_val_if_fail (backend != NULL, FALSE); + g_return_val_if_fail (self != NULL, FALSE); - group_map = group_map_new (error); - if (group_map == NULL) { - return FALSE; - } + grps = group_map_new (error); - return TRUE; + return (grps != NULL); } void -backend_destroy_groups (PkBackend *backend) +pk_backend_destroy_groups (PkBackend *self) { - g_return_if_fail (backend != NULL); + g_return_if_fail (self != NULL); - if (group_map != NULL) { - g_hash_table_unref (group_map); + if (grps != NULL) { + g_hash_table_unref (grps); } } const gchar * -pacman_package_get_group (PacmanPackage *package) +alpm_pkg_get_group (pmpkg_t *pkg) { - const PacmanList *list; + const alpm_list_t *i; - g_return_val_if_fail (group_map != NULL, NULL); - g_return_val_if_fail (package != NULL, NULL); + g_return_val_if_fail (pkg != NULL, NULL); + g_return_val_if_fail (grps != NULL, NULL); /* use the first group that we recognise */ - for (list = pacman_package_get_groups (package); list != NULL; list = pacman_list_next (list)) { - gpointer value = g_hash_table_lookup (group_map, pacman_list_get (list)); + for (i = alpm_pkg_get_groups (pkg); i != NULL; i = i->next) { + gpointer value = g_hash_table_lookup (grps, i->data); + if (value != NULL) { return (const gchar *) value; } @@ -139,12 +144,10 @@ pacman_package_get_group (PacmanPackage *package) return "other"; } -/** - * backend_get_groups: - **/ -PkBitfield backend_get_groups (PkBackend *backend) +PkBitfield +pk_backend_get_groups (PkBackend *self) { - g_return_val_if_fail (backend != NULL, 0); + g_return_val_if_fail (self != NULL, 0); return groups; } diff --git a/backends/pacman/backend-depends.h b/backends/alpm/pk-backend-groups.h index c6f7b6aac..28dcf65aa 100644 --- a/backends/pacman/backend-depends.h +++ b/backends/alpm/pk-backend-groups.h @@ -1,8 +1,8 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- * * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> - * Copyright (C) 2008, 2009 Valeriy Lyasotskiy <onestep@ukr.net> - * Copyright (C) 2010 Jonathan Conder <j@skurvy.no-ip.org> + * Copyright (C) 2008-2010 Valeriy Lyasotskiy <onestep@ukr.net> + * Copyright (C) 2010-2011 Jonathan Conder <jonno.conder@gmail.com> * * Licensed under the GNU General Public License Version 2 * @@ -21,13 +21,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include <alpm.h> #include <pk-backend.h> -void backend_get_depends (PkBackend *backend, - PkBitfield filters, - gchar **package_ids, - gboolean recursive); -void backend_get_requires (PkBackend *backend, - PkBitfield filters, - gchar **package_ids, - gboolean recursive); +gboolean pk_backend_initialize_groups (PkBackend *self, + GError **error); + +void pk_backend_destroy_groups (PkBackend *self); + +const gchar *alpm_pkg_get_group (pmpkg_t *pkg); diff --git a/backends/alpm/pk-backend-install.c b/backends/alpm/pk-backend-install.c new file mode 100644 index 000000000..65a6c1127 --- /dev/null +++ b/backends/alpm/pk-backend-install.c @@ -0,0 +1,124 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> + * Copyright (C) 2008-2010 Valeriy Lyasotskiy <onestep@ukr.net> + * Copyright (C) 2010-2011 Jonathan Conder <jonno.conder@gmail.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include <alpm.h> +#include <pk-backend.h> + +#include "pk-backend-alpm.h" +#include "pk-backend-error.h" +#include "pk-backend-install.h" +#include "pk-backend-transaction.h" + +static gint +alpm_add_file (const gchar *filename) +{ + pmpkg_t *pkg; + + g_return_val_if_fail (filename != NULL, -1); + + if (alpm_pkg_load (filename, 1, &pkg) < 0) { + return -1; + } + + if (alpm_add_pkg (pkg) < 0) { + alpm_pkg_free (pkg); + return -1; + } + + return 0; +} + +static gboolean +pk_backend_transaction_add_targets (PkBackend *self, GError **error) +{ + gchar **paths; + + g_return_val_if_fail (self != NULL, FALSE); + + paths = pk_backend_get_strv (self, "full_paths"); + + g_return_val_if_fail (paths != NULL, FALSE); + + for (; *paths != NULL; ++paths) { + if (alpm_add_file (*paths) < 0) { + g_set_error (error, ALPM_ERROR, pm_errno, "%s: %s", + *paths, alpm_strerrorlast ()); + return FALSE; + } + } + + return TRUE; +} + +static gboolean +pk_backend_simulate_install_files_thread (PkBackend *self) +{ + GError *error = NULL; + + g_return_val_if_fail (self != NULL, FALSE); + + if (pk_backend_transaction_initialize (self, 0, &error) && + pk_backend_transaction_add_targets (self, &error) && + pk_backend_transaction_simulate (self, &error)) { + pk_backend_transaction_packages (self); + } + + return pk_backend_transaction_finish (self, error); +} + +static gboolean +pk_backend_install_files_thread (PkBackend *self) +{ + GError *error = NULL; + + g_return_val_if_fail (self != NULL, FALSE); + + if (pk_backend_transaction_initialize (self, 0, &error) && + pk_backend_transaction_add_targets (self, &error) && + pk_backend_transaction_simulate (self, &error)) { + pk_backend_transaction_commit (self, &error); + } + + return pk_backend_transaction_finish (self, error); +} + +void +pk_backend_simulate_install_files (PkBackend *self, gchar **paths) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (paths != NULL); + + pk_backend_run (self, PK_STATUS_ENUM_SETUP, + pk_backend_simulate_install_files_thread); +} + +void +pk_backend_install_files (PkBackend *self, gboolean only_trusted, + gchar **full_paths) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (full_paths != NULL); + + pk_backend_run (self, PK_STATUS_ENUM_SETUP, + pk_backend_install_files_thread); +} diff --git a/backends/alpm/pk-backend-install.h b/backends/alpm/pk-backend-install.h new file mode 100644 index 000000000..368965a01 --- /dev/null +++ b/backends/alpm/pk-backend-install.h @@ -0,0 +1,22 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> + * Copyright (C) 2008-2010 Valeriy Lyasotskiy <onestep@ukr.net> + * Copyright (C) 2010-2011 Jonathan Conder <jonno.conder@gmail.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ diff --git a/backends/alpm/pk-backend-packages.c b/backends/alpm/pk-backend-packages.c new file mode 100644 index 000000000..e9a7c94e6 --- /dev/null +++ b/backends/alpm/pk-backend-packages.c @@ -0,0 +1,363 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> + * Copyright (C) 2008-2010 Valeriy Lyasotskiy <onestep@ukr.net> + * Copyright (C) 2010-2011 Jonathan Conder <jonno.conder@gmail.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "pk-backend-alpm.h" +#include "pk-backend-error.h" +#include "pk-backend-groups.h" +#include "pk-backend-packages.h" + +gchar * +alpm_pkg_build_id (pmpkg_t *pkg) +{ + const gchar *name, *version, *arch, *repo; + pmdb_t *db; + + g_return_val_if_fail (pkg != NULL, NULL); + g_return_val_if_fail (localdb != NULL, NULL); + + name = alpm_pkg_get_name (pkg); + version = alpm_pkg_get_version (pkg); + + arch = alpm_pkg_get_arch (pkg); + if (arch == NULL) { + arch = "any"; + } + + db = alpm_pkg_get_db (pkg); + /* TODO: check */ + if (db == NULL || db == localdb) { + repo = "installed"; + } else { + repo = alpm_db_get_name (db); + } + + return pk_package_id_build (name, version, arch, repo); +} + +void +pk_backend_pkg (PkBackend *self, pmpkg_t *pkg, PkInfoEnum info) +{ + gchar *package; + + g_return_if_fail (self != NULL); + g_return_if_fail (pkg != NULL); + + package = alpm_pkg_build_id (pkg); + pk_backend_package (self, info, package, alpm_pkg_get_desc (pkg)); + g_free (package); +} + +pmpkg_t * +pk_backend_find_pkg (PkBackend *self, const gchar *package_id, GError **error) +{ + gchar **package; + const gchar *repo_id; + pmdb_t *db = NULL; + pmpkg_t *pkg; + + g_return_val_if_fail (self != NULL, NULL); + g_return_val_if_fail (package_id != NULL, NULL); + g_return_val_if_fail (localdb != NULL, NULL); + + package = pk_package_id_split (package_id); + repo_id = package[PK_PACKAGE_ID_DATA]; + + /* find the database to search in */ + if (g_strcmp0 (repo_id, "installed") == 0) { + db = localdb; + } else { + const alpm_list_t *i; + for (i = alpm_option_get_syncdbs (); i != NULL; i = i->next) { + const gchar *repo = alpm_db_get_name (i->data); + + if (g_strcmp0 (repo, repo_id) == 0) { + db = i->data; + break; + } + } + } + + if (db != NULL) { + pkg = alpm_db_get_pkg (db, package[PK_PACKAGE_ID_NAME]); + } else { + pkg = NULL; + } + + if (pkg != NULL) { + const gchar *version = alpm_pkg_get_version (pkg); + if (g_strcmp0 (version, package[PK_PACKAGE_ID_VERSION]) != 0) { + pkg = NULL; + } + } + + if (pkg == NULL) { + int code = PM_ERR_PKG_NOT_FOUND; + g_set_error (error, ALPM_ERROR, code, "%s: %s", package_id, + alpm_strerror (code)); + } + g_strfreev (package); + return pkg; +} + +static gboolean +pk_backend_resolve_package (PkBackend *self, const gchar *package, + GError **error) +{ + pmpkg_t *pkg; + + PkBitfield filters; + gboolean skip_local, skip_remote; + + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (package != NULL, FALSE); + g_return_val_if_fail (localdb != NULL, FALSE); + + pkg = pk_backend_find_pkg (self, package, error); + if (pkg == NULL) { + return FALSE; + } + + filters = pk_backend_get_uint (self, "filters"); + skip_local = pk_bitfield_contain (filters, + PK_FILTER_ENUM_NOT_INSTALLED); + skip_remote = pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED); + + if (alpm_pkg_get_db (pkg) == localdb) { + if (!skip_local) { + pk_backend_pkg (self, pkg, PK_INFO_ENUM_INSTALLED); + } + } else { + if (!skip_remote) { + pk_backend_pkg (self, pkg, PK_INFO_ENUM_AVAILABLE); + } + } + + return TRUE; +} + +static gboolean +pk_backend_resolve_name (PkBackend *self, const gchar *name, GError **error) +{ + pmpkg_t *pkg; + int code; + + PkBitfield filters; + gboolean skip_local, skip_remote; + + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (name != NULL, FALSE); + g_return_val_if_fail (localdb != NULL, FALSE); + + filters = pk_backend_get_uint (self, "filters"); + skip_local = pk_bitfield_contain (filters, + PK_FILTER_ENUM_NOT_INSTALLED); + skip_remote = pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED); + + pkg = alpm_db_get_pkg (localdb, name); + if (pkg != NULL) { + if (!skip_local) { + pk_backend_pkg (self, pkg, PK_INFO_ENUM_INSTALLED); + return TRUE; + } + } else if (!skip_remote) { + const alpm_list_t *i; + for (i = alpm_option_get_syncdbs (); i != NULL; i = i->next) { + pkg = alpm_db_get_pkg (i->data, name); + if (pkg != NULL) { + pk_backend_pkg (self, pkg, + PK_INFO_ENUM_AVAILABLE); + return TRUE; + } + } + } + + code = PM_ERR_PKG_NOT_FOUND; + g_set_error (error, ALPM_ERROR, code, "%s: %s", name, + alpm_strerror (code)); + return FALSE; +} + +static gboolean +pk_backend_resolve_thread (PkBackend *self) +{ + gchar **packages; + GError *error = NULL; + + g_return_val_if_fail (self != NULL, FALSE); + + packages = pk_backend_get_strv (self, "package_ids"); + + g_return_val_if_fail (packages != NULL, FALSE); + + for (; *packages != NULL; ++packages) { + if (pk_backend_cancelled (self)) { + break; + } + + /* find a package with the given id or name */ + if (pk_package_id_check (*packages)) { + if (!pk_backend_resolve_package (self, *packages, + &error)) { + break; + } + } else { + if (!pk_backend_resolve_name (self, *packages, + &error)) { + break; + } + } + } + + return pk_backend_finish (self, error); +} + +void +pk_backend_resolve (PkBackend *self, PkBitfield filters, gchar **package_ids) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (package_ids != NULL); + + pk_backend_run (self, PK_STATUS_ENUM_QUERY, pk_backend_resolve_thread); +} + +static gboolean +pk_backend_get_details_thread (PkBackend *self) +{ + gchar **packages; + GError *error = NULL; + + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (localdb != NULL, FALSE); + + packages = pk_backend_get_strv (self, "package_ids"); + + g_return_val_if_fail (packages != NULL, FALSE); + + for (; *packages != NULL; ++packages) { + pmpkg_t *pkg; + const alpm_list_t *i; + + GString *licenses; + PkGroupEnum group; + const gchar *desc, *url; + gulong size; + + if (pk_backend_cancelled (self)) { + break; + } + + pkg = pk_backend_find_pkg (self, *packages, &error); + if (pkg == NULL) { + break; + } + + licenses = g_string_new (""); + i = alpm_pkg_get_licenses (pkg); + for (; i != NULL; i = i->next) { + /* assume OR although it may not be correct */ + g_string_append_printf (licenses, " or %s", + (const gchar *) i->data); + } + if (licenses->len == 0) { + g_string_append (licenses, " or Unknown"); + } + + group = pk_group_enum_from_string (alpm_pkg_get_group (pkg)); + desc = alpm_pkg_get_desc (pkg); + url = alpm_pkg_get_url (pkg); + + if (alpm_pkg_get_db (pkg) == localdb) { + size = alpm_pkg_get_isize (pkg); + } else { + size = alpm_pkg_download_size (pkg); + } + + pk_backend_details (self, *packages, licenses->str + 4, group, + desc, url, size); + g_string_free (licenses, TRUE); + } + + return pk_backend_finish (self, error); +} + +void +pk_backend_get_details (PkBackend *self, gchar **package_ids) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (package_ids != NULL); + + pk_backend_run (self, PK_STATUS_ENUM_QUERY, + pk_backend_get_details_thread); +} + +static gboolean +pk_backend_get_files_thread (PkBackend *self) +{ + gchar **packages; + GError *error = NULL; + + g_return_val_if_fail (self != NULL, FALSE); + + packages = pk_backend_get_strv (self, "package_ids"); + + g_return_val_if_fail (packages != NULL, FALSE); + + for (; *packages != NULL; ++packages) { + pmpkg_t *pkg; + const alpm_list_t *i; + + GString *files; + const gchar *root; + + if (pk_backend_cancelled (self)) { + break; + } + + pkg = pk_backend_find_pkg (self, *packages, &error); + if (pkg == NULL) { + break; + } + + files = g_string_new (""); + root = alpm_option_get_root (); + for (i = alpm_pkg_get_files (pkg); i != NULL; i = i->next) { + g_string_append_printf (files, ";%s%s", root, + (const gchar *) i->data); + } + + pk_backend_files (self, *packages, files->str + 1); + g_string_free (files, TRUE); + } + + return pk_backend_finish (self, error); +} + +void +pk_backend_get_files (PkBackend *self, gchar **package_ids) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (package_ids != NULL); + + pk_backend_run (self, PK_STATUS_ENUM_QUERY, + pk_backend_get_files_thread); +} diff --git a/backends/pacman/backend-remove.h b/backends/alpm/pk-backend-packages.h index 90f0374d9..4b2d7f85f 100644 --- a/backends/pacman/backend-remove.h +++ b/backends/alpm/pk-backend-packages.h @@ -1,8 +1,8 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- * * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> - * Copyright (C) 2008, 2009 Valeriy Lyasotskiy <onestep@ukr.net> - * Copyright (C) 2010 Jonathan Conder <j@skurvy.no-ip.org> + * Copyright (C) 2008-2010 Valeriy Lyasotskiy <onestep@ukr.net> + * Copyright (C) 2010-2011 Jonathan Conder <jonno.conder@gmail.com> * * Licensed under the GNU General Public License Version 2 * @@ -21,12 +21,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include <alpm.h> #include <pk-backend.h> -void backend_remove_packages (PkBackend *backend, - gchar **package_ids, - gboolean allow_deps, - gboolean autoremove); -void backend_simulate_remove_packages (PkBackend *backend, - gchar **package_ids, - gboolean autoremove); +gchar *alpm_pkg_build_id (pmpkg_t *pkg); + +void pk_backend_pkg (PkBackend *self, pmpkg_t *pkg, + PkInfoEnum info); + +pmpkg_t *pk_backend_find_pkg (PkBackend *self, const gchar *package_id, + GError **error); diff --git a/backends/alpm/pk-backend-remove.c b/backends/alpm/pk-backend-remove.c new file mode 100644 index 000000000..03329b1aa --- /dev/null +++ b/backends/alpm/pk-backend-remove.c @@ -0,0 +1,167 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> + * Copyright (C) 2008-2010 Valeriy Lyasotskiy <onestep@ukr.net> + * Copyright (C) 2010-2011 Jonathan Conder <jonno.conder@gmail.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include <alpm.h> +#include <pk-backend.h> + +#include "pk-backend-alpm.h" +#include "pk-backend-error.h" +#include "pk-backend-remove.h" +#include "pk-backend-transaction.h" + +static gint +alpm_remove_local (const gchar *name) +{ + pmpkg_t *pkg; + + g_return_val_if_fail (name != NULL, -1); + g_return_val_if_fail (localdb != NULL, -1); + + pkg = alpm_db_get_pkg (localdb, name); + if (pkg == NULL) { + pm_errno = PM_ERR_PKG_NOT_FOUND; + return -1; + } + + return alpm_remove_pkg (pkg); +} + +static gboolean +pk_backend_transaction_remove_targets (PkBackend *self, GError **error) +{ + gchar **packages; + + g_return_val_if_fail (self != NULL, FALSE); + + packages = pk_backend_get_strv (self, "package_ids"); + + g_return_val_if_fail (packages != NULL, FALSE); + + for (; *packages != NULL; ++packages) { + gchar **package = pk_package_id_split (*packages); + gchar *name = package[PK_PACKAGE_ID_NAME]; + + if (alpm_remove_local (name) < 0) { + g_set_error (error, ALPM_ERROR, pm_errno, "%s: %s", + name, alpm_strerrorlast ()); + g_strfreev (package); + return FALSE; + } + + g_strfreev (package); + } + + return TRUE; +} + +static gboolean +pk_backend_transaction_remove_simulate (PkBackend *self, GError **error) +{ + const alpm_list_t *i; + + if (!pk_backend_transaction_simulate (self, error)) { + return FALSE; + } + + for (i = alpm_trans_get_remove (); i != NULL; i = i->next) { + const gchar *name = alpm_pkg_get_name (i->data); + if (alpm_list_find_str (holdpkgs, name)) { + g_set_error (error, ALPM_ERROR, PM_ERR_PKG_HELD, + "%s: %s", name, + "could not remove HoldPkg"); + return FALSE; + } + } + + return TRUE; +} + +static gboolean +pk_backend_simulate_remove_packages_thread (PkBackend *self) +{ + pmtransflag_t flags = PM_TRANS_FLAG_CASCADE; + GError *error = NULL; + + g_return_val_if_fail (self != NULL, FALSE); + + /* remove unneeded packages that were required by those to be removed */ + if (pk_backend_get_bool (self, "autoremove")) { + flags |= PM_TRANS_FLAG_RECURSE; + } + + if (pk_backend_transaction_initialize (self, flags, &error) && + pk_backend_transaction_remove_targets (self, &error) && + pk_backend_transaction_remove_simulate (self, &error)) { + pk_backend_transaction_packages (self); + } + + return pk_backend_transaction_finish (self, error); +} + +static gboolean +pk_backend_remove_packages_thread (PkBackend *self) +{ + pmtransflag_t flags = 0; + GError *error = NULL; + + g_return_val_if_fail (self != NULL, FALSE); + + /* remove packages that depend on those to be removed */ + if (pk_backend_get_bool (self, "allow_deps")) { + flags |= PM_TRANS_FLAG_CASCADE; + } + /* remove unneeded packages that were required by those to be removed */ + if (pk_backend_get_bool (self, "autoremove")) { + flags |= PM_TRANS_FLAG_RECURSE; + } + + if (pk_backend_transaction_initialize (self, flags, &error) && + pk_backend_transaction_remove_targets (self, &error) && + pk_backend_transaction_remove_simulate (self, &error)) { + pk_backend_transaction_commit (self, &error); + } + + return pk_backend_transaction_finish (self, error); +} + +void +pk_backend_simulate_remove_packages (PkBackend *self, gchar **package_ids, + gboolean autoremove) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (package_ids != NULL); + + pk_backend_run (self, PK_STATUS_ENUM_SETUP, + pk_backend_simulate_remove_packages_thread); +} + +void +pk_backend_remove_packages (PkBackend *self, gchar **package_ids, + gboolean allow_deps, gboolean autoremove) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (package_ids != NULL); + + pk_backend_run (self, PK_STATUS_ENUM_SETUP, + pk_backend_remove_packages_thread); +} diff --git a/backends/alpm/pk-backend-remove.h b/backends/alpm/pk-backend-remove.h new file mode 100644 index 000000000..368965a01 --- /dev/null +++ b/backends/alpm/pk-backend-remove.h @@ -0,0 +1,22 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> + * Copyright (C) 2008-2010 Valeriy Lyasotskiy <onestep@ukr.net> + * Copyright (C) 2010-2011 Jonathan Conder <jonno.conder@gmail.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ diff --git a/backends/alpm/pk-backend-search.c b/backends/alpm/pk-backend-search.c new file mode 100644 index 000000000..592472d8f --- /dev/null +++ b/backends/alpm/pk-backend-search.c @@ -0,0 +1,450 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> + * Copyright (C) 2008-2010 Valeriy Lyasotskiy <onestep@ukr.net> + * Copyright (C) 2010-2011 Jonathan Conder <jonno.conder@gmail.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include <alpm.h> +#include <pk-backend.h> +#include <string.h> + +#include "pk-backend-alpm.h" +#include "pk-backend-groups.h" +#include "pk-backend-packages.h" +#include "pk-backend-search.h" + +static gpointer +pk_backend_pattern_needle (const gchar *needle, GError **error) +{ + return (gpointer) needle; +} + +static gpointer +pk_backend_pattern_regex (const gchar *needle, GError **error) +{ + gchar *pattern; + GRegex *regex; + + g_return_val_if_fail (needle != NULL, NULL); + + pattern = g_regex_escape_string (needle, -1); + regex = g_regex_new (pattern, G_REGEX_CASELESS, 0, error); + g_free (pattern); + + return regex; +} + +static gpointer +pk_backend_pattern_chroot (const gchar *needle, GError **error) +{ + g_return_val_if_fail (needle != NULL, NULL); + + if (G_IS_DIR_SEPARATOR (*needle)) { + const gchar *file = needle, *root = alpm_option_get_root (); + + /* adjust needle to the correct prefix */ + for (; *file == *root; ++file, ++root) { + if (*root == '\0') { + needle = file - 1; + break; + } else if (*file == '\0') { + break; + } + } + } + + return (gpointer) needle; +} + +static gboolean +pk_backend_match_all (pmpkg_t *pkg, gpointer pattern) +{ + g_return_val_if_fail (pkg != NULL, FALSE); + g_return_val_if_fail (pattern != NULL, FALSE); + + /* match all packages */ + return TRUE; +} + +static gboolean +pk_backend_match_details (pmpkg_t *pkg, GRegex *regex) +{ + const gchar *desc; + pmdb_t *db; + const alpm_list_t *i; + + g_return_val_if_fail (pkg != NULL, FALSE); + g_return_val_if_fail (regex != NULL, FALSE); + + /* match the name first... */ + if (g_regex_match (regex, alpm_pkg_get_name (pkg), 0, NULL)) { + return TRUE; + } + + /* ... then the description... */ + desc = alpm_pkg_get_desc (pkg); + if (desc != NULL && g_regex_match (regex, desc, 0, NULL)) { + return TRUE; + } + + /* ... then the database... */ + db = alpm_pkg_get_db (pkg); + if (db != NULL && g_regex_match (regex, alpm_db_get_name (db), + G_REGEX_MATCH_ANCHORED, NULL)) { + return TRUE; + } + + /* ... then the licenses */ + for (i = alpm_pkg_get_licenses (pkg); i != NULL; i = i->next) { + if (g_regex_match (regex, i->data, G_REGEX_MATCH_ANCHORED, + NULL)) { + return TRUE; + } + } + + return FALSE; +} + +static gboolean +pk_backend_match_file (pmpkg_t *pkg, const gchar *needle) +{ + const alpm_list_t *i; + + g_return_val_if_fail (pkg != NULL, FALSE); + g_return_val_if_fail (needle != NULL, FALSE); + + /* match any file the package contains */ + if (G_IS_DIR_SEPARATOR (*needle)) { + for (i = alpm_pkg_get_files (pkg); i != NULL; i = i->next) { + /* match the full path of file */ + if (g_strcmp0 (i->data, needle + 1) == 0) { + return TRUE; + } + } + } else { + for (i = alpm_pkg_get_files (pkg); i != NULL; i = i->next) { + const gchar *file = strrchr (i->data, G_DIR_SEPARATOR); + if (file == NULL) { + file = i->data; + } else { + ++file; + } + + /* match the basename of file */ + if (g_strcmp0 (file, needle) == 0) { + return TRUE; + } + } + } + + return FALSE; +} + +static gboolean +pk_backend_match_group (pmpkg_t *pkg, const gchar *needle) +{ + g_return_val_if_fail (pkg != NULL, FALSE); + g_return_val_if_fail (needle != NULL, FALSE); + + /* match the group the package is in */ + return g_strcmp0 (needle, alpm_pkg_get_group (pkg)) == 0; +} + +static gboolean +pk_backend_match_name (pmpkg_t *pkg, GRegex *regex) +{ + g_return_val_if_fail (pkg != NULL, FALSE); + g_return_val_if_fail (regex != NULL, FALSE); + + /* match the name of the package */ + return g_regex_match (regex, alpm_pkg_get_name (pkg), 0, NULL); +} + +static gboolean +pk_backend_match_provides (pmpkg_t *pkg, gpointer pattern) +{ + /* TODO: implement GStreamer codecs, Pango fonts, etc. */ + const alpm_list_t *i; + + g_return_val_if_fail (pkg != NULL, FALSE); + g_return_val_if_fail (pattern != NULL, FALSE); + + /* match features provided by package */ + for (i = alpm_pkg_get_provides (pkg); i != NULL; i = i->next) { + const gchar *needle = pattern, *name = i->data; + + for (; *needle == *name; ++needle, ++name) { + if (*needle == '\0') { + if (*name == '\0' || *name == '=') { + return TRUE; + } else { + break; + } + } + } + } + + return FALSE; +} + +typedef enum { + SEARCH_TYPE_ALL, + SEARCH_TYPE_DETAILS, + SEARCH_TYPE_FILES, + SEARCH_TYPE_GROUP, + SEARCH_TYPE_NAME, + SEARCH_TYPE_PROVIDES, + SEARCH_TYPE_LAST +} SearchType; + +typedef gpointer (*PatternFunc) (const gchar *needle, GError **error); +typedef gboolean (*MatchFunc) (pmpkg_t *pkg, gpointer pattern); + +static PatternFunc pattern_funcs[] = { + pk_backend_pattern_needle, + pk_backend_pattern_regex, + pk_backend_pattern_chroot, + pk_backend_pattern_needle, + pk_backend_pattern_regex, + pk_backend_pattern_needle +}; + +static GDestroyNotify pattern_frees[] = { + NULL, + (GDestroyNotify) g_regex_unref, + NULL, + NULL, + (GDestroyNotify) g_regex_unref, + NULL +}; + +static MatchFunc match_funcs[] = { + pk_backend_match_all, + (MatchFunc) pk_backend_match_details, + (MatchFunc) pk_backend_match_file, + (MatchFunc) pk_backend_match_group, + (MatchFunc) pk_backend_match_name, + pk_backend_match_provides +}; + +static gboolean +alpm_pkg_is_local (pmpkg_t *pkg) +{ + pmpkg_t *local; + + g_return_val_if_fail (pkg != NULL, FALSE); + g_return_val_if_fail (localdb != NULL, FALSE); + + /* find an installed package with the same name */ + local = alpm_db_get_pkg (localdb, alpm_pkg_get_name (pkg)); + if (local == NULL) { + return FALSE; + } + + /* make sure the installed version is the same */ + if (alpm_pkg_vercmp (alpm_pkg_get_version (local), + alpm_pkg_get_version (pkg)) != 0) { + return FALSE; + } + + /* make sure the installed arch is the same */ + if (g_strcmp0 (alpm_pkg_get_arch (local), + alpm_pkg_get_arch (pkg)) != 0) { + return FALSE; + } + + return TRUE; +} + +static void +pk_backend_search_db (PkBackend *self, pmdb_t *db, MatchFunc match, + const alpm_list_t *patterns) +{ + const alpm_list_t *i, *j; + + g_return_if_fail (self != NULL); + g_return_if_fail (db != NULL); + g_return_if_fail (match != NULL); + + /* emit packages that match all search terms */ + for (i = alpm_db_get_pkgcache (db); i != NULL; i = i->next) { + if (pk_backend_cancelled (self)) { + break; + } + + for (j = patterns; j != NULL; j = j->next) { + if (!match (i->data, j->data)) { + break; + } + } + + /* all search terms matched */ + if (j == NULL) { + if (db == localdb) { + pk_backend_pkg (self, i->data, + PK_INFO_ENUM_INSTALLED); + } else if (!alpm_pkg_is_local (i->data)) { + pk_backend_pkg (self, i->data, + PK_INFO_ENUM_AVAILABLE); + } + } + } +} + +static gboolean +pk_backend_search_thread (PkBackend *self) +{ + gchar **needles; + SearchType type; + + PatternFunc pattern_func; + GDestroyNotify pattern_free; + MatchFunc match_func; + + PkBitfield filters; + gboolean skip_local, skip_remote; + + const alpm_list_t *i; + alpm_list_t *patterns = NULL; + GError *error = NULL; + + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (localdb != NULL, FALSE); + + needles = pk_backend_get_strv (self, "search"); + type = pk_backend_get_uint (self, "search-type"); + + g_return_val_if_fail (needles != NULL, FALSE); + g_return_val_if_fail (type < SEARCH_TYPE_LAST, FALSE); + + pattern_func = pattern_funcs[type]; + pattern_free = pattern_frees[type]; + match_func = match_funcs[type]; + + g_return_val_if_fail (pattern_func != NULL, FALSE); + g_return_val_if_fail (match_func != NULL, FALSE); + + filters = pk_backend_get_uint (self, "filters"); + skip_local = pk_bitfield_contain (filters, + PK_FILTER_ENUM_NOT_INSTALLED); + skip_remote = pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED); + + /* convert search terms to the pattern requested */ + for (; *needles != NULL; ++needles) { + gpointer pattern = pattern_func (*needles, &error); + + if (pattern == NULL) { + goto out; + } + + patterns = alpm_list_add (patterns, pattern); + } + + /* find installed packages first */ + if (!skip_local) { + pk_backend_search_db (self, localdb, match_func, patterns); + } + + if (skip_remote) { + goto out; + } + + for (i = alpm_option_get_syncdbs (); i != NULL; i = i->next) { + if (pk_backend_cancelled (self)) { + break; + } + + pk_backend_search_db (self, i->data, match_func, patterns); + } + +out: + if (pattern_free != NULL) { + alpm_list_free_inner (patterns, pattern_free); + } + alpm_list_free (patterns); + return pk_backend_finish (self, error); +} + +void +pk_backend_get_packages (PkBackend *self, PkBitfield filters) +{ + g_return_if_fail (self != NULL); + + /* provide a dummy needle */ + pk_backend_set_strv (self, "search", g_strsplit ("", ";", 0)); + + pk_backend_set_uint (self, "search-type", SEARCH_TYPE_ALL); + pk_backend_run (self, PK_STATUS_ENUM_QUERY, pk_backend_search_thread); +} + +void +pk_backend_search_details (PkBackend *self, PkBitfield filters, gchar **values) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (values != NULL); + + pk_backend_set_uint (self, "search-type", SEARCH_TYPE_DETAILS); + pk_backend_run (self, PK_STATUS_ENUM_QUERY, pk_backend_search_thread); +} + +void +pk_backend_search_files (PkBackend *self, PkBitfield filters, gchar **values) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (values != NULL); + + /* speed up search by restricting it to local database */ + pk_bitfield_add (filters, PK_FILTER_ENUM_INSTALLED); + pk_backend_set_uint (self, "filters", filters); + + pk_backend_set_uint (self, "search-type", SEARCH_TYPE_FILES); + pk_backend_run (self, PK_STATUS_ENUM_QUERY, pk_backend_search_thread); +} + +void +pk_backend_search_groups (PkBackend *self, PkBitfield filters, gchar **values) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (values != NULL); + + pk_backend_set_uint (self, "search-type", SEARCH_TYPE_GROUP); + pk_backend_run (self, PK_STATUS_ENUM_QUERY, pk_backend_search_thread); +} + +void +pk_backend_search_names (PkBackend *self, PkBitfield filters, gchar **values) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (values != NULL); + + pk_backend_set_uint (self, "search-type", SEARCH_TYPE_NAME); + pk_backend_run (self, PK_STATUS_ENUM_QUERY, pk_backend_search_thread); +} + +void +pk_backend_what_provides (PkBackend *self, PkBitfield filters, + PkProvidesEnum provides, gchar **values) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (values != NULL); + + pk_backend_set_uint (self, "search-type", SEARCH_TYPE_PROVIDES); + pk_backend_run (self, PK_STATUS_ENUM_QUERY, pk_backend_search_thread); +} diff --git a/backends/alpm/pk-backend-search.h b/backends/alpm/pk-backend-search.h new file mode 100644 index 000000000..368965a01 --- /dev/null +++ b/backends/alpm/pk-backend-search.h @@ -0,0 +1,22 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> + * Copyright (C) 2008-2010 Valeriy Lyasotskiy <onestep@ukr.net> + * Copyright (C) 2010-2011 Jonathan Conder <jonno.conder@gmail.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ diff --git a/backends/alpm/pk-backend-sync.c b/backends/alpm/pk-backend-sync.c new file mode 100644 index 000000000..9e1e02bb8 --- /dev/null +++ b/backends/alpm/pk-backend-sync.c @@ -0,0 +1,286 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> + * Copyright (C) 2008-2010 Valeriy Lyasotskiy <onestep@ukr.net> + * Copyright (C) 2010-2011 Jonathan Conder <jonno.conder@gmail.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include <alpm.h> +#include <pk-backend.h> +#include <string.h> + +#include "pk-backend-alpm.h" +#include "pk-backend-error.h" +#include "pk-backend-sync.h" +#include "pk-backend-transaction.h" + +static gint +alpm_add_dbtarget (const gchar *repo, const gchar *name) +{ + const alpm_list_t *i; + pmpkg_t *pkg; + + g_return_val_if_fail (repo != NULL, -1); + g_return_val_if_fail (name != NULL, -1); + + for (i = alpm_option_get_syncdbs (); i != NULL; i = i->next) { + if (g_strcmp0 (alpm_db_get_name (i->data), repo) == 0) { + break; + } + } + + if (i == NULL) { + pm_errno = PM_ERR_DB_NOT_FOUND; + return -1; + } + + pkg = alpm_db_get_pkg (i->data, name); + if (pkg == NULL) { + pm_errno = PM_ERR_PKG_NOT_FOUND; + return -1; + } + + return alpm_add_pkg (pkg); +} + +static gboolean +pk_backend_transaction_sync_targets (PkBackend *self, GError **error) +{ + gchar **packages; + + g_return_val_if_fail (self != NULL, FALSE); + + packages = pk_backend_get_strv (self, "package_ids"); + + g_return_val_if_fail (packages != NULL, FALSE); + + for (; *packages != NULL; ++packages) { + gchar **package = pk_package_id_split (*packages); + gchar *repo = package[PK_PACKAGE_ID_DATA]; + gchar *name = package[PK_PACKAGE_ID_NAME]; + + if (alpm_add_dbtarget (repo, name) < 0) { + g_set_error (error, ALPM_ERROR, pm_errno, "%s/%s: %s", + repo, name, alpm_strerrorlast ()); + g_strfreev (package); + return FALSE; + } + + g_strfreev (package); + } + + return TRUE; +} + +static gboolean +pk_backend_download_packages_thread (PkBackend *self) +{ + alpm_list_t *cachedirs; + const gchar *directory; + pmtransflag_t flags = 0; + GError *error = NULL; + + g_return_val_if_fail (self != NULL, FALSE); + + directory = pk_backend_get_string (self, "directory"); + + if (directory != NULL) { + /* download files to a PackageKit directory */ + gchar *cachedir = strdup (directory); + cachedirs = alpm_list_strdup (alpm_option_get_cachedirs ()); + alpm_option_set_cachedirs (alpm_list_add (NULL, cachedir)); + } + + flags |= PM_TRANS_FLAG_NODEPS; + flags |= PM_TRANS_FLAG_NOCONFLICTS; + flags |= PM_TRANS_FLAG_DOWNLOADONLY; + + if (pk_backend_transaction_initialize (self, flags, &error) && + pk_backend_transaction_sync_targets (self, &error) && + pk_backend_transaction_simulate (self, &error)) { + pk_backend_transaction_commit (self, &error); + } + + if (directory != NULL) { + alpm_option_set_cachedirs (cachedirs); + } + + return pk_backend_transaction_finish (self, error); +} + +void +pk_backend_download_packages (PkBackend *self, gchar **package_ids, + const gchar *directory) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (package_ids != NULL); + g_return_if_fail (directory != NULL); + + pk_backend_run (self, PK_STATUS_ENUM_SETUP, + pk_backend_download_packages_thread); +} + +static gboolean +pk_backend_simulate_install_packages_thread (PkBackend *self) +{ + GError *error = NULL; + + g_return_val_if_fail (self != NULL, FALSE); + + if (pk_backend_transaction_initialize (self, 0, &error) && + pk_backend_transaction_sync_targets (self, &error) && + pk_backend_transaction_simulate (self, &error)) { + pk_backend_transaction_packages (self); + } + + return pk_backend_transaction_finish (self, error); +} + +static gboolean +pk_backend_install_packages_thread (PkBackend *self) +{ + GError *error = NULL; + + g_return_val_if_fail (self != NULL, FALSE); + + if (pk_backend_transaction_initialize (self, 0, &error) && + pk_backend_transaction_sync_targets (self, &error) && + pk_backend_transaction_simulate (self, &error)) { + pk_backend_transaction_commit (self, &error); + } + + return pk_backend_transaction_finish (self, error); +} + +void +pk_backend_simulate_install_packages (PkBackend *self, gchar **package_ids) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (package_ids != NULL); + + pk_backend_run (self, PK_STATUS_ENUM_SETUP, + pk_backend_simulate_install_packages_thread); +} + +void +pk_backend_install_packages (PkBackend *self, gboolean only_trusted, + gchar **package_ids) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (package_ids != NULL); + + pk_backend_run (self, PK_STATUS_ENUM_SETUP, + pk_backend_install_packages_thread); +} + +static gboolean +pk_backend_replaces_dependencies (PkBackend *self, pmpkg_t *pkg) +{ + const alpm_list_t *i, *replaces; + + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (pkg != NULL, FALSE); + + replaces = alpm_pkg_get_replaces (pkg); + for (i = alpm_trans_get_remove (); i != NULL; i = i->next) { + pmpkg_t *rpkg = (pmpkg_t *) i->data; + const gchar *rname = alpm_pkg_get_name (rpkg); + + if (pk_backend_cancelled (self)) { + return FALSE; + } else if (alpm_list_find_str (replaces, rname) == NULL) { + continue; + } + + if (alpm_pkg_get_reason (rpkg) == PM_PKG_REASON_EXPLICIT) { + return FALSE; + } + } + + return TRUE; +} + +static gboolean +pk_backend_update_packages_thread (PkBackend *self) +{ + const alpm_list_t *i; + alpm_list_t *asdeps = NULL; + GError *error = NULL; + + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (localdb != NULL, FALSE); + + if (!pk_backend_transaction_initialize (self, 0, &error) || + !pk_backend_transaction_sync_targets (self, &error) || + !pk_backend_transaction_simulate (self, &error)) { + goto out; + } + + /* change the install reason of packages that replace dependencies */ + for (i = alpm_trans_get_add (); i != NULL; i = i->next) { + pmpkg_t *pkg = (pmpkg_t *) i->data; + const gchar *name = alpm_pkg_get_name (pkg); + + if (pk_backend_cancelled (self)) { + goto out; + } else if (alpm_db_get_pkg (localdb, name) != NULL) { + continue; + } + + if (pk_backend_replaces_dependencies (self, pkg)) { + asdeps = alpm_list_add (asdeps, g_strdup (name)); + } + } + + if (!pk_backend_transaction_commit (self, &error)) { + goto out; + } + + for (i = asdeps; i != NULL; i = i->next) { + const gchar *name = (const gchar *) i->data; + alpm_db_set_pkgreason (localdb, name, PM_PKG_REASON_DEPEND); + } + +out: + alpm_list_free_inner (asdeps, g_free); + alpm_list_free (asdeps); + + return pk_backend_transaction_finish (self, error); +} + +void +pk_backend_simulate_update_packages (PkBackend *self, gchar **package_ids) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (package_ids != NULL); + + pk_backend_run (self, PK_STATUS_ENUM_SETUP, + pk_backend_simulate_install_packages_thread); +} + +void +pk_backend_update_packages (PkBackend *self, gboolean only_trusted, + gchar **package_ids) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (package_ids != NULL); + + pk_backend_run (self, PK_STATUS_ENUM_SETUP, + pk_backend_update_packages_thread); +} diff --git a/backends/alpm/pk-backend-sync.h b/backends/alpm/pk-backend-sync.h new file mode 100644 index 000000000..368965a01 --- /dev/null +++ b/backends/alpm/pk-backend-sync.h @@ -0,0 +1,22 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> + * Copyright (C) 2008-2010 Valeriy Lyasotskiy <onestep@ukr.net> + * Copyright (C) 2010-2011 Jonathan Conder <jonno.conder@gmail.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ diff --git a/backends/alpm/pk-backend-transaction.c b/backends/alpm/pk-backend-transaction.c new file mode 100644 index 000000000..f91930943 --- /dev/null +++ b/backends/alpm/pk-backend-transaction.c @@ -0,0 +1,916 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> + * Copyright (C) 2008-2010 Valeriy Lyasotskiy <onestep@ukr.net> + * Copyright (C) 2010-2011 Jonathan Conder <jonno.conder@gmail.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "pk-backend-alpm.h" +#include "pk-backend-error.h" +#include "pk-backend-packages.h" +#include "pk-backend-transaction.h" + +static off_t dcomplete = 0; +static off_t dtotal = 0; + +static pmpkg_t *dpkg = NULL; +static GString *dfiles = NULL; + +static gchar * +pk_backend_resolve_path (PkBackend *self, const gchar *basename) +{ + const gchar *dirname; + + g_return_val_if_fail (self != NULL, NULL); + g_return_val_if_fail (basename != NULL, NULL); + + dirname = pk_backend_get_string (self, "directory"); + + g_return_val_if_fail (dirname != NULL, NULL); + + return g_build_filename (dirname, basename, NULL); +} + +static gboolean +alpm_pkg_has_basename (pmpkg_t *pkg, const gchar *basename) +{ + const alpm_list_t *i; + + g_return_val_if_fail (pkg != NULL, FALSE); + g_return_val_if_fail (basename != NULL, FALSE); + + if (g_strcmp0 (alpm_pkg_get_filename (pkg), basename) == 0) { + return TRUE; + } + + if (alpm_option_get_usedelta () == 0) { + return FALSE; + } + + for (i = alpm_pkg_get_deltas (pkg); i != NULL; i = i->next) { + const gchar *patch = alpm_delta_get_filename (i->data); + + if (g_strcmp0 (patch, basename) == 0) { + return TRUE; + } + } + + return FALSE; +} + +static void +pk_backend_transaction_download_end (PkBackend *self) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (dpkg != NULL); + + pk_backend_pkg (self, dpkg, PK_INFO_ENUM_FINISHED); + + /* tell DownloadPackages what files were downloaded */ + if (dfiles != NULL) { + gchar *package_id; + + package_id = alpm_pkg_build_id (dpkg); + + pk_backend_files (self, package_id, dfiles->str); + + g_free (package_id); + g_string_free (dfiles, TRUE); + } + + dpkg = NULL; + dfiles = NULL; +} + +static void +pk_backend_transaction_download_start (PkBackend *self, const gchar *basename) +{ + gchar *path; + const alpm_list_t *i; + + g_return_if_fail (self != NULL); + g_return_if_fail (basename != NULL); + + /* continue or finish downloading the current package */ + if (dpkg != NULL) { + if (alpm_pkg_has_basename (dpkg, basename)) { + if (dfiles != NULL) { + path = pk_backend_resolve_path (self, basename); + g_string_append_printf (dfiles, ";%s", path); + g_free (path); + } + + return; + } else { + pk_backend_transaction_download_end (self); + dpkg = NULL; + } + } + + /* figure out what the next package is */ + for (i = alpm_trans_get_add (); i != NULL; i = i->next) { + pmpkg_t *pkg = (pmpkg_t *) i->data; + + if (alpm_pkg_has_basename (pkg, basename)) { + dpkg = pkg; + break; + } + } + + if (dpkg == NULL) { + return; + } + + pk_backend_pkg (self, dpkg, PK_INFO_ENUM_DOWNLOADING); + + /* start collecting files for the new package */ + if (pk_backend_get_role (self) == PK_ROLE_ENUM_DOWNLOAD_PACKAGES) { + path = pk_backend_resolve_path (self, basename); + dfiles = g_string_new (path); + g_free (path); + } +} + +static void +pk_backend_transaction_totaldlcb (off_t total) +{ + g_return_if_fail (backend != NULL); + + if (dtotal > 0 && dpkg != NULL) { + pk_backend_transaction_download_end (backend); + } + + dcomplete = 0; + dtotal = total; +} + +static void +pk_backend_transaction_dlcb (const gchar *basename, off_t complete, off_t total) +{ + guint percentage = 100, sub_percentage = 100; + + g_return_if_fail (basename != NULL); + g_return_if_fail (complete <= total); + g_return_if_fail (backend != NULL); + + if (total > 0) { + sub_percentage = complete * 100 / total; + } + + if (dtotal > 0) { + percentage = (dcomplete + complete) * 100 / dtotal; + } else if (dtotal < 0) { + /* database files */ + percentage = (dcomplete * 100 + sub_percentage) / -dtotal; + + if (complete == total) { + complete = total = 1; + } else { + complete = total + 1; + } + } + + if (complete == 0) { + g_debug ("downloading file %s", basename); + pk_backend_set_status (backend, PK_STATUS_ENUM_DOWNLOAD); + pk_backend_transaction_download_start (backend, basename); + } else if (complete == total) { + dcomplete += complete; + } + + pk_backend_set_sub_percentage (backend, sub_percentage); + pk_backend_set_percentage (backend, percentage); +} + +static void +pk_backend_transaction_progress_cb (pmtransprog_t type, const gchar *target, + gint percent, gsize targets, gsize current) +{ + static gint recent = 101; + gsize overall = percent + (current - 1) * 100; + + /* TODO: revert when fixed upstream */ + if (type == PM_TRANS_PROGRESS_CONFLICTS_START || + type == PM_TRANS_PROGRESS_DISKSPACE_START || + type == PM_TRANS_PROGRESS_INTEGRITY_START) { + if (current < targets) { + overall = percent + current++ * 100; + } + } + + if (current < 1 || targets < current) { + g_warning ("TODO: CURRENT/TARGETS FAILED for %d", type); + } + + g_return_if_fail (target != NULL); + g_return_if_fail (0 <= percent && percent <= 100); + g_return_if_fail (1 <= current && current <= targets); + g_return_if_fail (backend != NULL); + + /* update transaction progress */ + switch (type) { + case PM_TRANS_PROGRESS_ADD_START: + case PM_TRANS_PROGRESS_UPGRADE_START: + case PM_TRANS_PROGRESS_REMOVE_START: + case PM_TRANS_PROGRESS_CONFLICTS_START: + case PM_TRANS_PROGRESS_DISKSPACE_START: + case PM_TRANS_PROGRESS_INTEGRITY_START: + if (percent == recent) { + break; + } + + pk_backend_set_sub_percentage (backend, percent); + pk_backend_set_percentage (backend, overall / targets); + recent = percent; + + g_debug ("%d%% of %s complete (%zu of %zu)", percent, + target, current, targets); + break; + + default: + g_warning ("unknown progress type %d", type); + break; + } +} + +static void +pk_backend_install_ignorepkg (PkBackend *self, pmpkg_t *pkg, gint *result) +{ + gchar *output; + + g_return_if_fail (self != NULL); + g_return_if_fail (pkg != NULL); + g_return_if_fail (result != NULL); + + switch (pk_backend_get_role (self)) { + case PK_ROLE_ENUM_INSTALL_PACKAGES: + output = g_strdup_printf ("%s: was not ignored\n", + alpm_pkg_get_name (pkg)); + pk_backend_output (self, output); + g_free (output); + + case PK_ROLE_ENUM_DOWNLOAD_PACKAGES: + case PK_ROLE_ENUM_SIMULATE_INSTALL_PACKAGES: + *result = 1; + break; + + default: + *result = 0; + break; + } +} + +static void +pk_backend_select_provider (PkBackend *self, pmdepend_t *dep, + const alpm_list_t *providers) +{ + gchar *output; + + g_return_if_fail (self != NULL); + g_return_if_fail (dep != NULL); + g_return_if_fail (providers != NULL); + + output = g_strdup_printf ("provider package was selected " + "(%s provides %s)\n", + alpm_pkg_get_name (providers->data), + alpm_dep_get_name (dep)); + pk_backend_output (self, output); + g_free (output); +} + +static void +pk_backend_transaction_conv_cb (pmtransconv_t question, gpointer data1, + gpointer data2, gpointer data3, gint *result) +{ + g_return_if_fail (result != NULL); + g_return_if_fail (backend != NULL); + + switch (question) { + case PM_TRANS_CONV_INSTALL_IGNOREPKG: + pk_backend_install_ignorepkg (backend, data1, result); + break; + + case PM_TRANS_CONV_REPLACE_PKG: + case PM_TRANS_CONV_CONFLICT_PKG: + case PM_TRANS_CONV_CORRUPTED_PKG: + case PM_TRANS_CONV_LOCAL_NEWER: + /* these actions are mostly harmless */ + g_debug ("safe question %d", question); + *result = 1; + break; + + case PM_TRANS_CONV_REMOVE_PKGS: + g_debug ("unsafe question %d", question); + *result = 0; + break; + + case PM_TRANS_CONV_SELECT_PROVIDER: + pk_backend_select_provider (backend, data1, data2); + *result = 0; + break; + + default: + g_warning ("unknown question %d", question); + break; + } +} + +static void +pk_backend_transaction_dep_resolve (PkBackend *self) +{ + g_return_if_fail (self != NULL); + + pk_backend_set_status (self, PK_STATUS_ENUM_DEP_RESOLVE); +} + +static void +pk_backend_transaction_test_commit (PkBackend *self) +{ + g_return_if_fail (self != NULL); + + pk_backend_set_status (self, PK_STATUS_ENUM_TEST_COMMIT); +} + +static void +pk_backend_transaction_add_start (PkBackend *self, pmpkg_t *pkg) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (pkg != NULL); + + pk_backend_set_status (self, PK_STATUS_ENUM_INSTALL); + pk_backend_pkg (self, pkg, PK_INFO_ENUM_INSTALLING); +} + +static void +pk_backend_transaction_add_done (PkBackend *self, pmpkg_t *pkg) +{ + const gchar *name, *version; + const alpm_list_t *i, *optdepends; + + g_return_if_fail (self != NULL); + g_return_if_fail (pkg != NULL); + + name = alpm_pkg_get_name (pkg); + version = alpm_pkg_get_version (pkg); + + alpm_logaction ("installed %s (%s)\n", name, version); + pk_backend_pkg (self, pkg, PK_INFO_ENUM_FINISHED); + + optdepends = alpm_pkg_get_optdepends (pkg); + if (optdepends != NULL) { + GString *depends = g_string_new (""); + + g_string_append_printf (depends, + "Optional dependencies for %s:\n", + name); + + for (i = optdepends; i != NULL; i = i->next) { + g_string_append_printf (depends, "%s\n", + (const gchar *) i->data); + } + + pk_backend_output (self, depends->str); + g_string_free (depends, TRUE); + } +} + +static void +pk_backend_transaction_remove_start (PkBackend *self, pmpkg_t *pkg) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (pkg != NULL); + + pk_backend_set_status (self, PK_STATUS_ENUM_REMOVE); + pk_backend_pkg (self, pkg, PK_INFO_ENUM_REMOVING); +} + +static void +pk_backend_transaction_remove_done (PkBackend *self, pmpkg_t *pkg) +{ + const gchar *name, *version; + + g_return_if_fail (self != NULL); + g_return_if_fail (pkg != NULL); + + name = alpm_pkg_get_name (pkg); + version = alpm_pkg_get_version (pkg); + + alpm_logaction ("removed %s (%s)\n", name, version); + pk_backend_pkg (self, pkg, PK_INFO_ENUM_FINISHED); +} + +static void +pk_backend_transaction_upgrade_start (PkBackend *self, pmpkg_t *pkg, + pmpkg_t *old) +{ + PkRoleEnum role; + PkStatusEnum state; + PkInfoEnum info; + + g_return_if_fail (self != NULL); + g_return_if_fail (pkg != NULL); + + role = pk_backend_get_role (self); + if (role == PK_ROLE_ENUM_INSTALL_FILES || + role == PK_ROLE_ENUM_SIMULATE_INSTALL_FILES) { + state = PK_STATUS_ENUM_INSTALL; + info = PK_INFO_ENUM_INSTALLING; + } else { + state = PK_STATUS_ENUM_UPDATE; + info = PK_INFO_ENUM_UPDATING; + } + + pk_backend_set_status (self, state); + pk_backend_pkg (self, pkg, info); +} + +static void +pk_backend_transaction_upgrade_done (PkBackend *self, pmpkg_t *pkg, + pmpkg_t *old) +{ + const gchar *name, *pre, *post; + const alpm_list_t *i; + alpm_list_t *optdepends; + + g_return_if_fail (self != NULL); + g_return_if_fail (pkg != NULL); + g_return_if_fail (old != NULL); + + name = alpm_pkg_get_name (pkg); + pre = alpm_pkg_get_version (old); + post = alpm_pkg_get_version (pkg); + + alpm_logaction ("upgraded %s (%s -> %s)\n", name, pre, post); + pk_backend_pkg (self, pkg, PK_INFO_ENUM_FINISHED); + + optdepends = alpm_list_diff (alpm_pkg_get_optdepends (pkg), + alpm_pkg_get_optdepends (old), + (alpm_list_fn_cmp) g_strcmp0); + if (optdepends != NULL) { + GString *depends = g_string_new (""); + + g_string_append_printf (depends, + "New optional dependencies for %s\n", + name); + + for (i = optdepends; i != NULL; i = i->next) { + g_string_append_printf (depends, "%s\n", + (const gchar *) i->data); + } + + pk_backend_output (self, depends->str); + + g_string_free (depends, TRUE); + alpm_list_free (optdepends); + } +} + +static void +pk_backend_transaction_event_cb (pmtransevt_t event, gpointer data, + gpointer old) +{ + g_return_if_fail (backend != NULL); + + /* figure out the backend status and package info */ + switch (event) { + case PM_TRANS_EVT_CHECKDEPS_START: + case PM_TRANS_EVT_RESOLVEDEPS_START: + pk_backend_transaction_dep_resolve (backend); + break; + + case PM_TRANS_EVT_FILECONFLICTS_START: + case PM_TRANS_EVT_INTERCONFLICTS_START: + case PM_TRANS_EVT_INTEGRITY_START: + case PM_TRANS_EVT_DELTA_INTEGRITY_START: + case PM_TRANS_EVT_DISKSPACE_START: + pk_backend_transaction_test_commit (backend); + break; + + case PM_TRANS_EVT_ADD_START: + pk_backend_transaction_add_start (backend, data); + break; + + case PM_TRANS_EVT_ADD_DONE: + pk_backend_transaction_add_done (backend, data); + break; + + case PM_TRANS_EVT_REMOVE_START: + pk_backend_transaction_remove_start (backend, data); + break; + + case PM_TRANS_EVT_REMOVE_DONE: + pk_backend_transaction_remove_done (backend, data); + break; + + case PM_TRANS_EVT_UPGRADE_START: + pk_backend_transaction_upgrade_start (backend, data, + old); + break; + + case PM_TRANS_EVT_UPGRADE_DONE: + pk_backend_transaction_upgrade_done (backend, data, + old); + break; + + case PM_TRANS_EVT_SCRIPTLET_INFO: + pk_backend_output (backend, data); + break; + + default: + g_debug ("unhandled event %d", event); + break; + } +} + +static void +transaction_cancelled_cb (GCancellable *object, gpointer data) +{ + g_return_if_fail (data != NULL); + + alpm_trans_interrupt (); +} + +gboolean +pk_backend_transaction_initialize (PkBackend *self, pmtransflag_t flags, + GError **error) +{ + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (cancellable != NULL, FALSE); + + if (alpm_trans_init (flags, pk_backend_transaction_event_cb, + pk_backend_transaction_conv_cb, + pk_backend_transaction_progress_cb) < 0) { + g_set_error_literal (error, ALPM_ERROR, pm_errno, + alpm_strerrorlast ()); + return FALSE; + } + + alpm_option_set_dlcb (pk_backend_transaction_dlcb); + alpm_option_set_totaldlcb (pk_backend_transaction_totaldlcb); + + g_cancellable_connect (cancellable, + G_CALLBACK (transaction_cancelled_cb), + self, NULL); + + return TRUE; +} + +static gchar * +alpm_pkg_build_list (const alpm_list_t *i) +{ + GString *list; + + if (i == NULL) { + return NULL; + } else { + list = g_string_new (""); + } + + for (; i != NULL; i = i->next) { + g_string_append_printf (list, "%s, ", + alpm_pkg_get_name (i->data)); + } + + g_string_truncate (list, list->len - 2); + return g_string_free (list, FALSE); +} + +static gchar * +alpm_miss_build_list (const alpm_list_t *i) +{ + GString *list; + + if (i == NULL) { + return NULL; + } else { + list = g_string_new (""); + } + + for (; i != NULL; i = i->next) { + pmdepend_t *dep = alpm_miss_get_dep (i->data); + gchar *depend = alpm_dep_compute_string (dep); + g_string_append_printf (list, "%s <- %s, ", depend, + alpm_miss_get_target (i->data)); + free (depend); + } + + g_string_truncate (list, list->len - 2); + return g_string_free (list, FALSE); +} + +static void +alpm_dep_free (gpointer dep) +{ + /* TODO: remove when implemented in libalpm */ + free ((gpointer) alpm_dep_get_name (dep)); + free ((gpointer) alpm_dep_get_version (dep)); + free (dep); +} + +static void +alpm_miss_free (gpointer miss) +{ + /* TODO: remove when implemented in libalpm */ + const gchar *temp = alpm_miss_get_causingpkg (miss); + if (temp != NULL) { + free ((gpointer) temp); + } + + free ((gpointer) alpm_miss_get_target (miss)); + alpm_dep_free (alpm_miss_get_dep (miss)); + free (miss); +} + +static gchar * +alpm_conflict_build_list (const alpm_list_t *i) +{ + GString *list; + + if (i == NULL) { + return NULL; + } else { + list = g_string_new (""); + } + + for (; i != NULL; i = i->next) { + const gchar *first = alpm_conflict_get_package1 (i->data); + const gchar *second = alpm_conflict_get_package2 (i->data); + const gchar *reason = alpm_conflict_get_reason (i->data); + + if (g_strcmp0 (first, reason) == 0 || + g_strcmp0 (second, reason) == 0) { + g_string_append_printf (list, "%s <-> %s, ", first, + second); + } else { + g_string_append_printf (list, "%s <-> %s (%s), ", first, + second, reason); + } + } + + g_string_truncate (list, list->len - 2); + return g_string_free (list, FALSE); +} + +static void +alpm_conflict_free (gpointer conflict) +{ + /* TODO: remove when implemented in libalpm */ + free ((gpointer) alpm_conflict_get_package1 (conflict)); + free ((gpointer) alpm_conflict_get_package2 (conflict)); + free ((gpointer) alpm_conflict_get_reason (conflict)); + free (conflict); +} + +static gchar * +alpm_fileconflict_build_list (const alpm_list_t *i) +{ + GString *list; + + if (i == NULL) { + return NULL; + } else { + list = g_string_new (""); + } + + for (; i != NULL; i = i->next) { + const gchar *target = alpm_fileconflict_get_target (i->data); + const gchar *file = alpm_fileconflict_get_file (i->data); + const gchar *ctarget = alpm_fileconflict_get_ctarget (i->data); + if (*ctarget != '\0') { + g_string_append_printf (list, "%s <-> %s (%s), ", + target, ctarget, file); + } else { + g_string_append_printf (list, "%s (%s), ", target, + file); + } + } + + g_string_truncate (list, list->len - 2); + return g_string_free (list, FALSE); +} + +static void +alpm_fileconflict_free (gpointer conflict) +{ + /* TODO: remove when implemented in libalpm */ + const gchar *temp = alpm_fileconflict_get_ctarget (conflict); + if (*temp != '\0') { + free ((gpointer) temp); + } + + free ((gpointer) alpm_fileconflict_get_target (conflict)); + free ((gpointer) alpm_fileconflict_get_file (conflict)); + free (conflict); +} + +gboolean +pk_backend_transaction_simulate (PkBackend *self, GError **error) +{ + alpm_list_t *data = NULL; + gchar *prefix; + + if (alpm_trans_prepare (&data) >= 0) { + return TRUE; + } + + switch (pm_errno) { + case PM_ERR_PKG_INVALID_ARCH: + prefix = alpm_pkg_build_list (data); + alpm_list_free (data); + break; + + case PM_ERR_UNSATISFIED_DEPS: + prefix = alpm_miss_build_list (data); + alpm_list_free_inner (data, alpm_miss_free); + alpm_list_free (data); + break; + + case PM_ERR_CONFLICTING_DEPS: + prefix = alpm_conflict_build_list (data); + alpm_list_free_inner (data, alpm_conflict_free); + alpm_list_free (data); + break; + + case PM_ERR_FILE_CONFLICTS: + prefix = alpm_fileconflict_build_list (data); + alpm_list_free_inner (data, alpm_fileconflict_free); + alpm_list_free (data); + break; + + default: + prefix = NULL; + if (data != NULL) { + g_warning ("unhandled error %d", pm_errno); + } + break; + } + + if (prefix != NULL) { + g_set_error (error, ALPM_ERROR, pm_errno, "%s: %s", prefix, + alpm_strerrorlast ()); + g_free (prefix); + } else { + g_set_error_literal (error, ALPM_ERROR, pm_errno, + alpm_strerrorlast ()); + } + + return FALSE; +} + +void +pk_backend_transaction_packages (PkBackend *self) +{ + const alpm_list_t *i; + PkInfoEnum info; + + g_return_if_fail (self != NULL); + g_return_if_fail (localdb != NULL); + + /* emit packages that would have been installed */ + for (i = alpm_trans_get_add (); i != NULL; i = i->next) { + if (pk_backend_cancelled (self)) { + break; + } else { + const gchar *name = alpm_pkg_get_name (i->data); + + if (alpm_db_get_pkg (localdb, name) != NULL) { + info = PK_INFO_ENUM_UPDATING; + } else { + info = PK_INFO_ENUM_INSTALLING; + } + + pk_backend_pkg (self, i->data, info); + } + } + + switch (pk_backend_get_role (self)) { + case PK_ROLE_ENUM_SIMULATE_UPDATE_PACKAGES: + info = PK_INFO_ENUM_OBSOLETING; + break; + + default: + info = PK_INFO_ENUM_REMOVING; + break; + } + + /* emit packages that would have been removed */ + for (i = alpm_trans_get_remove (); i != NULL; i = i->next) { + if (pk_backend_cancelled (self)) { + break; + } else { + pk_backend_pkg (self, i->data, info); + } + } +} + +static gchar * +alpm_string_build_list (const alpm_list_t *i) +{ + GString *list; + + if (i == NULL) { + return NULL; + } else { + list = g_string_new (""); + } + + for (; i != NULL; i = i->next) { + g_string_append_printf (list, "%s, ", (const gchar *) i->data); + } + + g_string_truncate (list, list->len - 2); + return g_string_free (list, FALSE); +} + +gboolean +pk_backend_transaction_commit (PkBackend *self, GError **error) +{ + alpm_list_t *data = NULL; + gchar *prefix; + + if (pk_backend_cancelled (self)) { + return TRUE; + } + + pk_backend_set_allow_cancel (self, FALSE); + pk_backend_set_status (self, PK_STATUS_ENUM_RUNNING); + + if (alpm_trans_commit (&data) >= 0) { + return TRUE; + } + + switch (pm_errno) { + case PM_ERR_FILE_CONFLICTS: + prefix = alpm_fileconflict_build_list (data); + alpm_list_free_inner (data, alpm_fileconflict_free); + alpm_list_free (data); + break; + + case PM_ERR_PKG_INVALID: + case PM_ERR_DLT_INVALID: + prefix = alpm_string_build_list (data); + alpm_list_free (data); + break; + + default: + prefix = NULL; + if (data != NULL) { + g_warning ("unhandled error %d", pm_errno); + } + break; + } + + if (prefix != NULL) { + g_set_error (error, ALPM_ERROR, pm_errno, "%s: %s", prefix, + alpm_strerrorlast ()); + g_free (prefix); + } else { + g_set_error_literal (error, ALPM_ERROR, pm_errno, + alpm_strerrorlast ()); + } + + return FALSE; +} + +gboolean +pk_backend_transaction_end (PkBackend *self, GError **error) +{ + g_return_val_if_fail (self != NULL, FALSE); + + alpm_option_set_dlcb (NULL); + alpm_option_set_totaldlcb (NULL); + + if (alpm_trans_release () < 0) { + g_set_error_literal (error, ALPM_ERROR, pm_errno, + alpm_strerrorlast ()); + return FALSE; + } + + return TRUE; +} + +gboolean +pk_backend_transaction_finish (PkBackend *self, GError *error) +{ + g_return_val_if_fail (self != NULL, FALSE); + + pk_backend_transaction_end (self, (error == NULL) ? &error : NULL); + + return pk_backend_finish (self, error); +} diff --git a/backends/pacman/backend-packages.h b/backends/alpm/pk-backend-transaction.h index 2064b890f..7bc1af091 100644 --- a/backends/pacman/backend-packages.h +++ b/backends/alpm/pk-backend-transaction.h @@ -1,8 +1,8 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- * * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> - * Copyright (C) 2008, 2009 Valeriy Lyasotskiy <onestep@ukr.net> - * Copyright (C) 2010 Jonathan Conder <j@skurvy.no-ip.org> + * Copyright (C) 2008-2010 Valeriy Lyasotskiy <onestep@ukr.net> + * Copyright (C) 2010-2011 Jonathan Conder <jonno.conder@gmail.com> * * Licensed under the GNU General Public License Version 2 * @@ -21,21 +21,23 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include <pacman.h> +#include <alpm.h> #include <pk-backend.h> -gchar *pacman_package_make_id (PacmanPackage *package); -void backend_package (PkBackend *backend, - PacmanPackage *package, - PkInfoEnum info); +gboolean pk_backend_transaction_initialize (PkBackend *self, + pmtransflag_t flags, + GError **error); -PacmanPackage *backend_get_package (PkBackend *backend, - const gchar *package_id); -void backend_resolve (PkBackend *backend, - PkBitfield filters, - gchar **package_ids); +gboolean pk_backend_transaction_simulate (PkBackend *self, + GError **error); -void backend_get_details (PkBackend *backend, - gchar **package_ids); -void backend_get_files (PkBackend *backend, - gchar **package_ids); +void pk_backend_transaction_packages (PkBackend *self); + +gboolean pk_backend_transaction_commit (PkBackend *self, + GError **error); + +gboolean pk_backend_transaction_end (PkBackend *self, + GError **error); + +gboolean pk_backend_transaction_finish (PkBackend *self, + GError *error); diff --git a/backends/alpm/pk-backend-update.c b/backends/alpm/pk-backend-update.c new file mode 100644 index 000000000..a281953eb --- /dev/null +++ b/backends/alpm/pk-backend-update.c @@ -0,0 +1,443 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> + * Copyright (C) 2008-2010 Valeriy Lyasotskiy <onestep@ukr.net> + * Copyright (C) 2010-2011 Jonathan Conder <jonno.conder@gmail.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include <alpm.h> +#include <glib/gstdio.h> +#include <pk-backend.h> +#include <string.h> +#include <sys/stat.h> + +#include "pk-backend-alpm.h" +#include "pk-backend-error.h" +#include "pk-backend-packages.h" +#include "pk-backend-transaction.h" +#include "pk-backend-update.h" + +static gchar * +alpm_pkg_build_replaces (pmpkg_t *pkg) +{ + const alpm_list_t *i; + GString *string = NULL; + + g_return_val_if_fail (pkg != NULL, NULL); + g_return_val_if_fail (localdb != NULL, NULL); + + /* make a list of the packages that package replaces */ + for (i = alpm_pkg_get_replaces (pkg); i != NULL; i = i->next) { + pmpkg_t *replaces = alpm_db_get_pkg (localdb, i->data); + + if (replaces != NULL) { + gchar *package = alpm_pkg_build_id (replaces); + if (string == NULL) { + string = g_string_new (package); + } else { + g_string_append_printf (string, "&%s", package); + } + g_free (package); + } + } + + if (string != NULL) { + return g_string_free (string, FALSE); + } else { + return NULL; + } +} + +static gchar * +alpm_pkg_build_urls (pmpkg_t *pkg) +{ + GString *string = g_string_new (""); +#ifdef ALPM_PACKAGE_URL + const gchar *name, *arch, *repo, *url; +#else + const gchar *url; +#endif + + g_return_val_if_fail (pkg != NULL, NULL); + + /* grab the URL of the package... */ + url = alpm_pkg_get_url (pkg); + if (url != NULL) { + g_string_append_printf (string, "%s;Package website;", url); + } + +#ifdef ALPM_PACKAGE_URL + /* ... and construct the distro URL if possible */ + name = alpm_pkg_get_name (pkg); + arch = alpm_pkg_get_arch (pkg); + repo = alpm_db_get_name (alpm_pkg_get_db (pkg)); + + g_string_append_printf (string, ALPM_PACKAGE_URL ";Distribution page;", + repo, arch, name); +#endif + + g_string_truncate (string, string->len - 1); + return g_string_free (string, FALSE); +} + +static gboolean +alpm_pkg_same_pkgver (pmpkg_t *a, pmpkg_t *b) +{ + const gchar *version_a, *version_b, *last_a, *last_b; + gsize length_a, length_b; + + g_return_val_if_fail (a != NULL, (b == NULL)); + g_return_val_if_fail (b != NULL, FALSE); + + version_a = alpm_pkg_get_version (a); + version_b = alpm_pkg_get_version (b); + + last_a = strrchr (version_a, '-'); + last_b = strrchr (version_b, '-'); + + if (last_a != NULL) { + length_a = last_a - version_a; + } else { + length_a = strlen (version_a); + } + + if (last_b != NULL) { + length_b = last_b - version_b; + } else { + length_b = strlen (version_b); + } + + if (length_a != length_b) { + return FALSE; + } else { + return strncmp (version_a, version_b, length_a) == 0; + } +} + +static gboolean +pk_backend_get_update_detail_thread (PkBackend *self) +{ + gchar **packages; + GError *error = NULL; + + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (localdb != NULL, FALSE); + + packages = pk_backend_get_strv (self, "package_ids"); + + g_return_val_if_fail (packages != NULL, FALSE); + + /* collect details about updates */ + for (; *packages != NULL; ++packages) { + pmpkg_t *pkg, *old; + pmdb_t *db; + + gchar *upgrades, *replaces, *urls; + const gchar *reason; + + PkRestartEnum restart; + PkUpdateStateEnum state; + + GTimeVal built = { 0 }, installed = { 0 }; + gchar *issued, *updated; + + if (pk_backend_cancelled (self)) { + break; + } + + pkg = pk_backend_find_pkg (self, *packages, &error); + if (pkg == NULL) { + break; + } + + old = alpm_db_get_pkg (localdb, alpm_pkg_get_name (pkg)); + if (old != NULL) { + upgrades = alpm_pkg_build_id (old); + if (alpm_pkg_same_pkgver (pkg, old)) { + reason = "Update to a newer release"; + } else { + reason = "Update to a new upstream version"; + } + } else { + upgrades = NULL; + reason = "Install to replace an older package"; + } + + db = alpm_pkg_get_db (pkg); + replaces = alpm_pkg_build_replaces (pkg); + urls = alpm_pkg_build_urls (pkg); + + if (g_str_has_prefix (alpm_pkg_get_name (pkg), "kernel")) { + restart = PK_RESTART_ENUM_SYSTEM; + } else { + restart = PK_RESTART_ENUM_NONE; + } + + if (g_str_has_suffix (alpm_db_get_name (db), "testing")) { + state = PK_UPDATE_STATE_ENUM_TESTING; + } else { + state = PK_UPDATE_STATE_ENUM_STABLE; + } + + built.tv_sec = alpm_pkg_get_builddate (pkg); + if (built.tv_sec > 0) { + issued = g_time_val_to_iso8601 (&built); + } else { + issued = NULL; + } + + if (upgrades != NULL) { + installed.tv_sec = alpm_pkg_get_installdate (old); + if (installed.tv_sec > 0) { + updated = g_time_val_to_iso8601 (&installed); + } else { + updated = NULL; + } + } else { + updated = NULL; + } + + pk_backend_update_detail (self, *packages, upgrades, replaces, + urls, NULL, NULL, restart, reason, + NULL, state, issued, updated); + + g_free (issued); + g_free (updated); + + g_free (urls); + g_free (replaces); + g_free (upgrades); + } + + return pk_backend_finish (self, error); +} + +void +pk_backend_get_update_detail (PkBackend *self, gchar **package_ids) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (package_ids != NULL); + + pk_backend_run (self, PK_STATUS_ENUM_QUERY, + pk_backend_get_update_detail_thread); +} + +static gboolean +pk_backend_update_databases (PkBackend *self, gint force, GError **error) { + alpm_cb_download dlcb; + alpm_cb_totaldl totaldlcb; + const alpm_list_t *i; + + g_return_val_if_fail (self != NULL, FALSE); + + if (!pk_backend_transaction_initialize (self, 0, error)) { + return FALSE; + } + + alpm_logaction ("synchronizing package lists\n"); + + dlcb = alpm_option_get_dlcb (); + totaldlcb = alpm_option_get_totaldlcb (); + + /* set total size to minus the number of databases */ + i = alpm_option_get_syncdbs (); + totaldlcb (-alpm_list_count (i)); + + for (; i != NULL; i = i->next) { + gint result; + + if (pk_backend_cancelled (self)) { + /* pretend to be finished */ + i = NULL; + break; + } + + result = alpm_db_update (force, i->data); + + if (result > 0) { + /* fake the download when already up to date */ + dlcb ("", 1, 1); + } else if (result < 0) { + g_set_error (error, ALPM_ERROR, pm_errno, "[%s]: %s", + alpm_db_get_name (i->data), + alpm_strerrorlast ()); + break; + } + } + + totaldlcb (0); + + if (i == NULL) { + return pk_backend_transaction_end (self, error); + } else { + pk_backend_transaction_end (self, NULL); + return FALSE; + } +} + +static gboolean +alpm_pkg_is_ignorepkg (pmpkg_t *pkg) +{ + const alpm_list_t *ignorepkgs, *ignoregrps, *i; + + g_return_val_if_fail (pkg != NULL, TRUE); + + ignorepkgs = alpm_option_get_ignorepkgs (); + if (alpm_list_find_str (ignorepkgs, alpm_pkg_get_name (pkg)) != NULL) { + return TRUE; + } + + ignoregrps = alpm_option_get_ignoregrps (); + for (i = alpm_pkg_get_groups (pkg); i != NULL; i = i->next) { + if (alpm_list_find_str (ignoregrps, i->data) != NULL) { + return TRUE; + } + } + + return FALSE; +} + +static gboolean +alpm_pkg_is_syncfirst (pmpkg_t *pkg) +{ + g_return_val_if_fail (pkg != NULL, FALSE); + + if (alpm_list_find_str (syncfirsts, alpm_pkg_get_name (pkg)) != NULL) { + return TRUE; + } + + return FALSE; +} + +static pmpkg_t * +alpm_pkg_find_update (pmpkg_t *pkg, const alpm_list_t *dbs) +{ + const gchar *name; + const alpm_list_t *i; + + g_return_val_if_fail (pkg != NULL, NULL); + + name = alpm_pkg_get_name (pkg); + + for (; dbs != NULL; dbs = dbs->next) { + pmpkg_t *update = alpm_db_get_pkg (dbs->data, name); + + if (update != NULL) { + if (alpm_pkg_vercmp (alpm_pkg_get_version (update), + alpm_pkg_get_version (pkg)) > 0) { + return update; + } else { + return NULL; + } + } + + i = alpm_db_get_pkgcache (dbs->data); + for (; i != NULL; i = i->next) { + if (alpm_list_find_str (alpm_pkg_get_replaces (i->data), + name) != NULL) { + return i->data; + } + } + } + + return NULL; +} + +static gboolean +pk_backend_get_updates_thread (PkBackend *self) +{ + struct stat cache; + time_t one_hour_ago; + const alpm_list_t *i, *syncdbs; + + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (localdb != NULL, FALSE); + + time (&one_hour_ago); + one_hour_ago -= 60 * 60; + + /* refresh databases if they are older than an hour */ + if (g_stat (ALPM_CACHE_PATH, &cache) < 0 || + cache.st_mtime < one_hour_ago) { + GError *error = NULL; + /* show updates even if the databases could not be updated */ + if (!pk_backend_update_databases (self, 0, &error)) { + g_warning ("%s", error->message); + } + } else { + g_debug ("databases have been refreshed recently"); + } + + /* find outdated and replacement packages */ + syncdbs = alpm_option_get_syncdbs (); + for (i = alpm_db_get_pkgcache (localdb); i != NULL; i = i->next) { + pmpkg_t *upgrade = alpm_pkg_find_update (i->data, syncdbs); + + if (pk_backend_cancelled (self)) { + break; + } else if (upgrade != NULL) { + PkInfoEnum info; + + if (alpm_pkg_is_ignorepkg (upgrade)) { + info = PK_INFO_ENUM_BLOCKED; + } else if (alpm_pkg_is_syncfirst (upgrade)) { + info = PK_INFO_ENUM_IMPORTANT; + } else { + info = PK_INFO_ENUM_NORMAL; + } + + pk_backend_pkg (self, upgrade, info); + } + } + + return pk_backend_finish (self, NULL); +} + +void +pk_backend_get_updates (PkBackend *self, PkBitfield filters) +{ + g_return_if_fail (self != NULL); + + pk_backend_run (self, PK_STATUS_ENUM_QUERY, + pk_backend_get_updates_thread); +} + +static gboolean +pk_backend_refresh_cache_thread (PkBackend *self) +{ + gint force; + GError *error = NULL; + + g_return_val_if_fail (self != NULL, FALSE); + + /* download databases even if they are older than current */ + force = (gint) pk_backend_get_bool (self, "force"); + + pk_backend_update_databases (self, force, &error); + return pk_backend_finish (self, error); +} + +void +pk_backend_refresh_cache (PkBackend *self, gboolean force) +{ + g_return_if_fail (self != NULL); + + pk_backend_run (self, PK_STATUS_ENUM_SETUP, + pk_backend_refresh_cache_thread); +} diff --git a/backends/alpm/pk-backend-update.h b/backends/alpm/pk-backend-update.h new file mode 100644 index 000000000..368965a01 --- /dev/null +++ b/backends/alpm/pk-backend-update.h @@ -0,0 +1,22 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> + * Copyright (C) 2008-2010 Valeriy Lyasotskiy <onestep@ukr.net> + * Copyright (C) 2010-2011 Jonathan Conder <jonno.conder@gmail.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ diff --git a/backends/alpm/repos.list b/backends/alpm/repos.list new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/backends/alpm/repos.list diff --git a/backends/conary/Makefile.am b/backends/conary/Makefile.am index 7a71ef011..7a3fed330 100644 --- a/backends/conary/Makefile.am +++ b/backends/conary/Makefile.am @@ -7,11 +7,11 @@ dist_helper_DATA = \ conaryFilter.py \ conaryCallback.py \ conaryInit.py \ - XMLCache.py \ - generateXML.py \ + XMLCache.py \ + generateXML.py \ pkConaryLog.py \ - conarypk.py \ - conaryProgress.py \ + conarypk.py \ + conaryProgress.py \ conaryEnums.py plugindir = $(PK_PLUGIN_DIR) @@ -26,4 +26,3 @@ install-data-hook: clean-local : rm -f *~ - diff --git a/backends/conary/TODO b/backends/conary/TODO index bb7f580d7..b4e975ce7 100644 --- a/backends/conary/TODO +++ b/backends/conary/TODO @@ -1,15 +1,19 @@ * the XML cache doesn't include all packages (e.g. ubuntu-font-family/automake) - there is probably bugs in the tool ('ticache') that generates the cache. * should support system model - - the conary-api related code should all be put in conarypk.py - - Note: some allow_cancel/status() calls may be lost when moving the code. - - implement search + - don't use conary API directly in conaryBackend.py + - move self.xmlcache into conarypk, so it won't come in the way of system + model support. + - implement search (pending upcoming features of conary) * fix use of post_process and implement _pkg_compare in conaryFilter.py - http://lists.freedesktop.org/archives/packagekit/2011-March/006245.html -* update conaryCallback.py to base on new callbacks - (conary/cmds/updatecmd.py:UpdateCallback) so it can handle system-model. -* a bug (seems in conary?): - - sudo conary install gitweb --> "install gitweb" in /etc/conary/system-model - (right) - - sudo conary erase gitweb --> "install gitweb" becomes "erase gitweb" - (wrong; the line should be just deleted) +* simplify _resolve_list(). It calls conary API directly and has much + duplication with resolve(). + - _show_package_list() has duplication with the newly added _show_packages() + - the data structure dict(trove, metadata) (as used in _show_package_list()) + is too complicated than necessary. +* decide what to do with package components +* don't show dead packages: + - version == '0' +* conarypk.py: move _classic_build_update_job()/_classic_get_package_update()/_classic_get_updateall_job() + out of the ConaryPk and change them into functions, as the _model* functions. diff --git a/backends/conary/XMLCache.py b/backends/conary/XMLCache.py index c38d5ea74..9ab86f397 100644 --- a/backends/conary/XMLCache.py +++ b/backends/conary/XMLCache.py @@ -7,7 +7,6 @@ from packagekit.backend import * from packagekit.enums import ERROR_NO_CACHE,ERROR_REPO_CONFIGURATION_ERROR, ERROR_NO_NETWORK from pkConaryLog import log -from conarypk import ConaryPk from conaryEnums import groupMap import generateXML @@ -111,7 +110,7 @@ class XMLRepo: except: self.pk.error(ERROR_NO_NETWORK,"Failed to fetch %s." % wwwfile) else: - generateXML.init(self.label, self.xml_file, self.conarypk) + generateXML.init(self.label, self.xml_file) def refresh_cache(self, force=False): if force or not os.path.exists(self.xml_file): @@ -221,9 +220,7 @@ class XMLCache: dbPath = '/var/cache/conary/' xml_path = dbPath + "xmlrepo/" - def __init__(self): - self.conarypk = ConaryPk() - self.labels = ( x for x in self.conarypk.get_labels_from_config() ) + def __init__(self, labels): self.pk = PackageKitBaseBackend("") if not os.path.isdir(self.dbPath): @@ -231,7 +228,7 @@ class XMLCache: if not os.path.isdir( self.xml_path ): os.makedirs(self.xml_path ) - for label in self.labels: + for label in labels: self.repos.append(XMLRepo(label, self.xml_path, self.pk)) def convertTroveToDict(self, troveTupleList): diff --git a/backends/conary/conaryBackend.py b/backends/conary/conaryBackend.py index 61855caf4..093475e8c 100755 --- a/backends/conary/conaryBackend.py +++ b/backends/conary/conaryBackend.py @@ -1,5 +1,5 @@ #!/usr/bin/python -#{{{ Licensed under the GNU General Public License Version 2 +# 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 @@ -19,74 +19,54 @@ # Copyright (C) 2008 Richard Hughes <richard@hughsie.com> # Copyright (C) 2009-2010 Andres Vargas <zodman@foresightlinux.org> # Scott Parkerson <scott.parkerson@gmail.com> -# }}} -#{{{ LIBS + import sys -import os -import re -import xmlrpclib - -from conary import dbstore, queryrep, versions, updatecmd -from conary import errors, conarycfg, conaryclient -from conary import trove -from conary.conaryclient import cmdline -from conary.deps import deps -from conary.lib import util -from conary.local import database + +from conary.conaryclient import DepResolutionFailure +from conary.errors import InternalConaryError +from conary.trove import TroveIntegrityError from packagekit.backend import get_package_id, split_package_id, \ PackageKitBaseBackend -from packagekit.enums import * +from packagekit.enums import (ERROR_DEP_RESOLUTION_FAILED, ERROR_NO_CACHE, + ERROR_NO_PACKAGES_TO_UPDATE, ERROR_UNKNOWN, FILTER_INSTALLED, + FILTER_NOT_INSTALLED, INFO_INSTALLING, INFO_NORMAL, INFO_REMOVING, + INFO_SECURITY, INFO_UPDATING, MESSAGE_COULD_NOT_FIND_PACKAGE, + RESTART_APPLICATION, RESTART_NONE, RESTART_SYSTEM, STATUS_INFO, + STATUS_QUERY, STATUS_REFRESH_CACHE, STATUS_RUNNING, STATUS_UPDATE, + UPDATE_STATE_STABLE, UPDATE_STATE_TESTING, UPDATE_STATE_UNSTABLE) from conaryCallback import UpdateCallback, GetUpdateCallback from conaryCallback import RemoveCallback, UpdateSystemCallback from conaryFilter import ConaryFilter from XMLCache import XMLCache -from pkConaryLog import log import conarypk -sys.excepthook = util.genExcepthook() -#{{{ FUNCTIONS -def ExceptionHandler(func): - return func - def display(error): - log.info(error) - return str(error).replace('\n', ' ').replace("\t",'') +# To use the logger, uncomment this line: +# from pkConaryLog import log + +def ConaryExceptionHandler(func): + '''Centralized handler for conary Exceptions + + Currently only considers conary install/erase/updateall. + ''' def wrapper(self, *args, **kwargs): try: return func(self, *args, **kwargs) - #except Exception: - # raise - except conaryclient.NoNewTrovesError: - return - except conaryclient.DepResolutionFailure, e: - self.error(ERROR_DEP_RESOLUTION_FAILED, display(e), exit=True) - except conaryclient.UpdateError, e: - # FIXME: Need a enum for UpdateError - self.error(ERROR_UNKNOWN, display(e), exit=True) - except Exception, e: - self.error(ERROR_UNKNOWN, display(e), exit=True) + except DepResolutionFailure as e: + deps = [str(i[0][0]).split(":")[0] for i in e.cannotResolve] + self.error(ERROR_DEP_RESOLUTION_FAILED, ", ".join(set(deps))) + except InternalConaryError as e: + if str(e) == "Stale update job": + self.conary.clear_job_cache() + # The UpdateJob can be invalid. It's probably because after the + # update job is fozen, the state of the database has changed. + self.error(ERROR_NO_CACHE, + "The previously cached update job is broken. Please try again.") + except TroveIntegrityError: + self.error(ERROR_NO_PACKAGES_TO_UPDATE, "Network error. Try again") return wrapper -def _format_str(str): - """ - Convert a multi line string to a list separated by ';' - """ - if str: - lines = str.split('\n') - return ";".join(lines) - else: - return "" - -def _format_list(lst): - """ - Convert a multi line string to a list separated by ';' - """ - if lst: - return ";".join(lst) - else: - return "" - def _get_trovespec_from_ids(package_ids): ret = [] for p in package_ids: @@ -100,6 +80,31 @@ def _get_trovespec_from_ids(package_ids): ret.append(trovespec) return ret +def _get_fits(branch): + if "conary.rpath.com" in branch: + return "http://issues.rpath.com; rPath Issue Tracking System" + elif "foresight.rpath.org" in branch: + return "http://issues.foresightlinux.org; Foresight Issue Tracking System" + else: + return "" + +def _get_license(license_list): + if license_list == "": + return "" + + # license_list is a list of licenses in the format of + # 'rpath.com/licenses/copyright/GPL-2'. + return " ".join([i.split("/")[-1] for i in license_list]) + +def _get_branch(branch): + branchList = branch.split("@") + if "2-qa" in branchList[1]: + return UPDATE_STATE_TESTING + elif "2-devel" in branchList[1]: + return UPDATE_STATE_UNSTABLE + else: + return UPDATE_STATE_STABLE + class PackageKitConaryBackend(PackageKitBaseBackend): # Packages that require a reboot rebootpkgs = ("kernel", "glibc", "hal", "dbus") @@ -113,66 +118,16 @@ class PackageKitConaryBackend(PackageKitBaseBackend): self.cfg = conary.cfg self.client = conary.cli self.conary = conary - self.xmlcache = XMLCache() - - def _freezeData(self, version, flavor): - frzVersion = version.freeze() - frzFlavor = flavor.freeze() - return ','.join([frzVersion, frzFlavor]) - - def _thawData(self, frzVersion, frzFlavor ): - version = versions.ThawVersion(frzVersion) - flavor = deps.ThawFlavor(frzFlavor) - return version, flavor - #}}} - @ExceptionHandler - def check_installed(self, troveTuple): - log.info("============check installed =========") - result = self.conary.query(troveTuple[0]) - if result: - installed = INFO_INSTALLED - else: - installed = INFO_AVAILABLE - return installed + self.xmlcache = XMLCache(self.conary.get_labels()) def _get_package_name_from_ids(self, package_ids): return [split_package_id(x)[0] for x in package_ids] - def get_package_id_new(self,pkg): - name,version,flavor = pkg.get("trove") - metadata = pkg.get("metadata") - data = "" - if metadata: - if "shortDesc" in metadata: - data = metadata['shortDesc'].decode("UTF") - if data == "." or data == "": - data = name.replace("-",' ').capitalize() - return get_package_id(name, str(version.trailingRevision()), - conarypk.get_arch(flavor), data) - - @ExceptionHandler - def get_package_id(self, name, versionObj, flavor): - version = versionObj.trailingRevision() - arch = conarypk.get_arch(flavor) - data = "" - pkg = self.xmlcache.resolve(name) - if pkg: - if "shortDesc" in pkg: - data = pkg['shortDesc'].decode("UTF") - if data == "." or data == "": - data = name.replace("-",' ').capitalize() - - return get_package_id(name, version, arch, data) - - @ExceptionHandler - def get_package_from_id(self, package_id): - """ package_id(string) = - "dpaster;0.1-3-1;x86;Summary" - """ - log.info("=========== get package from package_id ======================") - name, verString, archString, data = split_package_id(package_id) - troves = self.conary.query(name) or self.conary.repo_query(name) - return troves + def _format_package_summary(self, name, short_desc): + data = short_desc + if data == "." or data == "": + data = name.replace("-",' ').capitalize() + return data def _search_package(self, pkg_list, name): for pkg in pkg_list: @@ -180,10 +135,10 @@ class PackageKitConaryBackend(PackageKitBaseBackend): return pkg return None - def _convert_package( self, trove , pkgDict ): + def _convert_package(self, trovetuple, metadata): return dict( - trove = trove , - metadata = pkgDict + trove = trovetuple, + metadata = metadata ) def _do_search(self, filters, searchlist, where = "name"): @@ -193,10 +148,8 @@ class PackageKitConaryBackend(PackageKitBaseBackend): """ fltlist = filters if where not in ("name", "details", "group", "all"): - log.info("where %s" % where) self.error(ERROR_UNKNOWN, "DORK---- search where not found") - log.debug((searchlist, where)) pkgList = self.xmlcache.search(searchlist, where ) if len(pkgList) > 0 : @@ -205,89 +158,74 @@ class PackageKitConaryBackend(PackageKitBaseBackend): self._resolve_list(to_resolve, fltlist) else: - log.info("NOT FOUND %s " % searchlist ) self.message(MESSAGE_COULD_NOT_FIND_PACKAGE,"search not found") - def _do_conary_update(self, op, *args): - '''Wrapper around ConaryPk.install/erase() so we are add exception - handling - ''' - try: - if op == 'install': - ret = self.conary.install(*args) - elif op == 'erase': - ret = self.conary.erase(*args) - else: - self.error(ERROR_INTERNAL_ERROR, 'Unkown command: %s' % op) - except conaryclient.DepResolutionFailure as e: - deps = [str(i[0][0]).split(":")[0] for i in e.cannotResolve] - self.error(ERROR_DEP_RESOLUTION_FAILED, ", ".join(set(deps))) - except errors.InternalConaryError as e: - if str(e) == "Stale update job": - self.conary.clear_job_cache() - # The UpdateJob can be invalid. It's probably because after the - # update job is fozen, the state of the database has changed. - self.error(ERROR_INVALID_PACKAGE_FILE, - "Previously cached file is broken. Try again") - except trove.TroveIntegrityError: - self.error(ERROR_NO_PACKAGES_TO_UPDATE, "Network error. Try again") - return ret - def _resolve_list(self, pkg_list, filters): - # 1. Resolve through local db - - list_trove_all = [p.get("trove") for p in pkg_list] - list_installed = [] - list_not_installed = [] - - if FILTER_NOT_INSTALLED in filters: - list_not_installed = pkg_list[:] - else: - db_trove_list = self.client.db.findTroves(None, list_trove_all, allowMissing=True) - for trove in list_trove_all: - pkg = self._search_package(pkg_list, trove[0]) - if trove in db_trove_list: - # A package may have different versions/flavors installed. - for t in db_trove_list[trove]: - list_installed.append(dict(trove=t, metadata=pkg["metadata"])) - else: - list_not_installed.append(pkg) - - # Our list of troves doesn't contain information about whether trove is - # installed, so ConaryFilter can't do proper filtering. Don't pass - # @filters to it. Instead manually check the filters before calling - # add_installed() and add_available(). pkgFilter = ConaryFilter() - pkgFilter.add_installed(list_installed) - log.info("Packages installed .... %s " % len(list_installed)) - log.info("Packages available .... %s " % len(list_not_installed)) - # 2. Resolve through repository + installed = [] + if FILTER_NOT_INSTALLED not in filters: + installed = self._resolve_local(pkgFilter, pkg_list) if FILTER_INSTALLED not in filters: - list_trove_not_installed = [] - for pkg in list_not_installed: - name,version,flavor = pkg.get("trove") - trove = (name, version, self.conary.flavor) - list_trove_not_installed.append(trove) - - list_available = [] - repo_trove_list = self.client.repos.findTroves(self.conary.default_label, - list_trove_not_installed, allowMissing=True) - - for trove in list_trove_not_installed: - if trove in repo_trove_list: - # only use the first trove in the list - t = repo_trove_list[trove][0] - pkg = self._search_package(pkg_list, t[0]) - pkg["trove"] = t - list_available.append(pkg) - pkgFilter.add_available( list_available ) + pkg_list = [x for x in pkg_list if x not in installed] + self._resolve_repo(pkgFilter, pkg_list) package_list = pkgFilter.post_process() self._show_package_list(package_list) - @ExceptionHandler + def _resolve_local(self, pkgFilter, pkg_list): + '''Find out installed packages from pkg_list + + If a package from pkg_list can be found locally, add it (after some + convertion) to pkgFilter. + + Returns the list of installed packages. + ''' + ret = [] + + list_trove_all = [p.get("trove") for p in pkg_list] + db_trove_list = self.client.db.findTroves(None, list_trove_all, allowMissing=True) + + list_installed = [] + for trv in list_trove_all: + if trv in db_trove_list: + pkg = self._search_package(pkg_list, trv[0]) + # A package may have different versions/flavors installed. + for t in db_trove_list[trv]: + list_installed.append(self._convert_package(t, pkg["metadata"])) + ret.append(pkg) + pkgFilter.add_installed(list_installed) + + return ret + + def _resolve_repo(self, pkgFilter, pkg_list): + '''Find out packages from pkg_list that are available in the repository + + If a package from pkg_list can be found in the repo, add it (after some + convertion) to pkgFilter. + + No return value. + ''' + list_trove_all = [] + for pkg in pkg_list: + name, version, flavor = pkg.get("trove") + trv = (name, version, self.conary.flavor) + list_trove_all.append(trv) + + repo_trove_list = self.client.repos.findTroves(self.conary.default_label, + list_trove_all, allowMissing=True) + + list_available = [] + for trv in list_trove_all: + if trv in repo_trove_list: + # only use the first trove in the list + t = repo_trove_list[trv][0] + pkg = self._search_package(pkg_list, t[0]) + pkg["trove"] = t + list_available.append(pkg) + pkgFilter.add_available(list_available) + def resolve(self, filters, package ): """ @filters (list) list of filters @@ -301,220 +239,160 @@ class PackageKitConaryBackend(PackageKitBaseBackend): if pkg_dict is None: return None - log.info("doing a resolve") # Our list of troves doesn't contain information about whether trove is # installed, so ConaryFilter can't do proper filtering. Don't pass # @filters to it. Instead manually check the filters before calling # add_installed() and add_available(). - filter = ConaryFilter() + pkgfilter = ConaryFilter() is_found_locally = False if FILTER_NOT_INSTALLED not in filters: trove_installed = self.conary.query(pkg_dict.get("name")) - log.info("end of conary query") for trv in trove_installed: pkg = self._convert_package(trv, pkg_dict) - filter.add_installed([pkg]) + pkgfilter.add_installed([pkg]) is_found_locally = True if not is_found_locally and FILTER_INSTALLED not in filters: trove_available = self.conary.repo_query(pkg_dict.get("name")) - log.info("end of conary rquery") - if trove_available: - pkg = self._convert_package(trove_available[0], pkg_dict) - filter.add_available([pkg]) + for trv in trove_available: + pkg = self._convert_package(trv, pkg_dict) + pkgfilter.add_available([pkg]) - package_list = filter.post_process() - log.info("package_list %s" % package_list) + package_list = pkgfilter.post_process() self._show_package_list(package_list) - log.info("end resolve ...................") def _show_package_list(self, lst): """@lst(list(tuple) = [ ( troveTuple, status ) ] """ for pkg, status in lst: - package_id = self.get_package_id_new(pkg) + name, v, f = pkg["trove"] + version = str(v.trailingRevision()) + label = str(v.trailingLabel()) + arch = conarypk.get_arch(f) - # split the list for get Determine info - summary = package_id.split(";") - name = summary[0] - meta = summary[3] + pkg_id = get_package_id(name, version, arch, label) - summary[3] = pkg.get("metadata").get("label") - pkg_id = ";".join(summary) - self.package(package_id, status, meta ) + summary = self._format_package_summary(name, + pkg["metadata"].get("shortDesc", "").decode("UTF")) + self.package(pkg_id, status, summary) - @ExceptionHandler def search_group(self, options, searchlist): - ''' - Implement the {backend}-search-group functionality - ''' - log.info("============= search_group ========") self.allow_cancel(True) self.percentage(None) self.status(STATUS_QUERY) - log.info("options: %s searchlist:%s "%(options, searchlist)) self._do_search(options, searchlist, 'group') - @ExceptionHandler def search_file(self, filters, search ): - - log.info("============= search_file ========") self.allow_cancel(True) - self.percentage(0) + self.percentage(None) self.status(STATUS_QUERY) - log.info("options: %s searchlist:%s "%(filters, search)) - self.percentage(10) - - - self.percentage(20) - - - self.percentage(30) name = self.conary.search_path( search ) - self.percentage(50) - log.info(name) if name: - log.info("resolving") if ":" in name: name = name.split(":")[0] self.resolve( filters, [name]) - @ExceptionHandler def search_name(self, options, searchlist): - ''' - Implement the {backend}-search-name functionality - ''' - log.info("============= search_name ========") self.allow_cancel(True) self.percentage(None) self.status(STATUS_QUERY) - log.info("options: %s searchlist:%s "%(options, searchlist)) self._do_search(options, searchlist, 'name') - @ExceptionHandler def search_details(self, options, search): - ''' - Implement the {backend}-search-details functionality - ''' - log.info("============= search_details ========") self.allow_cancel(True) #self.percentage(None) self.status(STATUS_QUERY) - log.info("options: %s searchlist:%s "%(options, search)) self._do_search(options, search, 'details' ) - - @ExceptionHandler - def get_packages(self, filter ): + def get_packages(self, filters): self.allow_cancel(False) self.status(STATUS_QUERY) - log.info("options: %s searchlist:%s "%(filter,"all")) - self._do_search(filter, "", 'all' ) - + self._do_search(filters, "", 'all' ) - def get_requires(self, filters, package_ids, recursive_text): - pass - - @ExceptionHandler def get_files(self, package_ids): self.allow_cancel(True) self.percentage(None) self.status(STATUS_INFO) - package_id = package_ids[0] - def _get_files(troveSource, n, v, f): - files = [] - trv = troveSource.getTrove(n, v, f) - for (n, v, f) in [x for x in trv.iterTroveList(strongRefs=True) - if troveSource.hasTrove(*x)]: - for (pathId, path, fileId, version, filename) in \ - troveSource.iterFilesInTrove(n, v, f, sortByPath = True, - withFiles=True, capsules=False): - files.append(path) - return files - - for package in package_id.split("&"): - log.info(package) - name, version, flavor, installed = self._findPackage(package) - - if installed == INFO_INSTALLED: - files = _get_files(self.client.db, name, version, flavor) - else: - files = _get_files(self.client.repos, name, version, flavor) + for package_id in package_ids: + name, version, arch, data = split_package_id(package_id) + files = self.conary.list_files('%s=%s[is: %s]' % + (name, version, arch)) self.files(package_id, ';'.join(files)) - def _do_conary_updateall(self, callback, dry_run): - '''Wrapper around ConaryPk.updateall() so we are add exception handling - ''' - try: - ret = self.conary.updateall(callback, dry_run) - except xmlrpclib.ProtocolError as e: - self.error(ERROR_NO_NETWORK, '%s. Try again.' % str(e)) - return ret - - @ExceptionHandler + @ConaryExceptionHandler def update_system(self, only_trusted): - # FIXME: use only_trusted - - self.allow_cancel(True) + self.allow_cancel(False) self.status(STATUS_UPDATE) cb = UpdateSystemCallback(self, self.cfg) - self._do_conary_updateall(cb, dry_run=False) + self.conary.updateall(cb, dry_run=False) -# @ExceptionHandler def refresh_cache(self, force): # TODO: use force ? - - #log.debug("refresh-cache command ") - # self.percentage() - self.percentage(None) self.status(STATUS_REFRESH_CACHE) self.percentage(None) self.xmlcache.refresh() + def _show_packages(self, pkgs): + '''Emit Package signals for a list of packages + + pkgs should be a list of (name, Version, Flavor, status) tuples. + ''' + for (name, v, f, status) in pkgs: + version = str(v.trailingRevision()) + arch = conarypk.get_arch(f) + label = str(v.trailingLabel()) + pkg_id = get_package_id(name, version, arch, label) + summary = self._format_package_summary(name, "") + self.package(pkg_id, status, summary) + def _display_update_jobs(self, install_jobs, erase_jobs, update_jobs): '''Emit package status for a list of installing/erasing/updating jobs ''' + ret = [] for (name, (oldVer, oldFla), (newVer, newFla)) in install_jobs: - v = str(newVer.trailingRevision()) - f = conarypk.get_arch(newFla) - pkg_id = get_package_id(name, v, f, '') - self.package(pkg_id, INFO_INSTALLING, '') + ret.append((name, newVer, newFla, INFO_INSTALLING)) for (name, (oldVer, oldFla), (newVer, newFla)) in erase_jobs: - v = str(oldVer.trailingRevision()) - f = conarypk.get_arch(oldFla) - pkg_id = get_package_id(name, v, f, '') - self.package(pkg_id, INFO_REMOVING, '') + ret.append((name, oldVer, oldFla, INFO_REMOVING)) for (name, (oldVer, oldFla), (newVer, newFla)) in update_jobs: - v = str(oldVer.trailingRevision()) - f = conarypk.get_arch(oldFla) - pkg_id = get_package_id(name, v, f, '') - self.package(pkg_id, INFO_UPDATING, '') + ret.append((name, oldVer, oldFla, INFO_UPDATING)) + + self._show_packages(ret) + + def install_packages(self, only_trusted, package_ids): + self._install_packages(only_trusted, package_ids) + + def simulate_install_packages(self, package_ids): + return self._install_packages(False, package_ids, simulate=True) - def install_packages(self, only_trusted, package_ids, simulate=False): + @ConaryExceptionHandler + def _install_packages(self, only_trusted, package_ids, simulate=False): self.allow_cancel(False) self.percentage(0) self.status(STATUS_RUNNING) pkglist = _get_trovespec_from_ids(package_ids) cb = UpdateCallback(self, self.cfg) - updJob, suggMap = self._do_conary_update('install', pkglist, cb, simulate) + updJob, suggMap = self.conary.install(pkglist, cb, simulate) if simulate: pkgs = self._get_package_name_from_ids(package_ids) - jobs = conarypk.parse_jobs(updJob, excludes=pkgs, - show_components=False) - self._display_update_jobs(*jobs) + installs, erases, updates = conarypk.parse_jobs(updJob, + excludes=pkgs, show_components=False) + self._display_update_jobs(installs, erases, updates) - @ExceptionHandler - def remove_packages(self, allowDeps, autoremove, package_ids, simulate=False): - ''' - Implement the {backend}-remove-packages functionality - ''' + def remove_packages(self, allowDeps, autoremove, package_ids): + self. _remove_packages(allowDeps, autoremove, package_ids) + + def simulate_remove_packages(self, package_ids): + return self._remove_packages(False, False, package_ids, simulate=True) + + @ConaryExceptionHandler + def _remove_packages(self, allowDeps, autoremove, package_ids, simulate=False): # TODO: use autoremove self.allow_cancel(False) self.percentage(0) @@ -522,28 +400,23 @@ class PackageKitConaryBackend(PackageKitBaseBackend): pkglist = _get_trovespec_from_ids(package_ids) cb = RemoveCallback(self, self.cfg) - updJob, suggMap = self._do_conary_update('remove', pkglist, cb, simulate) + updJob, suggMap = self.conary.erase(pkglist, cb, simulate) if simulate: pkgs = self._get_package_name_from_ids(package_ids) - jobs = conarypk.parse_jobs(updJob, excludes=pkgs, - show_components=False) - self._display_update_jobs(*jobs) + installs, erases, updates = conarypk.parse_jobs(updJob, + excludes=pkgs, show_components=False) + self._display_update_jobs(installs, erases, updates) def _check_for_reboot(self, name): if name in self.rebootpkgs: self.require_restart(RESTART_SYSTEM, "") - @ExceptionHandler def get_update_detail(self, package_ids): - ''' - Implement the {backend}-get-update_detail functionality - ''' self.allow_cancel(True) self.percentage(None) self.status(STATUS_INFO) for package_id in package_ids: - log.info(package_id) - name, version,arch,summary = get_package_from_id(package_id) + name, version, arch, label = split_package_id(package_id) pkgDict = self.xmlcache.resolve(name) update = "" obsolete = "" @@ -551,13 +424,12 @@ class PackageKitConaryBackend(PackageKitBaseBackend): if pkgDict: vendor_url = pkgDict.get("url","") desc = pkgDict.get("longDesc","") - reboot = self._get_restart(pkgDict.get("name")) - state = self._get_branch( pkgDict.get("label")) - bz_url = self._get_fits(pkgDict.get("label"), pkgDict.get("name")) + reboot = self._get_restart(name) + state = _get_branch(label) + bz_url = _get_fits(label) self.update_detail(package_id, update, obsolete, vendor_url, bz_url, cve_url, reboot, desc, changelog="", state= state, issued="", updated = "") - # @ExceptionHandler def get_details(self, package_ids): ''' Print a detailed description for a given package @@ -566,23 +438,21 @@ class PackageKitConaryBackend(PackageKitBaseBackend): self.percentage(None) self.status(STATUS_INFO) - log.info("========== get_details =============") for package_id in package_ids: - name,version,arch,data = split_package_id(package_id) + name, version, arch, data = split_package_id(package_id) pkgDict = self.xmlcache.resolve(name) if name and pkgDict: longDesc = "" url = "" categories = None - license = "" + licenses = "" longDesc = pkgDict.get("longDesc", "") url = pkgDict.get("url", "") categories = self.xmlcache.getGroup(pkgDict.get("category","")) - license = self._get_license(pkgDict.get("licenses","")) + licenses = _get_license(pkgDict.get("licenses","")) size = pkgDict.get("size", 0) - log.info("Details: %s, %s, %s, %s, %s, %d" % (package_id, license, categories, longDesc, url, size)) - self.details(package_id, license, categories, longDesc, url, size) + self.details(package_id, licenses, categories, longDesc, url, size) def _get_restart(self, name): if name in self.rebootpkgs: @@ -600,123 +470,39 @@ class PackageKitConaryBackend(PackageKitBaseBackend): else: return INFO_NORMAL - def _get_fits(self, branch, pkg_name): - if "conary.rpath.com" in branch: - return "http://issues.rpath.com;rPath Issues Tracker" - elif "foresight.rpath.org" in branch: - return "http://issues.foresightlinux.org; Foresight Issues Tracker" - else: - return "" - def _get_license(self, license_list ): - if license_list == "": - return "" - - # license_list is a list of licenses in the format of - # 'rpath.com/licenses/copyright/GPL-2'. - return " ".join([i.split("/")[-1] for i in license_list]) - - def _upgrade_from_branch( self, branch): - branchList = branch.split("@") - if "2-qa" in branchList[1]: - return DISTRO_UPGRADE_TESTING - elif "2-devel" in branchList[1]: - return DISTRO_UPGRADE_UNSTABLE - else: - return DISTRO_UPGRADE_STABLE - - - def _get_branch(self, branch ): - branchList = branch.split("@") - if "2-qa" in branchList[1]: - return UPDATE_STATE_TESTING - elif "2-devel" in branchList[1]: - return UPDATE_STATE_UNSTABLE - else: - return UPDATE_STATE_STABLE - def _display_updates(self, jobs): '''Emit Package signals for a list of update jobs jobs should only contain installs and updates. Shouldn't get any erase jobs. ''' + ret = [] for (name, (oldVer, oldFla), (newVer, newFla)) in jobs: - v = str(newVer.trailingRevision()) - f = conarypk.get_arch(newFla) - pkg_id = get_package_id(name, v, f, '') info = self._get_update_priority(name) - self.package(pkg_id, info, '') + ret.append((name, newVer, newFla, info)) + + self._show_packages(ret) - @ExceptionHandler + @ConaryExceptionHandler def get_updates(self, filters): self.allow_cancel(True) self.percentage(0) self.status(STATUS_INFO) cb = GetUpdateCallback(self, self.cfg) - updJob, suggMap = self._do_conary_updateall(cb, dry_run=True) + updJob, suggMap = self.conary.updateall(cb, dry_run=True) installs, erases, updates = conarypk.parse_jobs(updJob, show_components=False) self._display_updates(installs + updates) - def _findPackage(self, package_id): - ''' - find a package based on a package id (name;version;arch;summary) - ''' - log.info("========== _findPackage ==========") - log.info(package_id) - troveTuples = self.get_package_from_id(package_id) - log.info(troveTuples) - for troveTuple in troveTuples: - log.info("======== trove ") - log.info(troveTuple) - installed = self.check_installed(troveTuple) - log.info(installed) - name, version, flavor = troveTuple - return name, version, flavor, installed - else: - self.error(ERROR_INTERNAL_ERROR, "package_id Not Correct ") - - def repo_set_data(self, repoid, parameter, value): - ''' - Implement the {backend}-repo-set-data functionality - ''' - pass - def get_repo_list(self, filters): - ''' - Implement the {backend}-get-repo-list functionality - ''' - log.info("======= get repo list ===========0") - labels = self.conary.get_labels_from_config() + labels = self.conary.get_labels() self.status(STATUS_QUERY) for repo in labels: - repo_name = repo.split("@")[0] - repo_branch = repo.split("@")[1] - self.repo_detail(repo,repo,True) - - def repo_enable(self, repoid, enable): - ''' - Implement the {backend}-repo-enable functionality - ''' - pass - - def simulate_install_packages(self, package_ids): - ''' - Simulate an install of one or more packages. - ''' - return self.install_packages(False, package_ids, simulate=True) - - def simulate_remove_packages(self, package_ids): - ''' - Simulate an update of one or more packages. - ''' - return self.remove_packages(False, False, package_ids, simulate=True) + self.repo_detail(repo, repo, True) def main(): backend = PackageKitConaryBackend('') - log.info("======== argv =========== ") - log.info(sys.argv) backend.dispatcher(sys.argv[1:]) if __name__ == "__main__": diff --git a/backends/conary/conaryCallback.py b/backends/conary/conaryCallback.py index e4983b976..a1aa25e2e 100644 --- a/backends/conary/conaryCallback.py +++ b/backends/conary/conaryCallback.py @@ -17,10 +17,17 @@ # # Copyright (C) 2007 Elliot Peele <elliot@bentlogic.net> # Copyright (C) 2008 Richard Hughes <richard@hughsie.com> + from conary import callbacks -from packagekit.backend import * + +from packagekit.backend import get_package_id +from packagekit.enums import (INFO_INSTALLING, INFO_REMOVING, INFO_UPDATING, + STATUS_COMMIT, STATUS_DEP_RESOLVE, STATUS_DOWNLOAD, STATUS_INSTALL, + STATUS_REMOVE, STATUS_REQUEST, STATUS_UPDATE) + from conaryProgress import PackagekitProgress from pkConaryLog import log +import conarypk MEGA = 1048576.0 @@ -92,27 +99,33 @@ class BasePKConaryCallback(callbacks.UpdateCallback): # Don't do anything unless we actually rollback pass - def preparingUpdate(self, troveNum, troveCount, add=0): + def preparingUpdate(self, troveNum, troveCount): + + def _get_package_id(name, v, f): + version = str(v.trailingRevision()) + label = str(v.trailingLabel()) + arch = conarypk.get_arch(f) + package_id = get_package_id(name, version, arch, label) + return package_id + if not self.currentJob or len(self.currentJob) == 0 or troveNum > troveCount: return self.backend.percentage(self.progress.percent) job = self.currentJob[troveNum-1] - name = job[0] - oldVersion, oldFlavor = job[1] - newVersion, newFlavor = job[2] + name, (oldVersion, oldFlavor), (newVersion, newFlavor) = job[:3] if oldVersion and newVersion: - package_id = self.backend.get_package_id(name, newVersion, newFlavor) + package_id = _get_package_id(name, newVersion, newFlavor) log.info("Preparing Update %d out of %d: %s" % (troveNum, troveCount, package_id)) self.backend.status(STATUS_UPDATE) self.backend.package(package_id, INFO_UPDATING, '') elif oldVersion and not newVersion: - package_id = self.backend.get_package_id(name, oldVersion, oldFlavor) + package_id = _get_package_id(name, oldVersion, oldFlavor) log.info("Preparing Remove %d out of %d: %s" % (troveNum, troveCount, package_id)) self.backend.status(STATUS_REMOVE) self.backend.package(package_id, INFO_REMOVING, '') elif not oldVersion and newVersion: - package_id = self.backend.get_package_id(name, newVersion, newFlavor) + package_id = _get_package_id(name, newVersion, newFlavor) log.info("Preparing Install %d out of %d: %s" % (troveNum, troveCount, package_id)) self.backend.status(STATUS_INSTALL) self.backend.package(package_id, INFO_INSTALLING, '') diff --git a/backends/conary/conarypk.py b/backends/conary/conarypk.py index 7d0b64463..2d9eb61e9 100644 --- a/backends/conary/conarypk.py +++ b/backends/conary/conarypk.py @@ -9,19 +9,17 @@ import os from conary import conarycfg, conaryclient from conary import errors +from conary.cmds import query, queryrep from conary.conaryclient import ConaryClient, cmdline from conary.conaryclient import cml, systemmodel, modelupdate -from conary.conaryclient.update import NoNewTrovesError from conary.versions import Label from conary.deps import deps from conary.lib import sha1helper from conary.lib import util -from pkConaryLog import log - -from packagekit.backend import PackageKitBaseBackend -from packagekit.enums import ERROR_NO_NETWORK +# To use the logger, uncomment this line: +# from pkConaryLog import log def get_arch(flavor): '''Turn a Flavor into a string describing the arch @@ -163,7 +161,7 @@ def _model_do_conary_updateall(cfg, callback, dry_run=False): if not dry_run: _model_apply_update_job(ret[0], cfg, modelFile, callback) - return updJob + return ret class UpdateJobCache: '''A cache to store (freeze) conary UpdateJobs. @@ -173,7 +171,7 @@ class UpdateJobCache: def __init__(self, jobPath='/var/cache/conary/jobs/', createJobPath=True): if createJobPath and not os.path.isdir(jobPath): - os.mkdir(jobPath) + os.makedirs(jobPath) self._jobPath = jobPath def _getJobCachePath(self, applyList): @@ -231,11 +229,6 @@ class ConaryPk: self.job_cache = UpdateJobCache() - def _exist_network(self): - if not os.environ.get("NETWORK"): - Pk = PackageKitBaseBackend("") - Pk.error(ERROR_NO_NETWORK,"Not exist network conection") - def clear_job_cache(self): self.job_cache.clearCache() @@ -253,15 +246,55 @@ class ConaryPk: if installLabel: return Label(installLabel) return self.default_label - def get_labels_from_config(self): + def get_labels(self): labels = [] for i in self.default_label: #if "foresight.rpath.org" or "conary.rpath.com" in i.asString(): labels.append(i.asString()) return labels + def _findPackage(self, trovespec): + '''Turn a trovespec into a tuple of (name, Version, Flavor, status) + + If the package is not installed, do a repoquery. + ''' + troveTuples = self.query(trovespec) + installed = True + + if not troveTuples: + troveTuples = self.repo_query(trovespec) + installed = False + + if not troveTuples: + ret = None + else: + name, version, flavor = troveTuples[0] + ret = name, version, flavor, installed + return ret + + def list_files(self, trovespec): + '''List files of a package + ''' + def _get_files(troveSource, n, v, f): + files = [] + trv = troveSource.getTrove(n, v, f) + for (n, v, f) in [x for x in trv.iterTroveList(strongRefs=True) + if troveSource.hasTrove(*x)]: + for (pathId, path, fileId, version, filename) in \ + troveSource.iterFilesInTrove(n, v, f, sortByPath = True, + withFiles=True, capsules=False): + files.append(path) + return files + + name, version, flavor, installed = self._findPackage(trovespec) + if installed: + files = _get_files(self.db, name, version, flavor) + else: + files = _get_files(self.repos, name, version, flavor) + return files + def search_path(self,path_file ): - labels = self.get_labels_from_config() + labels = self.get_labels() where = self._get_repos() for label in self.default_label: trove = where.getTroveLeavesByPath([path_file], label) @@ -269,58 +302,36 @@ class ConaryPk: for ( name,version,flavor) in trove[path_file]: return name - def query(self, name): - """ do a conary query """ - if name is None or name == "": + def query(self, trove): + '''Finds the given trove + + This is a wrapper around getTrovesToDisplay. + + trove is a string "n[=v][[f]]". + Returns a list of (name, Version, Flavor) tuples. + ''' + if trove is None or trove == "": return [] try: - troves = self.db.findTrove( None ,(name , None, None )) - return troves + ret = query.getTrovesToDisplay(self.db, [trove], [], [], False)[0] except errors.TroveNotFound: - return [] + ret = [] + return ret - def repo_query(self, name, installLabel = None): - """ Do a conary request query """ - self._exist_network() - label = self.label( installLabel ) + def repo_query(self, trove): + ''' + trove is a string "n[=v][[f]]". + Returns a list of (name, Version, Flavor) tuples. + ''' repos = self._get_repos() try: - troves = repos.findTrove( label ,( name, None ,self.flavor ) ) - #return repos.getTroves(troves) - return troves + ret = queryrep.getTrovesToDisplay(repos, [trove], [], [], + queryrep.VERSION_FILTER_LATEST, + queryrep.FLAVOR_FILTER_BEST, self.default_label, + self.flavors, None) except errors.TroveNotFound: - return [] - - def get_metadata( self, name , installLabel = None): - pass - - def remove(self, name): - return self.update(name, remove = True ) - def update(self, name, installLabel= None, remove = False ): - cli = self.cli - #get a trove - troves = self.repo_query(name, installLabel) - for trove in troves: - trovespec = self.trove_to_spec( trove, remove ) - try: - # create a Job - job = cli.newUpdateJob() - # Add Update task to Job - cli.prepareUpdateJob(job, cmdline.parseChangeList(trovespec)) - # Apply the Job - cli.applyUpdateJob(job) - # im rulz - return "Update Success of %s" % trovespec - except NoNewTrovesError: - return "no new Troves Found by %s " % trovespec - - def trove_to_spec(self, trove, remove = False ): - # add a -app=blah.rpath.org@rpl:devel for remove packages - if remove: - tmp = '-' - else: - tmp = "" - return tmp + cmdline.toTroveSpec( trove[0], str(trove[1]), None) + ret = [] + return ret def _classic_build_update_job(self, applyList, cache=True): '''Build an UpdateJob from applyList @@ -331,7 +342,7 @@ class ConaryPk: if cache and jobPath: try: updJob.thaw(jobPath) - except IOError, err: + except IOError: updJob = None else: try: @@ -362,6 +373,7 @@ class ConaryPk: ret = self._classic_build_update_job(applyList) if not dry_run: self.cli.applyUpdateJob(ret[0]) + self.clear_job_cache() return ret def install(self, pkglist, callback, dry_run=False): @@ -408,10 +420,3 @@ class ConaryPk: if __name__ == "__main__": conary = ConaryPk() print conary.search_path("/usr/bin/vim") - #print conary.query("gimpasdas") - #print conary.repo_query("dpaster",'zodyrepo.rpath.org@rpl:devel') - #print conary.repo_query("gimp") - #print conary.repo_query("gimpasdasd") - #print conary.update("amsn") - #print conary.remove("amsn") - diff --git a/backends/conary/generateXML.py b/backends/conary/generateXML.py index b8b45a82e..8b3765607 100644 --- a/backends/conary/generateXML.py +++ b/backends/conary/generateXML.py @@ -58,7 +58,7 @@ def generate_xml( troves, label): for cat in value: cat_node = cElementTree.Element("category", lang = "en") cat_node.text = cat - package.append(node) + package.append(cat_node) else: node = cElementTree.Element(key, lang = "en") node.text = value @@ -67,10 +67,9 @@ def generate_xml( troves, label): document.append(package) return document -def init(label, fileoutput, conarypk=None): +def init(label, fileoutput): - if not conarypk: - conarypk = ConaryPk() + conarypk = ConaryPk() cli = conarypk.cli cfg = conarypk.cfg diff --git a/backends/conary/pk-backend-conary.c b/backends/conary/pk-backend-conary.c index 52f55df07..e10b8b28e 100644 --- a/backends/conary/pk-backend-conary.c +++ b/backends/conary/pk-backend-conary.c @@ -28,11 +28,29 @@ static PkBackendSpawn *spawn; /** - * backend_initialize: + * pk_backend_get_description: + */ +gchar * +pk_backend_get_description (PkBackend *backend) +{ + return g_strdup ("Conary"); +} + +/** + * pk_backend_get_author: + */ +gchar * +pk_backend_get_author (PkBackend *backend) +{ + return g_strdup ("Andres Vargas <zodman@foresightlinux.org>"); +} + +/** + * pk_backend_initialize: * This should only be run once per backend load, i.e. not every transaction */ -static void -backend_initialize (PkBackend *backend) +void +pk_backend_initialize (PkBackend *backend) { g_debug ("backend: initialize"); spawn = pk_backend_spawn_new (); @@ -40,21 +58,21 @@ backend_initialize (PkBackend *backend) } /** - * backend_destroy: + * pk_backend_destroy: * This should only be run once per backend load, i.e. not every transaction */ -static void -backend_destroy (PkBackend *backend) +void +pk_backend_destroy (PkBackend *backend) { g_debug ("backend: destroy"); g_object_unref (spawn); } /** - * backend_get_groups: + * pk_backend_get_groups: */ -static PkBitfield -backend_get_groups (PkBackend *backend) +PkBitfield +pk_backend_get_groups (PkBackend *backend) { return pk_bitfield_from_enums ( PK_GROUP_ENUM_ACCESSIBILITY, @@ -71,21 +89,20 @@ backend_get_groups (PkBackend *backend) -1); } - /** - * backend_get_filters: + * pk_backend_get_filters: */ -static PkBitfield -backend_get_filters (PkBackend *backend) +PkBitfield +pk_backend_get_filters (PkBackend *backend) { return pk_bitfield_from_enums (PK_FILTER_ENUM_INSTALLED, -1); } /** - * backend_get_roles: + * pk_backend_get_roles: */ -static PkBitfield -backend_get_roles (PkBackend *backend) +PkBitfield +pk_backend_get_roles (PkBackend *backend) { PkBitfield roles; roles = pk_bitfield_from_enums ( @@ -94,6 +111,7 @@ backend_get_roles (PkBackend *backend) PK_ROLE_ENUM_GET_FILES, PK_ROLE_ENUM_GET_PACKAGES, PK_ROLE_ENUM_GET_UPDATES, + PK_ROLE_ENUM_GET_UPDATE_DETAIL, PK_ROLE_ENUM_INSTALL_PACKAGES, PK_ROLE_ENUM_REFRESH_CACHE, PK_ROLE_ENUM_REMOVE_PACKAGES, @@ -114,18 +132,18 @@ backend_get_roles (PkBackend *backend) /** * pk_backend_cancel: */ -static void -backend_cancel (PkBackend *backend) +void +pk_backend_cancel (PkBackend *backend) { /* this feels bad... */ pk_backend_spawn_kill (spawn); } /** - * backend_get_details: + * pk_backend_get_details: */ -static void -backend_get_details (PkBackend *backend, gchar **package_ids) +void +pk_backend_get_details (PkBackend *backend, gchar **package_ids) { gchar *package_ids_temp; package_ids_temp = pk_package_ids_to_string (package_ids); @@ -134,10 +152,10 @@ backend_get_details (PkBackend *backend, gchar **package_ids) } /** - * backend_get_files: + * pk_backend_get_files: */ -static void -backend_get_files (PkBackend *backend, gchar **package_ids) +void +pk_backend_get_files (PkBackend *backend, gchar **package_ids) { gchar *package_ids_temp; package_ids_temp = pk_package_ids_to_string (package_ids); @@ -146,10 +164,10 @@ backend_get_files (PkBackend *backend, gchar **package_ids) } /** - * backend_get_updates: + * pk_backend_get_updates: */ -static void -backend_get_updates (PkBackend *backend, PkBitfield filters) +void +pk_backend_get_updates (PkBackend *backend, PkBitfield filters) { gchar *filters_text; filters_text = pk_filter_bitfield_to_string (filters); @@ -158,10 +176,10 @@ backend_get_updates (PkBackend *backend, PkBitfield filters) } /** - * backend_get_update_detail: + * pk_backend_get_update_detail: */ -static void -backend_get_update_detail (PkBackend *backend, gchar **package_ids) +void +pk_backend_get_update_detail (PkBackend *backend, gchar **package_ids) { gchar *package_ids_temp; package_ids_temp = pk_package_ids_to_string (package_ids); @@ -169,11 +187,11 @@ backend_get_update_detail (PkBackend *backend, gchar **package_ids) g_free (package_ids_temp); } /** - * backend_install_packages: + * pk_backend_install_packages: */ -static void -backend_install_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids) +void +pk_backend_install_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids) { gchar *package_ids_temp; @@ -191,24 +209,10 @@ backend_install_packages (PkBackend *backend, gboolean only_trusted, gchar **pac } /** - * backend_install_files: - */ -/** -static void -backend_install_files (PkBackend *backend, gboolean only_trusted, const gchar *full_paths) -{ - gchar *package_ids_temp; - - package_ids_temp = pk_package_ids_to_string (package_ids); - pk_backend_spawn_helper (spawn, "conaryBackend.py", "install-files", pk_backend_bool_to_string (only_trusted), full_paths, NULL); - g_free (package_ids_temp); -} -*/ -/** - * backend_refresh_cache: + * pk_backend_refresh_cache: */ -static void -backend_refresh_cache (PkBackend *backend, gboolean force) +void +pk_backend_refresh_cache (PkBackend *backend, gboolean force) { /* check network state */ if (!pk_backend_is_online (backend)) { @@ -223,14 +227,8 @@ backend_refresh_cache (PkBackend *backend, gboolean force) /** * pk_backend_remove_packages: */ - -/* - zodman notes: - python conaryBackend.py remove-packages none "pastebinit;0.7-1-1;x86;/foresight.rpath.org@fl:2-qa/1222042924.172:0.7-1-1,1#x86" - - */ -static void -backend_remove_packages (PkBackend *backend, gchar **package_ids, gboolean allow_deps, gboolean autoremove) +void +pk_backend_remove_packages (PkBackend *backend, gchar **package_ids, gboolean allow_deps, gboolean autoremove) { gchar *package_ids_temp; @@ -241,10 +239,10 @@ backend_remove_packages (PkBackend *backend, gchar **package_ids, gboolean allow } /** - * pk_backend_search_name: + * pk_backend_search_names: */ -static void -backend_search_name (PkBackend *backend, PkBitfield filters, gchar **values) +void +pk_backend_search_names (PkBackend *backend, PkBitfield filters, gchar **values) { gchar *filters_text; gchar *search; @@ -256,10 +254,10 @@ backend_search_name (PkBackend *backend, PkBitfield filters, gchar **values) } /** - pk_backend_search_groups -*/ -static void -backend_search_group (PkBackend *backend, PkBitfield filters, gchar **values) + * pk_backend_search_groups + */ +void +pk_backend_search_groups (PkBackend *backend, PkBitfield filters, gchar **values) { gchar *filters_text; gchar *search; @@ -271,14 +269,11 @@ backend_search_group (PkBackend *backend, PkBitfield filters, gchar **values) g_free (search); } - - - /** - pk_backend_search_details -*/ -static void -backend_search_details (PkBackend *backend, PkBitfield filters, gchar **values) + * pk_backend_search_details + */ +void +pk_backend_search_details (PkBackend *backend, PkBitfield filters, gchar **values) { gchar *filters_text; gchar *search; @@ -292,8 +287,8 @@ backend_search_details (PkBackend *backend, PkBitfield filters, gchar **values) /** * pk_backend_update_system: */ -static void -backend_update_system (PkBackend *backend, gboolean only_trusted) +void +pk_backend_update_system (PkBackend *backend, gboolean only_trusted) { pk_backend_spawn_helper (spawn, "conaryBackend.py", "update-system", pk_backend_bool_to_string (only_trusted), NULL); } @@ -301,8 +296,8 @@ backend_update_system (PkBackend *backend, gboolean only_trusted) /** * pk_backend_resolve: */ -static void -backend_resolve (PkBackend *backend, PkBitfield filters, gchar **package_ids) +void +pk_backend_resolve (PkBackend *backend, PkBitfield filters, gchar **package_ids) { gchar *filters_text; filters_text = pk_filter_bitfield_to_string (filters); @@ -310,23 +305,23 @@ backend_resolve (PkBackend *backend, PkBitfield filters, gchar **package_ids) g_free (filters_text); } - /** - * backend_get_packages: + * pk_backend_get_packages: */ -static void -backend_get_packages (PkBackend *backend, PkBitfield filters) +void +pk_backend_get_packages (PkBackend *backend, PkBitfield filters) { gchar *filters_text; filters_text = pk_filter_bitfield_to_string (filters); pk_backend_spawn_helper (spawn, "conaryBackend.py", "get-packages", filters_text, NULL); g_free (filters_text); } + /** - * pk_backend_search_file: + * pk_backend_search_files: */ -static void -backend_search_file (PkBackend *backend, PkBitfield filters, gchar **values) +void +pk_backend_search_files (PkBackend *backend, PkBitfield filters, gchar **values) { gchar *filters_text; gchar *search; @@ -339,20 +334,10 @@ backend_search_file (PkBackend *backend, PkBitfield filters, gchar **values) } /** - * backend_get_distro_upgrades: -static void -backend_get_distro_upgrades (PkBackend *backend) -{ - pk_backend_spawn_helper (spawn, "conaryBackend.py", "get-distro-upgrades", NULL); -} - - */ - - -/** * pk_backend_get_repo_list: */ -static void backend_get_repo_list (PkBackend *backend, PkBitfield filters) +void +pk_backend_get_repo_list (PkBackend *backend, PkBitfield filters) { gchar *filters_text; filters_text = pk_filter_bitfield_to_string (filters); @@ -361,10 +346,10 @@ static void backend_get_repo_list (PkBackend *backend, PkBitfield filters) } /** - * backend_simulate_install_packages: + * pk_backend_simulate_install_packages: */ -static void -backend_simulate_install_packages (PkBackend *backend, gchar **package_ids) +void +pk_backend_simulate_install_packages (PkBackend *backend, gchar **package_ids) { gchar *package_ids_temp; @@ -382,10 +367,10 @@ backend_simulate_install_packages (PkBackend *backend, gchar **package_ids) } /** - * backend_simulate_remove_packages: + * pk_backend_simulate_remove_packages: */ -static void -backend_simulate_remove_packages (PkBackend *backend, gchar **package_ids) +void +pk_backend_simulate_remove_packages (PkBackend *backend, gchar **package_ids, gboolean autoremove) { gchar *package_ids_temp; @@ -394,51 +379,3 @@ backend_simulate_remove_packages (PkBackend *backend, gchar **package_ids) pk_backend_spawn_helper (spawn, "conaryBackend.py", "simulate-remove-packages", package_ids_temp, NULL); g_free (package_ids_temp); } - -/* FIXME: port this away from PK_BACKEND_OPTIONS */ -PK_BACKEND_OPTIONS ( - "Conary with XMLCache", /* description */ - "Andres Vargas <zodman@foresightlinux.org>", /* author */ - backend_initialize, /* initalize */ - backend_destroy, /* destroy */ - backend_get_groups, /* get_groups */ - backend_get_filters, /* get_filters */ - backend_get_roles, /* get_roles */ - NULL, /* get_mime_types */ - backend_cancel, /* cancel */ - NULL, /* download_packages */ - NULL, /* get_categories */ - NULL, /* get_depends */ - backend_get_details, /* get_details */ - NULL, /* get_distro_upgrades */ - backend_get_files, /* get_files */ - backend_get_packages, /* get_packages */ - backend_get_repo_list, /* get_repo_list */ - NULL, /* get_requires */ - NULL,// 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, /* repo_enable */ - NULL, /* repo_set_data */ - backend_resolve, /* resolve */ - NULL, /* rollback */ - backend_search_details, /* search_details */ - backend_search_file, /* search_file */ - backend_search_group, /* search_group */ - backend_search_name, /* search_name */ - NULL, /* update_packages */ - backend_update_system, /* update_system */ - NULL, /* what_provides */ - NULL, /* simulate_install_files */ - backend_simulate_install_packages, /* simulate_install_packages */ - backend_simulate_remove_packages, /* simulate_remove_packages */ - NULL, /* simulate_update_packages */ - NULL, /* upgrade_system */ - NULL, /* transaction_start */ - NULL /* transaction_stop */ -); - diff --git a/backends/entropy/entropyBackend.py b/backends/entropy/entropyBackend.py index 0487b1225..02b83a7dd 100755 --- a/backends/entropy/entropyBackend.py +++ b/backends/entropy/entropyBackend.py @@ -65,11 +65,16 @@ from entropy.core.settings.base import SystemSettings from entropy.misc import LogFile from entropy.cache import EntropyCacher from entropy.exceptions import SystemDatabaseError +from entropy.db.exceptions import Error as EntropyRepositoryError try: from entropy.exceptions import DependenciesNotRemovable except ImportError: DependenciesNotRemovable = Exception from entropy.fetchers import UrlFetcher +try: + from entropy.services.client import WebService +except ImportError: + WebService = None import entropy.tools import entropy.dep @@ -357,19 +362,41 @@ class PackageKitEntropyMixin(object): self._repo_name_cache[repo_db] = repo_name return repo_name + def _etp_get_webservice(self, repository_id): + """ + Get Entropy Web Services service object (ClientWebService). + + @param entropy_client: Entropy Client interface + @type entropy_client: entropy.client.interfaces.Client + @param repository_id: repository identifier + @type repository_id: string + @return: the ClientWebService instance + @rtype: entropy.client.services.interfaces.ClientWebService + @raise WebService.UnsupportedService: if service is unsupported by + repository + """ + factory = self._entropy.WebServices() + return factory.new(repository_id) + def _etp_spawn_ugc(self, pkg_data): """ Inform repository maintainers that user fetched packages, if user enabled this feature. """ - if self._entropy.UGC is None: + if WebService is None: + # old entropy library, ignore all return - for repo_id in pkg_data: - repo_pkg_keys = sorted(pkg_data[repo_id]) + + for repository_id, repo_pkg_keys in pkg_data.items(): try: - self._entropy.UGC.add_download_stats(repo_id, repo_pkg_keys) - except: - pass + webserv = self._etp_get_webservice(repository_id) + except WebService.UnsupportedService: + continue + pkg_keys = sorted(repo_pkg_keys) + try: + webserv.add_downloads(pkg_keys) + except WebService.WebServiceException: + continue def _etp_get_category_description(self, category): """ @@ -835,12 +862,8 @@ class PackageKitEntropyBackend(PackageKitBaseBackend, PackageKitEntropyMixin): self._log_message(__name__, "_generic_message:", decolorize(message)) def _config_files_message(self): - if hasattr(self._entropy, "PackageFileUpdates"): - scandata = self._entropy.PackageFileUpdates().scan(dcache = True, - quiet = True) - else: - scandata = self._entropy.FileUpdates.scan(dcache = True, - quiet = True) + scandata = self._entropy.PackageFileUpdates().scan(dcache = True, + quiet = True) if scandata is None: return if len(scandata) > 0: @@ -961,6 +984,17 @@ class PackageKitEntropyBackend(PackageKitBaseBackend, PackageKitEntropyMixin): self.percentage(100) + def _etp_get_package_categories(self): + categories = set() + for repository_id in self._entropy.repositories(): + repo_db = self._entropy.open_repository(repository_id) + try: + categories.update(repo_db.listAllCategories()) + except EntropyRepositoryError: + # on broken repos this might cause issues + continue + return sorted(categories) + def get_categories(self): self._log_message(__name__, "get_categories: called") @@ -968,7 +1002,7 @@ class PackageKitEntropyBackend(PackageKitBaseBackend, PackageKitEntropyMixin): self.status(STATUS_QUERY) self.allow_cancel(True) - categories = self._entropy.get_package_categories() + categories = self._etp_get_package_categories() if not categories: self.error(ERROR_GROUP_LIST_INVALID, "no package categories") return @@ -1135,7 +1169,7 @@ class PackageKitEntropyBackend(PackageKitBaseBackend, PackageKitEntropyMixin): empty = False deep = False - reverse_deps = self._entropy.get_reverse_dependencies(matches, + reverse_deps = self._entropy.get_reverse_queue(matches, deep = deep, recursive = recursive) self._log_message(__name__, "get_requires: reverse_deps => %s" % ( @@ -1299,7 +1333,8 @@ class PackageKitEntropyBackend(PackageKitBaseBackend, PackageKitEntropyMixin): pkg_ids = [] for etp_file in inst_files: repo_id = os.path.basename(etp_file) - status, atomsfound = self._entropy.add_package_to_repos(etp_file) + status, atomsfound = self._entropy.add_package_to_repositories( + etp_file) if status != 0: self.error(ERROR_INVALID_PACKAGE_FILE, "Error while trying to add %s repository" % (repo_id,)) @@ -1367,6 +1402,24 @@ class PackageKitEntropyBackend(PackageKitBaseBackend, PackageKitEntropyMixin): self._execute_etp_pkgs_fetch(pkgs, directory) + def _etp_update_repository_stats(self, repository_ids): + """ + Update repository download statistics. + """ + if WebService is None: + # old entropy library, ignore all + return + + for repository_id in repository_ids: + try: + webserv = self._etp_get_webservice(repository_id) + except WebService.UnsupportedService: + continue + try: + webserv.add_downloads(repository_id, [repository_id]) + except WebService.WebServiceException: + continue + def refresh_cache(self, force): self.status(STATUS_REFRESH_CACHE) @@ -1388,10 +1441,7 @@ class PackageKitEntropyBackend(PackageKitBaseBackend, PackageKitEntropyMixin): ex_rc = repo_intf.sync() if not ex_rc: - for repo_id in repo_identifiers: - # inform UGC that we are syncing this repo - if self._entropy.UGC is not None: - self._entropy.UGC.add_download_stats(repo_id, [repo_id]) + self._etp_update_repository_stats(repo_identifiers) else: self.message(MESSAGE_REPO_METADATA_DOWNLOAD_FAILED, "Cannot update repositories!") diff --git a/backends/pacman/Makefile.am b/backends/pacman/Makefile.am deleted file mode 100644 index 9ea021796..000000000 --- a/backends/pacman/Makefile.am +++ /dev/null @@ -1,53 +0,0 @@ -INCLUDES = \ - -DG_LOG_DOMAIN=\"PackageKit-Pacman\" - -PACMAN_CONFIG_FILE = $(confdir)/pacman.conf -PACMAN_GROUP_LIST = $(confdir)/groups.list -PACMAN_REPO_LIST = $(confdir)/repos.list -PACMAN_REPO_LIST_HEADER = "\# Generated by $(PACKAGE_NAME) - DO NOT MODIFY" -PACMAN_CACHE_PATH = $(localstatedir)/lib/pacman/sync -PACMAN_PACKAGE_URL = "http://www.archlinux.org/packages/%s/%s/%s/" -PACMAN_DEFAULT_PATH = "/bin:/usr/bin:/sbin:/usr/sbin" - -DEFS = -DPACMAN_CONFIG_FILE=\"$(PACMAN_CONFIG_FILE)\" \ - -DPACMAN_GROUP_LIST=\"$(PACMAN_GROUP_LIST)\" \ - -DPACMAN_REPO_LIST=\"$(PACMAN_REPO_LIST)\" \ - -DPACMAN_REPO_LIST_HEADER=\"$(PACMAN_REPO_LIST_HEADER)\" \ - -DPACMAN_CACHE_PATH=\"$(PACMAN_CACHE_PATH)\" \ - -DPACMAN_PACKAGE_URL=\"$(PACMAN_PACKAGE_URL)\" \ - -DPACMAN_DEFAULT_PATH=\"$(PACMAN_DEFAULT_PATH)\" - -confdir = $(PK_CONF_DIR)/pacman.d -conf_DATA = groups.list \ - pacman.conf \ - repos.list - -plugindir = $(PK_PLUGIN_DIR) -plugin_LTLIBRARIES = libpk_backend_pacman.la - -libpk_backend_pacman_la_SOURCES = backend-depends.c \ - backend-error.c \ - backend-groups.c \ - backend-install.c \ - backend-packages.c \ - backend-pacman.c \ - backend-remove.c \ - backend-repos.c \ - backend-search.c \ - backend-transaction.c \ - backend-update.c -libpk_backend_pacman_la_LIBADD = $(PK_PLUGIN_LIBS) \ - $(PACMAN_LIBS) -libpk_backend_pacman_la_LDFLAGS = -module -avoid-version -libpk_backend_pacman_la_CFLAGS = $(PK_PLUGIN_CFLAGS) \ - $(PACMAN_CFLAGS) \ - $(WARNINGFLAGS_C) - -repos.list: - echo $(PACMAN_REPO_LIST_HEADER) > $@ - -BUILT_SOURCES = repos.list - -EXTRA_DIST = $(conf_DATA) $(libpk_backend_pacman_la_SOURCES:.c=.h) - -CLEANFILES = $(BUILT_SOURCES) diff --git a/backends/pacman/backend-depends.c b/backends/pacman/backend-depends.c deleted file mode 100644 index 9bd23244c..000000000 --- a/backends/pacman/backend-depends.c +++ /dev/null @@ -1,298 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> - * Copyright (C) 2008, 2009 Valeriy Lyasotskiy <onestep@ukr.net> - * Copyright (C) 2010 Jonathan Conder <j@skurvy.no-ip.org> - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <pacman.h> -#include "backend-packages.h" -#include "backend-pacman.h" -#include "backend-repos.h" -#include "backend-depends.h" - -static PacmanPackage * -pacman_list_find_provider (const PacmanList *packages, PacmanDependency *depend) -{ - const PacmanList *list; - - g_return_val_if_fail (depend != NULL, NULL); - - /* find a package that provides depend */ - for (list = packages; list != NULL; list = pacman_list_next (list)) { - PacmanPackage *provider = (PacmanPackage *) pacman_list_get (list); - - if (pacman_dependency_satisfied_by (depend, provider)) { - return provider; - } - } - - return NULL; -} - -static PacmanPackage * -pacman_sync_databases_find_provider (PacmanDependency *depend) -{ - const PacmanList *databases; - - g_return_val_if_fail (pacman != NULL, NULL); - g_return_val_if_fail (depend != NULL, NULL); - - /* find the default package that provides depend */ - for (databases = pacman_manager_get_sync_databases (pacman); databases != NULL; databases = pacman_list_next (databases)) { - PacmanDatabase *database = (PacmanDatabase *) pacman_list_get (databases); - PacmanPackage *provider = pacman_database_find_package (database, pacman_dependency_get_name (depend)); - - if (provider != NULL && pacman_dependency_satisfied_by (depend, provider)) { - return provider; - } - } - - /* find any package that provides depend */ - for (databases = pacman_manager_get_sync_databases (pacman); databases != NULL; databases = pacman_list_next (databases)) { - PacmanDatabase *database = (PacmanDatabase *) pacman_list_get (databases); - PacmanPackage *provider = pacman_list_find_provider (pacman_database_get_packages (database), depend); - - if (provider != NULL) { - return provider; - } - } - - return NULL; -} - -static gboolean -backend_get_depends_thread (PkBackend *backend) -{ - guint iterator; - PacmanList *list, *packages = NULL; - - PkBitfield filters; - gchar **package_ids; - gboolean recursive; - - gboolean search_installed; - gboolean search_not_installed; - - g_return_val_if_fail (local_database != NULL, FALSE); - g_return_val_if_fail (backend != NULL, FALSE); - - package_ids = pk_backend_get_strv (backend, "package_ids"); - recursive = pk_backend_get_bool (backend, "recursive"); - - g_return_val_if_fail (package_ids != NULL, FALSE); - - filters = pk_backend_get_uint (backend, "filters"); - search_installed = pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED); - search_not_installed = pk_bitfield_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED); - - /* construct an initial package list */ - for (iterator = 0; package_ids[iterator] != NULL; ++iterator) { - PacmanPackage *package = backend_get_package (backend, package_ids[iterator]); - - if (backend_cancelled (backend)) { - break; - } else if (package == NULL) { - pacman_list_free (packages); - backend_finished (backend); - return FALSE; - } - - packages = pacman_list_add (packages, package); - } - - /* package list might be modified along the way but that is ok */ - for (list = packages; list != NULL; list = pacman_list_next (list)) { - PacmanPackage *package = (PacmanPackage *) pacman_list_get (list); - const PacmanList *depends; - - if (backend_cancelled (backend)) { - break; - } - - for (depends = pacman_package_get_dependencies (package); depends != NULL; depends = pacman_list_next (depends)) { - PacmanDependency *depend = (PacmanDependency *) pacman_list_get (depends); - PacmanPackage *provider = pacman_list_find_provider (packages, depend); - - if (backend_cancelled (backend)) { - break; - } else if (provider != NULL) { - continue; - } - - /* look for installed dependencies */ - provider = pacman_list_find_provider (pacman_database_get_packages (local_database), depend); - if (provider != NULL) { - /* don't emit when not needed... */ - if (!search_not_installed) { - backend_package (backend, provider, PK_INFO_ENUM_INSTALLED); - /* ... and assume installed packages also have installed dependencies */ - if (recursive) { - packages = pacman_list_add (packages, provider); - } - } - continue; - } - - /* look for non-installed dependencies */ - provider = pacman_sync_databases_find_provider (depend); - if (provider != NULL) { - /* don't emit when not needed... */ - if (!search_installed) { - backend_package (backend, provider, PK_INFO_ENUM_AVAILABLE); - } - /* ... but keep looking for installed dependencies */ - if (recursive) { - packages = pacman_list_add (packages, provider); - } - } else { - gchar *depend_id = pacman_dependency_to_string (depend); - pk_backend_error_code (backend, PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, "Could not resolve dependency %s", depend_id); - g_free (depend_id); - - pacman_list_free (packages); - backend_finished (backend); - return FALSE; - } - } - } - - pacman_list_free (packages); - backend_finished (backend); - return TRUE; -} - -/** - * backend_get_depends: - **/ -void -backend_get_depends (PkBackend *backend, PkBitfield filters, gchar **package_ids, gboolean recursive) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (package_ids != NULL); - - backend_run (backend, PK_STATUS_ENUM_QUERY, backend_get_depends_thread); -} - -static PacmanPackage * -pacman_list_find_package (const PacmanList *packages, const gchar *name) -{ - const PacmanList *list; - - g_return_val_if_fail (name != NULL, NULL); - - /* find a package called name */ - for (list = packages; list != NULL; list = pacman_list_next (list)) { - PacmanPackage *package = (PacmanPackage *) pacman_list_get (list); - - if (g_strcmp0 (name, pacman_package_get_name (package)) == 0) { - return package; - } - } - - return NULL; -} - -static gboolean -backend_get_requires_thread (PkBackend *backend) -{ - guint iterator; - PacmanList *list, *packages = NULL; - - gchar **package_ids; - gboolean recursive; - - g_return_val_if_fail (local_database != NULL, FALSE); - g_return_val_if_fail (backend != NULL, FALSE); - - package_ids = pk_backend_get_strv (backend, "package_ids"); - recursive = pk_backend_get_bool (backend, "recursive"); - - g_return_val_if_fail (package_ids != NULL, FALSE); - - /* construct an initial package list */ - for (iterator = 0; package_ids[iterator] != NULL; ++iterator) { - PacmanPackage *package = backend_get_package (backend, package_ids[iterator]); - - if (backend_cancelled (backend)) { - break; - } else if (package == NULL) { - pacman_list_free (packages); - backend_finished (backend); - return FALSE; - } - - packages = pacman_list_add (packages, package); - } - - /* package list might be modified along the way but that is ok */ - for (list = packages; list != NULL; list = pacman_list_next (list)) { - PacmanPackage *package = (PacmanPackage *) pacman_list_get (list); - PacmanList *requires, *required_by = pacman_package_find_required_by (package); - - if (backend_cancelled (backend)) { - break; - } - - for (requires = required_by; requires != NULL; requires = pacman_list_next (requires)) { - const gchar *name = (const gchar *) pacman_list_get (requires); - PacmanPackage *requirer = pacman_list_find_package (packages, name); - - if (backend_cancelled (backend)) { - break; - } else if (requirer != NULL) { - continue; - } - - /* look for installed requirers */ - requirer = pacman_database_find_package (local_database, name); - if (requirer == NULL) { - pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "Could not find package %s", name); - - pacman_list_free_full (required_by, g_free); - pacman_list_free (packages); - backend_finished (backend); - return FALSE; - } - - backend_package (backend, requirer, PK_INFO_ENUM_INSTALLED); - if (recursive) { - packages = pacman_list_add (packages, requirer); - } - } - - pacman_list_free_full (required_by, g_free); - } - - pacman_list_free (packages); - backend_finished (backend); - return TRUE; -} - -/** - * backend_get_requires: - **/ -void -backend_get_requires (PkBackend *backend, PkBitfield filters, gchar **package_ids, gboolean recursive) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (package_ids != NULL); - - backend_run (backend, PK_STATUS_ENUM_QUERY, backend_get_requires_thread); -} diff --git a/backends/pacman/backend-error.c b/backends/pacman/backend-error.c deleted file mode 100644 index 233650803..000000000 --- a/backends/pacman/backend-error.c +++ /dev/null @@ -1,185 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> - * Copyright (C) 2008, 2009 Valeriy Lyasotskiy <onestep@ukr.net> - * Copyright (C) 2010 Jonathan Conder <j@skurvy.no-ip.org> - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <pacman.h> -#include "backend-error.h" - -void -backend_error (PkBackend *backend, GError *error) -{ - PkErrorEnum code = PK_ERROR_ENUM_INTERNAL_ERROR; - - g_return_if_fail (backend != NULL); - g_return_if_fail (error != NULL); - - /* convert error codes */ - if (error->domain == PACMAN_ERROR) { - switch (error->code) { - case PACMAN_ERROR_MEMORY: - code = PK_ERROR_ENUM_OOM; - break; - - case PACMAN_ERROR_SYSTEM: - case PACMAN_ERROR_INVALID_ARGS: - case PACMAN_ERROR_NOT_INITIALIZED: - case PACMAN_ERROR_DATABASE_NOT_INITIALIZED: - case PACMAN_ERROR_SERVER_INVALID_URL: - case PACMAN_ERROR_REGEX_INVALID: - case PACMAN_ERROR_LIBARCHIVE: - case PACMAN_ERROR_LIBFETCH: - case PACMAN_ERROR_DOWNLOAD_HANDLER: - code = PK_ERROR_ENUM_INTERNAL_ERROR; - break; - - case PACMAN_ERROR_NOT_PERMITTED: - code = PK_ERROR_ENUM_NOT_AUTHORIZED; - break; - - case PACMAN_ERROR_FILE_NOT_FOUND: - case PACMAN_ERROR_DIRECTORY_NOT_FOUND: - code = PK_ERROR_ENUM_FILE_NOT_FOUND; - break; - - case PACMAN_ERROR_ALREADY_INITIALIZED: - case PACMAN_ERROR_DATABASE_ALREADY_INITIALIZED: - code = PK_ERROR_ENUM_FAILED_INITIALIZATION; - break; - - case PACMAN_ERROR_ALREADY_RUNNING: - code = PK_ERROR_ENUM_CANNOT_GET_LOCK; - break; - - case PACMAN_ERROR_DATABASE_OPEN_FAILED: - code = PK_ERROR_ENUM_REPO_NOT_FOUND; - break; - - case PACMAN_ERROR_DATABASE_CREATE_FAILED: - code = PK_ERROR_ENUM_CANNOT_WRITE_REPO_CONFIG; - break; - - case PACMAN_ERROR_DATABASE_NOT_FOUND: - code = PK_ERROR_ENUM_REPO_NOT_FOUND; - break; - - case PACMAN_ERROR_DATABASE_UPDATE_FAILED: - code = PK_ERROR_ENUM_REPO_NOT_AVAILABLE; - break; - - case PACMAN_ERROR_DATABASE_REMOVE_FAILED: - code = PK_ERROR_ENUM_REPO_CONFIGURATION_ERROR; - break; - - case PACMAN_ERROR_SERVER_NONE_AVAILABLE: - code = PK_ERROR_ENUM_NO_MORE_MIRRORS_TO_TRY; - break; - - case PACMAN_ERROR_TRANSACTION_ALREADY_INITIALIZED: - case PACMAN_ERROR_TRANSACTION_NOT_INITIALIZED: - case PACMAN_ERROR_TRANSACTION_DUPLICATE_TARGET: - case PACMAN_ERROR_TRANSACTION_NOT_READY: - case PACMAN_ERROR_TRANSACTION_NOT_PREPARED: - case PACMAN_ERROR_TRANSACTION_INVALID_OPERATION: - case PACMAN_ERROR_TRANSACTION_NOT_LOCKED: - code = PK_ERROR_ENUM_TRANSACTION_ERROR; - break; - - case PACMAN_ERROR_TRANSACTION_ABORTED: - code = PK_ERROR_ENUM_TRANSACTION_CANCELLED; - break; - - case PACMAN_ERROR_PACKAGE_NOT_FOUND: - code = PK_ERROR_ENUM_PACKAGE_NOT_FOUND; - break; - - case PACMAN_ERROR_PACKAGE_IGNORED: - code = PK_ERROR_ENUM_PACKAGE_INSTALL_BLOCKED; - break; - - case PACMAN_ERROR_DELTA_INVALID: - case PACMAN_ERROR_PACKAGE_INVALID: - code = PK_ERROR_ENUM_INVALID_PACKAGE_FILE; - break; - - case PACMAN_ERROR_PACKAGE_OPEN_FAILED: - code = PK_ERROR_ENUM_PACKAGE_NOT_FOUND; - break; - - case PACMAN_ERROR_PACKAGE_REMOVE_FAILED: - code = PK_ERROR_ENUM_PACKAGE_FAILED_TO_REMOVE; - break; - - case PACMAN_ERROR_PACKAGE_UNKNOWN_FILENAME: - case PACMAN_ERROR_PACKAGE_DATABASE_NOT_FOUND: - code = PK_ERROR_ENUM_PACKAGE_FAILED_TO_CONFIGURE; - break; - - case PACMAN_ERROR_DELTA_PATCH_FAILED: - code = PK_ERROR_ENUM_PACKAGE_FAILED_TO_BUILD; - break; - - case PACMAN_ERROR_DEPENDENCY_UNSATISFIED: - code = PK_ERROR_ENUM_DEP_RESOLUTION_FAILED; - break; - - case PACMAN_ERROR_CONFLICT: - code = PK_ERROR_ENUM_PACKAGE_CONFLICTS; - break; - - case PACMAN_ERROR_FILE_CONFLICT: - code = PK_ERROR_ENUM_FILE_CONFLICTS; - break; - - case PACMAN_ERROR_DOWNLOAD_FAILED: - code = PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED; - break; - - case PACMAN_ERROR_CONFIG_INVALID: - code = PK_ERROR_ENUM_FAILED_CONFIG_PARSING; - break; - - case PACMAN_ERROR_PACKAGE_HELD: - code = PK_ERROR_ENUM_CANNOT_REMOVE_SYSTEM_PACKAGE; - break; - } - } - - pk_backend_error_code (backend, code, "%s", error->message); - g_error_free (error); -} - -void -backend_message (PkBackend *backend, const gchar *message) -{ - guint iterator; - gchar **messages = g_strsplit_set (message, "\r\n", 0); - - /* display multi-line messages in a nice format */ - for (iterator = 0; messages[iterator] != NULL; ++iterator) { - g_strstrip (messages[iterator]); - if (*messages[iterator] != '\0') { - pk_backend_message (backend, PK_MESSAGE_ENUM_UNKNOWN, "%s", messages[iterator]); - } - } - - g_strfreev (messages); -} diff --git a/backends/pacman/backend-groups.h b/backends/pacman/backend-groups.h deleted file mode 100644 index 9642015c1..000000000 --- a/backends/pacman/backend-groups.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> - * Copyright (C) 2008, 2009 Valeriy Lyasotskiy <onestep@ukr.net> - * Copyright (C) 2010 Jonathan Conder <j@skurvy.no-ip.org> - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <pacman.h> -#include <pk-backend.h> - -gboolean backend_initialize_groups (PkBackend *backend, - GError **error); -void backend_destroy_groups (PkBackend *backend); - -const gchar *pacman_package_get_group (PacmanPackage *package); -PkBitfield backend_get_groups (PkBackend *backend); diff --git a/backends/pacman/backend-install.c b/backends/pacman/backend-install.c deleted file mode 100644 index 5c188cc62..000000000 --- a/backends/pacman/backend-install.c +++ /dev/null @@ -1,348 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> - * Copyright (C) 2008, 2009 Valeriy Lyasotskiy <onestep@ukr.net> - * Copyright (C) 2010 Jonathan Conder <j@skurvy.no-ip.org> - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <pacman.h> -#include "backend-error.h" -#include "backend-pacman.h" -#include "backend-packages.h" -#include "backend-repos.h" -#include "backend-transaction.h" -#include "backend-install.h" - -static PacmanList * -backend_transaction_list_targets (PkBackend *backend) -{ - gchar **package_ids; - guint iterator; - PacmanList *list = NULL; - - g_return_val_if_fail (backend != NULL, NULL); - - package_ids = pk_backend_get_strv (backend, "package_ids"); - - g_return_val_if_fail (package_ids != NULL, NULL); - - for (iterator = 0; package_ids[iterator] != NULL; ++iterator) { - gchar **package_id_data = pk_package_id_split (package_ids[iterator]); - list = pacman_list_add (list, g_strdup_printf ("%s/%s", package_id_data[PK_PACKAGE_ID_DATA], package_id_data[PK_PACKAGE_ID_NAME])); - g_strfreev (package_id_data); - } - - return list; -} - -static gboolean -backend_download_packages_thread (PkBackend *backend) -{ - PacmanList *list; - PacmanList *cache_paths; - const gchar *directory; - - PacmanTransaction *transaction = NULL; - PacmanTransactionFlags flags = PACMAN_TRANSACTION_FLAGS_IGNORE_DEPENDENCIES | - PACMAN_TRANSACTION_FLAGS_IGNORE_DEPENDENCY_CONFLICTS | - PACMAN_TRANSACTION_FLAGS_SYNC_DOWNLOAD_ONLY; - - g_return_val_if_fail (pacman != NULL, FALSE); - g_return_val_if_fail (backend != NULL, FALSE); - - directory = pk_backend_get_string (backend, "directory"); - - g_return_val_if_fail (directory != NULL, FALSE); - - /* download files to a PackageKit directory */ - cache_paths = pacman_list_strdup (pacman_manager_get_cache_paths (pacman)); - pacman_manager_set_cache_paths (pacman, NULL); - pacman_manager_add_cache_path (pacman, directory); - - /* run the transaction */ - list = backend_transaction_list_targets (backend); - if (list != NULL) { - transaction = backend_transaction_run (backend, PACMAN_TRANSACTION_SYNC, flags, list); - pacman_list_free_full (list, g_free); - } - - pacman_manager_set_cache_paths (pacman, cache_paths); - pacman_list_free_full (cache_paths, g_free); - return backend_transaction_finished (backend, transaction); -} - -/** - * backend_download_packages: - **/ -void -backend_download_packages (PkBackend *backend, gchar **package_ids, const gchar *directory) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (package_ids != NULL); - g_return_if_fail (directory != NULL); - - backend_run (backend, PK_STATUS_ENUM_SETUP, backend_download_packages_thread); -} - -static gboolean -backend_install_files_thread (PkBackend *backend) -{ - guint iterator; - PacmanList *list = NULL; - - /* FS#5331: use only_trusted */ - gchar **full_paths; - - PacmanTransaction *transaction = NULL; - PacmanTransactionFlags flags = PACMAN_TRANSACTION_FLAGS_NONE; - - g_return_val_if_fail (backend != NULL, FALSE); - - full_paths = pk_backend_get_strv (backend, "full_paths"); - - g_return_val_if_fail (full_paths != NULL, FALSE); - - /* run the transaction */ - for (iterator = 0; full_paths[iterator] != NULL; ++iterator) { - list = pacman_list_add (list, full_paths[iterator]); - } - if (list != NULL) { - transaction = backend_transaction_run (backend, PACMAN_TRANSACTION_INSTALL, flags, list); - pacman_list_free (list); - } - - return backend_transaction_finished (backend, transaction); -} - -/** - * backend_install_files: - **/ -void -backend_install_files (PkBackend *backend, gboolean only_trusted, gchar **full_paths) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (full_paths != NULL); - - backend_run (backend, PK_STATUS_ENUM_SETUP, backend_install_files_thread); -} - -static gboolean -backend_simulate_install_files_thread (PkBackend *backend) -{ - guint iterator; - PacmanList *list = NULL; - - gchar **full_paths; - - PacmanTransaction *transaction = NULL; - PacmanTransactionFlags flags = PACMAN_TRANSACTION_FLAGS_NONE; - - g_return_val_if_fail (backend != NULL, FALSE); - - full_paths = pk_backend_get_strv (backend, "full_paths"); - - g_return_val_if_fail (full_paths != NULL, FALSE); - - /* prepare the transaction */ - for (iterator = 0; full_paths[iterator] != NULL; ++iterator) { - list = pacman_list_add (list, full_paths[iterator]); - } - if (list != NULL) { - transaction = backend_transaction_simulate (backend, PACMAN_TRANSACTION_INSTALL, flags, list); - pacman_list_free (list); - - if (transaction != NULL) { - /* emit packages that would have been installed or removed */ - backend_transaction_packages (backend, transaction); - } - } - - return backend_transaction_finished (backend, transaction); -} - -/** - * backend_install_files: - **/ -void -backend_simulate_install_files (PkBackend *backend, gchar **full_paths) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (full_paths != NULL); - - backend_run (backend, PK_STATUS_ENUM_SETUP, backend_simulate_install_files_thread); -} - -static gboolean -backend_install_packages_thread (PkBackend *backend) -{ - PacmanList *list; - /* FS#5331: use only_trusted */ - PacmanTransaction *transaction = NULL; - PacmanTransactionFlags flags = PACMAN_TRANSACTION_FLAGS_NONE; - - g_return_val_if_fail (backend != NULL, FALSE); - - /* run the transaction */ - list = backend_transaction_list_targets (backend); - if (list != NULL) { - transaction = backend_transaction_run (backend, PACMAN_TRANSACTION_SYNC, flags, list); - pacman_list_free_full (list, g_free); - } - - return backend_transaction_finished (backend, transaction); -} - -/** - * backend_install_packages: - **/ -void -backend_install_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (package_ids != NULL); - - backend_run (backend, PK_STATUS_ENUM_SETUP, backend_install_packages_thread); -} - -static gboolean -backend_simulate_install_packages_thread (PkBackend *backend) -{ - PacmanList *list; - - PacmanTransaction *transaction = NULL; - PacmanTransactionFlags flags = PACMAN_TRANSACTION_FLAGS_NONE; - - g_return_val_if_fail (backend != NULL, FALSE); - - /* prepare the transaction */ - list = backend_transaction_list_targets (backend); - if (list != NULL) { - transaction = backend_transaction_simulate (backend, PACMAN_TRANSACTION_SYNC, flags, list); - pacman_list_free_full (list, g_free); - - if (transaction != NULL) { - /* emit packages that would have been installed or removed */ - backend_transaction_packages (backend, transaction); - } - } - - return backend_transaction_finished (backend, transaction); -} - -/** - * backend_simulate_install_packages: - **/ -void -backend_simulate_install_packages (PkBackend *backend, gchar **package_ids) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (package_ids != NULL); - - backend_run (backend, PK_STATUS_ENUM_SETUP, backend_simulate_install_packages_thread); -} - -static gboolean -backend_update_packages_thread (PkBackend *backend) -{ - PacmanList *list, *asdeps = NULL; - /* FS#5331: use only_trusted */ - PacmanTransaction *transaction = NULL; - PacmanTransactionFlags sflags = PACMAN_TRANSACTION_FLAGS_NONE, mflags = PACMAN_TRANSACTION_FLAGS_INSTALL_IMPLICIT; - - g_return_val_if_fail (local_database != NULL, FALSE); - g_return_val_if_fail (backend != NULL, FALSE); - - /* prepare the transaction */ - list = backend_transaction_list_targets (backend); - if (list != NULL) { - transaction = backend_transaction_simulate (backend, PACMAN_TRANSACTION_SYNC, sflags, list); - pacman_list_free_full (list, g_free); - - if (transaction != NULL) { - const PacmanList *installs, *removes; - - /* change the install reason of for packages that replace only dependencies of other packages */ - for (installs = pacman_transaction_get_installs (transaction); installs != NULL; installs = pacman_list_next (installs)) { - PacmanPackage *install = (PacmanPackage *) pacman_list_get (installs); - const gchar *name = pacman_package_get_name (install); - - if (backend_cancelled (backend)) { - break; - } else if (pacman_database_find_package (local_database, name) == NULL) { - const PacmanList *replaces = pacman_package_get_replaces (install); - - for (removes = pacman_transaction_get_removes (transaction); removes != NULL; removes = pacman_list_next (removes)) { - PacmanPackage *remove = (PacmanPackage *) pacman_list_get (removes); - const gchar *replace = pacman_package_get_name (remove); - - if (backend_cancelled (backend)) { - break; - } else if (pacman_list_find_string (replaces, replace)) { - if (pacman_package_was_explicitly_installed (remove)) { - break; - } - } - } - - /* none of the replaced packages were installed explicitly */ - if (removes == NULL) { - asdeps = pacman_list_add (asdeps, g_strdup (name)); - } - } - } - - transaction = backend_transaction_commit (backend, transaction); - } - } - - /* mark replacements as deps if required */ - if (asdeps != NULL) { - if (transaction != NULL) { - g_object_unref (transaction); - transaction = backend_transaction_run (backend, PACMAN_TRANSACTION_MODIFY, mflags, asdeps); - } - pacman_list_free_full (asdeps, g_free); - } - - return backend_transaction_finished (backend, transaction); -} - -/** - * backend_update_packages: - **/ -void -backend_update_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (package_ids != NULL); - - backend_run (backend, PK_STATUS_ENUM_SETUP, backend_update_packages_thread); -} - -/** - * backend_simulate_update_packages: - **/ -void -backend_simulate_update_packages (PkBackend *backend, gchar **package_ids) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (package_ids != NULL); - - backend_run (backend, PK_STATUS_ENUM_SETUP, backend_simulate_install_packages_thread); -} diff --git a/backends/pacman/backend-install.h b/backends/pacman/backend-install.h deleted file mode 100644 index 0685a48ee..000000000 --- a/backends/pacman/backend-install.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> - * Copyright (C) 2008, 2009 Valeriy Lyasotskiy <onestep@ukr.net> - * Copyright (C) 2010 Jonathan Conder <j@skurvy.no-ip.org> - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <pk-backend.h> - -void backend_download_packages (PkBackend *backend, - gchar **package_ids, - const gchar *directory); -void backend_install_files (PkBackend *backend, - gboolean only_trusted, - gchar **full_paths); -void backend_simulate_install_files (PkBackend *backend, - gchar **full_paths); - -void backend_install_packages (PkBackend *backend, - gboolean only_trusted, - gchar **package_ids); -void backend_simulate_install_packages (PkBackend *backend, - gchar **package_ids); - -void backend_update_packages (PkBackend *backend, - gboolean only_trusted, - gchar **package_ids); -void backend_simulate_update_packages (PkBackend *backend, - gchar **package_ids); diff --git a/backends/pacman/backend-packages.c b/backends/pacman/backend-packages.c deleted file mode 100644 index a00f107cf..000000000 --- a/backends/pacman/backend-packages.c +++ /dev/null @@ -1,345 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> - * Copyright (C) 2008, 2009 Valeriy Lyasotskiy <onestep@ukr.net> - * Copyright (C) 2010 Jonathan Conder <j@skurvy.no-ip.org> - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <pacman.h> -#include "backend-groups.h" -#include "backend-pacman.h" -#include "backend-repos.h" -#include "backend-packages.h" - -gchar * -pacman_package_make_id (PacmanPackage *package) -{ - const gchar *name, *version, *arch, *repo; - PacmanDatabase *database; - - g_return_val_if_fail (local_database != NULL, NULL); - g_return_val_if_fail (package != NULL, NULL); - - name = pacman_package_get_name (package); - version = pacman_package_get_version (package); - - arch = pacman_package_get_arch (package); - if (arch == NULL) { - arch = "any"; - } - - /* PackageKit requires "local" for package files and "installed" for installed packages */ - database = pacman_package_get_database (package); - if (database == NULL) { - repo = "local"; - } else if (database == local_database) { - repo = "installed"; - } else { - repo = pacman_database_get_name (database); - } - - return pk_package_id_build (name, version, arch, repo); -} - -void -backend_package (PkBackend *backend, PacmanPackage *package, PkInfoEnum info) -{ - gchar *package_id; - - g_return_if_fail (backend != NULL); - g_return_if_fail (package != NULL); - - /* build and emit package id */ - package_id = pacman_package_make_id (package); - pk_backend_package (backend, info, package_id, pacman_package_get_description (package)); - g_free (package_id); -} - -PacmanPackage * -backend_get_package (PkBackend *backend, const gchar *package_id) -{ - gchar **package_id_data; - const gchar *repo; - PacmanDatabase *database; - PacmanPackage *package; - - g_return_val_if_fail (pacman != NULL, NULL); - g_return_val_if_fail (local_database != NULL, NULL); - g_return_val_if_fail (backend != NULL, NULL); - g_return_val_if_fail (package_id != NULL, NULL); - - package_id_data = pk_package_id_split (package_id); - repo = package_id_data[PK_PACKAGE_ID_DATA]; - - /* find the database to search in */ - if (g_strcmp0 (repo, "installed") == 0) { - database = local_database; - } else { - database = pacman_manager_find_sync_database (pacman, repo); - } - - if (database == NULL) { - pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, "Could not find repo [%s]", repo); - g_strfreev (package_id_data); - return NULL; - } - - /* find the package in the database */ - package = pacman_database_find_package (database, package_id_data[PK_PACKAGE_ID_NAME]); - if (package == NULL || g_strcmp0 (pacman_package_get_version (package), package_id_data[PK_PACKAGE_ID_VERSION]) != 0) { - pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "Could not find package with ID %s", package_id); - g_strfreev (package_id_data); - return NULL; - } - - g_strfreev (package_id_data); - return package; -} - -static gboolean -backend_resolve_thread (PkBackend *backend) -{ - guint iterator; - - gchar **package_ids; - PkBitfield filters; - - gboolean search_installed; - gboolean search_not_installed; - - g_return_val_if_fail (pacman != NULL, FALSE); - g_return_val_if_fail (local_database != NULL, FALSE); - g_return_val_if_fail (backend != NULL, FALSE); - - package_ids = pk_backend_get_strv (backend, "package_ids"); - filters = pk_backend_get_uint (backend, "filters"); - - g_return_val_if_fail (package_ids != NULL, FALSE); - - search_installed = pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED); - search_not_installed = pk_bitfield_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED); - - for (iterator = 0; package_ids[iterator] != NULL; ++iterator) { - if (backend_cancelled (backend)) { - break; - } - - /* find a package with the given id or name */ - if (pk_package_id_check (package_ids[iterator])) { - PacmanPackage *package = backend_get_package (backend, package_ids[iterator]); - if (package == NULL) { - backend_finished (backend); - return FALSE; - } - - /* don't emit when not needed */ - if (pacman_package_get_database (package) == local_database) { - if (!search_not_installed) { - backend_package (backend, package, PK_INFO_ENUM_INSTALLED); - } - } else { - if (!search_installed) { - backend_package (backend, package, PK_INFO_ENUM_AVAILABLE); - } - } - } else { - /* find installed packages first */ - if (!search_not_installed) { - PacmanPackage *package = pacman_database_find_package (local_database, package_ids[iterator]); - - if (package != NULL) { - backend_package (backend, package, PK_INFO_ENUM_INSTALLED); - continue; - } - } - - if (!search_installed) { - const PacmanList *databases; - - for (databases = pacman_manager_get_sync_databases (pacman); databases != NULL; databases = pacman_list_next (databases)) { - PacmanDatabase *database = (PacmanDatabase *) pacman_list_get (databases); - PacmanPackage *package = pacman_database_find_package (database, package_ids[iterator]); - - if (package != NULL) { - backend_package (backend, package, PK_INFO_ENUM_AVAILABLE); - break; - } - } - } - } - } - - backend_finished (backend); - return TRUE; -} - -/** - * backend_resolve: - **/ -void -backend_resolve (PkBackend *backend, PkBitfield filters, gchar **package_ids) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (package_ids != NULL); - - backend_run (backend, PK_STATUS_ENUM_QUERY, backend_resolve_thread); -} - -static gboolean -backend_get_details_thread (PkBackend *backend) -{ - guint iterator; - - gchar **package_ids; - - g_return_val_if_fail (local_database != NULL, FALSE); - g_return_val_if_fail (backend != NULL, FALSE); - - package_ids = pk_backend_get_strv (backend, "package_ids"); - - g_return_val_if_fail (package_ids != NULL, FALSE); - - /* collect details about packages */ - for (iterator = 0; package_ids[iterator] != NULL; ++iterator) { - PacmanPackage *package; - const PacmanList *list; - GString *string; - - gchar *licenses; - PkGroupEnum group; - const gchar *description, *url; - gulong size; - - if (backend_cancelled (backend)) { - break; - } - - package = backend_get_package (backend, package_ids[iterator]); - if (package == NULL) { - backend_finished (backend); - return FALSE; - } - - list = pacman_package_get_licenses (package); - if (list == NULL) { - string = g_string_new ("unknown"); - } else { - string = g_string_new ((const gchar *) pacman_list_get (list)); - for (list = pacman_list_next (list); list != NULL; list = pacman_list_next (list)) { - /* assume OR although it may not be correct */ - g_string_append_printf (string, " or %s", (const gchar *) pacman_list_get (list)); - } - } - - group = pk_group_enum_from_string (pacman_package_get_group (package)); - description = pacman_package_get_description (package); - url = pacman_package_get_url (package); - - if (pacman_package_get_database (package) == local_database) { - size = pacman_package_get_installed_size (package); - } else { - size = pacman_package_get_download_size (package); - } - - licenses = g_string_free (string, FALSE); - pk_backend_details (backend, package_ids[iterator], licenses, group, description, url, size); - g_free (licenses); - } - - backend_finished (backend); - return TRUE; -} - -/** - * backend_get_details: - **/ -void -backend_get_details (PkBackend *backend, gchar **package_ids) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (package_ids != NULL); - - backend_run (backend, PK_STATUS_ENUM_QUERY, backend_get_details_thread); -} - -static gboolean -backend_get_files_thread (PkBackend *backend) -{ - guint iterator; - - gchar **package_ids; - - g_return_val_if_fail (pacman != NULL, FALSE); - g_return_val_if_fail (backend != NULL, FALSE); - - package_ids = pk_backend_get_strv (backend, "package_ids"); - - g_return_val_if_fail (package_ids != NULL, FALSE); - - /* enumerate files provided by package */ - for (iterator = 0; package_ids[iterator] != NULL; ++iterator) { - PacmanPackage *package; - const PacmanList *list; - - GString *string; - gchar *files; - - if (backend_cancelled (backend)) { - break; - } - - package = backend_get_package (backend, package_ids[iterator]); - if (package == NULL) { - backend_finished (backend); - return FALSE; - } - - list = pacman_package_get_files (package); - if (list == NULL) { - string = g_string_new (""); - } else { - const gchar *root_path = pacman_manager_get_root_path (pacman); - string = g_string_new (root_path); - g_string_append (string, (const gchar *) pacman_list_get (list)); - - for (list = pacman_list_next (list); list != NULL; list = pacman_list_next (list)) { - g_string_append_printf (string, ";%s%s", root_path, (const gchar *) pacman_list_get (list)); - } - } - - files = g_string_free (string, FALSE); - pk_backend_files (backend, package_ids[iterator], files); - g_free (files); - } - - backend_finished (backend); - return TRUE; -} - -/** - * backend_get_files: - **/ -void -backend_get_files (PkBackend *backend, gchar **package_ids) -{ - g_return_if_fail (pacman != NULL); - g_return_if_fail (backend != NULL); - - backend_run (backend, PK_STATUS_ENUM_QUERY, backend_get_files_thread); -} diff --git a/backends/pacman/backend-pacman.c b/backends/pacman/backend-pacman.c deleted file mode 100644 index 1276f1560..000000000 --- a/backends/pacman/backend-pacman.c +++ /dev/null @@ -1,260 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> - * Copyright (C) 2008, 2009 Valeriy Lyasotskiy <onestep@ukr.net> - * Copyright (C) 2010 Jonathan Conder <j@skurvy.no-ip.org> - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "backend-depends.h" -#include "backend-error.h" -#include "backend-groups.h" -#include "backend-install.h" -#include "backend-packages.h" -#include "backend-remove.h" -#include "backend-repos.h" -#include "backend-search.h" -#include "backend-transaction.h" -#include "backend-update.h" -#include "backend-pacman.h" - -PacmanManager *pacman = NULL; -GCancellable *cancellable = NULL; - -static void -pacman_message_cb (const gchar *domain, GLogLevelFlags level, const gchar *message, gpointer user_data) -{ - g_return_if_fail (message != NULL); - g_return_if_fail (user_data != NULL); - -/* disable due to recursive logging, will fix via improving alpm backend */ -#if 0 - /* report important output to PackageKit */ - switch (level) { - case G_LOG_LEVEL_WARNING: - case G_LOG_LEVEL_MESSAGE: - g_warning ("pacman: %s", message); - backend_message ((PkBackend *) user_data, message); - break; - - case G_LOG_LEVEL_INFO: - case G_LOG_LEVEL_DEBUG: - g_debug ("pacman: %s", message); - break; - - default: - g_warning ("pacman: %s", message); - break; - } -#endif -} - -/** - * backend_initialize: - **/ -static void -backend_initialize (PkBackend *backend) -{ - GError *error = NULL; - GLogLevelFlags flags = G_LOG_LEVEL_MASK; - - g_return_if_fail (backend != NULL); - - /* handle output from pacman */ - g_log_set_handler ("Pacman", flags, pacman_message_cb, backend); - - /* PATH needs to be set for install scriptlets */ - g_setenv ("PATH", PACMAN_DEFAULT_PATH, FALSE); - - g_debug ("pacman: initializing"); - - /* initialize pacman-glib */ - pacman = pacman_manager_get (&error); - if (pacman == NULL) { - g_error ("pacman: %s", error->message); - g_error_free (error); - return; - } - - /* configure and disable the relevant databases */ - if (!backend_initialize_databases (backend, &error)) { - g_error ("pacman: %s", error->message); - g_error_free (error); - return; - } - - /* read the group mapping from a config file */ - if (!backend_initialize_groups (backend, &error)) { - g_error ("pacman: %s", error->message); - g_error_free (error); - return; - } - - /* setup better download progress reporting */ - if (!backend_initialize_downloads (backend, &error)) { - g_error ("pacman: %s", error->message); - g_error_free (error); - return; - } -} - -/** - * backend_destroy: - **/ -static void -backend_destroy (PkBackend *backend) -{ - g_return_if_fail (backend != NULL); - - g_debug ("pacman: cleaning up"); - - backend_destroy_downloads (backend); - backend_destroy_groups (backend); - backend_destroy_databases (backend); - - if (pacman != NULL) { - g_object_unref (pacman); - } -} - -/** - * backend_get_filters: - **/ -static PkBitfield -backend_get_filters (PkBackend *backend) -{ - g_return_val_if_fail (backend != NULL, 0); - - return pk_bitfield_from_enums (PK_FILTER_ENUM_INSTALLED, -1); -} - -/** - * backend_get_mime_types: - **/ -static gchar * -backend_get_mime_types (PkBackend *backend) -{ - g_return_val_if_fail (backend != NULL, NULL); - - /* packages currently use .pkg.tar.gz and .pkg.tar.xz */ - return g_strdup ("application/x-compressed-tar;application/x-xz-compressed-tar"); -} - -void -backend_run (PkBackend *backend, PkStatusEnum status, PkBackendThreadFunc func) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (func != NULL); - - if (cancellable != NULL) { - g_warning ("pacman: cancellable was not NULL"); - g_object_unref (cancellable); - } - cancellable = g_cancellable_new (); - pk_backend_set_allow_cancel (backend, TRUE); - - pk_backend_set_status (backend, status); - pk_backend_thread_create (backend, func); -} - -/** - * backend_cancel: - **/ -static void -backend_cancel (PkBackend *backend) -{ - g_return_if_fail (backend != NULL); - - if (cancellable != NULL) { - g_cancellable_cancel (cancellable); - } -} - -gboolean -backend_cancelled (PkBackend *backend) -{ - g_return_val_if_fail (cancellable != NULL, FALSE); - g_return_val_if_fail (backend != NULL, FALSE); - - if (g_cancellable_is_cancelled (cancellable)) { - pk_backend_set_status (backend, PK_STATUS_ENUM_CANCEL); - return TRUE; - } else { - return FALSE; - } -} - -void -backend_finished (PkBackend *backend) -{ - g_return_if_fail (backend != NULL); - - pk_backend_set_allow_cancel (backend, FALSE); - if (cancellable != NULL) { - g_object_unref (cancellable); - cancellable = NULL; - } - - pk_backend_thread_finished (backend); -} - -PK_BACKEND_OPTIONS ( - "pacman", /* description */ - "Jonathan Conder <j@skurvy.no-ip.org>", /* author */ - backend_initialize, /* initialize */ - backend_destroy, /* destroy */ - backend_get_groups, /* get_groups */ - backend_get_filters, /* get_filters */ - NULL, /* get_roles */ - backend_get_mime_types, /* get_mime_types */ - backend_cancel, /* cancel */ - backend_download_packages, /* download_packages */ - NULL, /* get_categories */ - backend_get_depends, /* get_depends */ - backend_get_details, /* get_details */ - NULL, /* get_distro_upgrades */ - backend_get_files, /* get_files */ - backend_get_packages, /* get_packages */ - backend_get_repo_list, /* get_repo_list */ - backend_get_requires, /* get_requires */ - backend_get_update_detail, /* get_update_detail */ - backend_get_updates, /* get_updates */ - backend_install_files, /* install_files */ - backend_install_packages, /* install_packages */ - NULL, /* install_signature */ - backend_refresh_cache, /* refresh_cache */ - backend_remove_packages, /* remove_packages */ - backend_repo_enable, /* repo_enable */ - NULL, /* repo_set_data */ - backend_resolve, /* resolve */ - NULL, /* rollback */ - backend_search_details, /* search_details */ - backend_search_files, /* search_files */ - backend_search_groups, /* search_groups */ - backend_search_names, /* search_names */ - backend_update_packages, /* update_packages */ - NULL, /* update_system */ - backend_what_provides, /* what_provides */ - backend_simulate_install_files, /* simulate_install_files */ - backend_simulate_install_packages, /* simulate_install_packages */ - backend_simulate_remove_packages, /* simulate_remove_packages */ - backend_simulate_update_packages, /* simulate_update_packages */ - NULL, /* upgrade_packages */ - NULL, /* transaction_start */ - NULL /* transaction_stop */ -); diff --git a/backends/pacman/backend-remove.c b/backends/pacman/backend-remove.c deleted file mode 100644 index b31218bc9..000000000 --- a/backends/pacman/backend-remove.c +++ /dev/null @@ -1,142 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> - * Copyright (C) 2008, 2009 Valeriy Lyasotskiy <onestep@ukr.net> - * Copyright (C) 2010 Jonathan Conder <j@skurvy.no-ip.org> - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <pacman.h> -#include "backend-error.h" -#include "backend-packages.h" -#include "backend-pacman.h" -#include "backend-transaction.h" -#include "backend-remove.h" - -static PacmanList * -backend_remove_list_targets (PkBackend *backend) -{ - gchar **package_ids; - guint iterator; - PacmanList *list = NULL; - - g_return_val_if_fail (backend != NULL, NULL); - - package_ids = pk_backend_get_strv (backend, "package_ids"); - - g_return_val_if_fail (package_ids != NULL, NULL); - - for (iterator = 0; package_ids[iterator] != NULL; ++iterator) { - gchar **package_id_data = pk_package_id_split (package_ids[iterator]); - list = pacman_list_add (list, g_strdup (package_id_data[PK_PACKAGE_ID_NAME])); - g_strfreev (package_id_data); - } - - return list; -} - -static gboolean -backend_remove_packages_thread (PkBackend *backend) -{ - PacmanList *list; - gboolean allow_deps; - gboolean autoremove; - - PacmanTransaction *transaction = NULL; - PacmanTransactionFlags flags = PACMAN_TRANSACTION_FLAGS_NONE; - - g_return_val_if_fail (backend != NULL, FALSE); - - allow_deps = pk_backend_get_bool (backend, "allow_deps"); - autoremove = pk_backend_get_bool (backend, "autoremove"); - - /* remove packages that depend on those to be removed */ - if (allow_deps) { - flags |= PACMAN_TRANSACTION_FLAGS_REMOVE_CASCADE; - } - /* remove unneeded packages that were required by those to be removed */ - if (autoremove) { - flags |= PACMAN_TRANSACTION_FLAGS_REMOVE_RECURSIVE; - } - - /* run the transaction */ - list = backend_remove_list_targets (backend); - if (list != NULL) { - transaction = backend_transaction_run (backend, PACMAN_TRANSACTION_REMOVE, flags, list); - pacman_list_free_full (list, g_free); - } - - return backend_transaction_finished (backend, transaction); -} - -/** - * backend_remove_packages: - **/ -void -backend_remove_packages (PkBackend *backend, gchar **package_ids, gboolean allow_deps, gboolean autoremove) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (package_ids != NULL); - - backend_run (backend, PK_STATUS_ENUM_SETUP, backend_remove_packages_thread); -} - -static gboolean -backend_simulate_remove_packages_thread (PkBackend *backend) -{ - PacmanList *list; - gboolean autoremove; - - PacmanTransaction *transaction = NULL; - PacmanTransactionFlags flags = PACMAN_TRANSACTION_FLAGS_REMOVE_CASCADE; - - g_return_val_if_fail (backend != NULL, FALSE); - - autoremove = pk_backend_get_bool (backend, "autoremove"); - - /* remove unneeded packages that were required by those to be removed */ - if (autoremove) { - flags |= PACMAN_TRANSACTION_FLAGS_REMOVE_RECURSIVE; - } - - /* prepare the transaction */ - list = backend_remove_list_targets (backend); - if (list != NULL) { - transaction = backend_transaction_simulate (backend, PACMAN_TRANSACTION_REMOVE, flags, list); - pacman_list_free_full (list, g_free); - - if (transaction != NULL) { - /* emit packages that would have been installed or removed */ - backend_transaction_packages (backend, transaction); - } - } - - return backend_transaction_finished (backend, transaction); -} - -/** - * backend_simulate_remove_packages: - **/ -void -backend_simulate_remove_packages (PkBackend *backend, gchar **package_ids, gboolean autoremove) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (package_ids != NULL); - - backend_run (backend, PK_STATUS_ENUM_SETUP, backend_simulate_remove_packages_thread); -} diff --git a/backends/pacman/backend-repos.c b/backends/pacman/backend-repos.c deleted file mode 100644 index 8ef23d91c..000000000 --- a/backends/pacman/backend-repos.c +++ /dev/null @@ -1,298 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> - * Copyright (C) 2008, 2009 Valeriy Lyasotskiy <onestep@ukr.net> - * Copyright (C) 2010 Jonathan Conder <j@skurvy.no-ip.org> - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "backend-error.h" -#include "backend-pacman.h" -#include "backend-repos.h" - -PacmanDatabase *local_database = NULL; -static GHashTable *disabled_repos = NULL; - -static GHashTable * -disabled_repos_new (GError **error) -{ - GHashTable *disabled; - GFile *file; - - GFileInputStream *file_stream; - GDataInputStream *data_stream; - - gchar *line; - GError *e = NULL; - - g_debug ("pacman: reading disabled repos from %s", PACMAN_REPO_LIST); - file = g_file_new_for_path (PACMAN_REPO_LIST); - file_stream = g_file_read (file, NULL, &e); - - if (file_stream == NULL) { - g_object_unref (file); - g_propagate_error (error, e); - return NULL; - } - - disabled = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - data_stream = g_data_input_stream_new (G_INPUT_STREAM (file_stream)); - - /* read disabled repos line by line, ignoring comments */ - while ((line = g_data_input_stream_read_line (data_stream, NULL, NULL, &e)) != NULL) { - g_strstrip (line); - - if (*line == '\0' || *line == '#') { - g_free (line); - continue; - } - - g_hash_table_insert (disabled, line, GINT_TO_POINTER (1)); - } - - g_object_unref (data_stream); - g_object_unref (file_stream); - g_object_unref (file); - - if (e != NULL) { - g_hash_table_unref (disabled); - g_propagate_error (error, e); - return NULL; - } else { - return disabled; - } -} - -static gboolean -disabled_repos_configure (GHashTable *disabled, GError **error) -{ - const PacmanList *databases; - - g_return_val_if_fail (pacman != NULL, FALSE); - - g_debug ("pacman: reading config from %s", PACMAN_CONFIG_FILE); - - /* read configuration from pacman config file */ - if (!pacman_manager_configure (pacman, PACMAN_CONFIG_FILE, error)) { - return FALSE; - } - - local_database = pacman_manager_get_local_database (pacman); - - /* disable disabled repos */ - for (databases = pacman_manager_get_sync_databases (pacman); databases != NULL; databases = pacman_list_next (databases)) { - PacmanDatabase *database = (PacmanDatabase *) pacman_list_get (databases); - const gchar *repo = pacman_database_get_name (database); - - if (g_hash_table_lookup (disabled, repo) != NULL) { - if (!pacman_manager_unregister_database (pacman, database, error)) { - return FALSE; - } - - /* start again as the list gets invalidated */ - databases = pacman_manager_get_sync_databases (pacman); - } - } - - return TRUE; -} - -static void -disabled_repos_free (GHashTable *disabled) -{ - GHashTableIter iter; - GFile *file; - - GFileOutputStream *file_stream; - GDataOutputStream *data_stream; - - const gchar *line = PACMAN_REPO_LIST_HEADER "\n"; - - g_return_if_fail (disabled != NULL); - - g_debug ("pacman: storing disabled repos in %s", PACMAN_REPO_LIST); - file = g_file_new_for_path (PACMAN_REPO_LIST); - file_stream = g_file_replace (file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, NULL); - - if (file_stream == NULL) { - g_object_unref (file); - g_hash_table_unref (disabled); - return; - } - - g_hash_table_iter_init (&iter, disabled); - data_stream = g_data_output_stream_new (G_OUTPUT_STREAM (file_stream)); - - /* write header, then all disabled repos line by line */ - if (g_data_output_stream_put_string (data_stream, line, NULL, NULL)) { - while (g_hash_table_iter_next (&iter, (gpointer *) &line, NULL) && - g_data_output_stream_put_string (data_stream, line, NULL, NULL) && - g_data_output_stream_put_string (data_stream, "\n", NULL, NULL)); - } - - g_object_unref (data_stream); - g_object_unref (file_stream); - g_object_unref (file); - g_hash_table_unref (disabled); -} - -gboolean -backend_initialize_databases (PkBackend *backend, GError **error) -{ - g_return_val_if_fail (pacman != NULL, FALSE); - g_return_val_if_fail (backend != NULL, FALSE); - - disabled_repos = disabled_repos_new (error); - if (disabled_repos == NULL) { - return FALSE; - } - - if (!disabled_repos_configure (disabled_repos, error)) { - return FALSE; - } - - return TRUE; -} - -void -backend_destroy_databases (PkBackend *backend) -{ - g_return_if_fail (backend != NULL); - - if (disabled_repos != NULL) { - disabled_repos_free (disabled_repos); - } -} - -static gboolean -backend_get_repo_list_thread (PkBackend *backend) -{ - const PacmanList *databases; - GHashTableIter iter; - gpointer key, value; - - g_return_val_if_fail (pacman != NULL, FALSE); - g_return_val_if_fail (disabled_repos != NULL, FALSE); - g_return_val_if_fail (backend != NULL, FALSE); - - /* emit enabled repos */ - for (databases = pacman_manager_get_sync_databases (pacman); databases != NULL; databases = pacman_list_next (databases)) { - PacmanDatabase *database = (PacmanDatabase *) pacman_list_get (databases); - const gchar *repo = pacman_database_get_name (database); - - if (backend_cancelled (backend)) { - break; - } else { - pk_backend_repo_detail (backend, repo, repo, TRUE); - } - } - - /* emit disabled repos */ - g_hash_table_iter_init (&iter, disabled_repos); - while (g_hash_table_iter_next (&iter, &key, &value)) { - const gchar *repo = (const gchar *) key; - - if (backend_cancelled (backend)) { - break; - } else { - pk_backend_repo_detail (backend, repo, repo, FALSE); - } - } - - backend_finished (backend); - return TRUE; -} - -/** - * backend_get_repo_list: - **/ -void -backend_get_repo_list (PkBackend *backend, PkBitfield filters) -{ - g_return_if_fail (backend != NULL); - - backend_run (backend, PK_STATUS_ENUM_QUERY, backend_get_repo_list_thread); -} - -static gboolean -backend_repo_enable_thread (PkBackend *backend) -{ - GError *error = NULL; - - const gchar *repo; - gboolean enabled; - - g_return_val_if_fail (pacman != NULL, FALSE); - g_return_val_if_fail (disabled_repos != NULL, FALSE); - g_return_val_if_fail (backend != NULL, FALSE); - - repo = pk_backend_get_string (backend, "repo_id"); - enabled = pk_backend_get_bool (backend, "enabled"); - - g_return_val_if_fail (repo != NULL, FALSE); - - if (enabled) { - /* check that repo is indeed disabled */ - if (g_hash_table_remove (disabled_repos, repo)) { - /* reload configuration to preserve the correct order */ - if (disabled_repos_configure (disabled_repos, &error)) { - pk_backend_repo_list_changed (backend); - } else { - backend_error (backend, error); - pk_backend_thread_finished (backend); - return FALSE; - } - } else { - pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, "Could not find repo [%s]", repo); - pk_backend_thread_finished (backend); - return FALSE; - } - } else { - PacmanDatabase *database = pacman_manager_find_sync_database (pacman, repo); - - if (database != NULL) { - if (pacman_manager_unregister_database (pacman, database, &error)) { - g_hash_table_insert (disabled_repos, g_strdup (repo), GINT_TO_POINTER (1)); - } else { - backend_error (backend, error); - pk_backend_thread_finished (backend); - return FALSE; - } - } else { - pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, "Could not find repo [%s]", repo); - pk_backend_thread_finished (backend); - return FALSE; - } - } - - pk_backend_thread_finished (backend); - return TRUE; -} - -/** - * backend_repo_enable: - **/ -void -backend_repo_enable (PkBackend *backend, const gchar *repo, gboolean enabled) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (repo != NULL); - - pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); - pk_backend_thread_create (backend, backend_repo_enable_thread); -} diff --git a/backends/pacman/backend-repos.h b/backends/pacman/backend-repos.h deleted file mode 100644 index 7faba0c53..000000000 --- a/backends/pacman/backend-repos.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> - * Copyright (C) 2008, 2009 Valeriy Lyasotskiy <onestep@ukr.net> - * Copyright (C) 2010 Jonathan Conder <j@skurvy.no-ip.org> - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <pacman.h> -#include <pk-backend.h> - -extern PacmanDatabase *local_database; - -gboolean backend_initialize_databases (PkBackend *backend, - GError **error); -void backend_destroy_databases (PkBackend *backend); - -void backend_get_repo_list (PkBackend *backend, - PkBitfield filters); -void backend_repo_enable (PkBackend *backend, - const gchar *repo, - gboolean enabled); diff --git a/backends/pacman/backend-search.c b/backends/pacman/backend-search.c deleted file mode 100644 index 32b4df837..000000000 --- a/backends/pacman/backend-search.c +++ /dev/null @@ -1,479 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> - * Copyright (C) 2008, 2009 Valeriy Lyasotskiy <onestep@ukr.net> - * Copyright (C) 2010 Jonathan Conder <j@skurvy.no-ip.org> - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <string.h> -#include <pacman.h> -#include "backend-error.h" -#include "backend-groups.h" -#include "backend-packages.h" -#include "backend-pacman.h" -#include "backend-repos.h" -#include "backend-search.h" - -static gpointer -backend_pattern_needle (const gchar *needle, GError **error) -{ - return (gpointer) needle; -} - -static gpointer -backend_pattern_regex (const gchar *needle, GError **error) -{ - gchar *pattern; - GRegex *regex; - - g_return_val_if_fail (needle != NULL, NULL); - - pattern = g_regex_escape_string (needle, -1); - regex = g_regex_new (pattern, G_REGEX_CASELESS, 0, error); - g_free (pattern); - - return regex; -} - -static gpointer -backend_pattern_chroot (const gchar *needle, GError **error) -{ - g_return_val_if_fail (pacman != NULL, FALSE); - g_return_val_if_fail (needle != NULL, NULL); - - if (G_IS_DIR_SEPARATOR (*needle)) { - const gchar *file = needle, *path = pacman_manager_get_root_path (pacman); - - /* adjust needle to the correct prefix */ - while (*file++ == *path++) { - if (*path == '\0') { - needle = file - 1; - break; - } else if (*file == '\0') { - break; - } - } - } - - return (gpointer) needle; -} - -static gboolean -backend_match_all (PacmanPackage *package, gpointer pattern) -{ - g_return_val_if_fail (package != NULL, FALSE); - g_return_val_if_fail (pattern != NULL, FALSE); - - /* match all packages */ - return TRUE; -} - -static gboolean -backend_match_details (PacmanPackage *package, gpointer pattern) -{ - const gchar *description; - PacmanDatabase *database; - const PacmanList *licenses; - - GRegex *regex = (GRegex *) pattern; - - g_return_val_if_fail (package != NULL, FALSE); - g_return_val_if_fail (regex != NULL, FALSE); - - /* match the name first... */ - if (g_regex_match (regex, pacman_package_get_name (package), 0, NULL)) { - return TRUE; - } - - /* ... then the description... */ - description = pacman_package_get_description (package); - if (description != NULL && g_regex_match (regex, description, 0, NULL)) { - return TRUE; - } - - /* ... then the database... */ - database = pacman_package_get_database (package); - if (database != NULL && g_regex_match (regex, pacman_database_get_name (database), G_REGEX_MATCH_ANCHORED, NULL)) { - return TRUE; - } - - /* ... then the licenses */ - for (licenses = pacman_package_get_licenses (package); licenses != NULL; licenses = pacman_list_next (licenses)) { - const gchar *license = (const gchar *) pacman_list_get (licenses); - if (g_regex_match (regex, license, G_REGEX_MATCH_ANCHORED, NULL)) { - return TRUE; - } - } - - return FALSE; -} - -static gboolean -backend_match_file (PacmanPackage *package, gpointer pattern) -{ - const PacmanList *files; - const gchar *needle = (const gchar *) pattern; - - g_return_val_if_fail (package != NULL, FALSE); - g_return_val_if_fail (needle != NULL, FALSE); - - /* match any file the package contains */ - if (G_IS_DIR_SEPARATOR (*needle)) { - for (files = pacman_package_get_files (package); files != NULL; files = pacman_list_next (files)) { - const gchar *file = (const gchar *) pacman_list_get (files); - - /* match the full path of file */ - if (g_strcmp0 (file, needle + 1) == 0) { - return TRUE; - } - } - } else { - for (files = pacman_package_get_files (package); files != NULL; files = pacman_list_next (files)) { - const gchar *file = (const gchar *) pacman_list_get (files); - file = strrchr (file, G_DIR_SEPARATOR); - - /* match the basename of file */ - if (file != NULL && g_strcmp0 (file + 1, needle) == 0) { - return TRUE; - } - } - } - - return FALSE; -} - -static gboolean -backend_match_group (PacmanPackage *package, gpointer pattern) -{ - const gchar *needle = (const gchar *) pattern; - - g_return_val_if_fail (package != NULL, FALSE); - g_return_val_if_fail (needle != NULL, FALSE); - - /* match the group the package is in */ - return g_strcmp0 (needle, pacman_package_get_group (package)) == 0; -} - -static gboolean -backend_match_name (PacmanPackage *package, gpointer pattern) -{ - GRegex *regex = (GRegex *) pattern; - - g_return_val_if_fail (package != NULL, FALSE); - g_return_val_if_fail (regex != NULL, FALSE); - - /* match the name of the package */ - return g_regex_match (regex, pacman_package_get_name (package), 0, NULL); -} - -static gboolean -backend_match_provides (PacmanPackage *package, gpointer pattern) -{ - /* TODO: implement GStreamer codecs, Pango fonts, etc. */ - const PacmanList *provides; - - g_return_val_if_fail (package != NULL, FALSE); - g_return_val_if_fail (pattern != NULL, FALSE); - - /* match features provided by package */ - for (provides = pacman_package_get_provides (package); provides != NULL; provides = pacman_list_next (provides)) { - const gchar *needle = (const gchar *) pattern, *name = (const gchar *) pacman_list_get (provides); - - while (*needle == *name && *needle != '\0') { - ++needle; - ++name; - } - - if (*needle == '\0' && (*name == '\0' || *name == '=')) { - return TRUE; - } - } - - return FALSE; -} - -typedef enum { - SEARCH_TYPE_ALL, - SEARCH_TYPE_DETAILS, - SEARCH_TYPE_FILES, - SEARCH_TYPE_GROUP, - SEARCH_TYPE_NAME, - SEARCH_TYPE_PROVIDES, - SEARCH_TYPE_LAST -} SearchType; - -typedef gpointer (*PatternFunc) (const gchar *needle, GError **error); -typedef gboolean (*MatchFunc) (PacmanPackage *package, gpointer pattern); - -static PatternFunc pattern_funcs[] = { - backend_pattern_needle, - backend_pattern_regex, - backend_pattern_chroot, - backend_pattern_needle, - backend_pattern_regex, - backend_pattern_needle -}; - -static GDestroyNotify pattern_frees[] = { - NULL, - (GDestroyNotify) g_regex_unref, - NULL, - NULL, - (GDestroyNotify) g_regex_unref, - NULL -}; - -static MatchFunc match_funcs[] = { - backend_match_all, - backend_match_details, - backend_match_file, - backend_match_group, - backend_match_name, - backend_match_provides -}; - -static gboolean -pacman_package_is_installed (PacmanPackage *package) -{ - PacmanPackage *installed; - - g_return_val_if_fail (local_database != NULL, FALSE); - g_return_val_if_fail (package != NULL, FALSE); - - /* find an installed package with the same name */ - installed = pacman_database_find_package (local_database, pacman_package_get_name (package)); - if (installed == NULL) { - return FALSE; - } - - /* make sure the installed version is the same */ - if (pacman_package_compare_version (pacman_package_get_version (installed), pacman_package_get_version (package)) != 0) { - return FALSE; - } - - /* make sure the installed arch is the same */ - if (g_strcmp0 (pacman_package_get_arch (installed), pacman_package_get_arch (package)) != 0) { - return FALSE; - } - - return TRUE; -} - -static void -backend_search_database (PkBackend *backend, PacmanDatabase *database, MatchFunc match, const PacmanList *patterns) -{ - const PacmanList *packages, *list; - - g_return_if_fail (backend != NULL); - g_return_if_fail (database != NULL); - g_return_if_fail (match != NULL); - - /* emit packages that match all search terms */ - for (packages = pacman_database_get_packages (database); packages != NULL; packages = pacman_list_next (packages)) { - PacmanPackage *package = (PacmanPackage *) pacman_list_get (packages); - - if (backend_cancelled (backend)) { - break; - } - - for (list = patterns; list != NULL; list = pacman_list_next (list)) { - if (!match (package, pacman_list_get (list))) { - break; - } - } - - /* all search terms matched */ - if (list == NULL) { - if (database == local_database) { - backend_package (backend, package, PK_INFO_ENUM_INSTALLED); - } else if (!pacman_package_is_installed (package)) { - backend_package (backend, package, PK_INFO_ENUM_AVAILABLE); - } - } - } -} - -static gboolean -backend_search_thread (PkBackend *backend) -{ - gchar **search; - SearchType search_type; - - PatternFunc pattern_func; - GDestroyNotify pattern_free; - MatchFunc match_func; - - PkBitfield filters; - gboolean search_installed; - gboolean search_not_installed; - - guint iterator; - PacmanList *patterns = NULL; - GError *error = NULL; - - g_return_val_if_fail (pacman != NULL, FALSE); - g_return_val_if_fail (local_database != NULL, FALSE); - g_return_val_if_fail (backend != NULL, FALSE); - - search = pk_backend_get_strv (backend, "search"); - search_type = (SearchType) pk_backend_get_uint (backend, "search-type"); - - g_return_val_if_fail (search != NULL, FALSE); - g_return_val_if_fail (search_type < SEARCH_TYPE_LAST, FALSE); - - pattern_func = pattern_funcs[search_type]; - pattern_free = pattern_frees[search_type]; - match_func = match_funcs[search_type]; - - g_return_val_if_fail (pattern_func != NULL, FALSE); - g_return_val_if_fail (match_func != NULL, FALSE); - - filters = pk_backend_get_uint (backend, "filters"); - search_installed = pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED); - search_not_installed = pk_bitfield_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED); - - /* convert search terms to the pattern requested */ - for (iterator = 0; search[iterator] != NULL; ++iterator) { - gpointer pattern = pattern_func (search[iterator], &error); - - if (pattern != NULL) { - patterns = pacman_list_add (patterns, pattern); - } else { - backend_error (backend, error); - if (pattern_free != NULL) { - pacman_list_free_full (patterns, pattern_free); - } else { - pacman_list_free (patterns); - } - backend_finished (backend); - return FALSE; - } - } - - /* find installed packages first */ - if (!search_not_installed) { - backend_search_database (backend, local_database, match_func, patterns); - } - - if (!search_installed) { - const PacmanList *databases; - - for (databases = pacman_manager_get_sync_databases (pacman); databases != NULL; databases = pacman_list_next (databases)) { - PacmanDatabase *database = (PacmanDatabase *) pacman_list_get (databases); - - if (backend_cancelled (backend)) { - break; - } - - backend_search_database (backend, database, match_func, patterns); - } - } - - if (pattern_free != NULL) { - pacman_list_free_full (patterns, pattern_free); - } else { - pacman_list_free (patterns); - } - backend_finished (backend); - return TRUE; -} - -/** - * backend_get_packages: - **/ -void -backend_get_packages (PkBackend *backend, PkBitfield filters) -{ - g_return_if_fail (backend != NULL); - - /* provide a dummy needle */ - pk_backend_set_strv (backend, "search", g_strsplit ("", ";", 0)); - - pk_backend_set_uint (backend, "search-type", SEARCH_TYPE_ALL); - backend_run (backend, PK_STATUS_ENUM_QUERY, backend_search_thread); -} - -/** - * backend_search_details: - **/ -void -backend_search_details (PkBackend *backend, PkBitfield filters, gchar **values) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (values != NULL); - - pk_backend_set_uint (backend, "search-type", SEARCH_TYPE_DETAILS); - backend_run (backend, PK_STATUS_ENUM_QUERY, backend_search_thread); -} - -/** - * backend_search_files: - **/ -void -backend_search_files (PkBackend *backend, PkBitfield filters, gchar **values) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (values != NULL); - - /* speed up search by restricting it to local database */ - pk_bitfield_add (filters, PK_FILTER_ENUM_INSTALLED); - pk_backend_set_uint (backend, "filters", filters); - - pk_backend_set_uint (backend, "search-type", SEARCH_TYPE_FILES); - backend_run (backend, PK_STATUS_ENUM_QUERY, backend_search_thread); -} - -/** - * backend_search_groups: - **/ -void -backend_search_groups (PkBackend *backend, PkBitfield filters, gchar **values) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (values != NULL); - - pk_backend_set_uint (backend, "search-type", SEARCH_TYPE_GROUP); - backend_run (backend, PK_STATUS_ENUM_QUERY, backend_search_thread); -} - -/** - * backend_search_names: - **/ -void -backend_search_names (PkBackend *backend, PkBitfield filters, gchar **values) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (values != NULL); - - pk_backend_set_uint (backend, "search-type", SEARCH_TYPE_NAME); - backend_run (backend, PK_STATUS_ENUM_QUERY, backend_search_thread); -} - -/** - * backend_what_provides: - **/ -void -backend_what_provides (PkBackend *backend, PkBitfield filters, PkProvidesEnum provides, gchar **values) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (values != NULL); - - pk_backend_set_uint (backend, "search-type", SEARCH_TYPE_PROVIDES); - backend_run (backend, PK_STATUS_ENUM_QUERY, backend_search_thread); -} diff --git a/backends/pacman/backend-search.h b/backends/pacman/backend-search.h deleted file mode 100644 index c2ce6a033..000000000 --- a/backends/pacman/backend-search.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> - * Copyright (C) 2008, 2009 Valeriy Lyasotskiy <onestep@ukr.net> - * Copyright (C) 2010 Jonathan Conder <j@skurvy.no-ip.org> - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <pk-backend.h> - -void backend_get_packages (PkBackend *backend, - PkBitfield filters); -void backend_search_details (PkBackend *backend, - PkBitfield filters, - gchar **values); -void backend_search_files (PkBackend *backend, - PkBitfield filters, - gchar **values); -void backend_search_groups (PkBackend *backend, - PkBitfield filters, - gchar **values); -void backend_search_names (PkBackend *backend, - PkBitfield filters, - gchar **values); -void backend_what_provides (PkBackend *backend, - PkBitfield filters, - PkProvidesEnum provides, - gchar **values); diff --git a/backends/pacman/backend-transaction.c b/backends/pacman/backend-transaction.c deleted file mode 100644 index 748760b1b..000000000 --- a/backends/pacman/backend-transaction.c +++ /dev/null @@ -1,532 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> - * Copyright (C) 2008, 2009 Valeriy Lyasotskiy <onestep@ukr.net> - * Copyright (C) 2010 Jonathan Conder <j@skurvy.no-ip.org> - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <string.h> -#include "backend-error.h" -#include "backend-packages.h" -#include "backend-pacman.h" -#include "backend-repos.h" -#include "backend-transaction.h" - -typedef struct { - guint complete; - guint total; - - PacmanPackage *package; - GString *files; -} BackendDownloadData; - -static GHashTable *downloads = NULL; - -gboolean -backend_initialize_downloads (PkBackend *backend, GError **error) -{ - g_return_val_if_fail (backend != NULL, FALSE); - - downloads = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free); - return TRUE; -} - -void -backend_destroy_downloads (PkBackend *backend) -{ - g_return_if_fail (backend != NULL); - - if (downloads != NULL) { - g_hash_table_unref (downloads); - } -} - -static void -transaction_download_end (PacmanTransaction *transaction, BackendDownloadData *download, PkBackend *backend) { - g_return_if_fail (transaction != NULL); - g_return_if_fail (download != NULL); - g_return_if_fail (backend != NULL); - - /* emit the finished signal for the old package */ - backend_package (backend, download->package, PK_INFO_ENUM_FINISHED); - - /* emit the list of files downloaded for DownloadPackages */ - if (download->files != NULL) { - gchar *package_id, *files; - - package_id = pacman_package_make_id (download->package); - files = g_string_free (download->files, FALSE); - - pk_backend_files (backend, package_id, files); - - g_free (package_id); - g_free (files); - } - - download->package = NULL; - download->files = NULL; -} - -static gchar * -backend_filename_make_path (PkBackend *backend, const gchar *filename) -{ - const gchar *directory; - - g_return_val_if_fail (backend != NULL, NULL); - g_return_val_if_fail (filename != NULL, NULL); - - directory = pk_backend_get_string (backend, "directory"); - - g_return_val_if_fail (directory != NULL, NULL); - - return g_build_filename (directory, filename, NULL); -} - -static void -transaction_download_start (PacmanTransaction *transaction, BackendDownloadData *download, const gchar *filename, PkBackend *backend) -{ - const PacmanList *packages; - - g_return_if_fail (transaction != NULL); - g_return_if_fail (download != NULL); - g_return_if_fail (filename != NULL); - g_return_if_fail (backend != NULL); - - /* continue or finish downloading the old package */ - if (download->package != NULL) { - if (pacman_package_has_filename (download->package, filename)) { - if (download->files != NULL) { - gchar *path = backend_filename_make_path (backend, filename); - g_string_append_printf (download->files, ";%s", path); - g_free (path); - } - return; - } else { - transaction_download_end (transaction, download, backend); - } - } - - /* find a new package for the current file */ - for (packages = pacman_transaction_get_installs (transaction); packages != NULL; packages = pacman_list_next (packages)) { - PacmanPackage *package = (PacmanPackage *) pacman_list_get (packages); - if (pacman_package_has_filename (package, filename)) { - download->package = package; - break; - } - } - - /* emit the downloading signal and start collecting files for the new package */ - if (download->package != NULL) { - backend_package (backend, download->package, PK_INFO_ENUM_DOWNLOADING); - - /* only emit files downloaded for DownloadPackages */ - if (pk_backend_get_role (backend) == PK_ROLE_ENUM_DOWNLOAD_PACKAGES) { - gchar *path = backend_filename_make_path (backend, filename); - download->files = g_string_new (path); - g_free (path); - } - } -} - -static void -transaction_download_cb (PacmanTransaction *transaction, const gchar *filename, guint complete, guint total, gpointer user_data) -{ - BackendDownloadData *download; - - g_return_if_fail (pacman != NULL); - g_return_if_fail (transaction != NULL); - g_return_if_fail (user_data != NULL); - - download = (BackendDownloadData *) g_hash_table_lookup (downloads, transaction); - - if (filename == NULL) { - if (download == NULL) { - /* start a new download */ - download = g_new0 (BackendDownloadData, 1); - download->complete = complete; - download->total = total; - g_hash_table_insert (downloads, transaction, download); - } else { - /* finish the current download */ - if (download->package != NULL) { - transaction_download_end (transaction, download, (PkBackend *) user_data); - } - g_hash_table_remove (downloads, transaction); - } - } else { - guint percentage = 100, sub_percentage = 100; - - g_return_if_fail (download != NULL); - - if (total > 0) { - sub_percentage = complete * 100 / total; - } - - if (strstr (filename, ".db.tar.") != NULL) { - const PacmanList *databases = pacman_manager_get_sync_databases (pacman); - guint database_total = pacman_list_length (databases); - - /* report download progress for databases */ - if (database_total > 0) { - percentage = (sub_percentage + download->complete * 100) / database_total; - } - - if (complete == 0) { - g_debug ("pacman: downloading database %s", filename); - pk_backend_set_status ((PkBackend *) user_data, PK_STATUS_ENUM_REFRESH_CACHE); - } - - if (complete == total) { - download->complete += 1; - } - } else { - /* report download progress for package or delta files */ - if (download->total > 0) { - percentage = (download->complete + complete) * 100 / download->total; - } - - if (complete == 0) { - g_debug ("pacman: downloading package %s", filename); - pk_backend_set_status ((PkBackend *) user_data, PK_STATUS_ENUM_DOWNLOAD); - transaction_download_start (transaction, download, filename, (PkBackend *) user_data); - } - - if (complete == total) { - download->complete += complete; - } - } - - pk_backend_set_sub_percentage ((PkBackend *) user_data, sub_percentage); - pk_backend_set_percentage ((PkBackend *) user_data, percentage); - } -} - -static void -transaction_progress_cb (PacmanTransaction *transaction, PacmanTransactionProgress type, const gchar *target, guint percent, guint current, guint targets, gpointer user_data) -{ - g_return_if_fail (transaction != NULL); - g_return_if_fail (user_data != NULL); - - g_return_if_fail (percent >= 0); - g_return_if_fail (percent <= 100); - g_return_if_fail (current >= 1); - g_return_if_fail (current <= targets); - - /* update transaction progress */ - switch (type) { - case PACMAN_TRANSACTION_PROGRESS_INSTALL: - case PACMAN_TRANSACTION_PROGRESS_UPGRADE: - case PACMAN_TRANSACTION_PROGRESS_REMOVE: - case PACMAN_TRANSACTION_PROGRESS_FILE_CONFLICT_CHECK: - { - g_debug ("pacman: progress for %s (%u of %u) is %u%%", target, current, targets, percent); - pk_backend_set_sub_percentage ((PkBackend *) user_data, percent); - pk_backend_set_percentage ((PkBackend *) user_data, (percent + (current - 1) * 100) / targets); - break; - } - default: - g_debug ("pacman: progress of type %d (%u of %u) is %u%%", type, current, targets, percent); - break; - } -} - -static gboolean -transaction_question_cb (PacmanTransaction *transaction, PacmanTransactionQuestion question, const gchar *message, gpointer user_data) -{ - g_return_val_if_fail (transaction != NULL, FALSE); - g_return_val_if_fail (user_data != NULL, FALSE); - - switch (question) { - case PACMAN_TRANSACTION_QUESTION_INSTALL_IGNORE_PACKAGE: - { - PkRoleEnum role = pk_backend_get_role ((PkBackend *) user_data); - if (role == PK_ROLE_ENUM_INSTALL_PACKAGES) { - gchar *packages = pacman_package_make_list (pacman_transaction_get_marked_packages (transaction)); - gchar *warning = g_strdup_printf ("The following packages were marked as ignored:\n%s\n", packages); - - /* ignored packages are blocked in updates, can be explicitly installed */ - g_warning ("pacman: %s", warning); - backend_message ((PkBackend *) user_data, warning); - - g_free (warning); - g_free (packages); - return TRUE; - } else if (role == PK_ROLE_ENUM_DOWNLOAD_PACKAGES || role == PK_ROLE_ENUM_SIMULATE_INSTALL_PACKAGES) { - return TRUE; - } else { - return FALSE; - } - } - case PACMAN_TRANSACTION_QUESTION_SKIP_UNRESOLVABLE_PACKAGES: - case PACMAN_TRANSACTION_QUESTION_REMOVE_HOLD_PACKAGES: - case PACMAN_TRANSACTION_QUESTION_SYNC_FIRST: - /* none of these actions are safe */ - g_warning ("pacman: ignoring question '%s'", message); - return FALSE; - - case PACMAN_TRANSACTION_QUESTION_REPLACE_PACKAGE: - case PACMAN_TRANSACTION_QUESTION_REMOVE_CONFLICTING_PACKAGE: - case PACMAN_TRANSACTION_QUESTION_INSTALL_OLDER_PACKAGE: - case PACMAN_TRANSACTION_QUESTION_DELETE_CORRUPTED_PACKAGE: - /* these actions are mostly harmless */ - g_warning ("pacman: confirming question '%s'", message); - return TRUE; - - default: - g_warning ("pacman: unrecognised question '%s'", message); - return FALSE; - } -} - -static void -transaction_status_cb (PacmanTransaction *transaction, PacmanTransactionStatus status, const gchar *message, gpointer user_data) -{ - PkStatusEnum state; - PkInfoEnum info; - - g_return_if_fail (transaction != NULL); - g_return_if_fail (user_data != NULL); - - /* figure out the backend status and package info */ - switch (status) { - case PACMAN_TRANSACTION_STATUS_INSTALL_START: - state = PK_STATUS_ENUM_INSTALL; - info = PK_INFO_ENUM_INSTALLING; - break; - - case PACMAN_TRANSACTION_STATUS_UPGRADE_START: - if (pk_backend_get_role ((PkBackend *) user_data) == PK_ROLE_ENUM_INSTALL_FILES) { - state = PK_STATUS_ENUM_INSTALL; - info = PK_INFO_ENUM_INSTALLING; - } else { - state = PK_STATUS_ENUM_UPDATE; - info = PK_INFO_ENUM_UPDATING; - } - break; - - case PACMAN_TRANSACTION_STATUS_REMOVE_START: - state = PK_STATUS_ENUM_REMOVE; - info = PK_INFO_ENUM_REMOVING; - break; - - case PACMAN_TRANSACTION_STATUS_INSTALL_END: - case PACMAN_TRANSACTION_STATUS_UPGRADE_END: - case PACMAN_TRANSACTION_STATUS_REMOVE_END: - state = PK_STATUS_ENUM_UNKNOWN; - info = PK_INFO_ENUM_FINISHED; - break; - - case PACMAN_TRANSACTION_STATUS_DEPENDENCY_CHECK_START: - case PACMAN_TRANSACTION_STATUS_DEPENDENCY_RESOLVE_START: - state = PK_STATUS_ENUM_DEP_RESOLVE; - info = PK_INFO_ENUM_UNKNOWN; - break; - - case PACMAN_TRANSACTION_STATUS_FILE_CONFLICT_CHECK_START: - case PACMAN_TRANSACTION_STATUS_CONFLICT_CHECK_START: - case PACMAN_TRANSACTION_STATUS_PACKAGE_INTEGRITY_CHECK_START: - case PACMAN_TRANSACTION_STATUS_DELTA_INTEGRITY_CHECK_START: - state = PK_STATUS_ENUM_TEST_COMMIT; - info = PK_INFO_ENUM_UNKNOWN; - break; - - default: - state = PK_STATUS_ENUM_UNKNOWN; - info = PK_INFO_ENUM_UNKNOWN; - g_debug ("pacman: %s", message); - break; - } - - /* update the backend status */ - if (state != PK_STATUS_ENUM_UNKNOWN) { - pk_backend_set_status ((PkBackend *) user_data, state); - } - - /* update the package info */ - if (info != PK_INFO_ENUM_UNKNOWN) { - const PacmanList *packages; - - for (packages = pacman_transaction_get_marked_packages (transaction); packages != NULL; packages = pacman_list_next (packages)) { - PacmanPackage *package; - - /* only report the old versions */ - if (status == PACMAN_TRANSACTION_STATUS_UPGRADE_START || status == PACMAN_TRANSACTION_STATUS_UPGRADE_END) { - packages = pacman_list_next (packages); - if (packages == NULL) { - break; - } - } - - package = (PacmanPackage *) pacman_list_get (packages); - backend_package ((PkBackend *) user_data, package, info); - } - } -} - -static void -transaction_cancelled_cb (GCancellable *object, gpointer user_data) -{ - g_return_if_fail (user_data != NULL); - - pacman_transaction_cancel ((PacmanTransaction *) user_data, NULL); -} - -PacmanTransaction * -backend_transaction_simulate (PkBackend *backend, PacmanTransactionType type, guint32 flags, const PacmanList *targets) -{ - PacmanTransaction *transaction; - GError *error = NULL; - - g_return_val_if_fail (pacman != NULL, NULL); - g_return_val_if_fail (cancellable != NULL, NULL); - g_return_val_if_fail (backend != NULL, NULL); - g_return_val_if_fail (type < PACMAN_TRANSACTION_LAST, NULL); - - switch (type) { - case PACMAN_TRANSACTION_INSTALL: - transaction = pacman_manager_install (pacman, flags, &error); - break; - case PACMAN_TRANSACTION_MODIFY: - transaction = pacman_manager_modify (pacman, flags, &error); - break; - case PACMAN_TRANSACTION_REMOVE: - transaction = pacman_manager_remove (pacman, flags, &error); - break; - case PACMAN_TRANSACTION_SYNC: - transaction = pacman_manager_sync (pacman, flags, &error); - break; - case PACMAN_TRANSACTION_UPDATE: - transaction = pacman_manager_update (pacman, flags, &error); - break; - default: - g_return_val_if_reached (NULL); - } - - if (transaction == NULL) { - backend_error (backend, error); - return NULL; - } - - g_signal_connect (transaction, "download", G_CALLBACK (transaction_download_cb), backend); - g_signal_connect (transaction, "progress", G_CALLBACK (transaction_progress_cb), backend); - g_signal_connect (transaction, "question", G_CALLBACK (transaction_question_cb), backend); - g_signal_connect (transaction, "status", G_CALLBACK (transaction_status_cb), backend); - - if (g_cancellable_connect (cancellable, G_CALLBACK (transaction_cancelled_cb), transaction, NULL) == 0 && backend_cancelled (backend)) { - return transaction; - } - - if (!pacman_transaction_prepare (transaction, targets, &error)) { - backend_error (backend, error); - g_object_unref (transaction); - return NULL; - } - - return transaction; -} - -PacmanTransaction * -backend_transaction_run (PkBackend *backend, PacmanTransactionType type, guint32 flags, const PacmanList *targets) -{ - PacmanTransaction *transaction; - - g_return_val_if_fail (backend != NULL, NULL); - - transaction = backend_transaction_simulate (backend, type, flags, targets); - - return backend_transaction_commit (backend, transaction); -} - -void -backend_transaction_packages (PkBackend *backend, PacmanTransaction *transaction) -{ - const PacmanList *installs, *removes; - PkInfoEnum info; - - g_return_if_fail (local_database != NULL); - g_return_if_fail (backend != NULL); - g_return_if_fail (transaction != NULL); - - /* emit packages that would have been installed */ - for (installs = pacman_transaction_get_installs (transaction); installs != NULL; installs = pacman_list_next (installs)) { - PacmanPackage *install = (PacmanPackage *) pacman_list_get (installs); - - if (backend_cancelled (backend)) { - break; - } else { - const gchar *name = pacman_package_get_name (install); - if (pacman_database_find_package (local_database, name) != NULL) { - backend_package (backend, install, PK_INFO_ENUM_UPDATING); - } else { - backend_package (backend, install, PK_INFO_ENUM_INSTALLING); - } - } - } - - if (pk_backend_get_role (backend) == PK_ROLE_ENUM_SIMULATE_UPDATE_PACKAGES) { - info = PK_INFO_ENUM_OBSOLETING; - } else { - info = PK_INFO_ENUM_REMOVING; - } - - /* emit packages that would have been removed */ - for (removes = pacman_transaction_get_removes (transaction); removes != NULL; removes = pacman_list_next (removes)) { - PacmanPackage *remove = (PacmanPackage *) pacman_list_get (removes); - - if (backend_cancelled (backend)) { - break; - } else { - backend_package (backend, remove, info); - } - } -} - -PacmanTransaction * -backend_transaction_commit (PkBackend *backend, PacmanTransaction *transaction) -{ - GError *error = NULL; - - if (transaction != NULL && !backend_cancelled (backend)) { - pk_backend_set_status (backend, PK_STATUS_ENUM_RUNNING); - - if (!pacman_transaction_commit (transaction, &error)) { - backend_error (backend, error); - g_hash_table_remove (downloads, transaction); - g_object_unref (transaction); - return NULL; - } - } - - return transaction; -} - -gboolean -backend_transaction_finished (PkBackend *backend, PacmanTransaction *transaction) -{ - g_return_val_if_fail (backend != NULL, FALSE); - - if (transaction != NULL) { - g_object_unref (transaction); - backend_finished (backend); - return TRUE; - } else { - backend_finished (backend); - return FALSE; - } -} diff --git a/backends/pacman/backend-transaction.h b/backends/pacman/backend-transaction.h deleted file mode 100644 index a7db49a58..000000000 --- a/backends/pacman/backend-transaction.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> - * Copyright (C) 2008, 2009 Valeriy Lyasotskiy <onestep@ukr.net> - * Copyright (C) 2010 Jonathan Conder <j@skurvy.no-ip.org> - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <pacman.h> -#include <pk-backend.h> - -typedef enum { - PACMAN_TRANSACTION_INSTALL, - PACMAN_TRANSACTION_MODIFY, - PACMAN_TRANSACTION_REMOVE, - PACMAN_TRANSACTION_SYNC, - PACMAN_TRANSACTION_UPDATE, - PACMAN_TRANSACTION_LAST -} PacmanTransactionType; - -gboolean backend_initialize_downloads (PkBackend *backend, - GError **error); -void backend_destroy_downloads (PkBackend *backend); - -PacmanTransaction *backend_transaction_simulate (PkBackend *backend, - PacmanTransactionType type, - guint32 flags, - const PacmanList *targets); -PacmanTransaction *backend_transaction_run (PkBackend *backend, - PacmanTransactionType type, - guint32 flags, - const PacmanList *targets); - -void backend_transaction_packages (PkBackend *backend, - PacmanTransaction *transaction); -PacmanTransaction *backend_transaction_commit (PkBackend *backend, - PacmanTransaction *transaction); -gboolean backend_transaction_finished (PkBackend *backend, - PacmanTransaction *transaction); diff --git a/backends/pacman/backend-update.c b/backends/pacman/backend-update.c deleted file mode 100644 index a34eb0530..000000000 --- a/backends/pacman/backend-update.c +++ /dev/null @@ -1,394 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2007 Andreas Obergrusberger <tradiaz@yahoo.de> - * Copyright (C) 2008, 2009 Valeriy Lyasotskiy <onestep@ukr.net> - * Copyright (C) 2010 Jonathan Conder <j@skurvy.no-ip.org> - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <string.h> -#include <pacman.h> -#include <glib/gstdio.h> -#include "backend-error.h" -#include "backend-pacman.h" -#include "backend-packages.h" -#include "backend-repos.h" -#include "backend-transaction.h" -#include "backend-update.h" - -static gchar * -pacman_package_make_replaces_ids (PacmanPackage *package) -{ - const PacmanList *list; - GString *string = NULL; - - g_return_val_if_fail (local_database != NULL, NULL); - g_return_val_if_fail (package != NULL, NULL); - - /* make a list of the packages that package replaces */ - for (list = pacman_package_get_replaces (package); list != NULL; list = pacman_list_next (list)) { - const gchar *name = pacman_list_get (list); - PacmanPackage *replaces = pacman_database_find_package (local_database, name); - - if (replaces != NULL) { - gchar *package_id = pacman_package_make_id (replaces); - if (string == NULL) { - string = g_string_new (package_id); - } else { - g_string_append_printf (string, "&%s", package_id); - } - g_free (package_id); - } - } - - if (string != NULL) { - return g_string_free (string, FALSE); - } else { - return NULL; - } -} - -static gchar * -pacman_package_make_vendor_url (PacmanPackage *package) -{ - GString *string = g_string_new (""); -#ifdef PACMAN_PACKAGE_URL - const gchar *name, *arch, *repo, *url; -#else - const gchar *url; -#endif - - g_return_val_if_fail (package != NULL, NULL); - - /* grab the URL of the package... */ - url = pacman_package_get_url (package); - if (url != NULL) { - g_string_append_printf (string, "%s;Package website;", url); - } - -#ifdef PACMAN_PACKAGE_URL - /* ... and construct the distro URL if possible */ - name = pacman_package_get_name (package); - arch = pacman_package_get_arch (package); - repo = pacman_database_get_name (pacman_package_get_database (package)); - - g_string_append_printf (string, PACMAN_PACKAGE_URL ";Distribution website;", repo, arch, name); -#endif - - g_string_truncate (string, string->len - 1); - return g_string_free (string, FALSE); -} - -static gint -pacman_package_compare_pkgver (PacmanPackage *a, PacmanPackage *b) -{ - gint result; - const gchar *version_a, *version_b, *last_a, *last_b; - gchar *pkgver_a, *pkgver_b; - - g_return_val_if_fail (a != NULL, (b == NULL) ? 0 : -1); - g_return_val_if_fail (b != NULL, 1); - - version_a = pacman_package_get_version (a); - version_b = pacman_package_get_version (b); - - last_a = strrchr (version_a, '-'); - last_b = strrchr (version_b, '-'); - - if (last_a != NULL) { - pkgver_a = g_strndup (version_a, last_a - version_a); - } else { - pkgver_a = g_strdup (version_a); - } - - if (last_b != NULL) { - pkgver_b = g_strndup (version_b, last_b - version_b); - } else { - pkgver_b = g_strdup (version_b); - } - - result = pacman_package_compare_version (pkgver_a, pkgver_b); - - g_free (pkgver_a); - g_free (pkgver_b); - - return result; -} - -static gboolean -backend_get_update_detail_thread (PkBackend *backend) -{ - guint iterator; - - gchar **package_ids; - - g_return_val_if_fail (local_database != NULL, FALSE); - g_return_val_if_fail (backend != NULL, FALSE); - - package_ids = pk_backend_get_strv (backend, "package_ids"); - - g_return_val_if_fail (package_ids != NULL, FALSE); - - /* collect details about updates */ - for (iterator = 0; package_ids[iterator] != NULL; ++iterator) { - PacmanPackage *package, *upgrades; - PacmanDatabase *database; - - gchar *upgrades_id, *replaces_ids, *vendor_url; - const gchar *message; - - PkRestartEnum restart; - PkUpdateStateEnum state; - - GTimeVal built = { 0 }, installed = { 0 }; - gchar *issued, *updated; - - if (backend_cancelled (backend)) { - break; - } - - package = backend_get_package (backend, package_ids[iterator]); - if (package == NULL) { - backend_finished (backend); - return FALSE; - } - - upgrades = pacman_database_find_package (local_database, pacman_package_get_name (package)); - if (upgrades != NULL) { - upgrades_id = pacman_package_make_id (upgrades); - if (pacman_package_compare_pkgver (package, upgrades) != 0) { - message = "Update to newest upstream version"; - } else { - message = "Update to newest release"; - } - } else { - upgrades_id = NULL; - message = "Install as a replacement for an older package"; - } - - database = pacman_package_get_database (package); - replaces_ids = pacman_package_make_replaces_ids (package); - vendor_url = pacman_package_make_vendor_url (package); - - if (g_str_has_prefix (pacman_package_get_name (package), "kernel")) { - restart = PK_RESTART_ENUM_SYSTEM; - } else { - restart = PK_RESTART_ENUM_NONE; - } - - if (g_str_has_suffix (pacman_database_get_name (database), "testing")) { - state = PK_UPDATE_STATE_ENUM_TESTING; - } else { - state = PK_UPDATE_STATE_ENUM_STABLE; - } - - built.tv_sec = pacman_package_get_build_date (package); - if (built.tv_sec > 0) { - issued = g_time_val_to_iso8601 (&built); - } else { - issued = NULL; - } - - if (upgrades != NULL) { - installed.tv_sec = pacman_package_get_install_date (upgrades); - if (installed.tv_sec > 0) { - updated = g_time_val_to_iso8601 (&installed); - } else { - updated = NULL; - } - } else { - updated = NULL; - } - - pk_backend_update_detail (backend, package_ids[iterator], upgrades_id, replaces_ids, vendor_url, NULL, NULL, restart, message, NULL, state, issued, updated); - - g_free (issued); - g_free (updated); - - g_free (vendor_url); - g_free (replaces_ids); - g_free (upgrades_id); - } - - backend_finished (backend); - return TRUE; -} - -/** - * backend_get_update_detail: - **/ -void -backend_get_update_detail (PkBackend *backend, gchar **package_ids) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (package_ids != NULL); - - backend_run (backend, PK_STATUS_ENUM_QUERY, backend_get_update_detail_thread); -} - -static gboolean -pacman_package_should_ignore (PacmanPackage *package) -{ - const PacmanList *groups; - const PacmanList *ignore_packages; - const PacmanList *ignore_groups; - - g_return_val_if_fail (pacman != NULL, TRUE); - g_return_val_if_fail (package != NULL, TRUE); - - ignore_packages = pacman_manager_get_ignore_packages (pacman); - - /* check if package is an IgnorePkg */ - if (pacman_list_find_string (ignore_packages, pacman_package_get_name (package)) != NULL) { - return TRUE; - } - - ignore_groups = pacman_manager_get_ignore_groups (pacman); - - /* check if package is in an IgnoreGroup */ - for (groups = pacman_package_get_groups (package); groups != NULL; groups = pacman_list_next (groups)) { - if (pacman_list_find_string (ignore_groups, (const gchar *) pacman_list_get (groups)) != NULL) { - return TRUE; - } - } - - return FALSE; -} - -static gboolean -pacman_package_should_sync_first (PacmanPackage *package) -{ - const PacmanList *sync_firsts; - - g_return_val_if_fail (pacman != NULL, FALSE); - g_return_val_if_fail (package != NULL, FALSE); - - sync_firsts = pacman_manager_get_sync_firsts (pacman); - - /* check if package is in SyncFirst */ - if (pacman_list_find_string (sync_firsts, pacman_package_get_name (package)) != NULL) { - return TRUE; - } - - return FALSE; -} - -static gboolean -backend_get_updates_thread (PkBackend *backend) -{ - struct stat cache; - time_t one_hour_ago; - - PacmanTransaction *transaction = NULL; - PacmanTransactionFlags flags = PACMAN_TRANSACTION_FLAGS_NONE; - - const PacmanList *packages; - - g_return_val_if_fail (local_database != NULL, FALSE); - g_return_val_if_fail (pacman != NULL, FALSE); - g_return_val_if_fail (backend != NULL, FALSE); - - time (&one_hour_ago); - one_hour_ago -= 60 * 60; - - /* refresh databases if they are older than an hour */ - if (g_stat (PACMAN_CACHE_PATH, &cache) < 0 || cache.st_mtime < one_hour_ago) { - transaction = backend_transaction_run (backend, PACMAN_TRANSACTION_UPDATE, flags, NULL); - - if (transaction != NULL) { - g_object_unref (transaction); - } else { - backend_finished (backend); - return FALSE; - } - } else { - g_debug ("pacman: databases have been refreshed recently"); - } - - /* find outdated and replacement packages */ - for (packages = pacman_database_get_packages (local_database); packages != NULL; packages = pacman_list_next (packages)) { - PacmanPackage *package = (PacmanPackage *) pacman_list_get (packages); - PacmanPackage *upgrade = pacman_package_find_upgrade (package, pacman_manager_get_sync_databases (pacman)); - - if (backend_cancelled (backend)) { - break; - } - - if (upgrade != NULL) { - PkInfoEnum info; - - if (pacman_package_should_ignore (upgrade)) { - info = PK_INFO_ENUM_BLOCKED; - } else if (pacman_package_should_sync_first (upgrade)) { - info = PK_INFO_ENUM_IMPORTANT; - } else { - info = PK_INFO_ENUM_NORMAL; - } - - backend_package (backend, upgrade, info); - } - } - - backend_finished (backend); - return TRUE; -} - -/** - * backend_get_updates: - **/ -void -backend_get_updates (PkBackend *backend, PkBitfield filters) -{ - g_return_if_fail (backend != NULL); - - backend_run (backend, PK_STATUS_ENUM_QUERY, backend_get_updates_thread); -} - -static gboolean -backend_refresh_cache_thread (PkBackend *backend) -{ - gboolean force; - - PacmanTransaction *transaction = NULL; - PacmanTransactionFlags flags = PACMAN_TRANSACTION_FLAGS_NONE; - - g_return_val_if_fail (backend != NULL, FALSE); - - force = pk_backend_get_bool (backend, "force"); - - /* download databases even if they are older than current */ - if (force) { - flags |= PACMAN_TRANSACTION_FLAGS_UPDATE_ALLOW_DOWNGRADE; - } - - /* run the transaction */ - transaction = backend_transaction_run (backend, PACMAN_TRANSACTION_UPDATE, flags, NULL); - - return backend_transaction_finished (backend, transaction); -} - -/** - * backend_refresh_cache: - **/ -void -backend_refresh_cache (PkBackend *backend, gboolean force) -{ - g_return_if_fail (backend != NULL); - - backend_run (backend, PK_STATUS_ENUM_SETUP, backend_refresh_cache_thread); -} diff --git a/backends/poldek/pk-backend-poldek.c b/backends/poldek/pk-backend-poldek.c index bfd472dfd..34baf89bf 100644 --- a/backends/poldek/pk-backend-poldek.c +++ b/backends/poldek/pk-backend-poldek.c @@ -1,6 +1,6 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- * - * Copyright (C) 2008-2010 Marcin Banasiak <megabajt@pld-linux.org> + * Copyright (C) 2008-2011 Marcin Banasiak <megabajt@pld-linux.org> * * Licensed under the GNU General Public License Version 2 * @@ -1685,16 +1685,12 @@ search_package_thread (PkBackend *backend) g_free (search); /* Resolve */ } else if (mode == SEARCH_ENUM_RESOLVE) { - gchar **package_ids; - gchar *packages_str; + search = g_strjoinv(" ", values); - package_ids = pk_backend_get_strv (backend, "package_ids"); - packages_str = g_strjoinv(" ", package_ids); - - search_cmd_installed = g_strdup_printf ("ls -q %s", packages_str); + search_cmd_installed = g_strdup_printf ("ls -q %s", search); search_cmd_available = g_strdup (search_cmd_installed); - g_free (packages_str); + g_free (search); } if ((search_cmd_installed != NULL && search_cmd_available != NULL) || mode == SEARCH_ENUM_DETAILS) { @@ -2219,10 +2215,28 @@ poldek_reload (PkBackend *backend, gboolean load_packages) { } /** - * backend_initalize: + * pk_backend_get_description: */ -static void -backend_initalize (PkBackend *backend) +gchar * +pk_backend_get_description (PkBackend *backend) +{ + return g_strdup ("Poldek"); +} + +/** + * pk_backend_get_author: + */ +gchar * +pk_backend_get_author (PkBackend *backend) +{ + return g_strdup ("Marcin Banasiak <megabajt@pld-linux.org>"); +} + +/** + * pk_backend_initialize: + */ +void +pk_backend_initialize (PkBackend *backend) { g_debug ("backend initalize start"); @@ -2236,10 +2250,10 @@ backend_initalize (PkBackend *backend) g_debug ("backend initalize end"); } /** - * backend_destroy: + * pk_backend_destroy: */ -static void -backend_destroy (PkBackend *backend) +void +pk_backend_destroy (PkBackend *backend) { do_poldek_destroy (backend); @@ -2253,7 +2267,68 @@ backend_destroy (PkBackend *backend) } /** - * backend_download_packages: + * pk_backend_get_groups: + */ +PkBitfield +pk_backend_get_groups (PkBackend *backend) +{ + return pk_bitfield_from_enums ( + PK_GROUP_ENUM_ACCESSORIES, + PK_GROUP_ENUM_ADMIN_TOOLS, + PK_GROUP_ENUM_COMMUNICATION, + PK_GROUP_ENUM_DOCUMENTATION, + PK_GROUP_ENUM_EDUCATION, + PK_GROUP_ENUM_FONTS, + PK_GROUP_ENUM_GAMES, + PK_GROUP_ENUM_GRAPHICS, + PK_GROUP_ENUM_LOCALIZATION, + PK_GROUP_ENUM_MULTIMEDIA, + PK_GROUP_ENUM_NETWORK, + PK_GROUP_ENUM_OFFICE, + PK_GROUP_ENUM_OTHER, + PK_GROUP_ENUM_PROGRAMMING, + PK_GROUP_ENUM_PUBLISHING, + PK_GROUP_ENUM_SERVERS, + PK_GROUP_ENUM_SYSTEM, + -1); +} + +/** + * pk_backend_get_filters: + */ +PkBitfield +pk_backend_get_filters (PkBackend *backend) +{ + return pk_bitfield_from_enums ( + PK_FILTER_ENUM_NEWEST, + PK_FILTER_ENUM_GUI, + PK_FILTER_ENUM_INSTALLED, + PK_FILTER_ENUM_DEVELOPMENT, + -1); +} + +/** + * pk_backend_get_mime_types: + */ +gchar * +pk_backend_get_mime_types (PkBackend *backend) +{ + return g_strdup ("application/x-rpm"); +} + +/** + * pk_backend_cancel: + */ +void +pk_backend_cancel (PkBackend *backend) +{ + pk_backend_set_status (backend, PK_STATUS_ENUM_CANCEL); + + sigint_emit (); +} + +/** + * pk_backend_download_packages: */ static gboolean backend_download_packages_thread (PkBackend *backend) @@ -2322,9 +2397,9 @@ backend_download_packages_thread (PkBackend *backend) return TRUE; } -static void -backend_download_packages (PkBackend *backend, gchar **package_ids, - const gchar *directory) +void +pk_backend_download_packages (PkBackend *backend, gchar **package_ids, + const gchar *directory) { pk_backend_set_status (backend, PK_STATUS_ENUM_DOWNLOAD); poldek_backend_set_allow_cancel (backend, FALSE, TRUE); @@ -2335,68 +2410,7 @@ backend_download_packages (PkBackend *backend, gchar **package_ids, } /** - * backend_get_groups: - **/ -static PkBitfield -backend_get_groups (PkBackend *backend) -{ - return pk_bitfield_from_enums ( - PK_GROUP_ENUM_ACCESSORIES, - PK_GROUP_ENUM_ADMIN_TOOLS, - PK_GROUP_ENUM_COMMUNICATION, - PK_GROUP_ENUM_DOCUMENTATION, - PK_GROUP_ENUM_EDUCATION, - PK_GROUP_ENUM_FONTS, - PK_GROUP_ENUM_GAMES, - PK_GROUP_ENUM_GRAPHICS, - PK_GROUP_ENUM_LOCALIZATION, - PK_GROUP_ENUM_MULTIMEDIA, - PK_GROUP_ENUM_NETWORK, - PK_GROUP_ENUM_OFFICE, - PK_GROUP_ENUM_OTHER, - PK_GROUP_ENUM_PROGRAMMING, - PK_GROUP_ENUM_PUBLISHING, - PK_GROUP_ENUM_SERVERS, - PK_GROUP_ENUM_SYSTEM, - -1); -} - -/** - * backend_get_filters: - */ -static PkBitfield -backend_get_filters (PkBackend *backend) -{ - return pk_bitfield_from_enums ( - PK_FILTER_ENUM_NEWEST, - PK_FILTER_ENUM_GUI, - PK_FILTER_ENUM_INSTALLED, - PK_FILTER_ENUM_DEVELOPMENT, - -1); -} - -/** - * backend_get_mime_types: - */ -static gchar * -backend_get_mime_types (PkBackend *backend) -{ - return g_strdup ("application/x-rpm"); -} - -/** - * backend_get_cancel: - **/ -static void -backend_get_cancel (PkBackend *backend) -{ - pk_backend_set_status (backend, PK_STATUS_ENUM_CANCEL); - - sigint_emit (); -} - -/** - * backend_get_depends: + * pk_backend_get_depends: */ static gboolean backend_get_depends_thread (PkBackend *backend) @@ -2436,8 +2450,8 @@ backend_get_depends_thread (PkBackend *backend) return TRUE; } -static void -backend_get_depends (PkBackend *backend, PkBitfield filters, gchar **package_ids, gboolean recursive) +void +pk_backend_get_depends (PkBackend *backend, PkBitfield filters, gchar **package_ids, gboolean recursive) { pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); poldek_backend_set_allow_cancel (backend, FALSE, TRUE); @@ -2447,7 +2461,7 @@ backend_get_depends (PkBackend *backend, PkBitfield filters, gchar **package_ids } /** - * backend_get_details: + * pk_backend_get_details: */ static gboolean backend_get_details_thread (PkBackend *backend) @@ -2495,8 +2509,8 @@ backend_get_details_thread (PkBackend *backend) return TRUE; } -static void -backend_get_details (PkBackend *backend, gchar **package_ids) +void +pk_backend_get_details (PkBackend *backend, gchar **package_ids) { pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); poldek_backend_set_allow_cancel (backend, FALSE, TRUE); @@ -2506,7 +2520,7 @@ backend_get_details (PkBackend *backend, gchar **package_ids) } /** - * backend_get_files: + * pk_backend_get_files: */ static gboolean backend_get_files_thread (PkBackend *backend) @@ -2572,8 +2586,8 @@ backend_get_files_thread (PkBackend *backend) return TRUE; } -static void -backend_get_files (PkBackend *backend, gchar **package_ids) +void +pk_backend_get_files (PkBackend *backend, gchar **package_ids) { pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); poldek_backend_set_allow_cancel (backend, FALSE, TRUE); @@ -2583,8 +2597,8 @@ backend_get_files (PkBackend *backend, gchar **package_ids) } /** - * backend_get_packages: - **/ + * pk_backend_get_packages: + */ static gboolean backend_get_packages_thread (PkBackend *backend) { @@ -2640,8 +2654,8 @@ backend_get_packages_thread (PkBackend *backend) return TRUE; } -static void -backend_get_packages (PkBackend *backend, PkBitfield filters) +void +pk_backend_get_packages (PkBackend *backend, PkBitfield filters) { pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); poldek_backend_set_allow_cancel (backend, TRUE, TRUE); @@ -2651,7 +2665,7 @@ backend_get_packages (PkBackend *backend, PkBitfield filters) } /** - * backend_get_requires: + * pk_backend_get_requires: */ static gboolean backend_get_requires_thread (PkBackend *backend) @@ -2689,8 +2703,8 @@ backend_get_requires_thread (PkBackend *backend) return TRUE; } -static void -backend_get_requires (PkBackend *backend, PkBitfield filters, gchar **package_ids, gboolean recursive) +void +pk_backend_get_requires (PkBackend *backend, PkBitfield filters, gchar **package_ids, gboolean recursive) { pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); poldek_backend_set_allow_cancel (backend, FALSE, TRUE); @@ -2700,7 +2714,7 @@ backend_get_requires (PkBackend *backend, PkBitfield filters, gchar **package_id } /** - * backend_get_update_detail: + * pk_backend_get_update_detail: */ static gchar* get_obsoletedby_pkg (struct pkg *pkg) @@ -2838,8 +2852,8 @@ backend_get_update_detail_thread (PkBackend *backend) return TRUE; } -static void -backend_get_update_detail (PkBackend *backend, gchar **package_ids) +void +pk_backend_get_update_detail (PkBackend *backend, gchar **package_ids) { pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); poldek_backend_set_allow_cancel (backend, FALSE, TRUE); @@ -2849,7 +2863,7 @@ backend_get_update_detail (PkBackend *backend, gchar **package_ids) } /** - * backend_get_updates: + * pk_backend_get_updates: */ static gboolean backend_get_updates_thread (PkBackend *backend) @@ -2893,8 +2907,8 @@ backend_get_updates_thread (PkBackend *backend) return TRUE; } -static void -backend_get_updates (PkBackend *backend, PkBitfield filters) +void +pk_backend_get_updates (PkBackend *backend, PkBitfield filters) { pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); poldek_backend_set_allow_cancel (backend, TRUE, TRUE); @@ -2904,7 +2918,7 @@ backend_get_updates (PkBackend *backend, PkBitfield filters) } /** - * backend_install_packages: + * pk_backend_install_packages: */ static gboolean backend_install_packages_thread (PkBackend *backend) @@ -2953,8 +2967,8 @@ backend_install_packages_thread (PkBackend *backend) return TRUE; } -static void -backend_install_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids) +void +pk_backend_install_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids) { if (!pk_backend_is_online (backend)) { pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot install package when offline!"); @@ -2971,7 +2985,7 @@ backend_install_packages (PkBackend *backend, gboolean only_trusted, gchar **pac /** * FIXME: force currently omited - * backend_refresh_cache: + * pk_backend_refresh_cache: */ static gboolean backend_refresh_cache_thread (PkBackend *backend) @@ -3027,8 +3041,8 @@ backend_refresh_cache_thread (PkBackend *backend) return TRUE; } -static void -backend_refresh_cache (PkBackend *backend, gboolean force) +void +pk_backend_refresh_cache (PkBackend *backend, gboolean force) { if (!pk_backend_is_online (backend)) { pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot refresh cache when offline!"); @@ -3045,7 +3059,7 @@ backend_refresh_cache (PkBackend *backend, gboolean force) } /** - * backend_remove_packages: + * pk_backend_remove_packages: */ static gboolean backend_remove_packages_thread (PkBackend *backend) @@ -3083,8 +3097,8 @@ backend_remove_packages_thread (PkBackend *backend) return TRUE; } -static void -backend_remove_packages (PkBackend *backend, gchar **package_ids, gboolean allow_deps, gboolean autoremove) +void +pk_backend_remove_packages (PkBackend *backend, gchar **package_ids, gboolean allow_deps, gboolean autoremove) { poldek_backend_set_allow_cancel (backend, FALSE, TRUE); pb_error_clean (); @@ -3092,23 +3106,24 @@ backend_remove_packages (PkBackend *backend, gchar **package_ids, gboolean allow } /** - * backend_resolve: + * pk_backend_resolve: */ -static void -backend_resolve (PkBackend *backend, PkBitfield filters, gchar **packages) +void +pk_backend_resolve (PkBackend *backend, PkBitfield filters, gchar **packages) { pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); poldek_backend_set_allow_cancel (backend, TRUE, TRUE); pk_backend_set_uint (backend, "mode", SEARCH_ENUM_RESOLVE); + pk_backend_set_strv (backend, "search", packages); pk_backend_thread_create (backend, search_package_thread); } /** - * backend_search_details: + * pk_backend_search_details: */ -static void -backend_search_details (PkBackend *backend, PkBitfield filters, gchar **values) +void +pk_backend_search_details (PkBackend *backend, PkBitfield filters, gchar **search) { pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); poldek_backend_set_allow_cancel (backend, TRUE, TRUE); @@ -3118,10 +3133,10 @@ backend_search_details (PkBackend *backend, PkBitfield filters, gchar **values) } /** - * backend_search_files: + * pk_backend_search_files: */ -static void -backend_search_files (PkBackend *backend, PkBitfield filters, gchar **values) +void +pk_backend_search_files (PkBackend *backend, PkBitfield filters, gchar **search) { pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); poldek_backend_set_allow_cancel (backend, TRUE, TRUE); @@ -3131,10 +3146,10 @@ backend_search_files (PkBackend *backend, PkBitfield filters, gchar **values) } /** - * backend_search_groups: + * pk_backend_search_groups: */ -static void -backend_search_groups (PkBackend *backend, PkBitfield filters, gchar **values) +void +pk_backend_search_groups (PkBackend *backend, PkBitfield filters, gchar **search) { pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); poldek_backend_set_allow_cancel (backend, TRUE, TRUE); @@ -3144,10 +3159,10 @@ backend_search_groups (PkBackend *backend, PkBitfield filters, gchar **values) } /** - * backend_search_names: + * pk_backend_search_names: */ -static void -backend_search_names (PkBackend *backend, PkBitfield filters, gchar **values) +void +pk_backend_search_names (PkBackend *backend, PkBitfield filters, gchar **search) { pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); poldek_backend_set_allow_cancel (backend, TRUE, TRUE); @@ -3157,10 +3172,10 @@ backend_search_names (PkBackend *backend, PkBitfield filters, gchar **values) } /** - * backend_update_packages: + * pk_backend_update_packages: */ -static void -backend_update_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids) +void +pk_backend_update_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids) { if (!pk_backend_is_online (backend)) { pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot update packages when offline!"); @@ -3177,10 +3192,10 @@ backend_update_packages (PkBackend *backend, gboolean only_trusted, gchar **pack } /** - * backend_update_system: + * pk_backend_update_system: **/ -static void -backend_update_system (PkBackend *backend, gboolean only_trusted) +void +pk_backend_update_system (PkBackend *backend, gboolean only_trusted) { if (!pk_backend_is_online (backend)) { pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot update system when offline!"); @@ -3198,10 +3213,10 @@ backend_update_system (PkBackend *backend, gboolean only_trusted) } /** - * backend_get_repo_list: + * pk_backend_get_repo_list: */ -static void -backend_get_repo_list (PkBackend *backend, PkBitfield filters) +void +pk_backend_get_repo_list (PkBackend *backend, PkBitfield filters) { tn_array *sources = NULL; @@ -3231,10 +3246,10 @@ backend_get_repo_list (PkBackend *backend, PkBitfield filters) } /** - * backend_what_provides: - **/ -static void -backend_what_provides (PkBackend *backend, PkBitfield filters, PkProvidesEnum provides, gchar **values) + * pk_backend_what_provides: + */ +void +pk_backend_what_provides (PkBackend *backend, PkBitfield filters, PkProvidesEnum provides, gchar **values) { GPtrArray *array = NULL; gchar **search = NULL; @@ -3359,10 +3374,10 @@ static gboolean do_simulate_packages (PkBackend *backend) } /** - * backend_simulate_install_packages: - **/ -static void -backend_simulate_install_packages (PkBackend *backend, gchar **package_ids) + * pk_backend_simulate_install_packages: + */ +void +pk_backend_simulate_install_packages (PkBackend *backend, gchar **package_ids) { poldek_backend_set_allow_cancel (backend, TRUE, TRUE); pb_error_clean (); @@ -3372,10 +3387,10 @@ backend_simulate_install_packages (PkBackend *backend, gchar **package_ids) } /** - * backend_simulate_remove_packages: - **/ -static void -backend_simulate_remove_packages (PkBackend *backend, gchar **package_ids, gboolean autoremove) + * pk_backend_simulate_remove_packages: + */ +void +pk_backend_simulate_remove_packages (PkBackend *backend, gchar **package_ids, gboolean autoremove) { poldek_backend_set_allow_cancel (backend, TRUE, TRUE); pb_error_clean (); @@ -3385,10 +3400,10 @@ backend_simulate_remove_packages (PkBackend *backend, gchar **package_ids, gbool } /** - * backend_simulate_update_packages: - **/ -static void -backend_simulate_update_packages (PkBackend *backend, gchar **package_ids) + * pk_backend_simulate_update_packages: + */ +void +pk_backend_simulate_update_packages (PkBackend *backend, gchar **package_ids) { poldek_backend_set_allow_cancel (backend, TRUE, TRUE); pb_error_clean (); @@ -3397,50 +3412,3 @@ backend_simulate_update_packages (PkBackend *backend, gchar **package_ids) pk_backend_thread_create (backend, do_simulate_packages); } -/* FIXME: port this away from PK_BACKEND_OPTIONS */ -PK_BACKEND_OPTIONS ( - "poldek", /* description */ - "Marcin Banasiak <megabajt@pld-linux.org>", /* author */ - backend_initalize, /* initalize */ - backend_destroy, /* destroy */ - backend_get_groups, /* get_groups */ - backend_get_filters, /* get_filters */ - NULL, /* get_roles */ - backend_get_mime_types, /* get_mime_types */ - backend_get_cancel, /* cancel */ - backend_download_packages, /* download_packages */ - NULL, /* get_categories */ - backend_get_depends, /* get_depends */ - backend_get_details, /* get_details */ - NULL, /* get_distro_upgrades */ - backend_get_files, /* get_files */ - backend_get_packages, /* get_packages */ - backend_get_repo_list, /* get_repo_list */ - backend_get_requires, /* get_requires */ - 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, /* repo_enable */ - NULL, /* repo_set_data */ - backend_resolve, /* resolve */ - NULL, /* rollback */ - backend_search_details, /* search_details */ - backend_search_files, /* search_file */ - backend_search_groups, /* search_group */ - backend_search_names, /* search_name */ - backend_update_packages, /* update_packages */ - backend_update_system, /* update_system */ - backend_what_provides, /* what_provides */ - NULL, /* simulate_install_files */ - backend_simulate_install_packages, /* simulate_install_packages */ - backend_simulate_remove_packages, /* simulate_remove_packages */ - backend_simulate_update_packages, /* simulate_update_packages */ - NULL, /* upgrade_system */ - NULL, /* transaction_start */ - NULL /* transaction_stop */ -); - diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp index 67b6d83df..3968f0113 100644 --- a/backends/zypp/pk-backend-zypp.cpp +++ b/backends/zypp/pk-backend-zypp.cpp @@ -72,13 +72,16 @@ enum PkgSearchType { SEARCH_TYPE_RESOLVE = 3 }; +using namespace std; +using namespace zypp; + /** * A map to keep track of the EventDirector objects for * each zypp backend that is created. */ -static std::map<PkBackend *, EventDirector *> _eventDirectors; +static map<PkBackend *, EventDirector *> _eventDirectors; -std::map<PkBackend *, std::vector<std::string> *> _signatures; +map<PkBackend *, vector<string> *> _signatures; /** * pk_backend_get_description: @@ -113,7 +116,7 @@ pk_backend_initialize (PkBackend *backend) g_debug ("zypp_backend_initialize"); EventDirector *eventDirector = new EventDirector (backend); _eventDirectors [backend] = eventDirector; - std::vector<std::string> *signature = new std::vector<std::string> (); + vector<string> *signature = new vector<string> (); _signatures [backend] = signature; _updating_self = FALSE; } @@ -144,7 +147,7 @@ backend_get_requires_thread (PkBackend *backend) { gchar **package_ids; PkBitfield _filters = (PkBitfield) pk_backend_get_uint (backend, "filters"); - zypp::ZYpp::Ptr zypp; + ZYpp::Ptr zypp; zypp = get_zypp (backend); if (zypp == NULL){ @@ -164,17 +167,17 @@ backend_get_requires_thread (PkBackend *backend) //pk_backend_set_percentage (backend, 0); for (uint i = 0; package_ids[i]; i++) { - zypp::sat::Solvable solvable = zypp_get_package_by_id (backend, package_ids[i]); - zypp::PoolItem package; + sat::Solvable solvable = zypp_get_package_by_id (backend, package_ids[i]); + PoolItem package; if (solvable.isSystem ()) { - zypp::ResPool pool = zypp_build_pool (backend, true); + ResPool pool = zypp_build_pool (backend, true); gboolean found = FALSE; gchar **id_parts = pk_package_id_split (package_ids[i]); - for (zypp::ResPool::byIdent_iterator it = pool.byIdentBegin (zypp::ResKind::package, id_parts[PK_PACKAGE_ID_NAME]); - it != pool.byIdentEnd (zypp::ResKind::package, id_parts[PK_PACKAGE_ID_NAME]); it++) { + for (ResPool::byIdent_iterator it = pool.byIdentBegin (ResKind::package, id_parts[PK_PACKAGE_ID_NAME]); + it != pool.byIdentEnd (ResKind::package, id_parts[PK_PACKAGE_ID_NAME]); it++) { if (it->status ().isInstalled ()) { package = (*it); found = TRUE; @@ -189,29 +192,29 @@ backend_get_requires_thread (PkBackend *backend) } // set Package as to be uninstalled - package.status ().setToBeUninstalled (zypp::ResStatus::USER); + package.status ().setToBeUninstalled (ResStatus::USER); } else { - if (solvable == zypp::sat::Solvable::noSolvable) { + if (solvable == sat::Solvable::noSolvable) { return zypp_backend_finished_error ( backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "Package couldn't be found"); } - zypp::ResPool pool = zypp::ResPool::instance (); + ResPool pool = ResPool::instance (); package = pool.find (solvable); //set Package as to be installed - package.status ().setToBeInstalled (zypp::ResStatus::USER); + package.status ().setToBeInstalled (ResStatus::USER); } // solver run - zypp::ResPool pool = zypp::ResPool::instance (); - zypp::Resolver solver(pool); + ResPool pool = ResPool::instance (); + Resolver solver(pool); solver.setForceResolve (true); if (!solver.resolvePool ()) { - std::list<zypp::ResolverProblem_Ptr> problems = solver.problems (); - for (std::list<zypp::ResolverProblem_Ptr>::iterator it = problems.begin (); it != problems.end (); it++){ + list<ResolverProblem_Ptr> problems = solver.problems (); + for (list<ResolverProblem_Ptr>::iterator it = problems.begin (); it != problems.end (); it++){ g_warning("Solver problem (This should never happen): '%s'", (*it)->description ().c_str ()); } return zypp_backend_finished_error ( @@ -221,8 +224,8 @@ backend_get_requires_thread (PkBackend *backend) // look for packages which would be uninstalled bool error = false; - for (zypp::ResPool::byKind_iterator it = pool.byKindBegin (zypp::ResKind::package); - it != pool.byKindEnd (zypp::ResKind::package); it++) { + for (ResPool::byKind_iterator it = pool.byKindBegin (ResKind::package); + it != pool.byKindEnd (ResKind::package); it++) { if (!error && !zypp_filter_solvable (_filters, it->resolvable()->satSolvable())) error = !zypp_backend_pool_item_notify (backend, *it); @@ -290,9 +293,9 @@ pk_backend_get_filters (PkBackend *backend) } static bool -zypp_is_no_solvable (const zypp::sat::Solvable &solv) +zypp_is_no_solvable (const sat::Solvable &solv) { - return solv.id() == zypp::sat::detail::noSolvableId; + return solv.id() == sat::detail::noSolvableId; } /* @@ -317,7 +320,7 @@ backend_get_depends_thread (PkBackend *backend) "invalid package id"); } - zypp::ZYpp::Ptr zypp; + ZYpp::Ptr zypp; zypp = get_zypp (backend); if (zypp == NULL){ pk_backend_finished (backend); @@ -331,14 +334,14 @@ backend_get_depends_thread (PkBackend *backend) gchar **id_parts = pk_package_id_split (package_ids[0]); pk_backend_set_percentage (backend, 20); // Load resolvables from all the enabled repositories - zypp::ResPool pool = zypp_build_pool (backend, true); + ResPool pool = zypp_build_pool (backend, true); - zypp::PoolItem pool_item; + PoolItem pool_item; gboolean pool_item_found = FALSE; // Iterate over the resolvables and mark the one we want to check its dependencies - for (zypp::ResPool::byIdent_iterator it = pool.byIdentBegin (zypp::ResKind::package, id_parts[PK_PACKAGE_ID_NAME]); - it != pool.byIdentEnd (zypp::ResKind::package, id_parts[PK_PACKAGE_ID_NAME]); it++) { - zypp::PoolItem selectable = *it; + for (ResPool::byIdent_iterator it = pool.byIdentBegin (ResKind::package, id_parts[PK_PACKAGE_ID_NAME]); + it != pool.byIdentEnd (ResKind::package, id_parts[PK_PACKAGE_ID_NAME]); it++) { + PoolItem selectable = *it; if (strcmp (selectable->name().c_str(), id_parts[PK_PACKAGE_ID_NAME]) == 0) { // This package matches the name we're looking char *edition_str = g_strdup (selectable->edition ().asString ().c_str()); @@ -370,15 +373,15 @@ backend_get_depends_thread (PkBackend *backend) // get dependencies - zypp::sat::Solvable solvable = pool_item.satSolvable (); - zypp::Capabilities req = solvable[zypp::Dep::REQUIRES]; + sat::Solvable solvable = pool_item.satSolvable (); + Capabilities req = solvable[Dep::REQUIRES]; // which package each capability - std::map<std::string, zypp::sat::Solvable> caps; + map<string, sat::Solvable> caps; // packages already providing a capability - std::vector<std::string> pkg_names; + vector<string> pkg_names; - for (zypp::Capabilities::const_iterator cap = req.begin (); cap != req.end (); ++cap) { + for (Capabilities::const_iterator cap = req.begin (); cap != req.end (); ++cap) { g_debug ("get_depends - capability '%s'", cap->asString().c_str()); if (caps.find (cap->asString ()) != caps.end()) { @@ -388,10 +391,10 @@ backend_get_depends_thread (PkBackend *backend) // Look for packages providing each capability bool have_preference = false; - zypp::sat::Solvable preferred; + sat::Solvable preferred; - zypp::sat::WhatProvides prov_list (*cap); - for (zypp::sat::WhatProvides::const_iterator provider = prov_list.begin (); + sat::WhatProvides prov_list (*cap); + for (sat::WhatProvides::const_iterator provider = prov_list.begin (); provider != prov_list.end (); provider++) { g_debug ("provider: '%s'", provider->asString().c_str()); @@ -401,7 +404,7 @@ backend_get_depends_thread (PkBackend *backend) continue; // Is this capability provided by a package we already have listed ? - if (std::find (pkg_names.begin (), pkg_names.end(), + if (find (pkg_names.begin (), pkg_names.end(), provider->name ()) != pkg_names.end()) { preferred = *provider; have_preference = true; @@ -422,7 +425,7 @@ backend_get_depends_thread (PkBackend *backend) } if (have_preference && - std::find (pkg_names.begin (), pkg_names.end(), + find (pkg_names.begin (), pkg_names.end(), preferred.name ()) == pkg_names.end()) { caps[cap->asString()] = preferred; pkg_names.push_back (preferred.name ()); @@ -430,7 +433,7 @@ backend_get_depends_thread (PkBackend *backend) } // print dependencies - for (std::map<std::string, zypp::sat::Solvable>::iterator it = caps.begin (); + for (map<string, sat::Solvable>::iterator it = caps.begin (); it != caps.end(); it++) { @@ -439,7 +442,7 @@ backend_get_depends_thread (PkBackend *backend) it->second.name ().c_str()[0] == '\0') continue; - zypp::PoolItem item = zypp::ResPool::instance ().find (it->second); + PoolItem item = ResPool::instance ().find (it->second); PkInfoEnum info = it->second.isSystem () ? PK_INFO_ENUM_INSTALLED : PK_INFO_ENUM_AVAILABLE; g_debug ("add dep - '%s' '%s' %d [%s]", it->second.name().c_str(), @@ -454,10 +457,10 @@ backend_get_depends_thread (PkBackend *backend) } pk_backend_set_percentage (backend, 100); - } catch (const zypp::repo::RepoNotFoundException &ex) { + } catch (const repo::RepoNotFoundException &ex) { return zypp_backend_finished_error ( backend, PK_ERROR_ENUM_REPO_NOT_FOUND, ex.asUserString().c_str()); - } catch (const zypp::Exception &ex) { + } catch (const Exception &ex) { return zypp_backend_finished_error ( backend, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString().c_str()); } @@ -479,7 +482,7 @@ static gboolean backend_get_details_thread (PkBackend *backend) { gchar **package_ids; - zypp::ZYpp::Ptr zypp; + ZYpp::Ptr zypp; zypp = get_zypp (backend); if (zypp == NULL){ @@ -497,28 +500,25 @@ backend_get_details_thread (PkBackend *backend) for (uint i = 0; package_ids[i]; i++) { gchar **id_parts = pk_package_id_split (package_ids[i]); - std::vector<zypp::sat::Solvable> *v; - std::vector<zypp::sat::Solvable> *v2; - std::vector<zypp::sat::Solvable> *v3; - v = zypp_get_packages_by_name (backend, (const gchar *)id_parts[PK_PACKAGE_ID_NAME], zypp::ResKind::package); - v2 = zypp_get_packages_by_name (backend, (const gchar *)id_parts[PK_PACKAGE_ID_NAME], zypp::ResKind::patch); - v3 = zypp_get_packages_by_name (backend, (const gchar *)id_parts[PK_PACKAGE_ID_NAME], zypp::ResKind::srcpackage); + vector<sat::Solvable> v; + vector<sat::Solvable> v2; + vector<sat::Solvable> v3; + zypp_get_packages_by_name (backend, (const gchar *)id_parts[PK_PACKAGE_ID_NAME], ResKind::package, v); + zypp_get_packages_by_name (backend, (const gchar *)id_parts[PK_PACKAGE_ID_NAME], ResKind::patch, v2); + zypp_get_packages_by_name (backend, (const gchar *)id_parts[PK_PACKAGE_ID_NAME], ResKind::srcpackage, v3); - v->insert (v->end (), v2->begin (), v2->end ()); - v->insert (v->end (), v3->begin (), v3->end ()); + v.insert (v.end (), v2.begin (), v2.end ()); + v.insert (v.end (), v3.begin (), v3.end ()); - zypp::sat::Solvable package; - for (std::vector<zypp::sat::Solvable>::iterator it = v->begin (); - it != v->end (); it++) { + sat::Solvable package; + for (vector<sat::Solvable>::iterator it = v.begin (); + it != v.end (); it++) { if (zypp_ver_and_arch_equal (*it, id_parts[PK_PACKAGE_ID_VERSION], id_parts[PK_PACKAGE_ID_ARCH])) { package = *it; break; } } - delete (v); - delete (v2); - delete (v3); g_strfreev (id_parts); if (package == NULL) { @@ -530,42 +530,42 @@ backend_get_details_thread (PkBackend *backend) PkGroupEnum group = get_enum_group (zypp_get_group (package)); if (package.isSystem ()){ - zypp::target::rpm::RpmHeader::constPtr rpmHeader = zypp_get_rpmHeader (package.name (), package.edition ()); + target::rpm::RpmHeader::constPtr rpmHeader = zypp_get_rpmHeader (package.name (), package.edition ()); pk_backend_details (backend, package_ids[i], // package_id rpmHeader->tag_license ().c_str (), // const gchar *license group, // PkGroupEnum group - package.lookupStrAttribute (zypp::sat::SolvAttr::description).c_str (), //pkg->description ().c_str (), + package.lookupStrAttribute (sat::SolvAttr::description).c_str (), //pkg->description ().c_str (), rpmHeader->tag_url (). c_str (), // const gchar *url (gulong)rpmHeader->tag_archivesize ()); // gulong size } else { gulong size = 0; - if (zypp::isKind<zypp::Patch>(package)) { - zypp::PoolItem item = zypp::ResPool::instance ().find (package); - zypp::Patch::constPtr patch = zypp::asKind<zypp::Patch>(item); + if (isKind<Patch>(package)) { + PoolItem item = ResPool::instance ().find (package); + Patch::constPtr patch = asKind<Patch>(item); - zypp::sat::SolvableSet content = patch->contents (); - for (zypp::sat::SolvableSet::const_iterator it = content.begin (); it != content.end (); it++) - size += it->lookupNumAttribute (zypp::sat::SolvAttr::downloadsize); + sat::SolvableSet content = patch->contents (); + for (sat::SolvableSet::const_iterator it = content.begin (); it != content.end (); it++) + size += it->lookupNumAttribute (sat::SolvAttr::downloadsize); } else - size = package.lookupNumAttribute (zypp::sat::SolvAttr::downloadsize); + size = package.lookupNumAttribute (sat::SolvAttr::downloadsize); pk_backend_details (backend, package_ids[i], - package.lookupStrAttribute (zypp::sat::SolvAttr::license).c_str (), + package.lookupStrAttribute (sat::SolvAttr::license).c_str (), group, - package.lookupStrAttribute (zypp::sat::SolvAttr::description).c_str (), + package.lookupStrAttribute (sat::SolvAttr::description).c_str (), "TODO", // pkg->url ().c_str (), size * 1024); } - } catch (const zypp::target::rpm::RpmException &ex) { + } catch (const target::rpm::RpmException &ex) { return zypp_backend_finished_error ( backend, PK_ERROR_ENUM_REPO_NOT_FOUND, "Couldn't open rpm-database"); - } catch (const zypp::Exception &ex) { + } catch (const Exception &ex) { return zypp_backend_finished_error ( backend, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString ().c_str ()); } @@ -587,7 +587,7 @@ pk_backend_get_details (PkBackend *backend, gchar **package_ids) static gboolean backend_get_distro_upgrades_thread(PkBackend *backend) { - zypp::ZYpp::Ptr zypp; + ZYpp::Ptr zypp; zypp = get_zypp (backend); if (zypp == NULL){ @@ -602,15 +602,15 @@ backend_get_distro_upgrades_thread(PkBackend *backend) return FALSE; } - std::vector<zypp::parser::ProductFileData> result; - if (!zypp::parser::ProductFileReader::scanDir (zypp::functor::getAll (std::back_inserter (result)), "/etc/products.d")) { + vector<parser::ProductFileData> result; + if (!parser::ProductFileReader::scanDir (functor::getAll (back_inserter (result)), "/etc/products.d")) { return zypp_backend_finished_error ( backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Could not parse /etc/products.d"); } - for (std::vector<zypp::parser::ProductFileData>::iterator it = result.begin (); it != result.end (); it++) { - std::vector<zypp::parser::ProductFileData::Upgrade> upgrades = it->upgrades(); - for (std::vector<zypp::parser::ProductFileData::Upgrade>::iterator it2 = upgrades.begin (); it2 != upgrades.end (); it2++) { + for (vector<parser::ProductFileData>::iterator it = result.begin (); it != result.end (); it++) { + vector<parser::ProductFileData::Upgrade> upgrades = it->upgrades(); + for (vector<parser::ProductFileData::Upgrade>::iterator it2 = upgrades.begin (); it2 != upgrades.end (); it2++) { if (it2->notify ()){ PkDistroUpgradeEnum status = PK_DISTRO_UPGRADE_ENUM_UNKNOWN; if (it2->status () == "stable") { @@ -662,13 +662,13 @@ pk_backend_refresh_cache (PkBackend *backend, gboolean force) 2. The patch contains the package "PackageKit" or "gnome-packagekit */ /*static gboolean -check_for_self_update (PkBackend *backend, std::set<zypp::PoolItem> *candidates) +check_for_self_update (PkBackend *backend, set<PoolItem> *candidates) { - std::set<zypp::PoolItem>::iterator cb = candidates->begin (), ce = candidates->end (), ci; + set<PoolItem>::iterator cb = candidates->begin (), ce = candidates->end (), ci; for (ci = cb; ci != ce; ++ci) { - zypp::ResObject::constPtr res = ci->resolvable(); - if (zypp::isKind<zypp::Patch>(res)) { - zypp::Patch::constPtr patch = zypp::asKind<zypp::Patch>(res); + ResObject::constPtr res = ci->resolvable(); + if (isKind<Patch>(res)) { + Patch::constPtr patch = asKind<Patch>(res); //g_debug ("restart_suggested is %d",(int)patch->restartSuggested()); if (patch->restartSuggested ()) { if (!strcmp (PACKAGEKIT_RPM_NAME, res->satSolvable ().name ().c_str ()) || @@ -687,7 +687,7 @@ static gboolean backend_get_updates_thread (PkBackend *backend) { PkBitfield _filters = (PkBitfield) pk_backend_get_uint (backend, "filters"); - zypp::ZYpp::Ptr zypp; + ZYpp::Ptr zypp; zypp = get_zypp (backend); if (zypp == NULL){ @@ -695,7 +695,7 @@ backend_get_updates_thread (PkBackend *backend) return FALSE; } - typedef std::set<zypp::PoolItem>::iterator pi_it_t; + typedef set<PoolItem>::iterator pi_it_t; pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); pk_backend_set_percentage (backend, 0); @@ -706,24 +706,25 @@ backend_get_updates_thread (PkBackend *backend) return FALSE; } - zypp::ResPool pool = zypp_build_pool (backend, TRUE); + ResPool pool = zypp_build_pool (backend, TRUE); pk_backend_set_percentage (backend, 40); // check if the repositories may be dead (feature #301904) warn_outdated_repos (backend, pool); - std::set<zypp::PoolItem> *candidates = zypp_get_updates (backend); + set<PoolItem> candidates; + zypp_get_updates (backend, candidates); pk_backend_set_percentage (backend, 80); - pi_it_t cb = candidates->begin (), ce = candidates->end (), ci; + pi_it_t cb = candidates.begin (), ce = candidates.end (), ci; for (ci = cb; ci != ce; ++ci) { - zypp::ResObject::constPtr res = ci->resolvable(); + ResObject::constPtr res = ci->resolvable(); // Emit the package PkInfoEnum infoEnum = PK_INFO_ENUM_ENHANCEMENT; - if (zypp::isKind<zypp::Patch>(res)) { - zypp::Patch::constPtr patch = zypp::asKind<zypp::Patch>(res); + if (isKind<Patch>(res)) { + Patch::constPtr patch = asKind<Patch>(res); if (patch->category () == "recommended") { infoEnum = PK_INFO_ENUM_IMPORTANT; } else if (patch->category () == "optional") { @@ -746,7 +747,6 @@ backend_get_updates_thread (PkBackend *backend) res->summary ().c_str ()); } } - delete (candidates); pk_backend_set_percentage (backend, 100); pk_backend_finished (backend); @@ -766,7 +766,7 @@ static gboolean backend_install_files_thread (PkBackend *backend) { gchar **full_paths; - zypp::ZYpp::Ptr zypp; + ZYpp::Ptr zypp; zypp = get_zypp (backend); if (zypp == NULL){ @@ -777,7 +777,7 @@ backend_install_files_thread (PkBackend *backend) full_paths = pk_backend_get_strv (backend, "full_paths"); // create a temporary directory - zypp::filesystem::TmpDir tmpDir; + filesystem::TmpDir tmpDir; if (tmpDir == NULL) { return zypp_backend_finished_error ( backend, PK_ERROR_ENUM_LOCAL_INSTALL_FAILED, @@ -787,8 +787,8 @@ backend_install_files_thread (PkBackend *backend) for (guint i = 0; full_paths[i]; i++) { // check if file is really a rpm - zypp::Pathname rpmPath (full_paths[i]); - zypp::target::rpm::RpmHeader::constPtr rpmHeader = zypp::target::rpm::RpmHeader::readPackage (rpmPath, zypp::target::rpm::RpmHeader::NOSIGNATURE); + Pathname rpmPath (full_paths[i]); + target::rpm::RpmHeader::constPtr rpmHeader = target::rpm::RpmHeader::readPackage (rpmPath, target::rpm::RpmHeader::NOSIGNATURE); if (rpmHeader == NULL) { return zypp_backend_finished_error ( @@ -797,8 +797,8 @@ backend_install_files_thread (PkBackend *backend) } // copy the rpm into tmpdir - std::string tempDest = tmpDir.path ().asString () + "/" + rpmHeader->tag_name () + ".rpm"; - if (zypp::filesystem::copy (full_paths[i], tempDest) != 0) { + string tempDest = tmpDir.path ().asString () + "/" + rpmHeader->tag_name () + ".rpm"; + if (filesystem::copy (full_paths[i], tempDest) != 0) { return zypp_backend_finished_error ( backend, PK_ERROR_ENUM_LOCAL_INSTALL_FAILED, "Could not copy the rpm-file into the temp-dir"); @@ -806,12 +806,12 @@ backend_install_files_thread (PkBackend *backend) } // create a plaindir-repo and cache it - zypp::RepoInfo tmpRepo; + RepoInfo tmpRepo; try { - tmpRepo.setType(zypp::repo::RepoType::RPMPLAINDIR); - std::string url = "dir://" + tmpDir.path ().asString (); - tmpRepo.addBaseUrl(zypp::Url::parseUrl(url)); + tmpRepo.setType(repo::RepoType::RPMPLAINDIR); + string url = "dir://" + tmpDir.path ().asString (); + tmpRepo.addBaseUrl(Url::parseUrl(url)); tmpRepo.setEnabled (true); tmpRepo.setAutorefresh (true); tmpRepo.setAlias ("PK_TMP_DIR"); @@ -820,16 +820,16 @@ backend_install_files_thread (PkBackend *backend) // add Repo to pool - zypp::RepoManager manager; + RepoManager manager; manager.addRepository (tmpRepo); if (!zypp_refresh_meta_and_cache (manager, tmpRepo)) return FALSE; - } catch (const zypp::url::UrlException &ex) { + } catch (const url::UrlException &ex) { return zypp_backend_finished_error ( backend, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString ().c_str ()); - } catch (const zypp::Exception &ex) { + } catch (const Exception &ex) { return zypp_backend_finished_error ( backend, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString ().c_str ()); } @@ -837,19 +837,19 @@ backend_install_files_thread (PkBackend *backend) bool error = false; for (guint i = 0; full_paths[i]; i++) { - zypp::Pathname rpmPath (full_paths[i]); - zypp::target::rpm::RpmHeader::constPtr rpmHeader = zypp::target::rpm::RpmHeader::readPackage (rpmPath, zypp::target::rpm::RpmHeader::NOSIGNATURE); + Pathname rpmPath (full_paths[i]); + target::rpm::RpmHeader::constPtr rpmHeader = target::rpm::RpmHeader::readPackage (rpmPath, target::rpm::RpmHeader::NOSIGNATURE); // look for the packages and set them to toBeInstalled - std::vector<zypp::sat::Solvable> *solvables = 0; - solvables = zypp_get_packages_by_name (backend, rpmHeader->tag_name ().c_str (), zypp::ResKind::package, TRUE); - zypp::PoolItem *item = NULL; + vector<sat::Solvable> solvables; + zypp_get_packages_by_name (backend, rpmHeader->tag_name ().c_str (), ResKind::package, solvables, TRUE); + PoolItem *item = NULL; gboolean found = FALSE; - for (std::vector<zypp::sat::Solvable>::iterator it = solvables->begin (); it != solvables->end (); it ++) { + for (vector<sat::Solvable>::iterator it = solvables.begin (); it != solvables.end (); it ++) { if (it->repository ().alias () == "PK_TMP_DIR") { - item = new zypp::PoolItem(*it); + item = new PoolItem(*it); found = TRUE; break; } @@ -859,7 +859,7 @@ backend_install_files_thread (PkBackend *backend) error = true; pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Could not find the rpm-Package in Pool"); } else if (!error) { - zypp::ResStatus status = item->status ().setToBeInstalled (zypp::ResStatus::USER); + ResStatus status = item->status ().setToBeInstalled (ResStatus::USER); } if (!error && !zypp_perform_execution (backend, INSTALL, FALSE)) { error = true; @@ -867,15 +867,14 @@ backend_install_files_thread (PkBackend *backend) } item->statusReset (); - delete (solvables); delete (item); } // remove tmp-dir and the tmp-repo try { - zypp::RepoManager manager; + RepoManager manager; manager.removeRepository (tmpRepo); - } catch (const zypp::repo::RepoNotFoundException &ex) { + } catch (const repo::RepoNotFoundException &ex) { pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, ex.asUserString().c_str() ); } @@ -905,7 +904,7 @@ static gboolean backend_get_update_detail_thread (PkBackend *backend) { gchar **package_ids; - zypp::ZYpp::Ptr zypp; + ZYpp::Ptr zypp; zypp = get_zypp (backend); if (zypp == NULL){ @@ -921,25 +920,25 @@ backend_get_update_detail_thread (PkBackend *backend) pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); for (uint i = 0; package_ids[i]; i++) { - zypp::sat::Solvable solvable = zypp_get_package_by_id (backend, package_ids[i]); + sat::Solvable solvable = zypp_get_package_by_id (backend, package_ids[i]); - zypp::Capabilities obs = solvable.obsoletes (); + Capabilities obs = solvable.obsoletes (); gchar *obsoletes = zypp_build_package_id_capabilities (obs); PkRestartEnum restart = PK_RESTART_ENUM_NONE; - zypp::PoolItem item = zypp::ResPool::instance ().find (solvable); + PoolItem item = ResPool::instance ().find (solvable); gchar *bugzilla = new gchar (); gchar *cve = new gchar (); - if (zypp::isKind<zypp::Patch>(solvable)) { - zypp::Patch::constPtr patch = zypp::asKind<zypp::Patch>(item); + if (isKind<Patch>(solvable)) { + Patch::constPtr patch = asKind<Patch>(item); zypp_check_restart (&restart, patch); // Building links like "http://www.distro-update.org/page?moo;Bugfix release for kernel;http://www.test.de/bgz;test domain" - for (zypp::Patch::ReferenceIterator it = patch->referencesBegin (); it != patch->referencesEnd (); it ++) { + for (Patch::ReferenceIterator it = patch->referencesBegin (); it != patch->referencesEnd (); it ++) { if (it.type () == "bugzilla") { if (strlen (bugzilla) == 0) { bugzilla = g_strconcat (it.href ().c_str (), ";", it.title ().c_str (), (gchar *)NULL); @@ -955,9 +954,9 @@ backend_get_update_detail_thread (PkBackend *backend) } } - zypp::sat::SolvableSet content = patch->contents (); + sat::SolvableSet content = patch->contents (); - for (zypp::sat::SolvableSet::const_iterator it = content.begin (); it != content.end (); it++) { + for (sat::SolvableSet::const_iterator it = content.begin (); it != content.end (); it++) { //obsoletes = g_strconcat (obsoletes, zypp_build_package_id_capabilities (it->obsoletes ()), PK_PACKAGE_IDS_DELIM, (gchar *)NULL); if (strlen(obsoletes) == 0) { obsoletes = zypp_build_package_id_capabilities (it->obsoletes ()); @@ -975,7 +974,7 @@ backend_get_update_detail_thread (PkBackend *backend) bugzilla, // bugzilla cve, // cve restart, // restart -flag - solvable.lookupStrAttribute (zypp::sat::SolvAttr::description).c_str (), // update-text + solvable.lookupStrAttribute (sat::SolvAttr::description).c_str (), // update-text NULL, // ChangeLog text PK_UPDATE_STATE_ENUM_UNKNOWN, // state of the update NULL, // date that the update was issued @@ -1002,7 +1001,7 @@ pk_backend_get_update_detail (PkBackend *backend, gchar **package_ids) static gboolean backend_update_system_thread (PkBackend *backend) { - zypp::ZYpp::Ptr zypp; + ZYpp::Ptr zypp; zypp = get_zypp (backend); if (zypp == NULL){ @@ -1013,23 +1012,24 @@ backend_update_system_thread (PkBackend *backend) pk_backend_set_percentage (backend, 0); /* FIXME: support only_trusted */ - zypp::ResPool pool = zypp_build_pool (backend, TRUE); + ResPool pool = zypp_build_pool (backend, TRUE); pk_backend_set_percentage (backend, 40); PkRestartEnum restart = PK_RESTART_ENUM_NONE; - std::set<zypp::PoolItem> *candidates = zypp_get_updates (backend); + set<PoolItem> candidates; + zypp_get_updates (backend, candidates); if (_updating_self) _updating_self = FALSE; pk_backend_set_percentage (backend, 80); - std::set<zypp::PoolItem>::iterator cb = candidates->begin (), ce = candidates->end (), ci; + set<PoolItem>::iterator cb = candidates.begin (), ce = candidates.end (), ci; for (ci = cb; ci != ce; ++ci) { // set the status of the update to ToBeInstalled - zypp::ResStatus &status = ci->status (); - status.setToBeInstalled (zypp::ResStatus::USER); - if (zypp::isKind<zypp::Patch>(ci->resolvable ())) { - zypp_check_restart (&restart, zypp::asKind<zypp::Patch>(ci->resolvable ())); + ResStatus &status = ci->status (); + status.setToBeInstalled (ResStatus::USER); + if (isKind<Patch>(ci->resolvable ())) { + zypp_check_restart (&restart, asKind<Patch>(ci->resolvable ())); } } @@ -1042,7 +1042,6 @@ backend_update_system_thread (PkBackend *backend) if (restart != PK_RESTART_ENUM_NONE) pk_backend_require_restart (backend, restart, "A restart is needed"); - delete (candidates); pk_backend_set_percentage (backend, 100); pk_backend_finished (backend); return TRUE; @@ -1071,7 +1070,7 @@ backend_install_packages_thread (PkBackend *backend) pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); pk_backend_set_percentage (backend, 0); - zypp::ZYpp::Ptr zypp; + ZYpp::Ptr zypp; zypp = get_zypp (backend); if (zypp == NULL){ pk_backend_finished (backend); @@ -1087,21 +1086,21 @@ backend_install_packages_thread (PkBackend *backend) try { - zypp::ResPool pool = zypp_build_pool (backend, TRUE); + ResPool pool = zypp_build_pool (backend, TRUE); pk_backend_set_percentage (backend, 10); - std::vector<zypp::PoolItem> *items = new std::vector<zypp::PoolItem> (); + vector<PoolItem> *items = new vector<PoolItem> (); guint to_install = 0; for (guint i = 0; package_ids[i]; i++) { gchar **id_parts = pk_package_id_split (package_ids[i]); // Iterate over the selectables and mark the one with the right name - zypp::ui::Selectable::constPtr selectable; - std::string name = id_parts[PK_PACKAGE_ID_NAME]; + ui::Selectable::constPtr selectable; + string name = id_parts[PK_PACKAGE_ID_NAME]; // Do we have this installed ? gboolean system = false; - for (zypp::ResPool::byName_iterator it = pool.byNameBegin (name); + for (ResPool::byName_iterator it = pool.byNameBegin (name); it != pool.byNameEnd (name); it++) { g_debug ("PoolItem '%s'", it->satSolvable().asString().c_str()); @@ -1120,7 +1119,7 @@ backend_install_packages_thread (PkBackend *backend) gboolean hit = false; // Choose the PoolItem with the right architecture and version - for (zypp::ResPool::byName_iterator it = pool.byNameBegin (name); + for (ResPool::byName_iterator it = pool.byNameBegin (name); it != pool.byNameEnd (name); it++) { if (zypp_ver_and_arch_equal (it->satSolvable(), id_parts[PK_PACKAGE_ID_VERSION], @@ -1128,7 +1127,7 @@ backend_install_packages_thread (PkBackend *backend) hit = true; to_install++; // set status to ToBeInstalled - it->status ().setToBeInstalled (zypp::ResStatus::USER); + it->status ().setToBeInstalled (ResStatus::USER); items->push_back (*it); break; } @@ -1156,7 +1155,7 @@ backend_install_packages_thread (PkBackend *backend) // PK_INFO_ENUM_DOWNLOADING | INSTALLING) for each package. if (!zypp_perform_execution (backend, INSTALL, FALSE)) { // reset the status of the marked packages - for (std::vector<zypp::PoolItem>::iterator it = items->begin (); it != items->end (); it++) { + for (vector<PoolItem>::iterator it = items->begin (); it != items->end (); it++) { it->statusReset (); } delete (items); @@ -1167,7 +1166,7 @@ backend_install_packages_thread (PkBackend *backend) pk_backend_set_percentage (backend, 100); - } catch (const zypp::Exception &ex) { + } catch (const Exception &ex) { return zypp_backend_finished_error ( backend, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString().c_str()); } @@ -1202,7 +1201,7 @@ backend_install_signature_thread (PkBackend *backend) pk_backend_set_status (backend, PK_STATUS_ENUM_SIG_CHECK); const gchar *key_id = pk_backend_get_string (backend, "key_id"); const gchar *package_id = pk_backend_get_string (backend, "package_id"); - _signatures[backend]->push_back ((std::string)(key_id)); + _signatures[backend]->push_back ((string)(key_id)); pk_backend_finished (backend); return TRUE; @@ -1222,13 +1221,13 @@ backend_remove_packages_thread (PkBackend *backend) { gboolean autoremove; gchar **package_ids; - std::vector<zypp::PoolItem> *items = new std::vector<zypp::PoolItem> (); + vector<PoolItem> *items = new vector<PoolItem> (); pk_backend_set_status (backend, PK_STATUS_ENUM_REMOVE); pk_backend_set_percentage (backend, 0); - zypp::Target_Ptr target; - zypp::ZYpp::Ptr zypp; + Target_Ptr target; + ZYpp::Ptr zypp; zypp = get_zypp (backend); if (zypp == NULL){ pk_backend_finished (backend); @@ -1252,13 +1251,15 @@ backend_remove_packages_thread (PkBackend *backend) gchar **id_parts = pk_package_id_split (package_ids[i]); // Iterate over the resolvables and mark the ones we want to remove - zypp::ResPool pool = zypp::ResPool::instance (); - for (zypp::ResPool::byIdent_iterator it = pool.byIdentBegin (zypp::ResKind::package, id_parts[PK_PACKAGE_ID_NAME]); - it != pool.byIdentEnd (zypp::ResKind::package, id_parts[PK_PACKAGE_ID_NAME]); it++) { + ResPool pool = ResPool::instance (); + for (ResPool::byIdent_iterator it = pool.byIdentBegin (ResKind::package, id_parts[PK_PACKAGE_ID_NAME]); + it != pool.byIdentEnd (ResKind::package, id_parts[PK_PACKAGE_ID_NAME]); it++) { if ((*it)->isSystem ()) { - it->status ().setToBeUninstalled (zypp::ResStatus::USER); + it->status ().setToBeUninstalled (ResStatus::USER); items->push_back (*it); break; + } else { + it->status ().resetTransact (ResStatus::USER); } } g_strfreev (id_parts); @@ -1270,7 +1271,7 @@ backend_remove_packages_thread (PkBackend *backend) { if (!zypp_perform_execution (backend, REMOVE, TRUE)) { //reset the status of the marked packages - for (std::vector<zypp::PoolItem>::iterator it = items->begin (); it != items->end (); it++) { + for (vector<PoolItem>::iterator it = items->begin (); it != items->end (); it++) { it->statusReset(); } delete (items); @@ -1282,10 +1283,10 @@ backend_remove_packages_thread (PkBackend *backend) delete (items); pk_backend_set_percentage (backend, 100); - } catch (const zypp::repo::RepoNotFoundException &ex) { + } catch (const repo::RepoNotFoundException &ex) { return zypp_backend_finished_error ( backend, PK_ERROR_ENUM_REPO_NOT_FOUND, ex.asUserString().c_str()); - } catch (const zypp::Exception &ex) { + } catch (const Exception &ex) { return zypp_backend_finished_error ( backend, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString().c_str()); } @@ -1314,7 +1315,7 @@ backend_resolve_thread (PkBackend *backend) { gchar **package_ids = pk_backend_get_strv (backend, "package_ids"); PkBitfield _filters = (PkBitfield) pk_backend_get_uint (backend, "filters"); - zypp::ZYpp::Ptr zypp; + ZYpp::Ptr zypp; zypp = get_zypp (backend); if (zypp == NULL){ @@ -1322,53 +1323,52 @@ backend_resolve_thread (PkBackend *backend) return FALSE; } + zypp->getTarget()->load(); + pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); for (uint i = 0; package_ids[i]; i++) { - std::vector<zypp::sat::Solvable> *v; + vector<sat::Solvable> v; /* build a list of packages with this name */ - v = zypp_get_packages_by_name (backend, package_ids[i], zypp::ResKind::package); + zypp_get_packages_by_name (backend, package_ids[i], ResKind::package, v); /* add source packages */ if (!pk_bitfield_contain (_filters, PK_FILTER_ENUM_NOT_SOURCE)) { - std::vector<zypp::sat::Solvable> *src; - src = zypp_get_packages_by_name (backend, package_ids[i], zypp::ResKind::srcpackage); - v->insert (v->end (), src->begin (), src->end ()); - delete (src); + vector<sat::Solvable> src; + zypp_get_packages_by_name (backend, package_ids[i], ResKind::srcpackage, src); + v.insert (v.end (), src.begin (), src.end ()); } /* include patches too */ - std::vector<zypp::sat::Solvable> *v2; - v2 = zypp_get_packages_by_name (backend, package_ids[i], zypp::ResKind::patch); - v->insert (v->end (), v2->begin (), v2->end ()); - delete (v2); + vector<sat::Solvable> v2; + zypp_get_packages_by_name (backend, package_ids[i], ResKind::patch, v2); + v.insert (v.end (), v2.begin (), v2.end ()); - zypp::sat::Solvable newest; - std::vector<zypp::sat::Solvable> pkgs; + sat::Solvable newest; + vector<sat::Solvable> pkgs; /* Filter the list of packages with this name to 'pkgs' */ - for (std::vector<zypp::sat::Solvable>::iterator it = v->begin (); it != v->end (); it++) { + for (vector<sat::Solvable>::iterator it = v.begin (); it != v.end (); it++) { if (zypp_filter_solvable (_filters, *it) || - *it == zypp::sat::Solvable::noSolvable) + *it == sat::Solvable::noSolvable) continue; - if (newest == zypp::sat::Solvable::noSolvable) { + if (newest == sat::Solvable::noSolvable) { newest = *it; } else if (it->edition().match (newest.edition()) > 0) { newest = *it; } pkgs.push_back (*it); } - delete (v); /* 'newest' filter support */ if (pk_bitfield_contain (_filters, PK_FILTER_ENUM_NEWEST)) { pkgs.clear(); pkgs.push_back (newest); } else if (pk_bitfield_contain (_filters, PK_FILTER_ENUM_NOT_NEWEST)) { - pkgs.erase (std::find (pkgs.begin (), pkgs.end(), newest)); + pkgs.erase (find (pkgs.begin (), pkgs.end(), newest)); } zypp_emit_filtered_packages_in_list (backend, pkgs); @@ -1399,7 +1399,7 @@ backend_find_packages_thread (PkBackend *backend) gchar **values; const gchar *search; guint mode; - zypp::ZYpp::Ptr zypp; + ZYpp::Ptr zypp; zypp = get_zypp (backend); if (zypp == NULL){ @@ -1420,9 +1420,9 @@ backend_find_packages_thread (PkBackend *backend) pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID); - std::vector<zypp::sat::Solvable> v; + vector<sat::Solvable> v; - zypp::PoolQuery q; + PoolQuery q; q.addString( search ); // may be called multiple times (OR'ed) q.setCaseSensitive( true ); q.setMatchSubstring(); @@ -1430,28 +1430,28 @@ backend_find_packages_thread (PkBackend *backend) switch (mode) { case SEARCH_TYPE_NAME: zypp_build_pool (backend, TRUE); // seems to be necessary? - q.addKind( zypp::ResKind::package ); - q.addKind( zypp::ResKind::srcpackage ); - q.addAttribute( zypp::sat::SolvAttr::name ); + q.addKind( ResKind::package ); + q.addKind( ResKind::srcpackage ); + q.addAttribute( sat::SolvAttr::name ); // Note: The query result is NOT sorted packages first, then srcpackage. // If that's necessary you need to sort the vector accordongly or use // two separate queries. break; case SEARCH_TYPE_DETAILS: zypp_build_pool (backend, TRUE); // seems to be necessary? - q.addKind( zypp::ResKind::package ); - //q.addKind( zypp::ResKind::srcpackage ); - q.addAttribute( zypp::sat::SolvAttr::name ); - q.addAttribute( zypp::sat::SolvAttr::description ); + q.addKind( ResKind::package ); + //q.addKind( ResKind::srcpackage ); + q.addAttribute( sat::SolvAttr::name ); + q.addAttribute( sat::SolvAttr::description ); // Note: Don't know if zypp_get_packages_by_details intentionally // did not search in srcpackages. break; case SEARCH_TYPE_FILE: { zypp_build_pool (backend, TRUE); - q.addKind( zypp::ResKind::package ); - q.addAttribute( zypp::sat::SolvAttr::name ); - q.addAttribute( zypp::sat::SolvAttr::description ); - q.addAttribute( zypp::sat::SolvAttr::filelist ); + q.addKind( ResKind::package ); + q.addAttribute( sat::SolvAttr::name ); + q.addAttribute( sat::SolvAttr::description ); + q.addAttribute( sat::SolvAttr::filelist ); q.setFilesMatchFullPath(true); q.setMatchExact(); break; @@ -1459,7 +1459,7 @@ backend_find_packages_thread (PkBackend *backend) }; if ( ! q.empty() ) { - std::copy( q.begin(), q.end(), std::back_inserter( v ) ); + copy( q.begin(), q.end(), back_inserter( v ) ); } zypp_emit_filtered_packages_in_list (backend, v); @@ -1492,7 +1492,7 @@ backend_search_group_thread (PkBackend *backend) { gchar **values; const gchar *group; - zypp::ZYpp::Ptr zypp; + ZYpp::Ptr zypp; zypp = get_zypp (backend); if (zypp == NULL){ @@ -1511,16 +1511,16 @@ backend_search_group_thread (PkBackend *backend) pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); pk_backend_set_percentage (backend, 0); - zypp::ResPool pool = zypp_build_pool (backend, true); + ResPool pool = zypp_build_pool (backend, true); pk_backend_set_percentage (backend, 30); - std::vector<zypp::sat::Solvable> v; + vector<sat::Solvable> v; PkGroupEnum pkGroup = pk_group_enum_from_string (group); - zypp::sat::LookupAttr look (zypp::sat::SolvAttr::group); + sat::LookupAttr look (sat::SolvAttr::group); - for (zypp::sat::LookupAttr::iterator it = look.begin (); it != look.end (); it++) { + for (sat::LookupAttr::iterator it = look.begin (); it != look.end (); it++) { PkGroupEnum rpmGroup = get_enum_group (it.asString ()); if (pkGroup == rpmGroup) v.push_back (it.inSolvable ()); @@ -1560,7 +1560,7 @@ pk_backend_search_files (PkBackend *backend, PkBitfield filters, gchar **values) void pk_backend_get_repo_list (PkBackend *backend, PkBitfield filters) { - zypp::ZYpp::Ptr zypp; + ZYpp::Ptr zypp; zypp = get_zypp (backend); if (zypp == NULL){ @@ -1570,22 +1570,22 @@ pk_backend_get_repo_list (PkBackend *backend, PkBitfield filters) pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); - zypp::RepoManager manager; - std::list <zypp::RepoInfo> repos; + RepoManager manager; + list <RepoInfo> repos; try { - repos = std::list<zypp::RepoInfo>(manager.repoBegin(),manager.repoEnd()); - } catch (const zypp::repo::RepoNotFoundException &ex) { + repos = list<RepoInfo>(manager.repoBegin(),manager.repoEnd()); + } catch (const repo::RepoNotFoundException &ex) { zypp_backend_finished_error ( backend, PK_ERROR_ENUM_REPO_NOT_FOUND, ex.asUserString().c_str()); return; - } catch (const zypp::Exception &ex) { + } catch (const Exception &ex) { zypp_backend_finished_error ( backend, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString().c_str()); return; } - for (std::list <zypp::RepoInfo>::iterator it = repos.begin(); it != repos.end(); it++) { + for (list <RepoInfo>::iterator it = repos.begin(); it != repos.end(); it++) { if (pk_bitfield_contain (filters, PK_FILTER_ENUM_NOT_DEVELOPMENT) && zypp_is_development_repo (backend, *it)) continue; // RepoInfo::alias - Unique identifier for this source. @@ -1606,7 +1606,7 @@ pk_backend_get_repo_list (PkBackend *backend, PkBitfield filters) void pk_backend_repo_enable (PkBackend *backend, const gchar *rid, gboolean enabled) { - zypp::ZYpp::Ptr zypp; + ZYpp::Ptr zypp; zypp = get_zypp (backend); if (zypp == NULL){ @@ -1615,8 +1615,8 @@ pk_backend_repo_enable (PkBackend *backend, const gchar *rid, gboolean enabled) } pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); - zypp::RepoManager manager; - zypp::RepoInfo repo; + RepoManager manager; + RepoInfo repo; try { repo = manager.getRepositoryInfo (rid); @@ -1627,15 +1627,15 @@ pk_backend_repo_enable (PkBackend *backend, const gchar *rid, gboolean enabled) repo.setEnabled (enabled); manager.modifyRepository (rid, repo); if (!enabled) { - zypp::Repository repository = zypp::sat::Pool::instance ().reposFind (repo.alias ()); + Repository repository = sat::Pool::instance ().reposFind (repo.alias ()); repository.eraseFromPool (); } - } catch (const zypp::repo::RepoNotFoundException &ex) { + } catch (const repo::RepoNotFoundException &ex) { zypp_backend_finished_error ( backend, PK_ERROR_ENUM_REPO_NOT_FOUND, ex.asUserString().c_str()); return; - } catch (const zypp::Exception &ex) { + } catch (const Exception &ex) { zypp_backend_finished_error ( backend, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString().c_str()); return; @@ -1648,7 +1648,7 @@ static gboolean backend_get_files_thread (PkBackend *backend) { gchar **package_ids; - zypp::ZYpp::Ptr zypp; + ZYpp::Ptr zypp; zypp = get_zypp (backend); if (zypp == NULL){ @@ -1666,16 +1666,16 @@ backend_get_files_thread (PkBackend *backend) gchar **id_parts = pk_package_id_split (package_ids[i]); pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); - std::vector<zypp::sat::Solvable> *v; - std::vector<zypp::sat::Solvable> *v2; - v = zypp_get_packages_by_name (backend, (const gchar *)id_parts[PK_PACKAGE_ID_NAME], zypp::ResKind::package); - v2 = zypp_get_packages_by_name (backend, (const gchar *)id_parts[PK_PACKAGE_ID_NAME], zypp::ResKind::srcpackage); + vector<sat::Solvable> v; + vector<sat::Solvable> v2; + zypp_get_packages_by_name (backend, (const gchar *)id_parts[PK_PACKAGE_ID_NAME], ResKind::package, v); + zypp_get_packages_by_name (backend, (const gchar *)id_parts[PK_PACKAGE_ID_NAME], ResKind::srcpackage, v2); - v->insert (v->end (), v2->begin (), v2->end ()); + v.insert (v.end (), v2.begin (), v2.end ()); - zypp::sat::Solvable package; - for (std::vector<zypp::sat::Solvable>::iterator it = v->begin (); - it != v->end (); it++) { + sat::Solvable package; + for (vector<sat::Solvable>::iterator it = v.begin (); + it != v.end (); it++) { char *version = g_strdup (it->edition ().asString ().c_str ()); if (strcmp (id_parts[PK_PACKAGE_ID_VERSION], version) == 0) { g_free (version); @@ -1684,9 +1684,6 @@ backend_get_files_thread (PkBackend *backend) } g_free (version); } - - delete (v); - delete (v2); g_strfreev (id_parts); if (package == NULL) { @@ -1695,18 +1692,18 @@ backend_get_files_thread (PkBackend *backend) "couldn't find package"); } - std::string temp; + string temp; if (package.isSystem ()){ try { - zypp::target::rpm::RpmHeader::constPtr rpmHeader = zypp_get_rpmHeader (package.name (), package.edition ()); - std::list<std::string> files = rpmHeader->tag_filenames (); + target::rpm::RpmHeader::constPtr rpmHeader = zypp_get_rpmHeader (package.name (), package.edition ()); + list<string> files = rpmHeader->tag_filenames (); - for (std::list<std::string>::iterator it = files.begin (); it != files.end (); it++) { + for (list<string>::iterator it = files.begin (); it != files.end (); it++) { temp.append (*it); temp.append (";"); } - } catch (const zypp::target::rpm::RpmException &ex) { + } catch (const target::rpm::RpmException &ex) { return zypp_backend_finished_error ( backend, PK_ERROR_ENUM_REPO_NOT_FOUND, "Couldn't open rpm-database"); @@ -1734,7 +1731,7 @@ pk_backend_get_files(PkBackend *backend, gchar **package_ids) static gboolean backend_get_packages_thread (PkBackend *backend) { - zypp::ZYpp::Ptr zypp; + ZYpp::Ptr zypp; zypp = get_zypp (backend); if (zypp == NULL){ @@ -1743,11 +1740,11 @@ backend_get_packages_thread (PkBackend *backend) } pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); - std::vector<zypp::sat::Solvable> v; + vector<sat::Solvable> v; zypp_build_pool (backend, TRUE); - zypp::ResPool pool = zypp::ResPool::instance (); - for (zypp::ResPool::byKind_iterator it = pool.byKindBegin (zypp::ResKind::package); it != pool.byKindEnd (zypp::ResKind::package); it++) { + ResPool pool = ResPool::instance (); + for (ResPool::byKind_iterator it = pool.byKindBegin (ResKind::package); it != pool.byKindEnd (ResKind::package); it++) { v.push_back (it->satSolvable ()); } @@ -1770,25 +1767,25 @@ backend_update_packages_thread (PkBackend *backend) { gboolean retval; gchar **package_ids; - zypp::ZYpp::Ptr zypp; + ZYpp::Ptr zypp; zypp = get_zypp (backend); if (zypp == NULL){ pk_backend_finished (backend); return FALSE; } - zypp::ResPool pool = zypp_build_pool (backend, TRUE); + ResPool pool = zypp_build_pool (backend, TRUE); /* FIXME: support only_trusted */ package_ids = pk_backend_get_strv (backend, "package_ids"); PkRestartEnum restart = PK_RESTART_ENUM_NONE; for (guint i = 0; package_ids[i]; i++) { gchar **id_parts = pk_package_id_split (package_ids[i]); - std::string name = id_parts[PK_PACKAGE_ID_NAME]; + string name = id_parts[PK_PACKAGE_ID_NAME]; // Do we have already the latest version. gboolean system = false; - for (zypp::ResPool::byName_iterator it = pool.byNameBegin (name); + for (ResPool::byName_iterator it = pool.byNameBegin (name); it != pool.byNameEnd (name); it++) { if (!it->satSolvable().isSystem()) continue; @@ -1800,10 +1797,10 @@ backend_update_packages_thread (PkBackend *backend) } if (system == true) continue; - zypp::sat::Solvable solvable = zypp_get_package_by_id (backend, package_ids[i]); - zypp::PoolItem item = zypp::ResPool::instance ().find (solvable); - item.status ().setToBeInstalled (zypp::ResStatus::USER); - zypp::Patch::constPtr patch = zypp::asKind<zypp::Patch>(item.resolvable ()); + sat::Solvable solvable = zypp_get_package_by_id (backend, package_ids[i]); + PoolItem item = ResPool::instance ().find (solvable); + item.status ().setToBeInstalled (ResStatus::USER); + Patch::constPtr patch = asKind<Patch>(item.resolvable ()); zypp_check_restart (&restart, patch); if (restart != PK_RESTART_ENUM_NONE){ pk_backend_require_restart (backend, restart, package_ids[i]); @@ -1841,7 +1838,7 @@ backend_repo_set_data_thread (PkBackend *backend) const gchar *repo_id; const gchar *parameter; const gchar *value; - zypp::ZYpp::Ptr zypp; + ZYpp::Ptr zypp; zypp = get_zypp (backend); if (zypp == NULL){ @@ -1854,8 +1851,8 @@ backend_repo_set_data_thread (PkBackend *backend) value = pk_backend_get_string (backend, "value"); pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); - zypp::RepoManager manager; - zypp::RepoInfo repo; + RepoManager manager; + RepoInfo repo; gboolean bReturn = TRUE; @@ -1871,7 +1868,7 @@ backend_repo_set_data_thread (PkBackend *backend) // add a new repo if (g_ascii_strcasecmp (parameter, "add") == 0) { repo.setAlias (repo_id); - repo.setBaseUrl (zypp::Url(value)); + repo.setBaseUrl (Url(value)); repo.setAutorefresh (TRUE); repo.setEnabled (TRUE); @@ -1906,7 +1903,7 @@ backend_repo_set_data_thread (PkBackend *backend) manager.modifyRepository (repo_id, repo); } else if (g_ascii_strcasecmp (parameter, "url") == 0) { - repo.setBaseUrl (zypp::Url(value)); + repo.setBaseUrl (Url(value)); manager.modifyRepository (repo_id, repo); } else if (g_ascii_strcasecmp (parameter, "name") == 0) { repo.setName(value); @@ -1947,19 +1944,19 @@ backend_repo_set_data_thread (PkBackend *backend) bReturn = FALSE; } - } catch (const zypp::repo::RepoNotFoundException &ex) { + } catch (const repo::RepoNotFoundException &ex) { pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, "Couldn't find the specified repository"); bReturn = FALSE; - } catch (const zypp::repo::RepoAlreadyExistsException &ex) { + } catch (const repo::RepoAlreadyExistsException &ex) { pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "This repo already exists"); bReturn = FALSE; - } catch (const zypp::repo::RepoUnknownTypeException &ex) { + } catch (const repo::RepoUnknownTypeException &ex) { pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Type of the repo can't be determined"); bReturn = FALSE; - } catch (const zypp::repo::RepoException &ex) { + } catch (const repo::RepoException &ex) { pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Can't access the given URL"); bReturn = FALSE; - } catch (const zypp::Exception &ex) { + } catch (const Exception &ex) { pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asString ().c_str ()); bReturn = FALSE; } @@ -1980,7 +1977,7 @@ pk_backend_repo_set_data (PkBackend *backend, const gchar *repo_id, const gchar static gboolean backend_what_provides_thread (PkBackend *backend) { - zypp::ZYpp::Ptr zypp; + ZYpp::Ptr zypp; zypp = get_zypp (backend); if (zypp == NULL){ @@ -1992,16 +1989,16 @@ backend_what_provides_thread (PkBackend *backend) const gchar *search = values[0]; //Fixme - support possible multiple search values (logical OR) PkProvidesEnum provides = (PkProvidesEnum) pk_backend_get_uint (backend, "provides"); PkBitfield _filters = (PkBitfield) pk_backend_get_uint (backend, "filters"); - zypp::ResPool pool = zypp_build_pool (backend, true); + ResPool pool = zypp_build_pool (backend, true); if((provides == PK_PROVIDES_ENUM_HARDWARE_DRIVER) || g_ascii_strcasecmp("drivers_for_attached_hardware", search) == 0) { // solver run - zypp::Resolver solver(pool); + Resolver solver(pool); solver.setIgnoreAlreadyRecommended (TRUE); if (!solver.resolvePool ()) { - std::list<zypp::ResolverProblem_Ptr> problems = solver.problems (); - for (std::list<zypp::ResolverProblem_Ptr>::iterator it = problems.begin (); it != problems.end (); it++){ + list<ResolverProblem_Ptr> problems = solver.problems (); + for (list<ResolverProblem_Ptr>::iterator it = problems.begin (); it != problems.end (); it++){ g_warning("Solver problem (This should never happen): '%s'", (*it)->description ().c_str ()); } solver.setIgnoreAlreadyRecommended (FALSE); @@ -2010,8 +2007,8 @@ backend_what_provides_thread (PkBackend *backend) } // look for packages which would be installed - for (zypp::ResPool::byKind_iterator it = pool.byKindBegin (zypp::ResKind::package); - it != pool.byKindEnd (zypp::ResKind::package); it++) { + for (ResPool::byKind_iterator it = pool.byKindBegin (ResKind::package); + it != pool.byKindEnd (ResKind::package); it++) { PkInfoEnum status = PK_INFO_ENUM_UNKNOWN; gboolean hit = FALSE; @@ -2029,15 +2026,15 @@ backend_what_provides_thread (PkBackend *backend) } solver.setIgnoreAlreadyRecommended (FALSE); } else { - zypp::Capability cap (search); - zypp::sat::WhatProvides prov (cap); + Capability cap (search); + sat::WhatProvides prov (cap); - for (zypp::sat::WhatProvides::const_iterator it = prov.begin (); it != prov.end (); it++) { + for (sat::WhatProvides::const_iterator it = prov.begin (); it != prov.end (); it++) { if (zypp_filter_solvable (_filters, *it)) continue; PkInfoEnum info = it->isSystem () ? PK_INFO_ENUM_INSTALLED : PK_INFO_ENUM_AVAILABLE; - zypp_backend_package (backend, info, *it, it->lookupStrAttribute (zypp::sat::SolvAttr::summary).c_str ()); + zypp_backend_package (backend, info, *it, it->lookupStrAttribute (sat::SolvAttr::summary).c_str ()); } } @@ -2065,13 +2062,13 @@ backend_download_packages_thread (PkBackend *backend) { gchar **package_ids; gulong size = 0; - + if (!zypp_refresh_cache (backend, FALSE)) { pk_backend_finished (backend); return FALSE; } - zypp::ZYpp::Ptr zypp; + ZYpp::Ptr zypp; zypp = get_zypp (backend); if (zypp == NULL){ pk_backend_finished (backend); @@ -2083,21 +2080,21 @@ backend_download_packages_thread (PkBackend *backend) return zypp_backend_finished_error ( backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id"); } - + try { - zypp::ResPool pool = zypp_build_pool (backend, FALSE); - zypp::PoolItem item; + ResPool pool = zypp_build_pool (backend, FALSE); + PoolItem item; pk_backend_set_status (backend, PK_STATUS_ENUM_DOWNLOAD); for (guint i = 0; package_ids[i]; i++) { gchar **id_parts = pk_package_id_split (package_ids[i]); - std::string name = id_parts[PK_PACKAGE_ID_NAME]; + string name = id_parts[PK_PACKAGE_ID_NAME]; - for (zypp::ResPool::byName_iterator it = pool.byNameBegin (name); it != pool.byNameEnd (name); it++) { + for (ResPool::byName_iterator it = pool.byNameBegin (name); it != pool.byNameEnd (name); it++) { if (zypp_ver_and_arch_equal (it->satSolvable(), id_parts[PK_PACKAGE_ID_VERSION], id_parts[PK_PACKAGE_ID_ARCH])) { - size += 2 * it->satSolvable().lookupNumAttribute (zypp::sat::SolvAttr::downloadsize); + size += 2 * it->satSolvable().lookupNumAttribute (sat::SolvAttr::downloadsize); item = *it; break; } @@ -2113,19 +2110,19 @@ backend_download_packages_thread (PkBackend *backend) return FALSE; } - zypp::sat::Solvable solvable = item.resolvable()->satSolvable(); - zypp::filesystem::Pathname tmp_file; - zypp::repo::RepoMediaAccess access; - zypp::repo::DeltaCandidates deltas; + sat::Solvable solvable = item.resolvable()->satSolvable(); + filesystem::Pathname tmp_file; + repo::RepoMediaAccess access; + repo::DeltaCandidates deltas; if (strcmp (id_parts[PK_PACKAGE_ID_ARCH], "source") == 0) { - zypp::SrcPackage::constPtr package = zypp::asKind<zypp::SrcPackage>(item.resolvable()); - zypp::repo::SrcPackageProvider pkgProvider(access); + SrcPackage::constPtr package = asKind<SrcPackage>(item.resolvable()); + repo::SrcPackageProvider pkgProvider(access); pkgProvider.provideSrcPackage(package); tmp_file = solvable.repository().info().packagesPath()+ package->location().filename(); - + } else { - zypp::Package::constPtr package = zypp::asKind<zypp::Package>(item.resolvable()); - zypp::repo::PackageProvider pkgProvider(access, package, deltas); + Package::constPtr package = asKind<Package>(item.resolvable()); + repo::PackageProvider pkgProvider(access, package, deltas); pkgProvider.providePackage(); tmp_file = solvable.repository().info().packagesPath()+ package->location().filename(); } @@ -2134,7 +2131,7 @@ backend_download_packages_thread (PkBackend *backend) g_strfreev (id_parts); } - } catch (const zypp::Exception &ex) { + } catch (const Exception &ex) { return zypp_backend_finished_error ( backend, PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED, ex.asUserString().c_str()); } @@ -2158,9 +2155,19 @@ pk_backend_download_packages (PkBackend *backend, gchar **package_ids, const gch void pk_backend_transaction_start (PkBackend *backend) { + gchar *locale; gchar *proxy_http; + gchar *proxy_https; gchar *proxy_ftp; gchar *uri; + gchar *proxy_socks; + gchar *no_proxy; + gchar *pac; + + locale = pk_backend_get_locale(backend); + if (!egg_strzero (locale)) { + setlocale(LC_ALL, locale); + } /* http_proxy */ proxy_http = pk_backend_get_proxy_http (backend); @@ -2170,6 +2177,14 @@ pk_backend_transaction_start (PkBackend *backend) g_free (uri); } + /* https_proxy */ + proxy_https = pk_backend_get_proxy_https (backend); + if (!egg_strzero (proxy_https)) { + uri = pk_backend_spawn_convert_uri (proxy_https); + g_setenv ("https_proxy", uri, TRUE); + g_free (uri); + } + /* ftp_proxy */ proxy_ftp = pk_backend_get_proxy_ftp (backend); if (!egg_strzero (proxy_ftp)) { @@ -2178,8 +2193,35 @@ pk_backend_transaction_start (PkBackend *backend) g_free (uri); } + /* socks_proxy */ + proxy_socks = pk_backend_get_proxy_socks (backend); + if (!egg_strzero (proxy_socks)) { + uri = pk_backend_spawn_convert_uri (proxy_socks); + g_setenv ("socks_proxy", uri, TRUE); + g_free (uri); + } + + /* no_proxy */ + no_proxy = pk_backend_get_no_proxy (backend); + if (!egg_strzero (no_proxy)) { + g_setenv ("no_proxy", no_proxy, TRUE); + } + + /* pac */ + pac = pk_backend_get_pac (backend); + if (!egg_strzero (pac)) { + uri = pk_backend_spawn_convert_uri (pac); + g_setenv ("pac", uri, TRUE); + g_free (uri); + } + + g_free (locale); g_free (proxy_http); + g_free (proxy_https); g_free (proxy_ftp); + g_free (proxy_socks); + g_free (no_proxy); + g_free (pac); } /** @@ -2191,6 +2233,10 @@ pk_backend_transaction_stop (PkBackend *backend) /* unset proxy info for this transaction */ g_unsetenv ("http_proxy"); g_unsetenv ("ftp_proxy"); + g_unsetenv ("https_proxy"); + g_unsetenv ("no_proxy"); + g_unsetenv ("socks_proxy"); + g_unsetenv ("pac"); } diff --git a/backends/zypp/zypp-events.h b/backends/zypp/zypp-events.h index cd8f4f35d..5877f8dd3 100644 --- a/backends/zypp/zypp-events.h +++ b/backends/zypp/zypp-events.h @@ -30,7 +30,7 @@ #include <pk-backend.h> #include <zypp/ZYppCallbacks.h> #include <zypp/Digest.h> -#include <zypp/KeyRing.h> +#include <zypp/KeyRing.h> #include "zypp-utils.h" @@ -163,6 +163,12 @@ struct ZyppBackendReceiver pk_backend_set_sub_percentage (_backend, _sub_percentage); } + inline void + update_speed (guint speed) + { + pk_backend_set_speed (_backend, speed); + } + void reset_sub_percentage () { @@ -310,8 +316,10 @@ struct DownloadProgressReportReceiver : public zypp::callback::ReceiveReport<zyp virtual bool progress (int value, const zypp::Url &file, double dbps_avg, double dbps_current) { //fprintf (stderr, "\n\n----> DownloadProgressReportReceiver::progress(), %s:%d\n\n", _package_id == NULL ? "unknown" : _package_id, value); - if (_package_id != NULL) + if (_package_id != NULL) { update_sub_percentage (value); + update_speed (static_cast<guint>(dbps_current)); + } return true; } diff --git a/backends/zypp/zypp-utils.cpp b/backends/zypp/zypp-utils.cpp index 91fd6feb5..68d59da86 100644 --- a/backends/zypp/zypp-utils.cpp +++ b/backends/zypp/zypp-utils.cpp @@ -64,33 +64,34 @@ gchar * _repoName; gboolean _updating_self = FALSE; +using namespace std; +using namespace zypp; using zypp::filesystem::PathInfo; -using zypp::InputStream; /** * Initialize Zypp (Factory method) */ -zypp::ZYpp::Ptr +ZYpp::Ptr get_zypp (PkBackend *backend) { static gboolean initialized = FALSE; - zypp::ZYpp::Ptr zypp = NULL; + ZYpp::Ptr zypp = NULL; try { - zypp = zypp::ZYppFactory::instance ().getZYpp (); + zypp = ZYppFactory::instance ().getZYpp (); /* TODO: we need to lifecycle manage this, detect changes in the requested 'root' etc. */ if (!initialized) { - zypp::filesystem::Pathname pathname(pk_backend_get_root (backend)); + filesystem::Pathname pathname(pk_backend_get_root (backend)); zypp->initializeTarget (pathname); initialized = TRUE; } - } catch (const zypp::ZYppFactoryException &ex) { + } catch (const ZYppFactoryException &ex) { pk_backend_error_code (backend, PK_ERROR_ENUM_FAILED_INITIALIZATION, ex.asUserString().c_str() ); return NULL; - } catch (const zypp::Exception &ex) { + } catch (const Exception &ex) { pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString().c_str() ); return NULL; } @@ -118,7 +119,7 @@ zypp_logging () } } - zypp::base::LogControl::instance ().logfile(file); + base::LogControl::instance ().logfile(file); g_free (file); g_free (file_old); @@ -127,15 +128,15 @@ zypp_logging () } gboolean -zypp_is_changeable_media (PkBackend *backend, const zypp::Url &url) +zypp_is_changeable_media (PkBackend *backend, const Url &url) { gboolean is_cd = false; try { - zypp::media::MediaManager mm; - zypp::media::MediaAccessId id = mm.open (url); + media::MediaManager mm; + media::MediaAccessId id = mm.open (url); is_cd = mm.isChangeable (id); mm.close (id); - } catch (const zypp::media::MediaException &e) { + } catch (const media::MediaException &e) { // TODO: Do anything about this? } @@ -143,14 +144,14 @@ zypp_is_changeable_media (PkBackend *backend, const zypp::Url &url) } gboolean -zypp_is_development_repo (PkBackend *backend, zypp::RepoInfo repo) +zypp_is_development_repo (PkBackend *backend, RepoInfo repo) { - std::string repo_debuginfo("-debuginfo"); - std::string repo_debug("-debug"); - std::string repo_development("-development"); - std::string repo_source ("-source"); + string repo_debuginfo("-debuginfo"); + string repo_debug("-debug"); + string repo_development("-development"); + string repo_source ("-source"); - std::string repo_name(repo.name()); + string repo_name(repo.name()); if (repo_name.length() > repo_debuginfo.length() && repo_name.compare(repo_name.length() - repo_debuginfo.length(), repo_debuginfo.length(), repo_debuginfo) == 0) @@ -172,7 +173,7 @@ zypp_is_development_repo (PkBackend *backend, zypp::RepoInfo repo) } gboolean -zypp_is_valid_repo (PkBackend *backend, zypp::RepoInfo repo) +zypp_is_valid_repo (PkBackend *backend, RepoInfo repo) { if (repo.alias().empty()){ @@ -184,39 +185,39 @@ zypp_is_valid_repo (PkBackend *backend, zypp::RepoInfo repo) pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_CONFIGURATION_ERROR, "%s: Repository has no or invalid url defined.\n", repo.alias ().c_str ()); return FALSE; } - + return TRUE; } -zypp::ResPool +ResPool zypp_build_pool (PkBackend *backend, gboolean include_local) { - zypp::ZYpp::Ptr zypp = get_zypp (backend); + ZYpp::Ptr zypp = get_zypp (backend); if (include_local) { // FIXME have to wait for fix in zypp (repeated loading of target) - if (zypp::sat::Pool::instance().reposFind( zypp::sat::Pool::systemRepoAlias() ).solvablesEmpty ()) + if (sat::Pool::instance().reposFind( sat::Pool::systemRepoAlias() ).solvablesEmpty ()) { // Add local resolvables - zypp::Target_Ptr target = zypp->target (); + Target_Ptr target = zypp->target (); target->load (); } } else { - if (!zypp::sat::Pool::instance().reposFind( zypp::sat::Pool::systemRepoAlias() ).solvablesEmpty ()) + if (!sat::Pool::instance().reposFind( sat::Pool::systemRepoAlias() ).solvablesEmpty ()) { // Remove local resolvables - zypp::Repository repository = zypp::sat::Pool::instance ().reposFind (zypp::sat::Pool::systemRepoAlias()); + Repository repository = sat::Pool::instance ().reposFind (sat::Pool::systemRepoAlias()); repository.eraseFromPool (); } } // Add resolvables from enabled repos - zypp::RepoManager manager; - std::list<zypp::RepoInfo> repos; + RepoManager manager; + list<RepoInfo> repos; try { - repos = std::list<zypp::RepoInfo>(manager.repoBegin(),manager.repoEnd()); - for (std::list<zypp::RepoInfo>::iterator it = repos.begin(); it != repos.end (); it++) { - zypp::RepoInfo repo (*it); + repos = list<RepoInfo>(manager.repoBegin(),manager.repoEnd()); + for (list<RepoInfo>::iterator it = repos.begin(); it != repos.end (); it++) { + RepoInfo repo (*it); // skip disabled repos if (repo.enabled () == false) @@ -227,14 +228,14 @@ zypp_build_pool (PkBackend *backend, gboolean include_local) continue; } //FIXME see above, skip already cached repos - if (zypp::sat::Pool::instance().reposFind( repo.alias ()) == zypp::Repository::noRepository) + if (sat::Pool::instance().reposFind( repo.alias ()) == Repository::noRepository) manager.loadFromCache (repo); } - } catch (const zypp::repo::RepoNoAliasException &ex) { + } catch (const repo::RepoNoAliasException &ex) { g_error ("Can't figure an alias to look in cache"); - } catch (const zypp::repo::RepoNotCachedException &ex) { + } catch (const repo::RepoNotCachedException &ex) { g_error ("The repo has to be cached at first: %s", ex.asUserString ().c_str ()); - } catch (const zypp::Exception &ex) { + } catch (const Exception &ex) { g_error ("TODO: Handle exceptions: %s", ex.asUserString ().c_str ()); } @@ -242,31 +243,31 @@ zypp_build_pool (PkBackend *backend, gboolean include_local) } void -warn_outdated_repos(PkBackend *backend, const zypp::ResPool & pool) +warn_outdated_repos(PkBackend *backend, const ResPool & pool) { - zypp::Repository repoobj; - zypp::ResPool::repository_iterator it; + Repository repoobj; + ResPool::repository_iterator it; for ( it = pool.knownRepositoriesBegin(); it != pool.knownRepositoriesEnd(); ++it ) { - zypp::Repository repo(*it); + Repository repo(*it); if ( repo.maybeOutdated() ) { // warn the user pk_backend_message (backend, PK_MESSAGE_ENUM_BROKEN_MIRROR, - zypp::str::form("The repository %s seems to be outdated. You may want to try another mirror.", + str::form("The repository %s seems to be outdated. You may want to try another mirror.", repo.alias().c_str()).c_str() ); } } } -zypp::target::rpm::RpmHeader::constPtr -zypp_get_rpmHeader (std::string name, zypp::Edition edition) +target::rpm::RpmHeader::constPtr +zypp_get_rpmHeader (const string &name, Edition edition) { - zypp::target::rpm::librpmDb::db_const_iterator it; - zypp::target::rpm::RpmHeader::constPtr result = new zypp::target::rpm::RpmHeader (); + target::rpm::librpmDb::db_const_iterator it; + target::rpm::RpmHeader::constPtr result = new target::rpm::RpmHeader (); for (it.findPackage (name, edition); *it; ++it) { result = *it; @@ -276,145 +277,142 @@ zypp_get_rpmHeader (std::string name, zypp::Edition edition) } -std::string -zypp_get_group (zypp::sat::Solvable item) +string +zypp_get_group (sat::Solvable item) { - std::string group; + string group; if (item.isSystem ()) { - zypp::target::rpm::RpmHeader::constPtr rpmHeader = zypp_get_rpmHeader (item.name (), item.edition ()); + target::rpm::RpmHeader::constPtr rpmHeader = zypp_get_rpmHeader (item.name (), item.edition ()); group = rpmHeader->tag_group (); } else { - group = item.lookupStrAttribute (zypp::sat::SolvAttr::group); + group = item.lookupStrAttribute (sat::SolvAttr::group); } - std::transform(group.begin(), group.end(), group.begin(), tolower); - return group; + return str::toLower(group); } PkGroupEnum -get_enum_group (std::string group) +get_enum_group (const string &group_) { + string group(str::toLower(group_)); - // TODO Look for a faster and nice way to do this conversion - std::transform(group.begin(), group.end(), group.begin(), tolower); - - if (group.find ("amusements") != std::string::npos) { + if (group.find ("amusements") != string::npos) { return PK_GROUP_ENUM_GAMES; - } else if (group.find ("development") != std::string::npos) { + } else if (group.find ("development") != string::npos) { return PK_GROUP_ENUM_PROGRAMMING; - } else if (group.find ("hardware") != std::string::npos) { + } else if (group.find ("hardware") != string::npos) { return PK_GROUP_ENUM_SYSTEM; - } else if (group.find ("archiving") != std::string::npos - || group.find("clustering") != std::string::npos - || group.find("system/monitoring") != std::string::npos - || group.find("databases") != std::string::npos - || group.find("system/management") != std::string::npos) { + } else if (group.find ("archiving") != string::npos + || group.find("clustering") != string::npos + || group.find("system/monitoring") != string::npos + || group.find("databases") != string::npos + || group.find("system/management") != string::npos) { return PK_GROUP_ENUM_ADMIN_TOOLS; - } else if (group.find ("graphics") != std::string::npos) { + } else if (group.find ("graphics") != string::npos) { return PK_GROUP_ENUM_GRAPHICS; - } else if (group.find ("multimedia") != std::string::npos) { + } else if (group.find ("multimedia") != string::npos) { return PK_GROUP_ENUM_MULTIMEDIA; - } else if (group.find ("network") != std::string::npos) { + } else if (group.find ("network") != string::npos) { return PK_GROUP_ENUM_NETWORK; - } else if (group.find ("office") != std::string::npos - || group.find("text") != std::string::npos - || group.find("editors") != std::string::npos) { + } else if (group.find ("office") != string::npos + || group.find("text") != string::npos + || group.find("editors") != string::npos) { return PK_GROUP_ENUM_OFFICE; - } else if (group.find ("publishing") != std::string::npos) { + } else if (group.find ("publishing") != string::npos) { return PK_GROUP_ENUM_PUBLISHING; - } else if (group.find ("security") != std::string::npos) { + } else if (group.find ("security") != string::npos) { return PK_GROUP_ENUM_SECURITY; - } else if (group.find ("telephony") != std::string::npos) { + } else if (group.find ("telephony") != string::npos) { return PK_GROUP_ENUM_COMMUNICATION; - } else if (group.find ("gnome") != std::string::npos) { + } else if (group.find ("gnome") != string::npos) { return PK_GROUP_ENUM_DESKTOP_GNOME; - } else if (group.find ("kde") != std::string::npos) { + } else if (group.find ("kde") != string::npos) { return PK_GROUP_ENUM_DESKTOP_KDE; - } else if (group.find ("xfce") != std::string::npos) { + } else if (group.find ("xfce") != string::npos) { return PK_GROUP_ENUM_DESKTOP_XFCE; - } else if (group.find ("gui/other") != std::string::npos) { + } else if (group.find ("gui/other") != string::npos) { return PK_GROUP_ENUM_DESKTOP_OTHER; - } else if (group.find ("localization") != std::string::npos) { + } else if (group.find ("localization") != string::npos) { return PK_GROUP_ENUM_LOCALIZATION; - } else if (group.find ("system") != std::string::npos) { + } else if (group.find ("system") != string::npos) { return PK_GROUP_ENUM_SYSTEM; - } else if (group.find ("scientific") != std::string::npos) { + } else if (group.find ("scientific") != string::npos) { return PK_GROUP_ENUM_EDUCATION; } return PK_GROUP_ENUM_UNKNOWN; } -std::vector<zypp::sat::Solvable> * -zypp_get_packages_by_name (PkBackend *backend, const gchar *package_name, - const zypp::ResKind kind, gboolean include_local) +void +zypp_get_packages_by_name (PkBackend *backend, + const gchar *package_name, + const ResKind kind, + vector<sat::Solvable> &result, + gboolean include_local) { - std::vector<zypp::sat::Solvable> *v = new std::vector<zypp::sat::Solvable> (); + ResPool pool = zypp_build_pool (backend, include_local); - zypp::ResPool pool = zypp_build_pool (backend, include_local); - - for (zypp::ResPool::byIdent_iterator it = pool.byIdentBegin (kind, package_name); + for (ResPool::byIdent_iterator it = pool.byIdentBegin (kind, package_name); it != pool.byIdentEnd (kind, package_name); it++) { - v->push_back (it->satSolvable ()); + result.push_back (it->satSolvable ()); } - - return v; } -std::vector<zypp::sat::Solvable> * -zypp_get_packages_by_file (PkBackend *backend, const gchar *search_file) +void +zypp_get_packages_by_file (PkBackend *backend, + const gchar *search_file, + vector<sat::Solvable> &ret) { - std::vector<zypp::sat::Solvable> *v = new std::vector<zypp::sat::Solvable> (); + ResPool pool = zypp_build_pool (backend, TRUE); - zypp::ResPool pool = zypp_build_pool (backend, TRUE); + string file (search_file); - std::string file (search_file); - - zypp::target::rpm::librpmDb::db_const_iterator it; - zypp::target::rpm::RpmHeader::constPtr result = new zypp::target::rpm::RpmHeader (); + target::rpm::librpmDb::db_const_iterator it; + target::rpm::RpmHeader::constPtr result = new target::rpm::RpmHeader (); for (it.findByFile (search_file); *it; ++it) { - for (zypp::ResPool::byName_iterator it2 = pool.byNameBegin (it->tag_name ()); it2 != pool.byNameEnd (it->tag_name ()); it2++) { + for (ResPool::byName_iterator it2 = pool.byNameBegin (it->tag_name ()); it2 != pool.byNameEnd (it->tag_name ()); it2++) { if ((*it2)->isSystem ()) - v->push_back ((*it2)->satSolvable ()); + ret.push_back ((*it2)->satSolvable ()); } } - if (v->empty ()) { - zypp::Capability cap (search_file); - zypp::sat::WhatProvides prov (cap); + if (ret.empty ()) { + Capability cap (search_file); + sat::WhatProvides prov (cap); - for(zypp::sat::WhatProvides::const_iterator it = prov.begin (); it != prov.end (); it++) { - v->push_back (*it); + for(sat::WhatProvides::const_iterator it = prov.begin (); it != prov.end (); it++) { + ret.push_back (*it); } } - - return v; } -zypp::sat::Solvable +sat::Solvable zypp_get_package_by_id (PkBackend *backend, const gchar *package_id) { if (!pk_package_id_check(package_id)) { // TODO: Do we need to do something more for this error? - return zypp::sat::Solvable::noSolvable; + return sat::Solvable::noSolvable; } gchar **id_parts = pk_package_id_split(package_id); - std::vector<zypp::sat::Solvable> *v = zypp_get_packages_by_name (backend, id_parts[PK_PACKAGE_ID_NAME], zypp::ResKind::package); - std::vector<zypp::sat::Solvable> *v2 = zypp_get_packages_by_name (backend, id_parts[PK_PACKAGE_ID_NAME], zypp::ResKind::patch); + vector<sat::Solvable> v; + vector<sat::Solvable> v2; + + zypp_get_packages_by_name (backend, id_parts[PK_PACKAGE_ID_NAME], ResKind::package, v); + zypp_get_packages_by_name (backend, id_parts[PK_PACKAGE_ID_NAME], ResKind::patch, v2); - v->insert (v->end (), v2->begin (), v2->end ()); + v.insert (v.end (), v2.begin (), v2.end ()); - if (v == NULL) - return zypp::sat::Solvable::noSolvable; + if (v.empty()) + return sat::Solvable::noSolvable; - zypp::sat::Solvable package; + sat::Solvable package; - for (std::vector<zypp::sat::Solvable>::iterator it = v->begin (); - it != v->end (); it++) { + for (vector<sat::Solvable>::iterator it = v.begin (); + it != v.end (); it++) { if (zypp_ver_and_arch_equal (*it, id_parts[PK_PACKAGE_ID_VERSION], id_parts[PK_PACKAGE_ID_ARCH])) { package = *it; @@ -422,23 +420,21 @@ zypp_get_package_by_id (PkBackend *backend, const gchar *package_id) } } - delete (v); - delete (v2); g_strfreev (id_parts); return package; } -zypp::RepoInfo +RepoInfo zypp_get_Repository (PkBackend *backend, const gchar *alias) { - zypp::RepoInfo info; + RepoInfo info; try { - zypp::RepoManager manager; + RepoManager manager; info = manager.getRepositoryInfo (alias); - } catch (const zypp::repo::RepoNotFoundException &ex) { + } catch (const repo::RepoNotFoundException &ex) { pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, ex.asUserString().c_str() ); - return zypp::RepoInfo (); + return RepoInfo (); } return info; @@ -464,23 +460,23 @@ class AbortTransactionException { }; gboolean -zypp_refresh_meta_and_cache (zypp::RepoManager &manager, zypp::RepoInfo &repo, bool force) +zypp_refresh_meta_and_cache (RepoManager &manager, RepoInfo &repo, bool force) { try { if (manager.checkIfToRefreshMetadata (repo, repo.url(), - zypp::RepoManager::RefreshIfNeededIgnoreDelay) - != zypp::RepoManager::REFRESH_NEEDED) + RepoManager::RefreshIfNeededIgnoreDelay) + != RepoManager::REFRESH_NEEDED) return TRUE; - zypp::sat::Pool pool = zypp::sat::Pool::instance (); + sat::Pool pool = sat::Pool::instance (); // Erase old solv file pool.reposErase (repo.alias ()); manager.refreshMetadata (repo, force ? - zypp::RepoManager::RefreshForced : - zypp::RepoManager::RefreshIfNeededIgnoreDelay); + RepoManager::RefreshForced : + RepoManager::RefreshIfNeededIgnoreDelay); manager.buildCache (repo, force ? - zypp::RepoManager::BuildForced : - zypp::RepoManager::BuildIfNeeded); + RepoManager::BuildForced : + RepoManager::BuildIfNeeded); manager.loadFromCache (repo); return TRUE; } catch (const AbortTransactionException &ex) { @@ -489,13 +485,13 @@ zypp_refresh_meta_and_cache (zypp::RepoManager &manager, zypp::RepoInfo &repo, b } gboolean -zypp_signature_required (PkBackend *backend, const zypp::PublicKey &key) +zypp_signature_required (PkBackend *backend, const PublicKey &key) { gboolean ok = FALSE; - if (std::find (_signatures[backend]->begin (), _signatures[backend]->end (), key.id ()) == _signatures[backend]->end ()) { - zypp::RepoInfo info = zypp_get_Repository (backend, _repoName); - if (info.type () == zypp::repo::RepoType::NONE) + if (find (_signatures[backend]->begin (), _signatures[backend]->end (), key.id ()) == _signatures[backend]->end ()) { + RepoInfo info = zypp_get_Repository (backend, _repoName); + if (info.type () == repo::RepoType::NONE) pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Repository unknown"); else { @@ -519,13 +515,13 @@ zypp_signature_required (PkBackend *backend, const zypp::PublicKey &key) } gboolean -zypp_signature_required (PkBackend *backend, const std::string &file, const std::string &id) +zypp_signature_required (PkBackend *backend, const string &file, const string &id) { gboolean ok = FALSE; - if (std::find (_signatures[backend]->begin (), _signatures[backend]->end (), id) == _signatures[backend]->end ()) { - zypp::RepoInfo info = zypp_get_Repository (backend, _repoName); - if (info.type () == zypp::repo::RepoType::NONE) + if (find (_signatures[backend]->begin (), _signatures[backend]->end (), id) == _signatures[backend]->end ()) { + RepoInfo info = zypp_get_Repository (backend, _repoName); + if (info.type () == repo::RepoType::NONE) pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Repository unknown"); else { @@ -549,13 +545,13 @@ zypp_signature_required (PkBackend *backend, const std::string &file, const std: } gboolean -zypp_signature_required (PkBackend *backend, const std::string &file) +zypp_signature_required (PkBackend *backend, const string &file) { gboolean ok = FALSE; - if (std::find (_signatures[backend]->begin (), _signatures[backend]->end (), file) == _signatures[backend]->end ()) { - zypp::RepoInfo info = zypp_get_Repository (backend, _repoName); - if (info.type () == zypp::repo::RepoType::NONE) + if (find (_signatures[backend]->begin (), _signatures[backend]->end (), file) == _signatures[backend]->end ()) { + RepoInfo info = zypp_get_Repository (backend, _repoName); + if (info.type () == repo::RepoType::NONE) pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Repository unknown"); else { @@ -579,17 +575,17 @@ zypp_signature_required (PkBackend *backend, const std::string &file) } gboolean -system_and_package_are_x86 (zypp::sat::Solvable item) +system_and_package_are_x86 (sat::Solvable item) { // i586, i686, ... all should be considered the same arch for our comparison return (!strcmp (item.arch ().asString ().c_str (), "i586") && - !strcmp (zypp::ZConfig::defaultSystemArchitecture ().asString().c_str(), "i686")); + !strcmp (ZConfig::defaultSystemArchitecture ().asString().c_str(), "i686")); } static gboolean -zypp_package_is_devel (const zypp::sat::Solvable &item) +zypp_package_is_devel (const sat::Solvable &item) { - const std::string &name = item.name(); + const string &name = item.name(); const char *cstr = name.c_str(); return ( g_str_has_suffix (cstr, "-debuginfo") || @@ -599,7 +595,7 @@ zypp_package_is_devel (const zypp::sat::Solvable &item) /* should we filter out this package ? */ gboolean -zypp_filter_solvable (PkBitfield filters, const zypp::sat::Solvable &item) +zypp_filter_solvable (PkBitfield filters, const sat::Solvable &item) { // iterate through the given filters if (!filters) @@ -613,19 +609,19 @@ zypp_filter_solvable (PkBitfield filters, const zypp::sat::Solvable &item) if (i == PK_FILTER_ENUM_NOT_INSTALLED && item.isSystem ()) return TRUE; if (i == PK_FILTER_ENUM_ARCH) { - if (item.arch () != zypp::ZConfig::defaultSystemArchitecture () && - item.arch () != zypp::Arch_noarch && + if (item.arch () != ZConfig::defaultSystemArchitecture () && + item.arch () != Arch_noarch && ! system_and_package_are_x86 (item)) return TRUE; } if (i == PK_FILTER_ENUM_NOT_ARCH) { - if (item.arch () == zypp::ZConfig::defaultSystemArchitecture () || + if (item.arch () == ZConfig::defaultSystemArchitecture () || system_and_package_are_x86 (item)) return TRUE; } - if (i == PK_FILTER_ENUM_SOURCE && !(zypp::isKind<zypp::SrcPackage>(item))) + if (i == PK_FILTER_ENUM_SOURCE && !(isKind<SrcPackage>(item))) return TRUE; - if (i == PK_FILTER_ENUM_NOT_SOURCE && zypp::isKind<zypp::SrcPackage>(item)) + if (i == PK_FILTER_ENUM_NOT_SOURCE && isKind<SrcPackage>(item)) return TRUE; if (i == PK_FILTER_ENUM_DEVELOPMENT && !zypp_package_is_devel (item)) return TRUE; @@ -646,11 +642,11 @@ zypp_filter_solvable (PkBitfield filters, const zypp::sat::Solvable &item) * PK doesn't handle re-installs (by some quirk). */ void -zypp_emit_filtered_packages_in_list (PkBackend *backend, const std::vector<zypp::sat::Solvable> &v) +zypp_emit_filtered_packages_in_list (PkBackend *backend, const vector<sat::Solvable> &v) { - typedef std::vector<zypp::sat::Solvable>::const_iterator sat_it_t; + typedef vector<sat::Solvable>::const_iterator sat_it_t; - std::vector<zypp::sat::Solvable> installed; + vector<sat::Solvable> installed; PkBitfield filters = (PkBitfield) pk_backend_get_uint (backend, "filters"); // always emit system installed packages first @@ -660,7 +656,7 @@ zypp_emit_filtered_packages_in_list (PkBackend *backend, const std::vector<zypp: continue; zypp_backend_package (backend, PK_INFO_ENUM_INSTALLED, *it, - it->lookupStrAttribute (zypp::sat::SolvAttr::summary).c_str ()); + it->lookupStrAttribute (sat::SolvAttr::summary).c_str ()); installed.push_back (*it); } @@ -675,19 +671,19 @@ zypp_emit_filtered_packages_in_list (PkBackend *backend, const std::vector<zypp: match = FALSE; for (sat_it_t i = installed.begin (); !match && i != installed.end (); i++) { match = it->sameNVRA (*i) && - !(!zypp::isKind<zypp::SrcPackage>(*it) ^ - !zypp::isKind<zypp::SrcPackage>(*i)); + !(!isKind<SrcPackage>(*it) ^ + !isKind<SrcPackage>(*i)); } if (!match) { zypp_backend_package (backend, PK_INFO_ENUM_AVAILABLE, *it, - it->lookupStrAttribute (zypp::sat::SolvAttr::summary).c_str ()); + it->lookupStrAttribute (sat::SolvAttr::summary).c_str ()); } } } void zypp_backend_package (PkBackend *backend, PkInfoEnum info, - const zypp::sat::Solvable &pkg, + const sat::Solvable &pkg, const char *opt_summary) { gchar *id = zypp_build_package_id_from_resolvable (pkg); @@ -699,92 +695,85 @@ zypp_backend_package (PkBackend *backend, PkInfoEnum info, * Returns a set of all packages the could be updated * (you're able to exclude a single (normally the 'patch' repo) */ -static std::set<zypp::PoolItem> * -zypp_get_package_updates (std::string repo) +static void +zypp_get_package_updates (string repo, set<PoolItem> &pks) { - std::set<zypp::PoolItem> *pks = new std::set<zypp::PoolItem> (); - zypp::ResPool pool = zypp::ResPool::instance (); + ResPool pool = ResPool::instance (); - zypp::ResObject::Kind kind = zypp::ResTraits<zypp::Package>::kind; - zypp::ResPool::byKind_iterator it = pool.byKindBegin (kind); - zypp::ResPool::byKind_iterator e = pool.byKindEnd (kind); + ResObject::Kind kind = ResTraits<Package>::kind; + ResPool::byKind_iterator it = pool.byKindBegin (kind); + ResPool::byKind_iterator e = pool.byKindEnd (kind); - zypp::getZYpp()->resolver()->doUpdate(); + getZYpp()->resolver()->doUpdate(); for (; it != e; ++it) if (it->status().isToBeInstalled()) { - zypp::ui::Selectable::constPtr s = - zypp::ui::Selectable::get((*it)->kind(), (*it)->name()); + ui::Selectable::constPtr s = + ui::Selectable::get((*it)->kind(), (*it)->name()); if (s->hasInstalledObj()) - pks->insert(*it); + pks.insert(*it); } - return pks; } /** * Returns a set of all patches the could be installed */ -static std::set<zypp::PoolItem> * -zypp_get_patches (PkBackend *backend) +static void +zypp_get_patches (PkBackend *backend, set<PoolItem> &patches) { - std::set<zypp::PoolItem> *patches = new std::set<zypp::PoolItem> (); _updating_self = FALSE; - zypp::ZYpp::Ptr zypp; + ZYpp::Ptr zypp; zypp = get_zypp (backend); zypp->resolver ()->resolvePool (); - for (zypp::ResPoolProxy::const_iterator it = zypp->poolProxy ().byKindBegin<zypp::Patch>(); - it != zypp->poolProxy ().byKindEnd<zypp::Patch>(); it ++) { + for (ResPoolProxy::const_iterator it = zypp->poolProxy ().byKindBegin<Patch>(); + it != zypp->poolProxy ().byKindEnd<Patch>(); it ++) { // check if patch is needed if((*it)->isNeeded()) { - zypp::Patch::constPtr patch = zypp::asKind<zypp::Patch>((*it)->candidateObj ().resolvable ()); + Patch::constPtr patch = asKind<Patch>((*it)->candidateObj ().resolvable ()); if (_updating_self) { if (patch->restartSuggested ()) - patches->insert ((*it)->candidateObj ()); + patches.insert ((*it)->candidateObj ()); } else - patches->insert ((*it)->candidateObj ()); + patches.insert ((*it)->candidateObj ()); // check if the patch updates libzypp or packageKit and show only these if (!_updating_self && patch->restartSuggested ()) { _updating_self = TRUE; - patches->clear (); - patches->insert ((*it)->candidateObj ()); + patches.clear (); + patches.insert ((*it)->candidateObj ()); } } } - - return patches; - } -std::set<zypp::PoolItem> * -zypp_get_updates (PkBackend *backend) +void +zypp_get_updates (PkBackend *backend, set<PoolItem> &candidates) { - typedef std::set<zypp::PoolItem>::iterator pi_it_t; - - std::set<zypp::PoolItem> *candidates = zypp_get_patches (backend); + typedef set<PoolItem>::iterator pi_it_t; + zypp_get_patches (backend, candidates); if (!_updating_self) { // exclude the patch-repository - std::string patchRepo; - if (!candidates->empty ()) { - patchRepo = candidates->begin ()->resolvable ()->repoInfo ().alias (); + string patchRepo; + if (!candidates.empty ()) { + patchRepo = candidates.begin ()->resolvable ()->repoInfo ().alias (); } bool hidePackages = false; if (PathInfo("/etc/PackageKit/ZYpp.conf").isExist()) { - zypp::parser::IniDict vendorConf(InputStream("/etc/PackageKit/ZYpp.conf")); + parser::IniDict vendorConf(InputStream("/etc/PackageKit/ZYpp.conf")); if (vendorConf.hasSection("Updates")) { - for ( zypp::parser::IniDict::entry_const_iterator eit = vendorConf.entriesBegin("Updates"); + for ( parser::IniDict::entry_const_iterator eit = vendorConf.entriesBegin("Updates"); eit != vendorConf.entriesEnd("Updates"); ++eit ) { if ((*eit).first == "HidePackages" && - zypp::str::strToTrue((*eit).second)) + str::strToTrue((*eit).second)) hidePackages = true; } } @@ -792,26 +781,28 @@ zypp_get_updates (PkBackend *backend) if (!hidePackages) { - std::set<zypp::PoolItem> *packages; - packages = zypp_get_package_updates (patchRepo); - pi_it_t cb = candidates->begin (), ce = candidates->end (), ci; + set<PoolItem> packages; + zypp_get_package_updates(patchRepo, packages); + + pi_it_t cb = candidates.begin (), ce = candidates.end (), ci; for (ci = cb; ci != ce; ++ci) { - if (!zypp::isKind<zypp::Patch>(ci->resolvable())) + if (!isKind<Patch>(ci->resolvable())) continue; - zypp::Patch::constPtr patch = zypp::asKind<zypp::Patch>(ci->resolvable()); + Patch::constPtr patch = asKind<Patch>(ci->resolvable()); // Remove contained packages from list of packages to add - zypp::sat::SolvableSet::const_iterator pki; - for (pki = patch->contents().begin(); pki != patch->contents().end(); pki++) { + sat::SolvableSet::const_iterator pki; + Patch::Contents content(patch->contents()); + for (pki = content.begin(); pki != content.end(); ++pki) { - pi_it_t pb = packages->begin (), pe = packages->end (), pi; + pi_it_t pb = packages.begin (), pe = packages.end (), pi; for (pi = pb; pi != pe; ++pi) { - if (pi->satSolvable() == zypp::sat::Solvable::noSolvable) + if (pi->satSolvable() == sat::Solvable::noSolvable) continue; if (pi->satSolvable().identical (*pki)) { - packages->erase (pi); + packages.erase (pi); break; } } @@ -819,15 +810,13 @@ zypp_get_updates (PkBackend *backend) } // merge into the list - candidates->insert (packages->begin (), packages->end ()); - delete (packages); + candidates.insert (packages.begin (), packages.end ()); } } - return candidates; } void -zypp_check_restart (PkRestartEnum *restart, zypp::Patch::constPtr patch) +zypp_check_restart (PkRestartEnum *restart, Patch::constPtr patch) { if (patch == NULL || restart == NULL) return; @@ -851,7 +840,7 @@ zypp_perform_execution (PkBackend *backend, PerformType type, gboolean force) gboolean simulate = pk_backend_get_bool (backend, "hint:simulate"); try { - zypp::ZYpp::Ptr zypp = get_zypp (backend); + ZYpp::Ptr zypp = get_zypp (backend); if (force) zypp->resolver ()->setForceResolve (force); @@ -867,10 +856,10 @@ zypp_perform_execution (PkBackend *backend, PerformType type, gboolean force) // TODO: Figure out what we need to do with PackageKit // to pull off interactive problem solving. - zypp::ResolverProblemList problems = zypp->resolver ()->problems (); + ResolverProblemList problems = zypp->resolver ()->problems (); gchar * emsg = NULL, * tempmsg = NULL; - for (zypp::ResolverProblemList::iterator it = problems.begin (); it != problems.end (); it++) { + for (ResolverProblemList::iterator it = problems.begin (); it != problems.end (); it++) { if (emsg == NULL) { emsg = g_strdup ((*it)->description ().c_str ()); } @@ -882,8 +871,8 @@ zypp_perform_execution (PkBackend *backend, PerformType type, gboolean force) } // reset the status of all touched PoolItems - zypp::ResPool pool = zypp::ResPool::instance (); - for (zypp::ResPool::const_iterator it = pool.begin (); it != pool.end (); it++) { + ResPool pool = ResPool::instance (); + for (ResPool::const_iterator it = pool.begin (); it != pool.end (); it++) { if (it->status ().isToBeInstalled ()) it->statusReset (); } @@ -906,13 +895,17 @@ zypp_perform_execution (PkBackend *backend, PerformType type, gboolean force) break; }; - zypp::ResPool pool = zypp::ResPool::instance (); + ResPool pool = ResPool::instance (); if (simulate) { ret = TRUE; g_debug ("simulating"); - for (zypp::ResPool::const_iterator it = pool.begin (); it != pool.end (); it++) { + for (ResPool::const_iterator it = pool.begin (); it != pool.end (); it++) { + if (type == REMOVE && !(*it)->isSystem ()) { + it->statusReset (); + continue; + } if (!zypp_backend_pool_item_notify (backend, *it, TRUE)) ret = FALSE; it->statusReset (); @@ -923,8 +916,8 @@ zypp_perform_execution (PkBackend *backend, PerformType type, gboolean force) // look for licenses to confirm - for (zypp::ResPool::const_iterator it = pool.begin (); it != pool.end (); it++) { - if (it->status ().isToBeInstalled () && !(it->satSolvable ().lookupStrAttribute (zypp::sat::SolvAttr::eula).empty ())) { + for (ResPool::const_iterator it = pool.begin (); it != pool.end (); it++) { + if (it->status ().isToBeInstalled () && !(it->satSolvable ().lookupStrAttribute (sat::SolvAttr::eula).empty ())) { gchar *eula_id = g_strdup ((*it)->name ().c_str ()); gboolean has_eula = pk_backend_is_eula_valid (backend, eula_id); if (!has_eula) { @@ -933,7 +926,7 @@ zypp_perform_execution (PkBackend *backend, PerformType type, gboolean force) eula_id, package_id, (*it)->vendor ().c_str (), - it->satSolvable ().lookupStrAttribute (zypp::sat::SolvAttr::eula).c_str ()); + it->satSolvable ().lookupStrAttribute (sat::SolvAttr::eula).c_str ()); pk_backend_error_code (backend, PK_ERROR_ENUM_NO_LICENSE_AGREEMENT, "You've to agree/decline a license"); g_free (package_id); g_free (eula_id); @@ -944,19 +937,22 @@ zypp_perform_execution (PkBackend *backend, PerformType type, gboolean force) } // Perform the installation - zypp::ZYppCommitPolicy policy; + gboolean only_trusted = pk_backend_get_bool (backend, "only_trusted"); + ZYppCommitPolicy policy; policy.restrictToMedia (0); // 0 == install all packages regardless to media - policy.downloadMode (zypp::DownloadInHeaps); + policy.downloadMode (DownloadInHeaps); policy.syncPoolAfterCommit (true); + if (only_trusted == FALSE) + policy.rpmNoSignature(true); - zypp::ZYppCommitResult result = zypp->commit (policy); + ZYppCommitResult result = zypp->commit (policy); if(!result._errors.empty () || !result._remaining.empty () || !result._srcremaining.empty ()){ - zypp::ZYppCommitResult::PoolItemList errors = result._errors; + ZYppCommitResult::PoolItemList errors = result._errors; gchar *emsg = NULL, *tmpmsg = NULL; - for (zypp::ZYppCommitResult::PoolItemList::iterator it = errors.begin (); it != errors.end (); it++){ + for (ZYppCommitResult::PoolItemList::iterator it = errors.begin (); it != errors.end (); it++){ if (emsg == NULL) { emsg = g_strdup ((*it)->name ().c_str ()); } else { @@ -966,8 +962,8 @@ zypp_perform_execution (PkBackend *backend, PerformType type, gboolean force) } } - zypp::ZYppCommitResult::PoolItemList remaining = result._remaining; - for (zypp::ZYppCommitResult::PoolItemList::iterator it = remaining.begin (); it != remaining.end (); it++){ + ZYppCommitResult::PoolItemList remaining = result._remaining; + for (ZYppCommitResult::PoolItemList::iterator it = remaining.begin (); it != remaining.end (); it++){ if (emsg == NULL) { emsg = g_strdup ((*it)->name ().c_str ()); } else { @@ -977,8 +973,8 @@ zypp_perform_execution (PkBackend *backend, PerformType type, gboolean force) } } - zypp::ZYppCommitResult::PoolItemList srcremaining = result._srcremaining; - for (zypp::ZYppCommitResult::PoolItemList::iterator it = srcremaining.begin (); it != srcremaining.end (); it++){ + ZYppCommitResult::PoolItemList srcremaining = result._srcremaining; + for (ZYppCommitResult::PoolItemList::iterator it = srcremaining.begin (); it != srcremaining.end (); it++){ if (emsg == NULL) { emsg = g_strdup ((*it)->name ().c_str ()); } else { @@ -997,50 +993,34 @@ zypp_perform_execution (PkBackend *backend, PerformType type, gboolean force) } ret = TRUE; - } catch (const zypp::repo::RepoNotFoundException &ex) { + } catch (const repo::RepoNotFoundException &ex) { pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, ex.asUserString().c_str() ); - } catch (const zypp::target::rpm::RpmException &ex) { + } catch (const target::rpm::RpmException &ex) { pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED, ex.asUserString().c_str () ); - } catch (const zypp::Exception &ex) { + } catch (const Exception &ex) { pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString().c_str() ); } exit: /* reset the various options */ try { - zypp::ZYpp::Ptr zypp = get_zypp (backend); + ZYpp::Ptr zypp = get_zypp (backend); zypp->resolver ()->setForceResolve (FALSE); if (type == UPDATE) zypp->resolver ()->setIgnoreAlreadyRecommended (FALSE); - } catch (const zypp::Exception &ex) { /* we tried */ } + } catch (const Exception &ex) { /* we tried */ } return ret; } -gchar ** -zypp_convert_set_char (std::set<zypp::sat::Solvable> *set) -{ - gchar **array = new gchar* [set->size ()]; - guint i = 0; - - for (std::set<zypp::sat::Solvable>::iterator it = set->begin (); it != set->end (); it++){ - gchar *package_id = zypp_build_package_id_from_resolvable (*it); - array[i] = g_strdup(package_id); - i++; - g_free (package_id); - } - - return array; -} - gchar * -zypp_build_package_id_capabilities (zypp::Capabilities caps) +zypp_build_package_id_capabilities (Capabilities caps) { gchar * package_ids = new gchar (); - zypp::sat::WhatProvides provs (caps); + sat::WhatProvides provs (caps); - for (zypp::sat::WhatProvides::const_iterator it = provs.begin (); it != provs.end (); it++) { + for (sat::WhatProvides::const_iterator it = provs.begin (); it != provs.end (); it++) { gchar *package_id = zypp_build_package_id_from_resolvable (*it); //package_ids = g_strconcat (package_ids, package_id, PK_PACKAGE_IDS_DELIM, (gchar *)NULL); if (strlen (package_ids) == 0) { @@ -1058,10 +1038,10 @@ gboolean zypp_refresh_cache (PkBackend *backend, gboolean force) { // This call is needed as it calls initializeTarget which appears to properly setup the keyring - zypp::ZYpp::Ptr zypp = get_zypp (backend); + ZYpp::Ptr zypp = get_zypp (backend); if (zypp == NULL) return FALSE; - zypp::filesystem::Pathname pathname(pk_backend_get_root (backend)); + filesystem::Pathname pathname(pk_backend_get_root (backend)); // This call is needed to refresh system rpmdb status while refresh cache zypp->finishTarget (); zypp->initializeTarget (pathname); @@ -1069,13 +1049,13 @@ zypp_refresh_cache (PkBackend *backend, gboolean force) pk_backend_set_status (backend, PK_STATUS_ENUM_REFRESH_CACHE); pk_backend_set_percentage (backend, 0); - zypp::RepoManager manager; - std::list <zypp::RepoInfo> repos; + RepoManager manager; + list <RepoInfo> repos; try { - repos = std::list<zypp::RepoInfo>(manager.repoBegin(),manager.repoEnd()); + repos = list<RepoInfo>(manager.repoBegin(),manager.repoEnd()); } - catch ( const zypp::Exception &e) + catch ( const Exception &e) { // FIXME: make sure this dumps out the right sring. pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, e.asUserString().c_str() ); @@ -1086,8 +1066,8 @@ zypp_refresh_cache (PkBackend *backend, gboolean force) int num_of_repos = repos.size (); gchar *repo_messages = NULL; - for (std::list <zypp::RepoInfo>::iterator it = repos.begin(); it != repos.end(); it++, i++) { - zypp::RepoInfo repo (*it); + for (list <RepoInfo>::iterator it = repos.begin(); it != repos.end(); it++, i++) { + RepoInfo repo (*it); if (!zypp_is_valid_repo (backend, repo)) return FALSE; @@ -1108,7 +1088,7 @@ zypp_refresh_cache (PkBackend *backend, gboolean force) g_free (_repoName); _repoName = g_strdup (repo.alias ().c_str ()); zypp_refresh_meta_and_cache (manager, repo, force); - } catch (const zypp::Exception &ex) { + } catch (const Exception &ex) { if (repo_messages == NULL) { repo_messages = g_strdup_printf ("%s: %s%s", repo.alias ().c_str (), ex.asUserString ().c_str (), "\n"); } else { @@ -1153,7 +1133,7 @@ zypp_backend_finished_error (PkBackend *backend, PkErrorEnum err_code, gboolean zypp_backend_pool_item_notify (PkBackend *backend, - const zypp::PoolItem &item, + const PoolItem &item, gboolean sanity_check) { PkInfoEnum status = PK_INFO_ENUM_UNKNOWN; @@ -1167,7 +1147,7 @@ zypp_backend_pool_item_notify (PkBackend *backend, } else if (item.status ().isToBeUninstalled ()) { status = PK_INFO_ENUM_REMOVING; - const std::string &name = item.satSolvable().name(); + const string &name = item.satSolvable().name(); if (name == "glibc" || name == "PackageKit" || name == "rpm" || name == "libzypp") { pk_backend_error_code (backend, PK_ERROR_ENUM_CANNOT_REMOVE_SYSTEM_PACKAGE, @@ -1180,19 +1160,19 @@ zypp_backend_pool_item_notify (PkBackend *backend, // FIXME: do we need more heavy lifting here cf. zypper's // Summary.cc (readPool) to generate _DOWNGRADING types ? if (status != PK_INFO_ENUM_UNKNOWN) { - const std::string &summary = item.resolvable ()->summary (); + const string &summary = item.resolvable ()->summary (); zypp_backend_package (backend, status, item.resolvable()->satSolvable(), summary.c_str ()); } return TRUE; } gchar * -zypp_build_package_id_from_resolvable (const zypp::sat::Solvable &resolvable) +zypp_build_package_id_from_resolvable (const sat::Solvable &resolvable) { gchar *package_id; const char *arch; - if (zypp::isKind<zypp::SrcPackage>(resolvable)) + if (isKind<SrcPackage>(resolvable)) arch = "source"; else arch = resolvable.arch ().asString ().c_str (); @@ -1206,18 +1186,18 @@ zypp_build_package_id_from_resolvable (const zypp::sat::Solvable &resolvable) } gboolean -zypp_ver_and_arch_equal (const zypp::sat::Solvable &pkg, +zypp_ver_and_arch_equal (const sat::Solvable &pkg, const char *name, const char *arch) { - const std::string &ver = pkg.edition ().asString(); + const string &ver = pkg.edition ().asString(); if (g_strcmp0 (ver.c_str (), name)) return FALSE; if (arch && !strcmp (arch, "source")) { - return zypp::isKind<zypp::SrcPackage>(pkg); + return isKind<SrcPackage>(pkg); } - const zypp::Arch &parch = pkg.arch(); + const Arch &parch = pkg.arch(); if (g_strcmp0 (parch.c_str(), arch)) return FALSE; diff --git a/backends/zypp/zypp-utils.h b/backends/zypp/zypp-utils.h index 586139eed..cc803f5ea 100644 --- a/backends/zypp/zypp-utils.h +++ b/backends/zypp/zypp-utils.h @@ -102,7 +102,7 @@ void warn_outdated_repos(PkBackend *backend, const zypp::ResPool & pool); /** * Return the rpmHeader of a package */ -zypp::target::rpm::RpmHeader::constPtr zypp_get_rpmHeader (std::string name, zypp::Edition edition); +zypp::target::rpm::RpmHeader::constPtr zypp_get_rpmHeader (const std::string &name, zypp::Edition edition); /** * Return the group of the given PoolItem. @@ -112,18 +112,19 @@ std::string zypp_get_group (zypp::sat::Solvable item); /** * Return the PkEnumGroup of the given PoolItem. */ -PkGroupEnum get_enum_group (std::string group); +PkGroupEnum get_enum_group (const std::string &group); /** * Returns a list of packages that match the specified package_name. */ -std::vector<zypp::sat::Solvable> * zypp_get_packages_by_name (PkBackend *backend, const gchar *package_name, - const zypp::ResKind kind, gboolean include_local = TRUE); +void zypp_get_packages_by_name (PkBackend *backend, const gchar *package_name, + const zypp::ResKind kind, std::vector<zypp::sat::Solvable> &result, + gboolean include_local = TRUE); /** * Returns a list of packages that owns the specified file. */ -std::vector<zypp::sat::Solvable> * zypp_get_packages_by_file (PkBackend *backend, const gchar *search_file); +void zypp_get_packages_by_file (PkBackend *backend, const gchar *search_file, std::vector<zypp::sat::Solvable> &result); /** * Returns the Resolvable for the specified package_id. @@ -167,7 +168,7 @@ zypp::PoolItem zypp_find_arch_update_item (const zypp::ResPool & pool, zypp::Poo * we can find. Also manages _updating_self to prioritise critical infrastructure * updates. */ -std::set<zypp::PoolItem> * zypp_get_updates (PkBackend *backend); +void zypp_get_updates (PkBackend *backend, std::set<zypp::PoolItem> &); /** * Sets the restart flag of a patch @@ -190,11 +191,6 @@ gboolean zypp_filter_solvable (PkBitfield filters, const zypp::sat::Solvable &it void zypp_emit_filtered_packages_in_list (PkBackend *backend, const std::vector<zypp::sat::Solvable> &list); /** - * convert a std::set<zypp::sat::Solvable to gchar ** array - */ -gchar ** zypp_convert_set_char (std::set<zypp::sat::Solvable> *set); - -/** * build string of package_id's seperated by blanks out of the capabilities of a solvable */ gchar * zypp_build_package_id_capabilities (zypp::Capabilities caps); diff --git a/client/pk-console.c b/client/pk-console.c index 38d2f0175..e00b94442 100644 --- a/client/pk-console.c +++ b/client/pk-console.c @@ -1203,9 +1203,10 @@ pk_console_get_summary (void) g_string_append_printf (string, " %s\n", "rollback"); if (pk_bitfield_contain (roles, PK_ROLE_ENUM_GET_REPO_LIST)) g_string_append_printf (string, " %s\n", "repo-list"); - if (pk_bitfield_contain (roles, PK_ROLE_ENUM_REPO_ENABLE)) + if (pk_bitfield_contain (roles, PK_ROLE_ENUM_REPO_ENABLE)) { g_string_append_printf (string, " %s\n", "repo-enable [repo_id]"); g_string_append_printf (string, " %s\n", "repo-disable [repo_id]"); + } if (pk_bitfield_contain (roles, PK_ROLE_ENUM_REPO_SET_DATA)) g_string_append_printf (string, " %s\n", "repo-set-data [repo_id] [parameter] [value];"); if (pk_bitfield_contain (roles, PK_ROLE_ENUM_WHAT_PROVIDES)) diff --git a/configure.ac b/configure.ac index d6520f123..327750ee7 100644 --- a/configure.ac +++ b/configure.ac @@ -496,7 +496,6 @@ AC_ARG_ENABLE(conary, AS_HELP_STRING([--enable-conary],[use the CONARY backend]) AC_ARG_ENABLE(dummy, AS_HELP_STRING([--enable-dummy],[use the dummy backend]),enable_dummy=$enableval,enable_dummy=yes) AC_ARG_ENABLE(entropy, AS_HELP_STRING([--enable-entropy],[use the entropy backend]),enable_entropy=$enableval,enable_entropy=no) AC_ARG_ENABLE(opkg, AS_HELP_STRING([--enable-opkg],[use the OPKG backend]),enable_opkg=$enableval,enable_opkg=no) -AC_ARG_ENABLE(pacman, AS_HELP_STRING([--enable-pacman],[use the Pacman backend]),enable_pacman=$enableval,enable_pacman=no) AC_ARG_ENABLE(pisi, AS_HELP_STRING([--enable-pisi],[use the PiSi backend]),enable_pisi=$enableval,enable_pisi=no) AC_ARG_ENABLE(poldek, AS_HELP_STRING([--enable-poldek],[use the poldek backend]),enable_poldek=$enableval,enable_poldek=no) AC_ARG_ENABLE(portage, AS_HELP_STRING([--enable-portage],[use the portage backend]),enable_portage=$enableval,enable_portage=no) @@ -518,7 +517,6 @@ AM_CONDITIONAL(BACKEND_TYPE_CONARY, [test x$enable_conary = xyes]) AM_CONDITIONAL(BACKEND_TYPE_DUMMY, [test x$enable_dummy = xyes]) AM_CONDITIONAL(BACKEND_TYPE_ENTROPY, [test x$enable_entropy = xyes]) AM_CONDITIONAL(BACKEND_TYPE_OPKG, [test x$enable_opkg = xyes]) -AM_CONDITIONAL(BACKEND_TYPE_PACMAN, [test x$enable_pacman = xyes]) AM_CONDITIONAL(BACKEND_TYPE_PISI, [test x$enable_pisi = xyes]) AM_CONDITIONAL(BACKEND_TYPE_POLDEK, [test x$enable_poldek = xyes]) AM_CONDITIONAL(BACKEND_TYPE_PORTAGE, [test x$enable_portage = xyes]) @@ -627,8 +625,6 @@ if test x$with_default_backend = x; then with_default_backend=slapt elif test -f /usr/bin/smart ; then with_default_backend=smart - elif test -f /usr/lib/libpacman-glib.so ; then - with_default_backend=pacman elif test -f /usr/bin/pisi ; then with_default_backend=pisi elif test -f /usr/bin/razor ; then @@ -738,12 +734,6 @@ if test x$enable_alpm = xyes; then [AC_MSG_ERROR([No ALPM headers found])]) fi -if test x$enable_pacman = xyes; then - PKG_CHECK_MODULES(PACMAN, pacman-glib >= 3.3.0) - AC_SUBST(PACMAN_CFLAGS) - AC_SUBST(PACMAN_LIBS) -fi - if test x$enable_poldek = xyes; then POLDEK_CFLAGS="-I/usr/include/poldek" POLDEK_LIBS="-lpoclidek -lpoldek" @@ -822,7 +812,6 @@ backends/conary/Makefile backends/dummy/Makefile backends/entropy/Makefile backends/opkg/Makefile -backends/pacman/Makefile backends/slapt/Makefile backends/smart/Makefile backends/test/Makefile @@ -901,7 +890,6 @@ echo " Entropy backend: ${enable_entropy} OPKG backend: ${enable_opkg} Razor backend: ${enable_razor} - Pacman backend: ${enable_pacman} PiSi backend: ${enable_pisi} poldek backend: ${enable_poldek} Portage backend: ${enable_portage} diff --git a/contrib/browser-plugin/Makefile.am b/contrib/browser-plugin/Makefile.am index cc3a9d549..2b469e633 100644 --- a/contrib/browser-plugin/Makefile.am +++ b/contrib/browser-plugin/Makefile.am @@ -7,6 +7,7 @@ packagekit_plugin_la_CPPFLAGS = \ -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \ -DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE \ -DMOZ_X11 \ + -DGSEAL_ENABLE \ -I$(top_srcdir)/lib packagekit_plugin_la_CFLAGS = \ diff --git a/contrib/browser-plugin/pk-main.c b/contrib/browser-plugin/pk-main.c index 62914e065..b9378cb47 100644 --- a/contrib/browser-plugin/pk-main.c +++ b/contrib/browser-plugin/pk-main.c @@ -219,7 +219,7 @@ pk_main_create_window (PkPlugin *plugin) } /* get parent */ - parent = gdk_window_foreign_new_for_display (gdk_display, xwindow); + parent = gdk_x11_window_foreign_new_for_display (gdk_display, xwindow); if (parent == NULL) { pk_debug ("invalid window given for setup (id %lu)\n", xwindow); return; diff --git a/docs/html/pk-bugs.html b/docs/html/pk-bugs.html index a0a1dacbe..0b9a974b4 100644 --- a/docs/html/pk-bugs.html +++ b/docs/html/pk-bugs.html @@ -57,7 +57,7 @@ useful when debugging problems. <pre> sudo killall packagekitd -sudo /usr/sbin/packagekitd --verbose +sudo /usr/libexec/packagekitd --verbose </pre> <h2>GConf session settings</h2> @@ -77,7 +77,7 @@ else the reports from gdb won't mean much to any of us. </p> <pre> -gdb /usr/sbin/packagekitd +gdb /usr/libexec/packagekitd </pre> <p> The GNU debugger (gdb) will start and put you at a prompt: diff --git a/docs/html/pk-download.html b/docs/html/pk-download.html index f27bbc0fc..715a855c4 100644 --- a/docs/html/pk-download.html +++ b/docs/html/pk-download.html @@ -35,7 +35,7 @@ your native package manager. </li> <li> Debian: Yes, packages are available for Debian Sid. - Just install <code>packagekit</code> via APT. PackageKit frontends are not yet packaged for Debian. + Just run <code>apt-get install packagekit gnome-packagekit</code> (as root). </li> <li> Ubuntu: Yes, starting with Hardy Heron (8.04), that ships an obsolete version (0.1.6) of PackageKit by default. diff --git a/docs/html/pk-matrix.html b/docs/html/pk-matrix.html index 33f2efbd7..9226b4186 100644 --- a/docs/html/pk-matrix.html +++ b/docs/html/pk-matrix.html @@ -28,7 +28,6 @@ <td><center>conary</center></td> <td><center>entropy</center></td> <td><center>opkg</center></td> -<td><center>pacman</center></td> <td><center>pisi</center></td> <td><center>poldek</center></td> <td><center>portage</center></td> @@ -43,12 +42,11 @@ <td><b>Cancel</b></td> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- apt --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- aptcc --> -<td><img src="img/status-bad.png" alt="[no]"/></td><!-- alpm --> +<td><img src="img/status-good.png" alt="[yes]"/></td><!-- alpm --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- box --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg --> -<td><img src="img/status-good.png" alt="[yes]"/></td><!-- pacman --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- portage --> @@ -68,7 +66,6 @@ <td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg --> -<td><img src="img/status-good.png" alt="[yes]"/></td><!-- pacman --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- pisi --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- poldek --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- portage --> @@ -77,7 +74,7 @@ <td><img src="img/status-good.png" alt="[yes]"/></td><!-- smart --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- urpmi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- yum --> -<td><img src="img/status-bad.png" alt="[no]"/></td><!-- zypp --> +<td><img src="img/status-good.png" alt="[yes]"/></td><!-- zypp --> </tr> <tr> <td><b>GetDepends</b></td> @@ -88,7 +85,6 @@ <td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- opkg --> -<td><img src="img/status-good.png" alt="[yes]"/></td><!-- pacman --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- portage --> @@ -108,7 +104,6 @@ <td><img src="img/status-good.png" alt="[yes]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- opkg --> -<td><img src="img/status-good.png" alt="[yes]"/></td><!-- pacman --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- portage --> @@ -128,7 +123,6 @@ <td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg --> -<td><img src="img/status-bad.png" alt="[no]"/></td><!-- pacman --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- pisi --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- poldek --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- portage --> @@ -148,7 +142,6 @@ <td><img src="img/status-good.png" alt="[yes]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg --> -<td><img src="img/status-good.png" alt="[yes]"/></td><!-- pacman --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- portage --> @@ -168,7 +161,6 @@ <td><img src="img/status-good.png" alt="[yes]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg --> -<td><img src="img/status-good.png" alt="[yes]"/></td><!-- pacman --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- pisi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- portage --> @@ -188,7 +180,6 @@ <td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg --> -<td><img src="img/status-good.png" alt="[yes]"/></td><!-- pacman --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- portage --> @@ -203,12 +194,11 @@ <td><b>GetRequires</b></td> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- apt --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- aptcc --> -<td><img src="img/status-bad.png" alt="[no]"/></td><!-- alpm --> +<td><img src="img/status-good.png" alt="[yes]"/></td><!-- alpm --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- box --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg --> -<td><img src="img/status-good.png" alt="[yes]"/></td><!-- pacman --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- portage --> @@ -228,7 +218,6 @@ <td><img src="img/status-good.png" alt="[yes]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg --> -<td><img src="img/status-good.png" alt="[yes]"/></td><!-- pacman --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- pisi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- portage --> @@ -248,7 +237,6 @@ <td><img src="img/status-good.png" alt="[yes]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- opkg --> -<td><img src="img/status-good.png" alt="[yes]"/></td><!-- pacman --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- portage --> @@ -268,7 +256,6 @@ <td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg --> -<td><img src="img/status-good.png" alt="[yes]"/></td><!-- pacman --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- poldek --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- portage --> @@ -288,7 +275,6 @@ <td><img src="img/status-good.png" alt="[yes]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- opkg --> -<td><img src="img/status-good.png" alt="[yes]"/></td><!-- pacman --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- portage --> @@ -308,7 +294,6 @@ <td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- entropy --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg --> -<td><img src="img/status-bad.png" alt="[no]"/></td><!-- pacman --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- pisi --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- poldek --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- portage --> @@ -328,7 +313,6 @@ <td><img src="img/status-good.png" alt="[yes]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- opkg --> -<td><img src="img/status-good.png" alt="[yes]"/></td><!-- pacman --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- portage --> @@ -348,7 +332,6 @@ <td><img src="img/status-good.png" alt="[yes]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- opkg --> -<td><img src="img/status-good.png" alt="[yes]"/></td><!-- pacman --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- portage --> @@ -363,12 +346,11 @@ <td><b>RepoEnable</b></td> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- apt --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- aptcc --> -<td><img src="img/status-bad.png" alt="[no]"/></td><!-- alpm --> +<td><img src="img/status-good.png" alt="[yes]"/></td><!-- alpm --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- box --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg --> -<td><img src="img/status-good.png" alt="[yes]"/></td><!-- pacman --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- pisi --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- poldek --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- portage --> @@ -388,7 +370,6 @@ <td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- entropy --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg --> -<td><img src="img/status-bad.png" alt="[no]"/></td><!-- pacman --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- poldek --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- portage --> @@ -408,7 +389,6 @@ <td><img src="img/status-good.png" alt="[yes]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg --> -<td><img src="img/status-good.png" alt="[yes]"/></td><!-- pacman --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- portage --> @@ -428,7 +408,6 @@ <td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[no]"/></td><!-- entropy --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg --> -<td><img src="img/status-bad.png" alt="[no]"/></td><!-- pacman --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- pisi --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- poldek --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- portage --> @@ -448,7 +427,6 @@ <td><img src="img/status-good.png" alt="[yes]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- opkg --> -<td><img src="img/status-good.png" alt="[yes]"/></td><!-- pacman --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- portage --> @@ -463,12 +441,11 @@ <td><b>SearchFile</b></td> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- apt --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- aptcc --> -<td><img src="img/status-bad.png" alt="[no]"/></td><!-- alpm --> +<td><img src="img/status-good.png" alt="[yes]"/></td><!-- alpm --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- box --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg --> -<td><img src="img/status-good.png" alt="[yes]"/></td><!-- pacman --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- portage --> @@ -488,7 +465,6 @@ <td><img src="img/status-good.png" alt="[yes]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- opkg --> -<td><img src="img/status-good.png" alt="[yes]"/></td><!-- pacman --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- portage --> @@ -508,7 +484,6 @@ <td><img src="img/status-good.png" alt="[yes]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- opkg --> -<td><img src="img/status-good.png" alt="[yes]"/></td><!-- pacman --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- portage --> @@ -523,12 +498,11 @@ <td><b>SimulateInstallFiles</b></td> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- apt --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- aptcc --> -<td><img src="img/status-bad.png" alt="[no]"/></td><!-- alpm --> +<td><img src="img/status-good.png" alt="[yes]"/></td><!-- alpm --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- box --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg --> -<td><img src="img/status-bad.png" alt="[no]"/></td><!-- pacman --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- pisi --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- poldek --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- portage --> @@ -543,12 +517,11 @@ <td><b>SimulateInstallPackages</b></td> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- apt --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- aptcc --> -<td><img src="img/status-bad.png" alt="[no]"/></td><!-- alpm --> +<td><img src="img/status-good.png" alt="[yes]"/></td><!-- alpm --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- box --> -<td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary --> +<td><img src="img/status-good.png" alt="[no]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg --> -<td><img src="img/status-good.png" alt="[yes]"/></td><!-- pacman --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- pisi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- portage --> @@ -563,12 +536,11 @@ <td><b>SimulateRemovePackages</b></td> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- apt --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- aptcc --> -<td><img src="img/status-bad.png" alt="[no]"/></td><!-- alpm --> +<td><img src="img/status-good.png" alt="[yes]"/></td><!-- alpm --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- box --> -<td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary --> +<td><img src="img/status-good.png" alt="[no]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg --> -<td><img src="img/status-good.png" alt="[yes]"/></td><!-- pacman --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- pisi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- portage --> @@ -583,12 +555,11 @@ <td><b>SimulateUpdatePackages</b></td> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- apt --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- aptcc --> -<td><img src="img/status-bad.png" alt="[no]"/></td><!-- alpm --> +<td><img src="img/status-good.png" alt="[yes]"/></td><!-- alpm --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- box --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg --> -<td><img src="img/status-good.png" alt="[yes]"/></td><!-- pacman --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- pisi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- portage --> @@ -605,10 +576,9 @@ <td><img src="img/status-good.png" alt="[yes]"/></td><!-- aptcc --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- alpm --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- box --> -<td><img src="img/status-good.png" alt="[yes]"/></td><!-- conary --> +<td><img src="img/status-bad.png" alt="[yes]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- opkg --> -<td><img src="img/status-good.png" alt="[yes]"/></td><!-- pacman --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- portage --> @@ -628,7 +598,6 @@ <td><img src="img/status-good.png" alt="[yes]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- opkg --> -<td><img src="img/status-bad.png" alt="[no]"/></td><!-- pacman --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- portage --> @@ -648,7 +617,6 @@ <td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg --> -<td><img src="img/status-good.png" alt="[yes]"/></td><!-- pacman --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- pisi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- portage --> @@ -672,7 +640,6 @@ <td><center>conary</center></td> <td><center>entropy</center></td> <td><center>opkg</center></td> -<td><center>pacman</center></td> <td><center>pisi</center></td> <td><center>poldek</center></td> <td><center>portage</center></td> @@ -692,7 +659,6 @@ <td><img src="img/status-good.png" alt="[yes]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- opkg --> -<td><img src="img/status-good.png" alt="[yes]"/></td><!-- pacman --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- portage --> @@ -712,7 +678,6 @@ <td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- opkg --> -<td><img src="img/status-bad.png" alt="[no]"/></td><!-- pacman --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- portage --> @@ -732,7 +697,6 @@ <td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- opkg --> -<td><img src="img/status-bad.png" alt="[no]"/></td><!-- pacman --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- portage --> @@ -752,7 +716,6 @@ <td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- entropy --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg --> -<td><img src="img/status-bad.png" alt="[no]"/></td><!-- pacman --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- pisi --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- poldek --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- portage --> @@ -772,7 +735,6 @@ <td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- entropy --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg --> -<td><img src="img/status-bad.png" alt="[no]"/></td><!-- pacman --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- pisi --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- poldek --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- portage --> @@ -792,7 +754,6 @@ <td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- entropy --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg --> -<td><img src="img/status-bad.png" alt="[no]"/></td><!-- pacman --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- pisi --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- poldek --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- portage --> @@ -812,7 +773,6 @@ <td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- entropy --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg --> -<td><img src="img/status-bad.png" alt="[no]"/></td><!-- pacman --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- pisi --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek --> <td><img src="img/status-good.png" alt="[yes]"/></td><!-- portage --> @@ -832,7 +792,6 @@ <td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- entropy --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg --> -<td><img src="img/status-bad.png" alt="[no]"/></td><!-- pacman --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- pisi --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- poldek --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- portage --> @@ -852,7 +811,6 @@ <td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- entropy --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg --> -<td><img src="img/status-bad.png" alt="[no]"/></td><!-- pacman --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- pisi --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- poldek --> <td><img src="img/status-bad.png" alt="[no]"/></td><!-- portage --> diff --git a/lib/packagekit-glib2/pk-catalog.c b/lib/packagekit-glib2/pk-catalog.c index 24eb09a59..f5941c422 100644 --- a/lib/packagekit-glib2/pk-catalog.c +++ b/lib/packagekit-glib2/pk-catalog.c @@ -615,7 +615,7 @@ pk_catalog_init (PkCatalog *catalog) control = pk_control_new (); ret = pk_control_get_properties (control, NULL, &error); if (!ret) { - g_error ("Failed to contact PackageKit: %s", error->message); + g_warning ("Failed to contact PackageKit: %s", error->message); g_error_free (error); return; } diff --git a/lib/packagekit-glib2/pk-client.c b/lib/packagekit-glib2/pk-client.c index b9156e69f..028e0db05 100644 --- a/lib/packagekit-glib2/pk-client.c +++ b/lib/packagekit-glib2/pk-client.c @@ -1843,13 +1843,14 @@ out: static gboolean pk_client_create_helper_argv_envp (PkClientState *state, gchar ***argv, - gchar ***envp) + gchar ***envp_out) { const gchar *dialog = NULL; const gchar *display; const gchar *term; gboolean ret; guint envpi = 0; + gchar **envp; /* check we have the right file */ ret = g_file_test ("/usr/bin/debconf-communicate", @@ -1861,23 +1862,24 @@ pk_client_create_helper_argv_envp (PkClientState *state, *argv = g_new0 (gchar *, 2); *argv[0] = g_strdup ("/usr/bin/debconf-communicate"); - *envp = g_new0 (gchar *, 8); - *envp[envpi++] = g_strdup ("DEBCONF_DB_REPLACE=configdb"); - *envp[envpi++] = g_strdup ("DEBCONF_DB_OVERRIDE=Pipe{infd:none outfd:none}"); + *envp_out = g_new0 (gchar *, 8); + envp = *envp_out; + envp[envpi++] = g_strdup ("DEBCONF_DB_REPLACE=configdb"); + envp[envpi++] = g_strdup ("DEBCONF_DB_OVERRIDE=Pipe{infd:none outfd:none}"); if (pk_debug_is_verbose ()) - *envp[envpi++] = g_strdup ("DEBCONF_DEBUG=."); + envp[envpi++] = g_strdup ("DEBCONF_DEBUG=."); /* do we have an available terminal to use */ term = g_getenv ("TERM"); if (term != NULL) { - *envp[envpi++] = g_strdup_printf ("TERM=%s", term); + envp[envpi++] = g_strdup_printf ("TERM=%s", term); dialog = "dialog"; } /* do we have access to the display */ display = g_getenv ("DISPLAY"); if (display != NULL) { - *envp[envpi++] = g_strdup_printf ("DISPLAY=%s", display); + envp[envpi++] = g_strdup_printf ("DISPLAY=%s", display); if (g_strcmp0 (g_getenv ("KDE_FULL_SESSION"), "true") == 0) dialog = "kde"; else @@ -1886,7 +1888,7 @@ pk_client_create_helper_argv_envp (PkClientState *state, /* indicate a prefered frontend */ if (dialog != NULL) { - *envp[envpi++] = g_strdup_printf ("DEBIAN_FRONTEND=%s", dialog); + envp[envpi++] = g_strdup_printf ("DEBIAN_FRONTEND=%s", dialog); g_debug ("using frontend %s", dialog); } out: diff --git a/po/LINGUAS b/po/LINGUAS index c3f7e98a3..dfda8bf20 100644 --- a/po/LINGUAS +++ b/po/LINGUAS @@ -11,11 +11,13 @@ es eu fi fr +gl gu he hi hu id +it_IT it ja kn diff --git a/po/gl.po b/po/gl.po new file mode 100644 index 000000000..ff1bffa9c --- /dev/null +++ b/po/gl.po @@ -0,0 +1,2139 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: PackageKit\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-12-13 12:23+0000\n" +"PO-Revision-Date: 2011-03-04 18:34+0000\n" +"Last-Translator: mbouzada <mbouzada@gmail.com>\n" +"Language-Team: Galician <None>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: gl\n" +"Plural-Forms: nplurals=2; plural=(n != 1)\n" + +#. TRANSLATORS: this is an atomic transaction +#. TRANSLATORS: the role is the point of the transaction, e.g. update-system +#: ../client/pk-console.c:174 ../client/pk-console.c:596 +msgid "Transaction" +msgstr "Transacción" + +#. TRANSLATORS: this is the time the transaction was started in system +#. timezone +#: ../client/pk-console.c:176 +msgid "System time" +msgstr "Hora do sistema" + +#. TRANSLATORS: this is if the transaction succeeded or not +#: ../client/pk-console.c:178 +msgid "Succeeded" +msgstr "Correcto" + +#: ../client/pk-console.c:178 +msgid "True" +msgstr "Verdadeiro" + +#: ../client/pk-console.c:178 +msgid "False" +msgstr "Falso" + +#. TRANSLATORS: this is the transactions role, e.g. "update-system" +#. TRANSLATORS: the trasaction role, e.g. update-system +#: ../client/pk-console.c:180 ../src/pk-polkit-action-lookup.c:332 +msgid "Role" +msgstr "Rol" + +#. TRANSLATORS: this is The duration of the transaction +#: ../client/pk-console.c:185 +msgid "Duration" +msgstr "Duración" + +#: ../client/pk-console.c:185 +msgid "(seconds)" +msgstr "(segundos)" + +#. TRANSLATORS: this is The command line used to do the action +#. TRANSLATORS: the command line of the thing that wants the authentication +#: ../client/pk-console.c:189 ../src/pk-polkit-action-lookup.c:346 +msgid "Command line" +msgstr "Liña de ordes" + +#. TRANSLATORS: this is the user ID of the user that started the action +#: ../client/pk-console.c:191 +msgid "User ID" +msgstr "ID de usuario" + +#. TRANSLATORS: this is the username, e.g. hughsie +#: ../client/pk-console.c:198 +msgid "Username" +msgstr "Nome de usuario" + +#. TRANSLATORS: this is the users real name, e.g. "Richard Hughes" +#: ../client/pk-console.c:202 +msgid "Real name" +msgstr "Nome real" + +#: ../client/pk-console.c:210 +msgid "Affected packages:" +msgstr "Paquetes afectados:" + +#: ../client/pk-console.c:212 +msgid "Affected packages: None" +msgstr "Paquetes afectados: ningún" + +#. TRANSLATORS: this is the distro, e.g. Fedora 10 +#: ../client/pk-console.c:247 +msgid "Distribution" +msgstr "Distribución" + +#. TRANSLATORS: this is type of update, stable or testing +#: ../client/pk-console.c:249 +msgid "Type" +msgstr "Tipo" + +#. TRANSLATORS: this is any summary text describing the upgrade +#. TRANSLATORS: this is the summary of the group +#: ../client/pk-console.c:251 ../client/pk-console.c:290 +msgid "Summary" +msgstr "Resumo" + +#. TRANSLATORS: this is the group category name +#: ../client/pk-console.c:279 +msgid "Category" +msgstr "CategorÃa" + +#. TRANSLATORS: this is group identifier +#: ../client/pk-console.c:281 +msgid "ID" +msgstr "ID" + +#. TRANSLATORS: this is the parent group +#: ../client/pk-console.c:284 +msgid "Parent" +msgstr "Pai" + +#. TRANSLATORS: this is the name of the parent group +#: ../client/pk-console.c:287 +msgid "Name" +msgstr "Nome" + +#. TRANSLATORS: this is preferred icon for the group +#: ../client/pk-console.c:293 +msgid "Icon" +msgstr "Icona" + +#. TRANSLATORS: this is a header for the package that can be updated +#: ../client/pk-console.c:339 +msgid "Details about the update:" +msgstr "Detalles sobre a actualización:" + +#. TRANSLATORS: details about the update, package name and version +#. TRANSLATORS: the package that is being processed +#. TRANSLATORS: the package that is not signed by a known key +#. TRANSLATORS: the package name that was trying to be installed +#. TRANSLATORS: title, the names of the packages that the method is processing +#: ../client/pk-console.c:345 ../client/pk-console.c:615 +#: ../lib/packagekit-glib2/pk-task-text.c:124 +#: ../lib/packagekit-glib2/pk-task-text.c:206 +#: ../src/pk-polkit-action-lookup.c:357 +msgid "Package" +msgid_plural "Packages" +msgstr[0] "Paquete" +msgstr[1] "Paquetes" + +#. TRANSLATORS: details about the update, any packages that this update +#. updates +#: ../client/pk-console.c:348 +msgid "Updates" +msgstr "Actualizacións" + +#. TRANSLATORS: details about the update, any packages that this update +#. obsoletes +#: ../client/pk-console.c:352 +msgid "Obsoletes" +msgstr "Obsoletos" + +#. TRANSLATORS: details about the update, the vendor URLs +#. TRANSLATORS: the vendor (e.g. vmware) that is providing the EULA +#: ../client/pk-console.c:356 ../lib/packagekit-glib2/pk-task-text.c:209 +msgid "Vendor" +msgstr "Provedor" + +#. TRANSLATORS: details about the update, the bugzilla URLs +#: ../client/pk-console.c:360 +msgid "Bugzilla" +msgstr "Bugzilla" + +#. TRANSLATORS: details about the update, the CVE URLs +#: ../client/pk-console.c:364 +msgid "CVE" +msgstr "CVE" + +#. TRANSLATORS: details about the update, if the package requires a restart +#: ../client/pk-console.c:368 +msgid "Restart" +msgstr "Reiniciar" + +#. TRANSLATORS: details about the update, any description of the update +#: ../client/pk-console.c:372 +msgid "Update text" +msgstr "Texto de actualización" + +#. TRANSLATORS: details about the update, the changelog for the package +#: ../client/pk-console.c:376 +msgid "Changes" +msgstr "Cambios" + +#. TRANSLATORS: details about the update, the ongoing state of the update +#: ../client/pk-console.c:380 +msgid "State" +msgstr "Estado" + +#. TRANSLATORS: details about the update, date the update was issued +#: ../client/pk-console.c:384 +msgid "Issued" +msgstr "Publicada" + +#. TRANSLATORS: details about the update, date the update was updated +#. TRANSLATORS: The action of the package, in past tense +#: ../client/pk-console.c:388 ../lib/packagekit-glib2/pk-console-shared.c:515 +msgid "Updated" +msgstr "Actualizado" + +#. TRANSLATORS: if the repo is enabled +#: ../client/pk-console.c:424 +msgid "Enabled" +msgstr "Activado" + +#. TRANSLATORS: if the repo is disabled +#: ../client/pk-console.c:427 +msgid "Disabled" +msgstr "Desactivado" + +#. TRANSLATORS: a package requires the system to be restarted +#: ../client/pk-console.c:459 +msgid "System restart required by:" +msgstr "Reinicio do sistema requirido por:" + +#. TRANSLATORS: a package requires the session to be restarted +#: ../client/pk-console.c:462 +msgid "Session restart required:" +msgstr "Reinicio da sesión requirido por:" + +#. TRANSLATORS: a package requires the system to be restarted due to a +#. security update +#: ../client/pk-console.c:465 +msgid "System restart (security) required by:" +msgstr "Reinicio do sistema (seguranza) requirido por:" + +#. TRANSLATORS: a package requires the session to be restarted due to a +#. security update +#: ../client/pk-console.c:468 +msgid "Session restart (security) required:" +msgstr "Reinicio da sesión (seguranza) requirido por:" + +#. TRANSLATORS: a package requires the application to be restarted +#: ../client/pk-console.c:471 +msgid "Application restart required by:" +msgstr "Reinicio do aplicativo requirido por:" + +#. TRANSLATORS: This a list of details about the package +#: ../client/pk-console.c:506 +msgid "Package description" +msgstr "Descrición do paquete" + +#. TRANSLATORS: This a message (like a little note that may be of interest) +#. from the transaction +#: ../client/pk-console.c:537 +msgid "Message:" +msgstr "Mensaxe:" + +#. TRANSLATORS: This where the package has no files +#: ../client/pk-console.c:558 +msgid "No files" +msgstr "Sen ficheiros" + +#. TRANSLATORS: This a list files contained in the package +#: ../client/pk-console.c:563 +msgid "Package files" +msgstr "Ficheiros do paquete" + +#. TRANSLATORS: the percentage complete of the transaction +#: ../client/pk-console.c:631 +msgid "Percentage" +msgstr "Porcentaxe" + +#. TRANSLATORS: the status of the transaction (e.g. downloading) +#: ../client/pk-console.c:649 +msgid "Status" +msgstr "Estado" + +#. TRANSLATORS: the results from the transaction +#: ../client/pk-console.c:678 +msgid "Results:" +msgstr "Resultados:" + +#. TRANSLATORS: we failed to get any results, which is pretty fatal in my book +#: ../client/pk-console.c:685 +msgid "Fatal error" +msgstr "Produciuse un erro moi grave" + +#. TRANSLATORS: the user asked to update everything, but there is nothing that +#. can be updated +#: ../client/pk-console.c:701 +msgid "There are no packages to update." +msgstr "Non hai paquetes que actualizar" + +#. TRANSLATORS: the transaction failed in a way we could not expect +#: ../client/pk-console.c:704 +#: ../contrib/command-not-found/pk-command-not-found.c:639 +msgid "The transaction failed" +msgstr "Produciuse un fallo durante a transacción" + +#. TRANSLATORS: print a message when there are no updates +#: ../client/pk-console.c:733 +msgid "There are no updates available at this time." +msgstr "Non hai actualizacións dispoñÃbeis neste momento" + +#: ../client/pk-console.c:756 +msgid "There are no upgrades available at this time." +msgstr "Non hai anovacións dispoñÃbeis neste momento" + +#. TRANSLATORS: a package needs to restart their system +#: ../client/pk-console.c:823 +msgid "Please restart the computer to complete the update." +msgstr "Reinicie o equipo para completar a actualización." + +#. TRANSLATORS: a package needs to restart the session +#: ../client/pk-console.c:826 +msgid "Please logout and login to complete the update." +msgstr "Peche a sesión e volva a entrar para completar a actualización." + +#. TRANSLATORS: a package needs to restart their system (due to security) +#: ../client/pk-console.c:829 +msgid "" +"Please restart the computer to complete the update as important security " +"updates have been installed." +msgstr "" +"Reinicie o equipo para completar a actualización, foi instalada unha " +"actualización de seguranza importante." + +#. TRANSLATORS: a package needs to restart the session (due to security) +#: ../client/pk-console.c:832 +msgid "" +"Please logout and login to complete the update as important security updates" +" have been installed." +msgstr "" +"Peche a sesión e volva a entrar para completar a actualización, foi " +"instalada unha actualización de seguranza importante." + +#. TRANSLATORS: The user used 'pkcon install dave.rpm' rather than 'pkcon +#. install-local dave.rpm' +#: ../client/pk-console.c:858 +#, c-format +msgid "" +"Expected package name, actually got file. Try using 'pkcon install-local %s'" +" instead." +msgstr "" +"Agardábase o nome dun paquete, mais obtÃvose un ficheiro. No seu canto tente" +" empregar «pkcon install-local %s»." + +#. TRANSLATORS: There was an error getting the list of files for the package. +#. The detailed error follows +#: ../client/pk-console.c:866 +#, c-format +msgid "This tool could not find any available package: %s" +msgstr "Esta ferramenta non foi quen de atopar ningún paquete dispoñÃbel: %s" + +#. TRANSLATORS: There was an error getting the list of files for the package. +#. The detailed error follows +#: ../client/pk-console.c:894 +#, c-format +msgid "This tool could not find the installed package: %s" +msgstr "Esta ferramenta non foi quen de atopar o paquete instalado: %s" + +#. TRANSLATORS: There was an error getting the list of files for the package. +#. The detailed error follows +#: ../client/pk-console.c:922 ../client/pk-console.c:950 +#, c-format +msgid "This tool could not find the package: %s" +msgstr "Esta ferramenta non foi quen de atopar o paquete: %s" + +#. TRANSLATORS: There was an error getting the list of files for the package. +#. The detailed error follows +#. TRANSLATORS: There was an error getting the dependencies for the package. +#. The detailed error follows +#. TRANSLATORS: There was an error getting the details about the package. The +#. detailed error follows +#. TRANSLATORS: The package name was not found in any software sources. The +#. detailed error follows +#: ../client/pk-console.c:978 ../client/pk-console.c:1006 +#: ../client/pk-console.c:1034 ../client/pk-console.c:1062 +#: ../client/pk-console.c:1090 +#, c-format +msgid "This tool could not find all the packages: %s" +msgstr "Esta ferramenta non foi quen de atopar todos os paquetes: %s" + +#. TRANSLATORS: This is when the daemon crashed, and we are up shit creek +#. without a paddle +#: ../client/pk-console.c:1119 +msgid "The daemon crashed mid-transaction!" +msgstr "O daemon estragouse no medio dunha transacción." + +#. TRANSLATORS: This is the header to the --help menu +#: ../client/pk-console.c:1153 +msgid "PackageKit Console Interface" +msgstr "Interface de consola de PackageKit" + +#. these are commands we can use with pkcon +#: ../client/pk-console.c:1155 +msgid "Subcommands:" +msgstr "Subordes:" + +#. TRANSLATORS: we keep a database updated with the time that an action was +#. last executed +#: ../client/pk-console.c:1234 +msgid "Failed to get the time since this action was last completed" +msgstr "" +"Produciuse un fallo ao obter a hora da última vez que se completou esta " +"acción" + +#. TRANSLATORS: command line argument, just show the version string +#: ../client/pk-console.c:1275 ../client/pk-monitor.c:371 +msgid "Show the program version and exit" +msgstr "Mostrar a versión do programa e saÃr" + +#. TRANSLATORS: command line argument, use a filter to narrow down results +#: ../client/pk-console.c:1278 +msgid "Set the filter, e.g. installed" +msgstr "Estabelecer o filtro, p.ex., instalado" + +#. TRANSLATORS: command line argument, use a non-standard install prefix +#: ../client/pk-console.c:1281 +msgid "Set the install root, e.g. '/' or '/mnt/ltsp'" +msgstr "Estabelecer a raÃz de instalación, p. ex., «/», ou «/mnt/ltsp»" + +#. TRANSLATORS: command line argument, work asynchronously +#: ../client/pk-console.c:1284 +msgid "Exit without waiting for actions to complete" +msgstr "SaÃr sen agardar a que se completen as accións" + +#. command line argument, do we ask questions +#: ../client/pk-console.c:1287 +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:525 +msgid "Install the packages without asking for confirmation" +msgstr "Instalar os paquetes sen pedir confirmación" + +#. TRANSLATORS: command line argument, this command is not a priority +#: ../client/pk-console.c:1290 +msgid "Run the command using idle network bandwidth and also using less power" +msgstr "Executa a orde empregando menos potencia, e o largo de banda libre" + +#. TRANSLATORS: command line argument, just output without fancy formatting +#: ../client/pk-console.c:1293 +msgid "" +"Print to screen a machine readable output, rather than using animated " +"widgets" +msgstr "" +"Imprime na pantalla unha saÃda lexÃbel por unha máquina, no canto de " +"empregar trebellos animados" + +#. TRANSLATORS: command line argument, just output without fancy formatting +#: ../client/pk-console.c:1296 +msgid "The maximum metadata cache age. Use -1 for 'never'." +msgstr "A idade máxima para a caché de metadatos. Usar -1 para «nunca»." + +#. TRANSLATORS: we failed to contact the daemon +#: ../client/pk-console.c:1333 +msgid "Failed to contact PackageKit" +msgstr "Produciuse un fallo ao contactar con PackageKit" + +#. TRANSLATORS: The user specified an incorrect filter +#: ../client/pk-console.c:1381 +msgid "The proxy could not be set" +msgstr "Non foi posÃbel definir o proxy" + +#. TRANSLATORS: The user specified an incorrect filter +#: ../client/pk-console.c:1393 +msgid "The install root could not be set" +msgstr "Non foi posÃbel definir a raÃz da instalación" + +#. TRANSLATORS: The user specified an incorrect filter +#: ../client/pk-console.c:1405 +msgid "The filter specified was invalid" +msgstr "O filtro especificado foi incorrecto" + +#. TRANSLATORS: a search type can be name, details, file, etc +#: ../client/pk-console.c:1424 +msgid "A search type is required, e.g. name" +msgstr "Precisase dun tipo de busca, p.ex. nome" + +#. TRANSLATORS: the user needs to provide a search term +#: ../client/pk-console.c:1431 ../client/pk-console.c:1443 +#: ../client/pk-console.c:1455 ../client/pk-console.c:1467 +msgid "A search term is required" +msgstr "RequÃrese un termo de busca" + +#. TRANSLATORS: the search type was provided, but invalid +#: ../client/pk-console.c:1477 +msgid "Invalid search type" +msgstr "Tipo de busca incorrecto" + +#. TRANSLATORS: the user did not specify what they wanted to install +#: ../client/pk-console.c:1483 +msgid "A package name to install is required" +msgstr "RequÃrese o nome do paquete a instalar" + +#. TRANSLATORS: the user did not specify what they wanted to install +#: ../client/pk-console.c:1492 +msgid "A filename to install is required" +msgstr "RequÃrese o nome do ficheiro a instalar" + +#. TRANSLATORS: geeky error, 99.9999% of users won't see this +#: ../client/pk-console.c:1503 +msgid "A type, key_id and package_id are required" +msgstr "RequÃrense o tipos key_id e package_id" + +#. TRANSLATORS: the user did not specify what they wanted to remove +#: ../client/pk-console.c:1514 +msgid "A package name to remove is required" +msgstr "RequÃrese o nome do paquete a retirar" + +#. TRANSLATORS: the user did not specify anything about what to download or +#. where +#: ../client/pk-console.c:1523 +msgid "A destination directory and the package names to download are required" +msgstr "" +"RequÃrense o directorio de destino e os nomes dos paquetes a descargar" + +#. TRANSLATORS: the directory does not exist, so we can't continue +#: ../client/pk-console.c:1530 +msgid "Directory not found" +msgstr "Non se atopou o directorio" + +#. TRANSLATORS: geeky error, 99.9999% of users won't see this +#: ../client/pk-console.c:1539 +msgid "A licence identifier (eula-id) is required" +msgstr "RequÃrese o identificador de licenza (eula-id)" + +#. TRANSLATORS: geeky error, 99.9999% of users won't see this +#: ../client/pk-console.c:1550 +msgid "A transaction identifier (tid) is required" +msgstr "RequÃrese o identificador de transacción (tid)" + +#. TRANSLATORS: The user did not specify a package name +#: ../client/pk-console.c:1571 +msgid "A package name to resolve is required" +msgstr "RequÃrese un nome de paquete para buscar" + +#. TRANSLATORS: The user did not specify a repository (software source) name +#: ../client/pk-console.c:1582 ../client/pk-console.c:1593 +msgid "A repository name is required" +msgstr "RequÃrese o nome do repositorio" + +#. TRANSLATORS: The user didn't provide any data +#: ../client/pk-console.c:1604 +msgid "A repo name, parameter and value are required" +msgstr "RequÃrese o nome do repositorio, o parámetro e o valor" + +#. TRANSLATORS: The user didn't specify what action to use +#: ../client/pk-console.c:1621 +msgid "An action, e.g. 'update-system' is required" +msgstr "RequÃrese unha acción, p.ex. «update-system»" + +#. TRANSLATORS: The user specified an invalid action +#: ../client/pk-console.c:1628 +msgid "A correct role is required" +msgstr "RequÃrese un rol correcto" + +#. TRANSLATORS: The user did not provide a package name +#. TRANSLATORS: This is when the user fails to supply the package name +#: ../client/pk-console.c:1638 ../client/pk-console.c:1652 +#: ../client/pk-console.c:1661 ../client/pk-console.c:1681 +#: ../client/pk-console.c:1690 ../client/pk-generate-pack.c:314 +msgid "A package name is required" +msgstr "RequÃrese un nome de paquete" + +#. TRANSLATORS: each package "provides" certain things, e.g. mime(gstreamer- +#. decoder-mp3), the user didn't specify it +#: ../client/pk-console.c:1670 +msgid "A package provide string is required" +msgstr "RequÃrese a cadea previda polo paquete" + +#. TRANSLATORS: The user did not provide a distro name +#: ../client/pk-console.c:1714 +msgid "A distribution name is required" +msgstr "RequÃrese o nome da distribución" + +#. TRANSLATORS: The user did not provide an upgrade type +#: ../client/pk-console.c:1720 +msgid "An upgrade type is required, e.g. 'minimal', 'default' or 'complete'" +msgstr "" +"RequÃrese un tipo de anovación. p.ex «mÃnimal», «default» ou «complete»." + +#. TRANSLATORS: The user tried to use an unsupported option on the command +#. line +#: ../client/pk-console.c:1770 +#, c-format +msgid "Option '%s' is not supported" +msgstr "A opción «%s» non está admitida" + +#. TRANSLATORS: Generic failure of what they asked to do +#: ../client/pk-console.c:1780 +msgid "Command failed" +msgstr "Fallou a orde" + +#. TRANSLATORS: we can exclude certain packages (glibc) when we know they'll +#. exist on the target +#: ../client/pk-generate-pack.c:253 +msgid "Set the file name of dependencies to be excluded" +msgstr "Estabeleza o nome do ficheiro de dependencias para excluÃr" + +#. TRANSLATORS: the output location +#: ../client/pk-generate-pack.c:256 +msgid "" +"The output file or directory (the current directory is used if omitted)" +msgstr "" +"O ficheiro ou directorio de saÃda (por omisión empregarase o actual " +"directorio)" + +#. TRANSLATORS: put a list of packages in the pack +#: ../client/pk-generate-pack.c:259 +msgid "The package to be put into the service pack" +msgstr "O paquete será posto no paquete de servizo" + +#. TRANSLATORS: put all pending updates in the pack +#: ../client/pk-generate-pack.c:262 +msgid "Put all updates available in the service pack" +msgstr "Pór todas as actualizacións dispoñÃbeis no paquete de servizo" + +#. TRANSLATORS: This is when the user fails to supply the correct arguments +#: ../client/pk-generate-pack.c:298 +msgid "Neither --package or --updates option selected." +msgstr "Non se seleccionou nin a opción --package nin --updates." + +#. TRANSLATORS: This is when the user fails to supply just one argument +#: ../client/pk-generate-pack.c:306 +msgid "Both options selected." +msgstr "Seleccionáronse ambas opcións." + +#. TRANSLATORS: This is when the user fails to supply the output +#: ../client/pk-generate-pack.c:322 +msgid "A output directory or file name is required" +msgstr "RequÃrese o nome do ficheiro ou directorio de saÃda" + +#. TRANSLATORS: This is when the daemon is not-installed/broken and fails to +#. startup +#: ../client/pk-generate-pack.c:340 +msgid "The daemon failed to startup" +msgstr "O daemon fallou ao iniciar" + +#. TRANSLATORS: This is when the backend doesn't have the capability to get- +#. depends +#. TRANSLATORS: This is when the backend doesn't have the capability to +#. download +#: ../client/pk-generate-pack.c:351 ../client/pk-generate-pack.c:357 +msgid "The package manager cannot perform this type of operation." +msgstr "O xestor de paquetes non é quen de realizar este tipo de operación." + +#. TRANSLATORS: This is when the distro didn't include libarchive support into +#. PK +#: ../client/pk-generate-pack.c:364 +msgid "" +"Service packs cannot be created as PackageKit was not built with libarchive " +"support." +msgstr "" +"Non é posÃbel crear paquetes de servizo xa que PackageKit non foi construÃdo" +" con compatibilidade con «libarchive»." + +#. TRANSLATORS: the user specified an absolute path, but didn't get the +#. extension correct +#: ../client/pk-generate-pack.c:375 +msgid "If specifying a file, the service pack name must end with" +msgstr "" +"Se especifica un ficheiro, o nome do paquete de servizo debe rematar con" + +#. TRANSLATORS: This is when file already exists +#: ../client/pk-generate-pack.c:391 +msgid "A pack with the same name already exists, do you want to overwrite it?" +msgstr "Xa existe un paquete con ese nome, desexa sobrescribilo?" + +#. TRANSLATORS: This is when the pack was not overwritten +#: ../client/pk-generate-pack.c:394 +msgid "The pack was not overwritten." +msgstr "Non se sobrescribiu o paquete." + +#. TRANSLATORS: This is when the temporary directory cannot be created, the +#. directory name follows +#: ../client/pk-generate-pack.c:407 +msgid "Failed to create directory:" +msgstr "Produciuse un fallo ao crear o directorio:" + +#. TRANSLATORS: This is when the list of packages from the remote computer +#. cannot be opened +#: ../client/pk-generate-pack.c:419 +msgid "Failed to open package list." +msgstr "Produciuse un fallo ao abrir a lista de paquetes." + +#. TRANSLATORS: The package name is being matched up to available packages +#: ../client/pk-generate-pack.c:428 +msgid "Finding package name." +msgstr "Buscando o nome de paquete." + +#. TRANSLATORS: This is when the package cannot be found in any software +#. source. The detailed error follows +#: ../client/pk-generate-pack.c:432 +#, c-format +msgid "Failed to find package '%s': %s" +msgstr "Produciuse un fallo ao buscar o paquete «%s»: %s" + +#. TRANSLATORS: This is telling the user we are in the process of making the +#. pack +#: ../client/pk-generate-pack.c:440 +msgid "Creating service pack..." +msgstr "Creando o paquete de servizo..." + +#. TRANSLATORS: we succeeded in making the file +#: ../client/pk-generate-pack.c:455 +#, c-format +msgid "Service pack created '%s'" +msgstr "Paquete de servizo «%s» creado" + +#. TRANSLATORS: we failed to make te file +#: ../client/pk-generate-pack.c:460 +#, c-format +msgid "Failed to create '%s': %s" +msgstr "Produciuse un fallo ao crear «%s»: %s" + +#: ../client/pk-monitor.c:284 +msgid "Failed to get daemon state" +msgstr "Produciuse un fallo ao obter o estado do daemon" + +#: ../client/pk-monitor.c:349 +msgid "Failed to get properties" +msgstr "Produciuse un fallo ao obter as propiedades" + +#. TRANSLATORS: this is a program that monitors PackageKit +#: ../client/pk-monitor.c:387 +msgid "PackageKit Monitor" +msgstr "Monitor de PackageKit" + +#. TRANSLATORS: when we are getting data from the daemon +#: ../contrib/browser-plugin/pk-plugin-install.c:499 +msgid "Getting package information..." +msgstr "Extraendo a información do paquete..." + +#. TRANSLATORS: run an applicaiton +#: ../contrib/browser-plugin/pk-plugin-install.c:505 +#, c-format +msgid "Run %s" +msgstr "Executar %s" + +#. TRANSLATORS: show the installed version of a package +#: ../contrib/browser-plugin/pk-plugin-install.c:511 +msgid "Installed version" +msgstr "Versión instalada" + +#. TRANSLATORS: run the application now +#: ../contrib/browser-plugin/pk-plugin-install.c:519 +#, c-format +msgid "Run version %s now" +msgstr "Executar agora a versión %s" + +#. TRANSLATORS: run the application now +#: ../contrib/browser-plugin/pk-plugin-install.c:525 +msgid "Run now" +msgstr "Executar agora" + +#. TRANSLATORS: update to a new version of the package +#: ../contrib/browser-plugin/pk-plugin-install.c:531 +#, c-format +msgid "Update to version %s" +msgstr "Actualizar á versión %s" + +#. TRANSLATORS: To install a package +#: ../contrib/browser-plugin/pk-plugin-install.c:537 +#, c-format +msgid "Install %s now" +msgstr "Instalar %s agora" + +#. TRANSLATORS: the version of the package +#: ../contrib/browser-plugin/pk-plugin-install.c:540 +msgid "Version" +msgstr "Versión" + +#. TRANSLATORS: noting found, so can't install +#: ../contrib/browser-plugin/pk-plugin-install.c:545 +msgid "No packages found for your system" +msgstr "Non se atopou ningún paquete para o seu sistema" + +#. TRANSLATORS: package is being installed +#: ../contrib/browser-plugin/pk-plugin-install.c:550 +msgid "Installing..." +msgstr "Instalando..." + +#. TRANSLATORS: downloading repo data so we can search +#: ../contrib/command-not-found/pk-command-not-found.c:366 +msgid "Downloading details about the software sources." +msgstr "Descargando detalles sobre as orixes de software" + +#. TRANSLATORS: downloading file lists so we can search +#: ../contrib/command-not-found/pk-command-not-found.c:370 +msgid "Downloading filelists (this may take some time to complete)." +msgstr "" +"Descargando listas de ficheiros (isto poderÃa tardar bastante tempo en " +"completarse)." + +#. TRANSLATORS: waiting for native lock +#: ../contrib/command-not-found/pk-command-not-found.c:374 +msgid "Waiting for package manager lock." +msgstr "Agardando polo bloqueo do xestor de paquetes." + +#. TRANSLATORS: loading package cache so we can search +#: ../contrib/command-not-found/pk-command-not-found.c:378 +msgid "Loading list of packages." +msgstr "Cargando listas de paquetes." + +#. TRANSLATORS: we failed to find the package, this shouldn't happen +#: ../contrib/command-not-found/pk-command-not-found.c:444 +msgid "Failed to search for file" +msgstr "Produciuse un fallo ao buscar o ficheiro" + +#. TRANSLATORS: the transaction failed in a way we could not expect +#: ../contrib/command-not-found/pk-command-not-found.c:456 +msgid "Getting the list of files failed" +msgstr "Produciuse un fallo ao obter a lista de ficheiros" + +#. TRANSLATORS: we failed to launch the executable, the error follows +#: ../contrib/command-not-found/pk-command-not-found.c:602 +msgid "Failed to launch:" +msgstr "Produciuse un fallo ao iniciar:" + +#. TRANSLATORS: we failed to install the package +#: ../contrib/command-not-found/pk-command-not-found.c:630 +msgid "Failed to install packages" +msgstr "Produciuse un fallo durante a instalación dos paquetes" + +#. TRANSLATORS: tool that gets called when the command is not found +#: ../contrib/command-not-found/pk-command-not-found.c:706 +msgid "PackageKit Command Not Found" +msgstr "Non se atopou a orde PackageKit" + +#. TRANSLATORS: the prefix of all the output telling the user +#. * why it's not executing. NOTE: this is lowercase to mimic +#. * the style of bash itself -- apologies +#: ../contrib/command-not-found/pk-command-not-found.c:739 +msgid "command not found" +msgstr "non se atopou a orde" + +#. TRANSLATORS: tell the user what we think the command is +#: ../contrib/command-not-found/pk-command-not-found.c:757 +msgid "Similar command is:" +msgstr "Unha orde similar é:" + +#. TRANSLATORS: Ask the user if we should run the similar command +#: ../contrib/command-not-found/pk-command-not-found.c:771 +msgid "Run similar command:" +msgstr "Executar unha orde similar:" + +#. TRANSLATORS: show the user a list of commands that they could have meant +#. TRANSLATORS: show the user a list of commands we could run +#: ../contrib/command-not-found/pk-command-not-found.c:785 +#: ../contrib/command-not-found/pk-command-not-found.c:794 +msgid "Similar commands are:" +msgstr "As ordes similares son:" + +#. TRANSLATORS: ask the user to choose a file to run +#: ../contrib/command-not-found/pk-command-not-found.c:801 +msgid "Please choose a command to run" +msgstr "Elixa unha orde para executar" + +#. TRANSLATORS: tell the user what package provides the command +#: ../contrib/command-not-found/pk-command-not-found.c:819 +msgid "The package providing this file is:" +msgstr "O paquete que fornece este ficheiro é:" + +#. TRANSLATORS: as the user if we want to install a package to provide the +#. command +#: ../contrib/command-not-found/pk-command-not-found.c:826 +#, c-format +msgid "Install package '%s' to provide command '%s'?" +msgstr "Instalar o paquete «%s» para fornecer a orde «%s»?" + +#. TRANSLATORS: Show the user a list of packages that provide this command +#: ../contrib/command-not-found/pk-command-not-found.c:853 +msgid "Packages providing this file are:" +msgstr "Os paquetes que fornecen este ficheiro son:" + +#. TRANSLATORS: Show the user a list of packages that they can install to +#. provide this command +#: ../contrib/command-not-found/pk-command-not-found.c:863 +msgid "Suitable packages are:" +msgstr "Os posÃbeis paquetes son:" + +#. get selection +#. TRANSLATORS: ask the user to choose a file to install +#: ../contrib/command-not-found/pk-command-not-found.c:872 +msgid "Please choose a package to install" +msgstr "Elixa un paquete para instalar" + +#. TRANSLATORS: we are starting to install the packages +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:195 +msgid "Starting install" +msgstr "Iniciando a instalación" + +#. TRANSLATORS: we couldn't find the package name, non-fatal +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:407 +#, c-format +msgid "Failed to find the package %s, or already installed: %s" +msgstr "" +"Non foi posÃbel atopar o paquete %s, é probábel que xa estea instalado: %s" + +#. command line argument, simulate what would be done, but don't actually do +#. it +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:516 +msgid "" +"Don't actually install any packages, only simulate what would be installed" +msgstr "Non se instala ningún paquete, só se indica cales serÃan instalados" + +#. command line argument, do we skip packages that depend on the ones +#. specified +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:519 +msgid "Do not install dependencies of the core packages" +msgstr "Non se instalan dependencias dos paquetes principais" + +#. command line argument, do we operate quietly +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:522 +msgid "Do not display information or progress" +msgstr "Non se mostra información nin progreso" + +#. TRANSLATORS: tool that gets called when the command is not found +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:540 +msgid "PackageKit Debuginfo Installer" +msgstr "Instalador de depuración de erros de PackageKit" + +#. TRANSLATORS: the use needs to specify a list of package names on the +#. command line +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:554 +#, c-format +msgid "ERROR: Specify package names to install." +msgstr "ERRO: Debe especificar os nomes dos paquetes a instalar." + +#. TRANSLATORS: we are getting the list of repositories +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:590 +#, c-format +msgid "Getting sources list" +msgstr "Obtendo a lista desde as orixes" + +#. TRANSLATORS: operation was not successful +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:600 +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:675 +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:759 +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:803 +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:870 +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:914 +msgid "FAILED." +msgstr "FALLOU." + +#. TRANSLATORS: all completed 100% +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:615 +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:655 +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:690 +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:774 +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:818 +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:885 +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:929 +#, c-format +msgid "OK." +msgstr "Aceptar." + +#. TRANSLATORS: tell the user what we found +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:618 +#, c-format +msgid "Found %i enabled and %i disabled sources." +msgstr "Atopáronse %i orixes activas e %i orixes desactivadas." + +#. TRANSLATORS: we're finding repositories that match out pattern +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:625 +#, c-format +msgid "Finding debugging sources" +msgstr "Buscando orixes para depuración" + +#. TRANSLATORS: tell the user what we found +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:658 +#, c-format +msgid "Found %i disabled debuginfo repos." +msgstr "Atopáronse %i repositorios desactivados para depuración." + +#. TRANSLATORS: we're now enabling all the debug sources we found +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:665 +#, c-format +msgid "Enabling debugging sources" +msgstr "Activando orixes para depuración" + +#. TRANSLATORS: tell the user how many we enabled +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:693 +#, c-format +msgid "Enabled %i debugging sources." +msgstr "Activáronse %i orixes para depuración." + +#. TRANSLATORS: we're now finding packages that match in all the repos +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:700 +#, c-format +msgid "Finding debugging packages" +msgstr "Buscando paquetes de depuración." + +#. TRANSLATORS: we couldn't find the package name, non-fatal +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:712 +#, c-format +msgid "Failed to find the package %s: %s" +msgstr "Produciuse un fallo ao buscar o paquete %s: %s" + +#. TRANSLATORS: we couldn't find the debuginfo package name, non-fatal +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:735 +#, c-format +msgid "Failed to find the debuginfo package %s: %s" +msgstr "Produciuse un fallo ao buscar o paquete de depuración %s: %s" + +#. TRANSLATORS: no debuginfo packages could be found to be installed +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:763 +#, c-format +msgid "Found no packages to install." +msgstr "Non se atoparon paquetes para instalar." + +#. TRANSLATORS: tell the user we found some packages, and then list them +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:777 +#, c-format +msgid "Found %i packages:" +msgstr "Atopáronse %i paquetes:" + +#. TRANSLATORS: tell the user we are searching for deps +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:793 +#, c-format +msgid "Finding packages that depend on these packages" +msgstr "Buscando paquetes que dependan deses paquetes." + +#. TRANSLATORS: could not install, detailed error follows +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:806 +#, c-format +msgid "Could not find dependant packages: %s" +msgstr "Non foi posÃbel atopar paquetes dependentes: %s" + +#. TRANSLATORS: tell the user we found some more packages +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:822 +#, c-format +msgid "Found %i extra packages." +msgstr "Atopáronse %i paquetes extra." + +#. TRANSLATORS: tell the user we found some more packages +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:826 +#, c-format +msgid "No extra packages required." +msgstr "Non son necesarios paquetes extra." + +#. TRANSLATORS: tell the user we found some packages (and deps), and then list +#. them +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:835 +#, c-format +msgid "Found %i packages to install:" +msgstr "Atopáronse %i paquetes para instalar:" + +#. TRANSLATORS: simulate mode is a testing mode where we quit before the +#. action +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:848 +#, c-format +msgid "Not installing packages in simulate mode" +msgstr "En modo simulación non se instalan paquetes" + +#. TRANSLATORS: we are now installing the debuginfo packages we found earlier +#. TRANSLATORS: transaction state, installing packages +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:860 +#: ../lib/packagekit-glib2/pk-console-shared.c:287 +#, c-format +msgid "Installing packages" +msgstr "Instalando os paquetes" + +#. TRANSLATORS: could not install, detailed error follows +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:873 +#, c-format +msgid "Could not install packages: %s" +msgstr "Non foi posÃbel instalar os paquetes: %s" + +#. TRANSLATORS: we are now disabling all debuginfo repos we previously enabled +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:905 +#, c-format +msgid "Disabling sources previously enabled" +msgstr "Desactivando orixes que foran activadas anteriormente" + +#. TRANSLATORS: no debuginfo packages could be found to be installed, detailed +#. error follows +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:917 +#, c-format +msgid "Could not disable the debugging sources: %s" +msgstr "Non é posÃbel desactivar as orixes para depuración:%s" + +#. TRANSLATORS: we disabled all the debugging repos that we enabled before +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:932 +#, c-format +msgid "Disabled %i debugging sources." +msgstr "Desactiváronse %i orixes para depuración." + +#. TRANSLATORS: couldn't open device to write +#: ../contrib/device-rebind/pk-device-rebind.c:62 +msgid "Failed to open file" +msgstr "Produciuse un fallo ao abrir o ficheiro" + +#. TRANSLATORS: could not write to the device +#: ../contrib/device-rebind/pk-device-rebind.c:71 +msgid "Failed to write to the file" +msgstr "Produciuse un fallo ao escribir no ficheiro" + +#. TRANSLATORS: we failed to release the current driver +#: ../contrib/device-rebind/pk-device-rebind.c:111 +#: ../contrib/device-rebind/pk-device-rebind.c:148 +msgid "Failed to write to device" +msgstr "Produciuse un fallo ao escribir no dispositivo" + +#. TRANSLATORS: the device could not be found in sysfs +#: ../contrib/device-rebind/pk-device-rebind.c:176 +msgid "Device could not be found" +msgstr "Non foi posÃbel atopar o dispositivo" + +#. TRANSLATORS: we failed to release the current driver +#: ../contrib/device-rebind/pk-device-rebind.c:203 +msgid "Failed to unregister driver" +msgstr "Produciuse un fallo ao quitar do rexistro o controlador" + +#. TRANSLATORS: we failed to bind the old driver +#: ../contrib/device-rebind/pk-device-rebind.c:212 +msgid "Failed to register driver" +msgstr "Produciuse un fallo ao rexistrar o controlador" + +#. TRANSLATORS: user did not specify a device sysfs path that exists +#: ../contrib/device-rebind/pk-device-rebind.c:261 +msgid "Device path not found" +msgstr "Non foi posÃbel atopar a ruta ao dispositivo" + +#. TRANSLATORS: user did not specify a valid device sysfs path +#: ../contrib/device-rebind/pk-device-rebind.c:269 +msgid "Incorrect device path specified" +msgstr "Especificouse unha ruta de dispositivo incorrecta" + +#: ../contrib/device-rebind/pk-device-rebind.c:294 +msgid "Show extra debugging information" +msgstr "Mostrar información adicional de depuración" + +#. command line argument, simulate what would be done, but don't actually do +#. it +#: ../contrib/device-rebind/pk-device-rebind.c:297 +msgid "Don't actually touch the hardware, only simulate what would be done" +msgstr "Non afecta ao hardware, só simula o que se farÃa" + +#. TRANSLATORS: command line option: a list of files to install +#: ../contrib/device-rebind/pk-device-rebind.c:300 +msgid "Device paths" +msgstr "Rutas de dispositivo" + +#. TRANSLATORS: tool that gets called when the device needs reloading after +#. installing firmware +#: ../contrib/device-rebind/pk-device-rebind.c:315 +msgid "PackageKit Device Reloader" +msgstr "Recargador de dispositivo de PackageKit" + +#. TRANSLATORS: user did not specify a valid device sysfs path +#: ../contrib/device-rebind/pk-device-rebind.c:323 +msgid "You need to specify at least one valid device path" +msgstr "Precisa especificar polo menos unha ruta de dispositivo correcta" + +#. TRANSLATORS: user did not specify a valid device sysfs path +#: ../contrib/device-rebind/pk-device-rebind.c:333 +msgid "This script can only be used by the root user" +msgstr "Este script só pode ser empregado polo usuario administrador (root)" + +#. TRANSLATORS: we're going to verify the path first +#: ../contrib/device-rebind/pk-device-rebind.c:342 +msgid "Verifying device path" +msgstr "Verificando a ruta ao dispositivo" + +#. TRANSLATORS: user did not specify a device sysfs path that exists +#: ../contrib/device-rebind/pk-device-rebind.c:347 +msgid "Failed to verify device path" +msgstr "Produciuse un fallo ao verificar a ruta do dispositivo" + +#. TRANSLATORS: we're going to try +#: ../contrib/device-rebind/pk-device-rebind.c:361 +msgid "Attempting to rebind device" +msgstr "Tentando volver a asociar o dispositivo" + +#. TRANSLATORS: we failed to release the current driver +#: ../contrib/device-rebind/pk-device-rebind.c:366 +msgid "Failed to rebind device" +msgstr "Produciuse un fallo ao volver a asociar o dispositivo" + +#: ../data/packagekit-catalog.xml.in.h:1 +msgid "PackageKit Catalog" +msgstr "Catálogo de PackageKit" + +#: ../data/packagekit-package-list.xml.in.h:1 +msgid "PackageKit Package List" +msgstr "Lista de paquetes de PackageKit" + +#: ../data/packagekit-servicepack.xml.in.h:1 +msgid "PackageKit Service Pack" +msgstr "Paquete de servizo de PackageKit" + +#: ../lib/packagekit-glib2/pk-console-shared.c:63 +#, c-format +msgid "Please enter a number from 1 to %i: " +msgstr "Introduza un número do 1 ao %i: " + +#. TRANSLATORS: more than one package could be found that matched, to follow +#. is a list of possible packages +#: ../lib/packagekit-glib2/pk-console-shared.c:189 +msgid "More than one package matches:" +msgstr "Coincide máis dun paquete:" + +#. TRANSLATORS: This finds out which package in the list to use +#: ../lib/packagekit-glib2/pk-console-shared.c:200 +msgid "Please choose the correct package: " +msgstr "Elixa o paquete correcto: " + +#. TRANSLATORS: This is when the transaction status is not known +#: ../lib/packagekit-glib2/pk-console-shared.c:255 +msgid "Unknown state" +msgstr "Estado descoñecido" + +#. TRANSLATORS: transaction state, the daemon is in the process of starting +#: ../lib/packagekit-glib2/pk-console-shared.c:259 +msgid "Starting" +msgstr "Comezando" + +#. TRANSLATORS: transaction state, the transaction is waiting for another to +#. complete +#: ../lib/packagekit-glib2/pk-console-shared.c:263 +msgid "Waiting in queue" +msgstr "Agardando na cola" + +#. TRANSLATORS: transaction state, just started +#: ../lib/packagekit-glib2/pk-console-shared.c:267 +msgid "Running" +msgstr "Executando" + +#. TRANSLATORS: transaction state, is querying data +#: ../lib/packagekit-glib2/pk-console-shared.c:271 +msgid "Querying" +msgstr "Consultando" + +#. TRANSLATORS: transaction state, getting data from a server +#: ../lib/packagekit-glib2/pk-console-shared.c:275 +msgid "Getting information" +msgstr "Obtendo información" + +#. TRANSLATORS: transaction state, removing packages +#: ../lib/packagekit-glib2/pk-console-shared.c:279 +msgid "Removing packages" +msgstr "Retirando paquetes" + +#. TRANSLATORS: transaction state, downloading package files +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:283 +#: ../lib/packagekit-glib2/pk-console-shared.c:661 +msgid "Downloading packages" +msgstr "Descargando os paquetes" + +#. TRANSLATORS: transaction state, refreshing internal lists +#: ../lib/packagekit-glib2/pk-console-shared.c:291 +msgid "Refreshing software list" +msgstr "Actualizando a lista de software" + +#. TRANSLATORS: transaction state, installing updates +#: ../lib/packagekit-glib2/pk-console-shared.c:295 +msgid "Installing updates" +msgstr "Instalando actualizacións" + +#. TRANSLATORS: transaction state, removing old packages, and cleaning config +#. files +#: ../lib/packagekit-glib2/pk-console-shared.c:299 +msgid "Cleaning up packages" +msgstr "Limpando paquetes" + +#. TRANSLATORS: transaction state, obsoleting old packages +#: ../lib/packagekit-glib2/pk-console-shared.c:303 +msgid "Obsoleting packages" +msgstr "Paquetes obsoletos" + +#. TRANSLATORS: transaction state, checking the transaction before we do it +#: ../lib/packagekit-glib2/pk-console-shared.c:307 +msgid "Resolving dependencies" +msgstr "Buscando as dependencias" + +#. TRANSLATORS: transaction state, checking if we have all the security keys +#. for the operation +#: ../lib/packagekit-glib2/pk-console-shared.c:311 +msgid "Checking signatures" +msgstr "Comprobando as sinaturas" + +#. TRANSLATORS: transaction state, when we return to a previous system state +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:315 +#: ../lib/packagekit-glib2/pk-console-shared.c:621 +msgid "Rolling back" +msgstr "Volvendo atrás" + +#. TRANSLATORS: transaction state, when we're doing a test transaction +#: ../lib/packagekit-glib2/pk-console-shared.c:319 +msgid "Testing changes" +msgstr "Probando os cambios" + +#. TRANSLATORS: transaction state, when we're writing to the system package +#. database +#: ../lib/packagekit-glib2/pk-console-shared.c:323 +msgid "Committing changes" +msgstr "Realizando os cambios" + +#. TRANSLATORS: transaction state, requesting data from a server +#: ../lib/packagekit-glib2/pk-console-shared.c:327 +msgid "Requesting data" +msgstr "Solicitando os datos" + +#. TRANSLATORS: transaction state, all done! +#: ../lib/packagekit-glib2/pk-console-shared.c:331 +msgid "Finished" +msgstr "Rematado" + +#. TRANSLATORS: transaction state, in the process of cancelling +#: ../lib/packagekit-glib2/pk-console-shared.c:335 +msgid "Cancelling" +msgstr "Cancelando" + +#. TRANSLATORS: transaction state, downloading metadata +#: ../lib/packagekit-glib2/pk-console-shared.c:339 +msgid "Downloading repository information" +msgstr "Descargando a información do repositorio" + +#. TRANSLATORS: transaction state, downloading metadata +#: ../lib/packagekit-glib2/pk-console-shared.c:343 +msgid "Downloading list of packages" +msgstr "Descargando a lista de paquetes" + +#. TRANSLATORS: transaction state, downloading metadata +#: ../lib/packagekit-glib2/pk-console-shared.c:347 +msgid "Downloading file lists" +msgstr "Descargando as listas de ficheiros" + +#. TRANSLATORS: transaction state, downloading metadata +#: ../lib/packagekit-glib2/pk-console-shared.c:351 +msgid "Downloading lists of changes" +msgstr "Descargando as lista de cambios" + +#. TRANSLATORS: transaction state, downloading metadata +#: ../lib/packagekit-glib2/pk-console-shared.c:355 +msgid "Downloading groups" +msgstr "Descargando os grupos" + +#. TRANSLATORS: transaction state, downloading metadata +#: ../lib/packagekit-glib2/pk-console-shared.c:359 +msgid "Downloading update information" +msgstr "Descargando a información da actualización" + +#. TRANSLATORS: transaction state, repackaging delta files +#: ../lib/packagekit-glib2/pk-console-shared.c:363 +msgid "Repackaging files" +msgstr "Empaquetando de novo os ficheiros" + +#. TRANSLATORS: transaction state, loading databases +#: ../lib/packagekit-glib2/pk-console-shared.c:367 +msgid "Loading cache" +msgstr "Cargando a caché" + +#. TRANSLATORS: transaction state, scanning for running processes +#: ../lib/packagekit-glib2/pk-console-shared.c:371 +msgid "Scanning applications" +msgstr "Escaneando aplicativos" + +#. TRANSLATORS: transaction state, generating a list of packages installed on +#. the system +#: ../lib/packagekit-glib2/pk-console-shared.c:375 +msgid "Generating package lists" +msgstr "Xerando as listas de paquetes" + +#. TRANSLATORS: transaction state, when we're waiting for the native tools to +#. exit +#: ../lib/packagekit-glib2/pk-console-shared.c:379 +msgid "Waiting for package manager lock" +msgstr "Agardando polo bloqueo do xestor de paquetes" + +#. TRANSLATORS: transaction state, waiting for user to type in a password +#: ../lib/packagekit-glib2/pk-console-shared.c:383 +msgid "Waiting for authentication" +msgstr "Agardando pola autenticación" + +#. TRANSLATORS: transaction state, we are updating the list of processes +#: ../lib/packagekit-glib2/pk-console-shared.c:387 +msgid "Updating running applications" +msgstr "Actualizando aplicativos executados" + +#. TRANSLATORS: transaction state, we are checking executable files currently +#. in use +#: ../lib/packagekit-glib2/pk-console-shared.c:391 +msgid "Checking applications in use" +msgstr "Comprobando aplicativos en uso" + +#. TRANSLATORS: transaction state, we are checking for libraries currently in +#. use +#: ../lib/packagekit-glib2/pk-console-shared.c:395 +msgid "Checking libraries in use" +msgstr "Comprobando bibliotecas en uso" + +#. TRANSLATORS: transaction state, we are copying package files before or +#. after the transaction +#: ../lib/packagekit-glib2/pk-console-shared.c:399 +msgid "Copying files" +msgstr "Copiando ficheiros" + +#. TRANSLATORS: The type of update +#: ../lib/packagekit-glib2/pk-console-shared.c:417 +msgid "Trivial" +msgstr "Trivial" + +#. TRANSLATORS: The type of update +#: ../lib/packagekit-glib2/pk-console-shared.c:421 +msgid "Normal" +msgstr "Normal" + +#. TRANSLATORS: The type of update +#: ../lib/packagekit-glib2/pk-console-shared.c:425 +msgid "Important" +msgstr "Importante" + +#. TRANSLATORS: The type of update +#: ../lib/packagekit-glib2/pk-console-shared.c:429 +msgid "Security" +msgstr "Seguranza" + +#. TRANSLATORS: The type of update +#: ../lib/packagekit-glib2/pk-console-shared.c:433 +msgid "Bug fix " +msgstr "Solución de erros " + +#. TRANSLATORS: The type of update +#: ../lib/packagekit-glib2/pk-console-shared.c:437 +msgid "Enhancement" +msgstr "Optimización" + +#. TRANSLATORS: The type of update +#: ../lib/packagekit-glib2/pk-console-shared.c:441 +msgid "Blocked" +msgstr "Bloqueado" + +#. TRANSLATORS: The state of a package +#. TRANSLATORS: The action of the package, in past tense +#: ../lib/packagekit-glib2/pk-console-shared.c:446 +#: ../lib/packagekit-glib2/pk-console-shared.c:519 +msgid "Installed" +msgstr "Instalado" + +#. TRANSLATORS: The state of a package, i.e. not installed +#: ../lib/packagekit-glib2/pk-console-shared.c:451 +msgid "Available" +msgstr "DispoñÃbel" + +#. TRANSLATORS: The action of the package, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:469 +msgid "Downloading" +msgstr "Descargando" + +#. TRANSLATORS: The action of the package, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:473 +msgid "Updating" +msgstr "Actualizando" + +#. TRANSLATORS: The action of the package, in present tense +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:477 +#: ../lib/packagekit-glib2/pk-console-shared.c:597 +msgid "Installing" +msgstr "Instalando" + +#. TRANSLATORS: The action of the package, in present tense +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:481 +#: ../lib/packagekit-glib2/pk-console-shared.c:593 +msgid "Removing" +msgstr "Retirando" + +#. TRANSLATORS: The action of the package, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:485 +msgid "Cleaning up" +msgstr "Limpando" + +#. TRANSLATORS: The action of the package, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:489 +msgid "Obsoleting" +msgstr "Marcando como obsoleto" + +#. TRANSLATORS: The action of the package, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:493 +msgid "Reinstalling" +msgstr "Reinstalando" + +#. TRANSLATORS: The action of the package, in past tense +#: ../lib/packagekit-glib2/pk-console-shared.c:511 +msgid "Downloaded" +msgstr "Descargado" + +#. TRANSLATORS: The action of the package, in past tense +#: ../lib/packagekit-glib2/pk-console-shared.c:523 +msgid "Removed" +msgstr "Retirado" + +#. TRANSLATORS: The action of the package, in past tense +#: ../lib/packagekit-glib2/pk-console-shared.c:527 +msgid "Cleaned up" +msgstr "Limpo" + +#. TRANSLATORS: The action of the package, in past tense +#: ../lib/packagekit-glib2/pk-console-shared.c:531 +msgid "Obsoleted" +msgstr "Obsoleto" + +#. TRANSLATORS: The action of the package, in past tense +#: ../lib/packagekit-glib2/pk-console-shared.c:535 +msgid "Reinstalled" +msgstr "Reinstalado" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:553 +msgid "Unknown role type" +msgstr "Tipo de rol descoñecido" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:557 +msgid "Getting dependencies" +msgstr "Obtendo as dependencias" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:561 +msgid "Getting update details" +msgstr "Obtendo detalles da actualización" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:565 +msgid "Getting details" +msgstr "Obtendo os detalles" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:569 +msgid "Getting requires" +msgstr "Obtendo os requisitos" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:573 +msgid "Getting updates" +msgstr "Obtendo as actualizacións" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:577 +msgid "Searching by details" +msgstr "Buscando por detalles" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:581 +msgid "Searching by file" +msgstr "Buscando por ficheiro" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:585 +msgid "Searching groups" +msgstr "Buscando os grupos" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:589 +msgid "Searching by name" +msgstr "Buscando por nome" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:601 +msgid "Installing files" +msgstr "Instalando ficheiros" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:605 +msgid "Refreshing cache" +msgstr "Actualizando a caché" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:609 +msgid "Updating packages" +msgstr "Actualizando os paquetes" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:613 +msgid "Updating system" +msgstr "Actualizando o sistema" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:617 +msgid "Canceling" +msgstr "Cancelando" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:625 +msgid "Getting repositories" +msgstr "Obtendo repositorios" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:629 +msgid "Enabling repository" +msgstr "Activando o repositorio" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:633 +msgid "Setting data" +msgstr "Configurando os datos" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:637 +msgid "Resolving" +msgstr "Resolvendo" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:641 +msgid "Getting file list" +msgstr "Obtendo a lista de ficheiros" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:645 +msgid "Getting provides" +msgstr "Obtendo o que fornece" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:649 +msgid "Installing signature" +msgstr "Instalando a sinatura" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:653 +msgid "Getting packages" +msgstr "Obtendo os paquetes" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:657 +msgid "Accepting EULA" +msgstr "Aceptando a EULA" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:665 +msgid "Getting upgrades" +msgstr "Obtendo anovacións" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:669 +msgid "Getting categories" +msgstr "Obtendo as categorÃas" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:673 +msgid "Getting transactions" +msgstr "Obtendo as transaccións" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:677 +#: ../lib/packagekit-glib2/pk-console-shared.c:681 +msgid "Simulating install" +msgstr "Simulando a instalación" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:685 +msgid "Simulating remove" +msgstr "Simulando a retirada" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:689 +msgid "Simulating update" +msgstr "Simulando a actualización" + +#. TRANSLATORS: turn on all debugging +#: ../lib/packagekit-glib2/pk-debug.c:133 +msgid "Show debugging information for all files" +msgstr "Mostrar a información de depuración para todos os ficheiros" + +#: ../lib/packagekit-glib2/pk-debug.c:201 +msgid "Debugging Options" +msgstr "Opcións de depuración" + +#: ../lib/packagekit-glib2/pk-debug.c:201 +msgid "Show debugging options" +msgstr "Mostrar as opcións de depuración" + +#. TRANSLATORS: ask the user if they are comfortable installing insecure +#. packages +#: ../lib/packagekit-glib2/pk-task-text.c:67 +msgid "Do you want to allow installing of unsigned software?" +msgstr "Desexa permitir a instalación de software que non estea asinado?" + +#. TRANSLATORS: tell the user we've not done anything +#: ../lib/packagekit-glib2/pk-task-text.c:72 +msgid "The unsigned software will not be installed." +msgstr "Non instalar o software non asinado." + +#. TRANSLATORS: the package repository is signed by a key that is not +#. recognised +#: ../lib/packagekit-glib2/pk-task-text.c:121 +msgid "Software source signature required" +msgstr "RequÃrese da sinatura da orixe do software" + +#. TRANSLATORS: the package repository name +#: ../lib/packagekit-glib2/pk-task-text.c:127 +msgid "Software source name" +msgstr "Nome da orixe do software" + +#. TRANSLATORS: the key URL +#: ../lib/packagekit-glib2/pk-task-text.c:130 +msgid "Key URL" +msgstr "URL da chave" + +#. TRANSLATORS: the username of the key +#: ../lib/packagekit-glib2/pk-task-text.c:133 +msgid "Key user" +msgstr "Usuario da chave" + +#. TRANSLATORS: the key ID, usually a few hex digits +#: ../lib/packagekit-glib2/pk-task-text.c:136 +msgid "Key ID" +msgstr "ID da chave" + +#. TRANSLATORS: the key fingerprint, again, yet more hex +#: ../lib/packagekit-glib2/pk-task-text.c:139 +msgid "Key fingerprint" +msgstr "Pegada da chave" + +#. TRANSLATORS: the timestamp (a bit like a machine readable time) +#: ../lib/packagekit-glib2/pk-task-text.c:142 +msgid "Key Timestamp" +msgstr "Data e hora da chave" + +#. TRANSLATORS: ask the user if they want to import +#: ../lib/packagekit-glib2/pk-task-text.c:155 +msgid "Do you accept this signature?" +msgstr "Acepta esta sinatura?" + +#. TRANSLATORS: tell the user we've not done anything +#: ../lib/packagekit-glib2/pk-task-text.c:160 +msgid "The signature was not accepted." +msgstr "A sinatura non foi aceptada." + +#. TRANSLATORS: this is another name for a software licence that has to be +#. read before installing +#: ../lib/packagekit-glib2/pk-task-text.c:203 +msgid "End user licence agreement required" +msgstr "Precisase do acordo de licenza de usuario final" + +#. TRANSLATORS: the EULA text itself (long and boring) +#: ../lib/packagekit-glib2/pk-task-text.c:212 +msgid "Agreement" +msgstr "Acordo" + +#. TRANSLATORS: ask the user if they've read and accepted the EULA +#: ../lib/packagekit-glib2/pk-task-text.c:221 +msgid "Do you accept this agreement?" +msgstr "Acepta este acordo?" + +#. TRANSLATORS: tell the user we've not done anything +#: ../lib/packagekit-glib2/pk-task-text.c:226 +msgid "The agreement was not accepted." +msgstr "O acordo non foi aceptado." + +#. TRANSLATORS: the user needs to change media inserted into the computer +#: ../lib/packagekit-glib2/pk-task-text.c:265 +msgid "Media change required" +msgstr "É necesario cambiar o soporte" + +#. TRANSLATORS: the type, e.g. DVD, CD, etc +#: ../lib/packagekit-glib2/pk-task-text.c:268 +msgid "Media type" +msgstr "Tipo de soporte" + +#. TRANSLATORS: the media label, usually like 'disk-1of3' +#: ../lib/packagekit-glib2/pk-task-text.c:271 +msgid "Media label" +msgstr "Etiqueta do soporte" + +#. TRANSLATORS: the media description, usually like 'Fedora 12 disk 5' +#: ../lib/packagekit-glib2/pk-task-text.c:274 +msgid "Text" +msgstr "Texto" + +#. TRANSLATORS: ask the user to insert the media +#: ../lib/packagekit-glib2/pk-task-text.c:280 +msgid "Please insert the correct media" +msgstr "Insira o soporte correcto" + +#. TRANSLATORS: tell the user we've not done anything as they are lazy +#: ../lib/packagekit-glib2/pk-task-text.c:285 +msgid "The correct media was not inserted." +msgstr "Non foi inserido o soporte correcto." + +#. TRANSLATORS: When processing, we might have to remove other dependencies +#: ../lib/packagekit-glib2/pk-task-text.c:300 +msgid "The following packages have to be removed:" +msgstr "Retiraranse os seguintes paquetes:" + +#. TRANSLATORS: When processing, we might have to install other dependencies +#: ../lib/packagekit-glib2/pk-task-text.c:305 +msgid "The following packages have to be installed:" +msgstr "Teñen de ser instalados os seguintes paquetes:" + +#. TRANSLATORS: When processing, we might have to update other dependencies +#: ../lib/packagekit-glib2/pk-task-text.c:310 +msgid "The following packages have to be updated:" +msgstr "Teñen de ser actualizados os seguintes paquetes:" + +#. TRANSLATORS: When processing, we might have to reinstall other dependencies +#: ../lib/packagekit-glib2/pk-task-text.c:315 +msgid "The following packages have to be reinstalled:" +msgstr "Teñen de ser reinstalados os seguintes paquetes:" + +#. TRANSLATORS: When processing, we might have to downgrade other dependencies +#: ../lib/packagekit-glib2/pk-task-text.c:320 +msgid "The following packages have to be downgraded:" +msgstr "Teñen de ser revertidos os seguintes paquetes:" + +#. TRANSLATORS: ask the user if the proposed changes are okay +#: ../lib/packagekit-glib2/pk-task-text.c:380 +msgid "Proceed with changes?" +msgstr "Proceder a facer as modificacións?" + +#. TRANSLATORS: tell the user we didn't do anything +#: ../lib/packagekit-glib2/pk-task-text.c:385 +msgid "The transaction did not proceed." +msgstr "Non foi posÃbel realizar a transacción." + +#. SECURITY: +#. - Normal users do not require admin authentication to accept new +#. licence agreements. +#. - Change this to 'auth_admin' for environments where users should not +#. be given the option to make legal decisions. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:7 +msgid "Accept EULA" +msgstr "Aceptar a EULA" + +#: ../policy/org.freedesktop.packagekit.policy.in.h:8 +msgid "Authentication is required to accept a EULA" +msgstr "RequÃrese a autenticación para aceptar unha EULA" + +#: ../policy/org.freedesktop.packagekit.policy.in.h:9 +msgid "" +"Authentication is required to cancel a task that was not started by yourself" +msgstr "" +"RequÃrese a autenticación para cancelar unha tarefa que non foi iniciada por" +" vostede." + +#: ../policy/org.freedesktop.packagekit.policy.in.h:10 +msgid "Authentication is required to change software source parameters" +msgstr "" +"RequÃrese a autenticación para cambiar os parámetros da orixe do software" + +#: ../policy/org.freedesktop.packagekit.policy.in.h:11 +msgid "" +"Authentication is required to change the location used to decompress " +"packages" +msgstr "" +"RequÃrese a autenticación para modificar a localización empregada para " +"descomprimir paquetes" + +#: ../policy/org.freedesktop.packagekit.policy.in.h:12 +msgid "" +"Authentication is required to consider a key used for signing packages as " +"trusted" +msgstr "" +"RequÃrese a autenticación para fiar nunha chave empregada para asinar " +"paquetes" + +#: ../policy/org.freedesktop.packagekit.policy.in.h:13 +msgid "Authentication is required to install a signed package" +msgstr "RequÃrese a autenticación para instalar un paquete asinado" + +#: ../policy/org.freedesktop.packagekit.policy.in.h:14 +msgid "Authentication is required to install an untrusted package" +msgstr "RequÃrese a autenticación para instalar un paquete non fiábel" + +#: ../policy/org.freedesktop.packagekit.policy.in.h:15 +msgid "Authentication is required to refresh the system sources" +msgstr "RequÃrese a autenticación para actualizar as fontes do sistema" + +#: ../policy/org.freedesktop.packagekit.policy.in.h:16 +msgid "Authentication is required to reload the device with a new driver" +msgstr "" +"RequÃrese a autenticación para recargar o dispositivo cun controlador novo" + +#: ../policy/org.freedesktop.packagekit.policy.in.h:17 +msgid "Authentication is required to remove packages" +msgstr "RequÃrese a autenticación para retirar paquetes" + +#: ../policy/org.freedesktop.packagekit.policy.in.h:18 +msgid "Authentication is required to rollback a transaction" +msgstr "RequÃrese a autenticación para desfacer una transacción" + +#: ../policy/org.freedesktop.packagekit.policy.in.h:19 +msgid "" +"Authentication is required to set the network proxy used for downloading " +"packages" +msgstr "" +"RequÃrese a autenticación para cambiar o proxy de rede empregado para " +"descargar paquetes" + +#: ../policy/org.freedesktop.packagekit.policy.in.h:20 +msgid "Authentication is required to update packages" +msgstr "RequÃrese a autenticación para actualizar paquetes" + +#: ../policy/org.freedesktop.packagekit.policy.in.h:21 +msgid "Authentication is required to upgrade the operating system" +msgstr "RequÃrese a autenticación para actualizar o sistema operativo" + +#. SECURITY: +#. - Normal users are allowed to cancel their own task without +#. authentication, but a different user id needs the admin password +#. to cancel another users task. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:27 +msgid "Cancel foreign task" +msgstr "Cancelar tarefa externa" + +#. SECURITY: +#. - This is used when users want to install to a different prefix, for +#. instance to a LTSP image or a virtual machine. +#. - This could be used to overwrite files not owned by the user using +#. a carefully created package file. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:34 +msgid "Change location that packages are installed" +msgstr "Cambiar a localización onde instalar os paquetes" + +#. SECURITY: +#. - Normal users require admin authentication to enable or disable +#. software sources as this can be used to enable new updates or +#. install different versions of software. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:40 +msgid "Change software source parameters" +msgstr "Cambiar os parámetros da orixe do software" + +#. SECURITY: +#. - Normal users do not need authentication to install signed packages +#. from signed repositories, as this cannot exploit a system. +#. - Paranoid users (or parents!) can change this to 'auth_admin' or +#. 'auth_admin_keep'. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:47 +msgid "Install signed package" +msgstr "Instalar paquete asinado" + +#. SECURITY: +#. - Normal users require admin authentication to install untrusted or +#. unrecognised packages, as allowing users to do this without a +#. password would be a massive security hole. +#. - This is not retained as each package should be authenticated. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:54 +msgid "Install untrusted local file" +msgstr "Instalar un ficheiro local sen confianza" + +#. SECURITY: +#. - Normal users do not require admin authentication to refresh the +#. cache, as this doesn't actually install or remove software. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:59 +msgid "Refresh system sources" +msgstr "Actualizar as orixes do sistema" + +#. SECURITY: +#. - Normal users require admin authentication to rebind a driver +#. so that it works after we install firmware. +#. - This should not be set to 'yes' as unprivileged users could then +#. try to rebind drivers in use, for instance security authentication +#. devices. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:67 +msgid "Reload a device" +msgstr "Recargar un dispositivo" + +#. SECURITY: +#. - Normal users require admin authentication to remove packages as +#. this can make the system unbootable or stop other applications from +#. working. +#. - Be sure to close the tool used to remove the packages after the +#. admin authentication has been obtained, otherwise packages can still +#. be removed. If this is not possible, change this authentication to +#. 'auth_admin'. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:77 +msgid "Remove package" +msgstr "Retirar paquete" + +#. SECURITY: +#. - Normal users require admin authentication to rollback system state +#. as this will change a large number of packages, and could expose the +#. system to previously patched security vulnerabilities. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:83 +msgid "Rollback to a previous transaction" +msgstr "Desfacer ata unha transacción anterior" + +#. SECURITY: +#. - Normal users do not require admin authentication to set the proxy +#. used for downloading packages. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:88 +msgid "Set network proxy" +msgstr "Estabelecer o proxy da rede" + +#. SECURITY: +#. - Normal users require admin authentication to add signing keys. +#. - This implies adding an explicit trust, and should not be granted +#. without a secure authentication. +#. - This is not kept as each package should be authenticated. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:95 +msgid "Trust a key used for signing packages" +msgstr "Confiar nunha chave empregada para asinar paquetes" + +#. SECURITY: +#. - Normal users do not require admin authentication to update the +#. system as the packages will be signed, and the action is required +#. to update the system when unattended. +#. - Changing this to anything other than 'yes' will break unattended +#. updates. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:103 +msgid "Update packages" +msgstr "Actualizar paquetes" + +#. SECURITY: +#. - Normal users require admin authentication to upgrade the disto as +#. this can make the system unbootable or stop other applications from +#. working. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:109 +msgid "Upgrade System" +msgstr "Actualizar sistema" + +#. TRANSLATORS: failed due to DBus security +#: ../src/pk-main.c:87 +msgid "Startup failed due to security policies on this machine." +msgstr "O arranque fallou debido ás polÃticas de seguranza nesta máquina." + +#. TRANSLATORS: only two ways this can fail... +#: ../src/pk-main.c:89 +msgid "This can happen for two reasons:" +msgstr "Isto pode acontecer por dúas razóns:" + +#. TRANSLATORS: only allowed to be owned by root +#: ../src/pk-main.c:91 +msgid "The correct user is not launching the executable (usually root)" +msgstr "O usuario correcto non esta iniciando o executábel (xeralmente root)" + +#. TRANSLATORS: or we are installed in a prefix +#: ../src/pk-main.c:93 +msgid "" +"The org.freedesktop.PackageKit.conf file is not installed in the system " +"directory:" +msgstr "" +"O ficheiro org.freedesktop.PackageKit.conf non está instalado no directorio " +"do sistema:" + +#. TRANSLATORS: a backend is the system package tool, e.g. yum, apt +#: ../src/pk-main.c:200 +msgid "Packaging backend to use, e.g. dummy" +msgstr "Administrador de paquetes que usar, p.ex., dummy" + +#. TRANSLATORS: if we should run in the background +#: ../src/pk-main.c:203 +msgid "Daemonize and detach from the terminal" +msgstr "Daemonizar e desacoplar do terminal" + +#. TRANSLATORS: if we should not monitor how long we are inactive for +#: ../src/pk-main.c:206 +msgid "Disable the idle timer" +msgstr "Desactivar o contador de inactividade" + +#. TRANSLATORS: show version +#: ../src/pk-main.c:209 +msgid "Show version and exit" +msgstr "Mostrar a versión e saÃr" + +#. TRANSLATORS: exit after we've started up, used for user profiling +#: ../src/pk-main.c:212 +msgid "Exit after a small delay" +msgstr "SaÃr despois dunha pequena pausa" + +#. TRANSLATORS: exit straight away, used for automatic profiling +#: ../src/pk-main.c:215 +msgid "Exit after the engine has loaded" +msgstr "SaÃr despois de que o motor estea cargado" + +#. TRANSLATORS: describing the service that is running +#: ../src/pk-main.c:230 +msgid "PackageKit service" +msgstr "Servizo PackageKit" + +#. TRANSLATORS: fatal error, dbus is not running +#: ../src/pk-main.c:267 +msgid "Cannot connect to the system bus" +msgstr "Non se pode conectar ao bus do sistema" + +#. TRANSLATORS: cannot register on system bus, unknown reason -- geeky error +#. follows +#: ../src/pk-main.c:316 +msgid "Error trying to start:" +msgstr "Produciuse un erro tentando iniciar:" + +#: ../src/pk-polkit-action-lookup.c:150 +msgid "To install debugging packages, extra sources need to be enabled" +msgstr "" +"Para poder instalar paquetes de depuración, é necesario activar novas orixes" + +#. TRANSLATORS: is not GPG signed +#: ../src/pk-polkit-action-lookup.c:171 ../src/pk-polkit-action-lookup.c:190 +msgid "The software is not from a trusted source." +msgstr "O software non proven dunha orixe de confianza." + +#: ../src/pk-polkit-action-lookup.c:176 +msgid "Do not update this package unless you are sure it is safe to do so." +msgstr "" +"Non actualice este paquete a non ser que saiba con certeza que é seguro " +"facelo." + +#: ../src/pk-polkit-action-lookup.c:177 +msgid "Do not update these packages unless you are sure it is safe to do so." +msgstr "" +"Non actualice estes paquetes a non ser que saiba con certeza que é seguro " +"facelo." + +#: ../src/pk-polkit-action-lookup.c:195 +msgid "Do not install this package unless you are sure it is safe to do so." +msgstr "" +"Non instale este paquete a non ser que saiba con certeza que é seguro " +"facelo." + +#: ../src/pk-polkit-action-lookup.c:196 +msgid "Do not install these packages unless you are sure it is safe to do so." +msgstr "" +"Non instale estes paquetes a non ser que saiba con certeza que é seguro " +"facelo." + +#. TRANSLATORS: too many packages to list each one +#: ../src/pk-polkit-action-lookup.c:273 +msgid "Many packages" +msgstr "Varios paquetes" + +#. TRANSLATORS: if the transaction is forced to install only trusted packages +#: ../src/pk-polkit-action-lookup.c:339 +msgid "Only trusted" +msgstr "Só os de confianza" diff --git a/po/it_IT.po b/po/it_IT.po new file mode 100644 index 000000000..7a936adc6 --- /dev/null +++ b/po/it_IT.po @@ -0,0 +1,2105 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: PackageKit\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-12-13 12:23+0000\n" +"PO-Revision-Date: 2011-03-04 18:34+0000\n" +"Last-Translator: ElleUca <elle.uca@libero.it>\n" +"Language-Team: LANGUAGE <LL@li.org>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: it_IT\n" +"Plural-Forms: nplurals=2; plural=(n != 1)\n" + +#. TRANSLATORS: this is an atomic transaction +#. TRANSLATORS: the role is the point of the transaction, e.g. update-system +#: ../client/pk-console.c:174 ../client/pk-console.c:596 +msgid "Transaction" +msgstr "Transazione" + +#. TRANSLATORS: this is the time the transaction was started in system +#. timezone +#: ../client/pk-console.c:176 +msgid "System time" +msgstr "Ora di sistema" + +#. TRANSLATORS: this is if the transaction succeeded or not +#: ../client/pk-console.c:178 +msgid "Succeeded" +msgstr "Riuscito" + +#: ../client/pk-console.c:178 +msgid "True" +msgstr "Vero" + +#: ../client/pk-console.c:178 +msgid "False" +msgstr "Falso" + +#. TRANSLATORS: this is the transactions role, e.g. "update-system" +#. TRANSLATORS: the trasaction role, e.g. update-system +#: ../client/pk-console.c:180 ../src/pk-polkit-action-lookup.c:332 +msgid "Role" +msgstr "Ruolo" + +#. TRANSLATORS: this is The duration of the transaction +#: ../client/pk-console.c:185 +msgid "Duration" +msgstr "Durata" + +#: ../client/pk-console.c:185 +msgid "(seconds)" +msgstr "(secondi)" + +#. TRANSLATORS: this is The command line used to do the action +#. TRANSLATORS: the command line of the thing that wants the authentication +#: ../client/pk-console.c:189 ../src/pk-polkit-action-lookup.c:346 +msgid "Command line" +msgstr "Riga di comando" + +#. TRANSLATORS: this is the user ID of the user that started the action +#: ../client/pk-console.c:191 +msgid "User ID" +msgstr "ID utente" + +#. TRANSLATORS: this is the username, e.g. hughsie +#: ../client/pk-console.c:198 +msgid "Username" +msgstr "Nome utente" + +#. TRANSLATORS: this is the users real name, e.g. "Richard Hughes" +#: ../client/pk-console.c:202 +msgid "Real name" +msgstr "Nome reale" + +#: ../client/pk-console.c:210 +msgid "Affected packages:" +msgstr "Pacchetti interessati:" + +#: ../client/pk-console.c:212 +msgid "Affected packages: None" +msgstr "Pacchetti interessati: nessuno" + +#. TRANSLATORS: this is the distro, e.g. Fedora 10 +#: ../client/pk-console.c:247 +msgid "Distribution" +msgstr "Distribuzione" + +#. TRANSLATORS: this is type of update, stable or testing +#: ../client/pk-console.c:249 +msgid "Type" +msgstr "Tipo" + +#. TRANSLATORS: this is any summary text describing the upgrade +#. TRANSLATORS: this is the summary of the group +#: ../client/pk-console.c:251 ../client/pk-console.c:290 +msgid "Summary" +msgstr "Sommario" + +#. TRANSLATORS: this is the group category name +#: ../client/pk-console.c:279 +msgid "Category" +msgstr "Categoria" + +#. TRANSLATORS: this is group identifier +#: ../client/pk-console.c:281 +msgid "ID" +msgstr "ID" + +#. TRANSLATORS: this is the parent group +#: ../client/pk-console.c:284 +msgid "Parent" +msgstr "Genitore" + +#. TRANSLATORS: this is the name of the parent group +#: ../client/pk-console.c:287 +msgid "Name" +msgstr "Nome" + +#. TRANSLATORS: this is preferred icon for the group +#: ../client/pk-console.c:293 +msgid "Icon" +msgstr "Icona" + +#. TRANSLATORS: this is a header for the package that can be updated +#: ../client/pk-console.c:339 +msgid "Details about the update:" +msgstr "Dettagli sull'aggiornamento:" + +#. TRANSLATORS: details about the update, package name and version +#. TRANSLATORS: the package that is being processed +#. TRANSLATORS: the package that is not signed by a known key +#. TRANSLATORS: the package name that was trying to be installed +#. TRANSLATORS: title, the names of the packages that the method is processing +#: ../client/pk-console.c:345 ../client/pk-console.c:615 +#: ../lib/packagekit-glib2/pk-task-text.c:124 +#: ../lib/packagekit-glib2/pk-task-text.c:206 +#: ../src/pk-polkit-action-lookup.c:357 +msgid "Package" +msgid_plural "Packages" +msgstr[0] "Pacchetto" +msgstr[1] "Pacchetti" + +#. TRANSLATORS: details about the update, any packages that this update +#. updates +#: ../client/pk-console.c:348 +msgid "Updates" +msgstr "Aggiornamenti" + +#. TRANSLATORS: details about the update, any packages that this update +#. obsoletes +#: ../client/pk-console.c:352 +msgid "Obsoletes" +msgstr "Obsoleti" + +#. TRANSLATORS: details about the update, the vendor URLs +#. TRANSLATORS: the vendor (e.g. vmware) that is providing the EULA +#: ../client/pk-console.c:356 ../lib/packagekit-glib2/pk-task-text.c:209 +msgid "Vendor" +msgstr "Vendor" + +#. TRANSLATORS: details about the update, the bugzilla URLs +#: ../client/pk-console.c:360 +msgid "Bugzilla" +msgstr "Bugzilla" + +#. TRANSLATORS: details about the update, the CVE URLs +#: ../client/pk-console.c:364 +msgid "CVE" +msgstr "CVE" + +#. TRANSLATORS: details about the update, if the package requires a restart +#: ../client/pk-console.c:368 +msgid "Restart" +msgstr "Riavvia" + +#. TRANSLATORS: details about the update, any description of the update +#: ../client/pk-console.c:372 +msgid "Update text" +msgstr "Testo dell'aggiornamento" + +#. TRANSLATORS: details about the update, the changelog for the package +#: ../client/pk-console.c:376 +msgid "Changes" +msgstr "Cambiamenti" + +#. TRANSLATORS: details about the update, the ongoing state of the update +#: ../client/pk-console.c:380 +msgid "State" +msgstr "Stato" + +#. TRANSLATORS: details about the update, date the update was issued +#: ../client/pk-console.c:384 +msgid "Issued" +msgstr "" + +#. TRANSLATORS: details about the update, date the update was updated +#. TRANSLATORS: The action of the package, in past tense +#: ../client/pk-console.c:388 ../lib/packagekit-glib2/pk-console-shared.c:515 +msgid "Updated" +msgstr "Aggiornato" + +#. TRANSLATORS: if the repo is enabled +#: ../client/pk-console.c:424 +msgid "Enabled" +msgstr "Abilitato" + +#. TRANSLATORS: if the repo is disabled +#: ../client/pk-console.c:427 +msgid "Disabled" +msgstr "Disabilitato" + +#. TRANSLATORS: a package requires the system to be restarted +#: ../client/pk-console.c:459 +msgid "System restart required by:" +msgstr "Riavvio del sistema richiesto da:" + +#. TRANSLATORS: a package requires the session to be restarted +#: ../client/pk-console.c:462 +msgid "Session restart required:" +msgstr "Riavvio della sessione richiesto da:" + +#. TRANSLATORS: a package requires the system to be restarted due to a +#. security update +#: ../client/pk-console.c:465 +msgid "System restart (security) required by:" +msgstr "Riavvio del sistema (sicurezza) richiesto da:" + +#. TRANSLATORS: a package requires the session to be restarted due to a +#. security update +#: ../client/pk-console.c:468 +msgid "Session restart (security) required:" +msgstr "Riavvio della sessione (sicurezza) richiesto da:" + +#. TRANSLATORS: a package requires the application to be restarted +#: ../client/pk-console.c:471 +msgid "Application restart required by:" +msgstr "Riavvio dell'applicazione richesto da:" + +#. TRANSLATORS: This a list of details about the package +#: ../client/pk-console.c:506 +msgid "Package description" +msgstr "Descrizione del pacchetto:" + +#. TRANSLATORS: This a message (like a little note that may be of interest) +#. from the transaction +#: ../client/pk-console.c:537 +msgid "Message:" +msgstr "Messaggio:" + +#. TRANSLATORS: This where the package has no files +#: ../client/pk-console.c:558 +msgid "No files" +msgstr "Nessun file" + +#. TRANSLATORS: This a list files contained in the package +#: ../client/pk-console.c:563 +msgid "Package files" +msgstr "File del pacchetto" + +#. TRANSLATORS: the percentage complete of the transaction +#: ../client/pk-console.c:631 +msgid "Percentage" +msgstr "Percentuale" + +#. TRANSLATORS: the status of the transaction (e.g. downloading) +#: ../client/pk-console.c:649 +msgid "Status" +msgstr "Stato" + +#. TRANSLATORS: the results from the transaction +#: ../client/pk-console.c:678 +msgid "Results:" +msgstr "Risultati:" + +#. TRANSLATORS: we failed to get any results, which is pretty fatal in my book +#: ../client/pk-console.c:685 +msgid "Fatal error" +msgstr "" + +#. TRANSLATORS: the user asked to update everything, but there is nothing that +#. can be updated +#: ../client/pk-console.c:701 +msgid "There are no packages to update." +msgstr "Non c'è alcun pacchetto da aggiornare." + +#. TRANSLATORS: the transaction failed in a way we could not expect +#: ../client/pk-console.c:704 +#: ../contrib/command-not-found/pk-command-not-found.c:639 +msgid "The transaction failed" +msgstr "La transazione non è riuscita" + +#. TRANSLATORS: print a message when there are no updates +#: ../client/pk-console.c:733 +msgid "There are no updates available at this time." +msgstr "Al momento non c'è alcun aggiornamento disponibile." + +#: ../client/pk-console.c:756 +msgid "There are no upgrades available at this time." +msgstr "Al momento non c'è alcun avanzamento disponibile." + +#. TRANSLATORS: a package needs to restart their system +#: ../client/pk-console.c:823 +msgid "Please restart the computer to complete the update." +msgstr "Riavviare il computer per completare l'aggiornamento" + +#. TRANSLATORS: a package needs to restart the session +#: ../client/pk-console.c:826 +msgid "Please logout and login to complete the update." +msgstr "Terminare la sessione e riaccedere per completare l'aggiornamento." + +#. TRANSLATORS: a package needs to restart their system (due to security) +#: ../client/pk-console.c:829 +msgid "" +"Please restart the computer to complete the update as important security " +"updates have been installed." +msgstr "" +"Riavviare il computer per completare l'aggiornamento, poiché sono stati " +"installi importanti aggiornamenti di sicurezza." + +#. TRANSLATORS: a package needs to restart the session (due to security) +#: ../client/pk-console.c:832 +msgid "" +"Please logout and login to complete the update as important security updates" +" have been installed." +msgstr "" +"Terminare la sessione e riaccedere per completare l'aggiornamento, poiché " +"sono stati installi importanti aggiornamenti di sicurezza." + +#. TRANSLATORS: The user used 'pkcon install dave.rpm' rather than 'pkcon +#. install-local dave.rpm' +#: ../client/pk-console.c:858 +#, c-format +msgid "" +"Expected package name, actually got file. Try using 'pkcon install-local %s'" +" instead." +msgstr "" +"Atteso un nome di pacchetto, ottenuto un file. Provare ad usare invece " +"\"pkcon install-local %s\"" + +#. TRANSLATORS: There was an error getting the list of files for the package. +#. The detailed error follows +#: ../client/pk-console.c:866 +#, c-format +msgid "This tool could not find any available package: %s" +msgstr "" +"Questo strumento non è riuscito a trovare alcun pacchetto disponibile: %s" + +#. TRANSLATORS: There was an error getting the list of files for the package. +#. The detailed error follows +#: ../client/pk-console.c:894 +#, c-format +msgid "This tool could not find the installed package: %s" +msgstr "" + +#. TRANSLATORS: There was an error getting the list of files for the package. +#. The detailed error follows +#: ../client/pk-console.c:922 ../client/pk-console.c:950 +#, c-format +msgid "This tool could not find the package: %s" +msgstr "" + +#. TRANSLATORS: There was an error getting the list of files for the package. +#. The detailed error follows +#. TRANSLATORS: There was an error getting the dependencies for the package. +#. The detailed error follows +#. TRANSLATORS: There was an error getting the details about the package. The +#. detailed error follows +#. TRANSLATORS: The package name was not found in any software sources. The +#. detailed error follows +#: ../client/pk-console.c:978 ../client/pk-console.c:1006 +#: ../client/pk-console.c:1034 ../client/pk-console.c:1062 +#: ../client/pk-console.c:1090 +#, c-format +msgid "This tool could not find all the packages: %s" +msgstr "" + +#. TRANSLATORS: This is when the daemon crashed, and we are up shit creek +#. without a paddle +#: ../client/pk-console.c:1119 +msgid "The daemon crashed mid-transaction!" +msgstr "" + +#. TRANSLATORS: This is the header to the --help menu +#: ../client/pk-console.c:1153 +msgid "PackageKit Console Interface" +msgstr "" + +#. these are commands we can use with pkcon +#: ../client/pk-console.c:1155 +msgid "Subcommands:" +msgstr "" + +#. TRANSLATORS: we keep a database updated with the time that an action was +#. last executed +#: ../client/pk-console.c:1234 +msgid "Failed to get the time since this action was last completed" +msgstr "" + +#. TRANSLATORS: command line argument, just show the version string +#: ../client/pk-console.c:1275 ../client/pk-monitor.c:371 +msgid "Show the program version and exit" +msgstr "" + +#. TRANSLATORS: command line argument, use a filter to narrow down results +#: ../client/pk-console.c:1278 +msgid "Set the filter, e.g. installed" +msgstr "" + +#. TRANSLATORS: command line argument, use a non-standard install prefix +#: ../client/pk-console.c:1281 +msgid "Set the install root, e.g. '/' or '/mnt/ltsp'" +msgstr "" + +#. TRANSLATORS: command line argument, work asynchronously +#: ../client/pk-console.c:1284 +msgid "Exit without waiting for actions to complete" +msgstr "" + +#. command line argument, do we ask questions +#: ../client/pk-console.c:1287 +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:525 +msgid "Install the packages without asking for confirmation" +msgstr "" + +#. TRANSLATORS: command line argument, this command is not a priority +#: ../client/pk-console.c:1290 +msgid "Run the command using idle network bandwidth and also using less power" +msgstr "" + +#. TRANSLATORS: command line argument, just output without fancy formatting +#: ../client/pk-console.c:1293 +msgid "" +"Print to screen a machine readable output, rather than using animated " +"widgets" +msgstr "" + +#. TRANSLATORS: command line argument, just output without fancy formatting +#: ../client/pk-console.c:1296 +msgid "The maximum metadata cache age. Use -1 for 'never'." +msgstr "" + +#. TRANSLATORS: we failed to contact the daemon +#: ../client/pk-console.c:1333 +msgid "Failed to contact PackageKit" +msgstr "" + +#. TRANSLATORS: The user specified an incorrect filter +#: ../client/pk-console.c:1381 +msgid "The proxy could not be set" +msgstr "" + +#. TRANSLATORS: The user specified an incorrect filter +#: ../client/pk-console.c:1393 +msgid "The install root could not be set" +msgstr "" + +#. TRANSLATORS: The user specified an incorrect filter +#: ../client/pk-console.c:1405 +msgid "The filter specified was invalid" +msgstr "" + +#. TRANSLATORS: a search type can be name, details, file, etc +#: ../client/pk-console.c:1424 +msgid "A search type is required, e.g. name" +msgstr "" + +#. TRANSLATORS: the user needs to provide a search term +#: ../client/pk-console.c:1431 ../client/pk-console.c:1443 +#: ../client/pk-console.c:1455 ../client/pk-console.c:1467 +msgid "A search term is required" +msgstr "" + +#. TRANSLATORS: the search type was provided, but invalid +#: ../client/pk-console.c:1477 +msgid "Invalid search type" +msgstr "" + +#. TRANSLATORS: the user did not specify what they wanted to install +#: ../client/pk-console.c:1483 +msgid "A package name to install is required" +msgstr "" + +#. TRANSLATORS: the user did not specify what they wanted to install +#: ../client/pk-console.c:1492 +msgid "A filename to install is required" +msgstr "" + +#. TRANSLATORS: geeky error, 99.9999% of users won't see this +#: ../client/pk-console.c:1503 +msgid "A type, key_id and package_id are required" +msgstr "" + +#. TRANSLATORS: the user did not specify what they wanted to remove +#: ../client/pk-console.c:1514 +msgid "A package name to remove is required" +msgstr "" + +#. TRANSLATORS: the user did not specify anything about what to download or +#. where +#: ../client/pk-console.c:1523 +msgid "A destination directory and the package names to download are required" +msgstr "" + +#. TRANSLATORS: the directory does not exist, so we can't continue +#: ../client/pk-console.c:1530 +msgid "Directory not found" +msgstr "" + +#. TRANSLATORS: geeky error, 99.9999% of users won't see this +#: ../client/pk-console.c:1539 +msgid "A licence identifier (eula-id) is required" +msgstr "" + +#. TRANSLATORS: geeky error, 99.9999% of users won't see this +#: ../client/pk-console.c:1550 +msgid "A transaction identifier (tid) is required" +msgstr "" + +#. TRANSLATORS: The user did not specify a package name +#: ../client/pk-console.c:1571 +msgid "A package name to resolve is required" +msgstr "" + +#. TRANSLATORS: The user did not specify a repository (software source) name +#: ../client/pk-console.c:1582 ../client/pk-console.c:1593 +msgid "A repository name is required" +msgstr "" + +#. TRANSLATORS: The user didn't provide any data +#: ../client/pk-console.c:1604 +msgid "A repo name, parameter and value are required" +msgstr "" + +#. TRANSLATORS: The user didn't specify what action to use +#: ../client/pk-console.c:1621 +msgid "An action, e.g. 'update-system' is required" +msgstr "" + +#. TRANSLATORS: The user specified an invalid action +#: ../client/pk-console.c:1628 +msgid "A correct role is required" +msgstr "" + +#. TRANSLATORS: The user did not provide a package name +#. TRANSLATORS: This is when the user fails to supply the package name +#: ../client/pk-console.c:1638 ../client/pk-console.c:1652 +#: ../client/pk-console.c:1661 ../client/pk-console.c:1681 +#: ../client/pk-console.c:1690 ../client/pk-generate-pack.c:314 +msgid "A package name is required" +msgstr "" + +#. TRANSLATORS: each package "provides" certain things, e.g. mime(gstreamer- +#. decoder-mp3), the user didn't specify it +#: ../client/pk-console.c:1670 +msgid "A package provide string is required" +msgstr "" + +#. TRANSLATORS: The user did not provide a distro name +#: ../client/pk-console.c:1714 +msgid "A distribution name is required" +msgstr "" + +#. TRANSLATORS: The user did not provide an upgrade type +#: ../client/pk-console.c:1720 +msgid "An upgrade type is required, e.g. 'minimal', 'default' or 'complete'" +msgstr "" + +#. TRANSLATORS: The user tried to use an unsupported option on the command +#. line +#: ../client/pk-console.c:1770 +#, c-format +msgid "Option '%s' is not supported" +msgstr "" + +#. TRANSLATORS: Generic failure of what they asked to do +#: ../client/pk-console.c:1780 +msgid "Command failed" +msgstr "" + +#. TRANSLATORS: we can exclude certain packages (glibc) when we know they'll +#. exist on the target +#: ../client/pk-generate-pack.c:253 +msgid "Set the file name of dependencies to be excluded" +msgstr "" + +#. TRANSLATORS: the output location +#: ../client/pk-generate-pack.c:256 +msgid "" +"The output file or directory (the current directory is used if omitted)" +msgstr "" + +#. TRANSLATORS: put a list of packages in the pack +#: ../client/pk-generate-pack.c:259 +msgid "The package to be put into the service pack" +msgstr "" + +#. TRANSLATORS: put all pending updates in the pack +#: ../client/pk-generate-pack.c:262 +msgid "Put all updates available in the service pack" +msgstr "" + +#. TRANSLATORS: This is when the user fails to supply the correct arguments +#: ../client/pk-generate-pack.c:298 +msgid "Neither --package or --updates option selected." +msgstr "" + +#. TRANSLATORS: This is when the user fails to supply just one argument +#: ../client/pk-generate-pack.c:306 +msgid "Both options selected." +msgstr "" + +#. TRANSLATORS: This is when the user fails to supply the output +#: ../client/pk-generate-pack.c:322 +msgid "A output directory or file name is required" +msgstr "" + +#. TRANSLATORS: This is when the daemon is not-installed/broken and fails to +#. startup +#: ../client/pk-generate-pack.c:340 +msgid "The daemon failed to startup" +msgstr "" + +#. TRANSLATORS: This is when the backend doesn't have the capability to get- +#. depends +#. TRANSLATORS: This is when the backend doesn't have the capability to +#. download +#: ../client/pk-generate-pack.c:351 ../client/pk-generate-pack.c:357 +msgid "The package manager cannot perform this type of operation." +msgstr "" + +#. TRANSLATORS: This is when the distro didn't include libarchive support into +#. PK +#: ../client/pk-generate-pack.c:364 +msgid "" +"Service packs cannot be created as PackageKit was not built with libarchive " +"support." +msgstr "" + +#. TRANSLATORS: the user specified an absolute path, but didn't get the +#. extension correct +#: ../client/pk-generate-pack.c:375 +msgid "If specifying a file, the service pack name must end with" +msgstr "" + +#. TRANSLATORS: This is when file already exists +#: ../client/pk-generate-pack.c:391 +msgid "A pack with the same name already exists, do you want to overwrite it?" +msgstr "" + +#. TRANSLATORS: This is when the pack was not overwritten +#: ../client/pk-generate-pack.c:394 +msgid "The pack was not overwritten." +msgstr "" + +#. TRANSLATORS: This is when the temporary directory cannot be created, the +#. directory name follows +#: ../client/pk-generate-pack.c:407 +msgid "Failed to create directory:" +msgstr "" + +#. TRANSLATORS: This is when the list of packages from the remote computer +#. cannot be opened +#: ../client/pk-generate-pack.c:419 +msgid "Failed to open package list." +msgstr "" + +#. TRANSLATORS: The package name is being matched up to available packages +#: ../client/pk-generate-pack.c:428 +msgid "Finding package name." +msgstr "" + +#. TRANSLATORS: This is when the package cannot be found in any software +#. source. The detailed error follows +#: ../client/pk-generate-pack.c:432 +#, c-format +msgid "Failed to find package '%s': %s" +msgstr "" + +#. TRANSLATORS: This is telling the user we are in the process of making the +#. pack +#: ../client/pk-generate-pack.c:440 +msgid "Creating service pack..." +msgstr "" + +#. TRANSLATORS: we succeeded in making the file +#: ../client/pk-generate-pack.c:455 +#, c-format +msgid "Service pack created '%s'" +msgstr "" + +#. TRANSLATORS: we failed to make te file +#: ../client/pk-generate-pack.c:460 +#, c-format +msgid "Failed to create '%s': %s" +msgstr "" + +#: ../client/pk-monitor.c:284 +msgid "Failed to get daemon state" +msgstr "" + +#: ../client/pk-monitor.c:349 +msgid "Failed to get properties" +msgstr "" + +#. TRANSLATORS: this is a program that monitors PackageKit +#: ../client/pk-monitor.c:387 +msgid "PackageKit Monitor" +msgstr "" + +#. TRANSLATORS: when we are getting data from the daemon +#: ../contrib/browser-plugin/pk-plugin-install.c:499 +msgid "Getting package information..." +msgstr "" + +#. TRANSLATORS: run an applicaiton +#: ../contrib/browser-plugin/pk-plugin-install.c:505 +#, c-format +msgid "Run %s" +msgstr "" + +#. TRANSLATORS: show the installed version of a package +#: ../contrib/browser-plugin/pk-plugin-install.c:511 +msgid "Installed version" +msgstr "" + +#. TRANSLATORS: run the application now +#: ../contrib/browser-plugin/pk-plugin-install.c:519 +#, c-format +msgid "Run version %s now" +msgstr "" + +#. TRANSLATORS: run the application now +#: ../contrib/browser-plugin/pk-plugin-install.c:525 +msgid "Run now" +msgstr "" + +#. TRANSLATORS: update to a new version of the package +#: ../contrib/browser-plugin/pk-plugin-install.c:531 +#, c-format +msgid "Update to version %s" +msgstr "" + +#. TRANSLATORS: To install a package +#: ../contrib/browser-plugin/pk-plugin-install.c:537 +#, c-format +msgid "Install %s now" +msgstr "" + +#. TRANSLATORS: the version of the package +#: ../contrib/browser-plugin/pk-plugin-install.c:540 +msgid "Version" +msgstr "" + +#. TRANSLATORS: noting found, so can't install +#: ../contrib/browser-plugin/pk-plugin-install.c:545 +msgid "No packages found for your system" +msgstr "" + +#. TRANSLATORS: package is being installed +#: ../contrib/browser-plugin/pk-plugin-install.c:550 +msgid "Installing..." +msgstr "" + +#. TRANSLATORS: downloading repo data so we can search +#: ../contrib/command-not-found/pk-command-not-found.c:366 +msgid "Downloading details about the software sources." +msgstr "" + +#. TRANSLATORS: downloading file lists so we can search +#: ../contrib/command-not-found/pk-command-not-found.c:370 +msgid "Downloading filelists (this may take some time to complete)." +msgstr "" + +#. TRANSLATORS: waiting for native lock +#: ../contrib/command-not-found/pk-command-not-found.c:374 +msgid "Waiting for package manager lock." +msgstr "" + +#. TRANSLATORS: loading package cache so we can search +#: ../contrib/command-not-found/pk-command-not-found.c:378 +msgid "Loading list of packages." +msgstr "" + +#. TRANSLATORS: we failed to find the package, this shouldn't happen +#: ../contrib/command-not-found/pk-command-not-found.c:444 +msgid "Failed to search for file" +msgstr "" + +#. TRANSLATORS: the transaction failed in a way we could not expect +#: ../contrib/command-not-found/pk-command-not-found.c:456 +msgid "Getting the list of files failed" +msgstr "" + +#. TRANSLATORS: we failed to launch the executable, the error follows +#: ../contrib/command-not-found/pk-command-not-found.c:602 +msgid "Failed to launch:" +msgstr "" + +#. TRANSLATORS: we failed to install the package +#: ../contrib/command-not-found/pk-command-not-found.c:630 +msgid "Failed to install packages" +msgstr "" + +#. TRANSLATORS: tool that gets called when the command is not found +#: ../contrib/command-not-found/pk-command-not-found.c:706 +msgid "PackageKit Command Not Found" +msgstr "" + +#. TRANSLATORS: the prefix of all the output telling the user +#. * why it's not executing. NOTE: this is lowercase to mimic +#. * the style of bash itself -- apologies +#: ../contrib/command-not-found/pk-command-not-found.c:739 +msgid "command not found" +msgstr "" + +#. TRANSLATORS: tell the user what we think the command is +#: ../contrib/command-not-found/pk-command-not-found.c:757 +msgid "Similar command is:" +msgstr "" + +#. TRANSLATORS: Ask the user if we should run the similar command +#: ../contrib/command-not-found/pk-command-not-found.c:771 +msgid "Run similar command:" +msgstr "" + +#. TRANSLATORS: show the user a list of commands that they could have meant +#. TRANSLATORS: show the user a list of commands we could run +#: ../contrib/command-not-found/pk-command-not-found.c:785 +#: ../contrib/command-not-found/pk-command-not-found.c:794 +msgid "Similar commands are:" +msgstr "" + +#. TRANSLATORS: ask the user to choose a file to run +#: ../contrib/command-not-found/pk-command-not-found.c:801 +msgid "Please choose a command to run" +msgstr "" + +#. TRANSLATORS: tell the user what package provides the command +#: ../contrib/command-not-found/pk-command-not-found.c:819 +msgid "The package providing this file is:" +msgstr "" + +#. TRANSLATORS: as the user if we want to install a package to provide the +#. command +#: ../contrib/command-not-found/pk-command-not-found.c:826 +#, c-format +msgid "Install package '%s' to provide command '%s'?" +msgstr "" + +#. TRANSLATORS: Show the user a list of packages that provide this command +#: ../contrib/command-not-found/pk-command-not-found.c:853 +msgid "Packages providing this file are:" +msgstr "" + +#. TRANSLATORS: Show the user a list of packages that they can install to +#. provide this command +#: ../contrib/command-not-found/pk-command-not-found.c:863 +msgid "Suitable packages are:" +msgstr "" + +#. get selection +#. TRANSLATORS: ask the user to choose a file to install +#: ../contrib/command-not-found/pk-command-not-found.c:872 +msgid "Please choose a package to install" +msgstr "" + +#. TRANSLATORS: we are starting to install the packages +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:195 +msgid "Starting install" +msgstr "" + +#. TRANSLATORS: we couldn't find the package name, non-fatal +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:407 +#, c-format +msgid "Failed to find the package %s, or already installed: %s" +msgstr "" + +#. command line argument, simulate what would be done, but don't actually do +#. it +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:516 +msgid "" +"Don't actually install any packages, only simulate what would be installed" +msgstr "" + +#. command line argument, do we skip packages that depend on the ones +#. specified +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:519 +msgid "Do not install dependencies of the core packages" +msgstr "" + +#. command line argument, do we operate quietly +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:522 +msgid "Do not display information or progress" +msgstr "" + +#. TRANSLATORS: tool that gets called when the command is not found +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:540 +msgid "PackageKit Debuginfo Installer" +msgstr "" + +#. TRANSLATORS: the use needs to specify a list of package names on the +#. command line +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:554 +#, c-format +msgid "ERROR: Specify package names to install." +msgstr "" + +#. TRANSLATORS: we are getting the list of repositories +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:590 +#, c-format +msgid "Getting sources list" +msgstr "" + +#. TRANSLATORS: operation was not successful +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:600 +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:675 +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:759 +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:803 +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:870 +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:914 +msgid "FAILED." +msgstr "" + +#. TRANSLATORS: all completed 100% +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:615 +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:655 +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:690 +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:774 +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:818 +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:885 +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:929 +#, c-format +msgid "OK." +msgstr "" + +#. TRANSLATORS: tell the user what we found +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:618 +#, c-format +msgid "Found %i enabled and %i disabled sources." +msgstr "" + +#. TRANSLATORS: we're finding repositories that match out pattern +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:625 +#, c-format +msgid "Finding debugging sources" +msgstr "" + +#. TRANSLATORS: tell the user what we found +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:658 +#, c-format +msgid "Found %i disabled debuginfo repos." +msgstr "" + +#. TRANSLATORS: we're now enabling all the debug sources we found +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:665 +#, c-format +msgid "Enabling debugging sources" +msgstr "" + +#. TRANSLATORS: tell the user how many we enabled +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:693 +#, c-format +msgid "Enabled %i debugging sources." +msgstr "" + +#. TRANSLATORS: we're now finding packages that match in all the repos +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:700 +#, c-format +msgid "Finding debugging packages" +msgstr "" + +#. TRANSLATORS: we couldn't find the package name, non-fatal +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:712 +#, c-format +msgid "Failed to find the package %s: %s" +msgstr "" + +#. TRANSLATORS: we couldn't find the debuginfo package name, non-fatal +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:735 +#, c-format +msgid "Failed to find the debuginfo package %s: %s" +msgstr "" + +#. TRANSLATORS: no debuginfo packages could be found to be installed +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:763 +#, c-format +msgid "Found no packages to install." +msgstr "" + +#. TRANSLATORS: tell the user we found some packages, and then list them +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:777 +#, c-format +msgid "Found %i packages:" +msgstr "" + +#. TRANSLATORS: tell the user we are searching for deps +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:793 +#, c-format +msgid "Finding packages that depend on these packages" +msgstr "" + +#. TRANSLATORS: could not install, detailed error follows +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:806 +#, c-format +msgid "Could not find dependant packages: %s" +msgstr "" + +#. TRANSLATORS: tell the user we found some more packages +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:822 +#, c-format +msgid "Found %i extra packages." +msgstr "" + +#. TRANSLATORS: tell the user we found some more packages +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:826 +#, c-format +msgid "No extra packages required." +msgstr "" + +#. TRANSLATORS: tell the user we found some packages (and deps), and then list +#. them +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:835 +#, c-format +msgid "Found %i packages to install:" +msgstr "" + +#. TRANSLATORS: simulate mode is a testing mode where we quit before the +#. action +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:848 +#, c-format +msgid "Not installing packages in simulate mode" +msgstr "" + +#. TRANSLATORS: we are now installing the debuginfo packages we found earlier +#. TRANSLATORS: transaction state, installing packages +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:860 +#: ../lib/packagekit-glib2/pk-console-shared.c:287 +#, c-format +msgid "Installing packages" +msgstr "" + +#. TRANSLATORS: could not install, detailed error follows +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:873 +#, c-format +msgid "Could not install packages: %s" +msgstr "" + +#. TRANSLATORS: we are now disabling all debuginfo repos we previously enabled +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:905 +#, c-format +msgid "Disabling sources previously enabled" +msgstr "" + +#. TRANSLATORS: no debuginfo packages could be found to be installed, detailed +#. error follows +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:917 +#, c-format +msgid "Could not disable the debugging sources: %s" +msgstr "" + +#. TRANSLATORS: we disabled all the debugging repos that we enabled before +#: ../contrib/debuginfo-install/pk-debuginfo-install.c:932 +#, c-format +msgid "Disabled %i debugging sources." +msgstr "" + +#. TRANSLATORS: couldn't open device to write +#: ../contrib/device-rebind/pk-device-rebind.c:62 +msgid "Failed to open file" +msgstr "" + +#. TRANSLATORS: could not write to the device +#: ../contrib/device-rebind/pk-device-rebind.c:71 +msgid "Failed to write to the file" +msgstr "" + +#. TRANSLATORS: we failed to release the current driver +#: ../contrib/device-rebind/pk-device-rebind.c:111 +#: ../contrib/device-rebind/pk-device-rebind.c:148 +msgid "Failed to write to device" +msgstr "" + +#. TRANSLATORS: the device could not be found in sysfs +#: ../contrib/device-rebind/pk-device-rebind.c:176 +msgid "Device could not be found" +msgstr "" + +#. TRANSLATORS: we failed to release the current driver +#: ../contrib/device-rebind/pk-device-rebind.c:203 +msgid "Failed to unregister driver" +msgstr "" + +#. TRANSLATORS: we failed to bind the old driver +#: ../contrib/device-rebind/pk-device-rebind.c:212 +msgid "Failed to register driver" +msgstr "" + +#. TRANSLATORS: user did not specify a device sysfs path that exists +#: ../contrib/device-rebind/pk-device-rebind.c:261 +msgid "Device path not found" +msgstr "" + +#. TRANSLATORS: user did not specify a valid device sysfs path +#: ../contrib/device-rebind/pk-device-rebind.c:269 +msgid "Incorrect device path specified" +msgstr "" + +#: ../contrib/device-rebind/pk-device-rebind.c:294 +msgid "Show extra debugging information" +msgstr "" + +#. command line argument, simulate what would be done, but don't actually do +#. it +#: ../contrib/device-rebind/pk-device-rebind.c:297 +msgid "Don't actually touch the hardware, only simulate what would be done" +msgstr "" + +#. TRANSLATORS: command line option: a list of files to install +#: ../contrib/device-rebind/pk-device-rebind.c:300 +msgid "Device paths" +msgstr "" + +#. TRANSLATORS: tool that gets called when the device needs reloading after +#. installing firmware +#: ../contrib/device-rebind/pk-device-rebind.c:315 +msgid "PackageKit Device Reloader" +msgstr "" + +#. TRANSLATORS: user did not specify a valid device sysfs path +#: ../contrib/device-rebind/pk-device-rebind.c:323 +msgid "You need to specify at least one valid device path" +msgstr "" + +#. TRANSLATORS: user did not specify a valid device sysfs path +#: ../contrib/device-rebind/pk-device-rebind.c:333 +msgid "This script can only be used by the root user" +msgstr "" + +#. TRANSLATORS: we're going to verify the path first +#: ../contrib/device-rebind/pk-device-rebind.c:342 +msgid "Verifying device path" +msgstr "" + +#. TRANSLATORS: user did not specify a device sysfs path that exists +#: ../contrib/device-rebind/pk-device-rebind.c:347 +msgid "Failed to verify device path" +msgstr "" + +#. TRANSLATORS: we're going to try +#: ../contrib/device-rebind/pk-device-rebind.c:361 +msgid "Attempting to rebind device" +msgstr "" + +#. TRANSLATORS: we failed to release the current driver +#: ../contrib/device-rebind/pk-device-rebind.c:366 +msgid "Failed to rebind device" +msgstr "" + +#: ../data/packagekit-catalog.xml.in.h:1 +msgid "PackageKit Catalog" +msgstr "" + +#: ../data/packagekit-package-list.xml.in.h:1 +msgid "PackageKit Package List" +msgstr "" + +#: ../data/packagekit-servicepack.xml.in.h:1 +msgid "PackageKit Service Pack" +msgstr "" + +#: ../lib/packagekit-glib2/pk-console-shared.c:63 +#, c-format +msgid "Please enter a number from 1 to %i: " +msgstr "" + +#. TRANSLATORS: more than one package could be found that matched, to follow +#. is a list of possible packages +#: ../lib/packagekit-glib2/pk-console-shared.c:189 +msgid "More than one package matches:" +msgstr "" + +#. TRANSLATORS: This finds out which package in the list to use +#: ../lib/packagekit-glib2/pk-console-shared.c:200 +msgid "Please choose the correct package: " +msgstr "" + +#. TRANSLATORS: This is when the transaction status is not known +#: ../lib/packagekit-glib2/pk-console-shared.c:255 +msgid "Unknown state" +msgstr "" + +#. TRANSLATORS: transaction state, the daemon is in the process of starting +#: ../lib/packagekit-glib2/pk-console-shared.c:259 +msgid "Starting" +msgstr "" + +#. TRANSLATORS: transaction state, the transaction is waiting for another to +#. complete +#: ../lib/packagekit-glib2/pk-console-shared.c:263 +msgid "Waiting in queue" +msgstr "" + +#. TRANSLATORS: transaction state, just started +#: ../lib/packagekit-glib2/pk-console-shared.c:267 +msgid "Running" +msgstr "" + +#. TRANSLATORS: transaction state, is querying data +#: ../lib/packagekit-glib2/pk-console-shared.c:271 +msgid "Querying" +msgstr "" + +#. TRANSLATORS: transaction state, getting data from a server +#: ../lib/packagekit-glib2/pk-console-shared.c:275 +msgid "Getting information" +msgstr "" + +#. TRANSLATORS: transaction state, removing packages +#: ../lib/packagekit-glib2/pk-console-shared.c:279 +msgid "Removing packages" +msgstr "" + +#. TRANSLATORS: transaction state, downloading package files +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:283 +#: ../lib/packagekit-glib2/pk-console-shared.c:661 +msgid "Downloading packages" +msgstr "" + +#. TRANSLATORS: transaction state, refreshing internal lists +#: ../lib/packagekit-glib2/pk-console-shared.c:291 +msgid "Refreshing software list" +msgstr "" + +#. TRANSLATORS: transaction state, installing updates +#: ../lib/packagekit-glib2/pk-console-shared.c:295 +msgid "Installing updates" +msgstr "" + +#. TRANSLATORS: transaction state, removing old packages, and cleaning config +#. files +#: ../lib/packagekit-glib2/pk-console-shared.c:299 +msgid "Cleaning up packages" +msgstr "" + +#. TRANSLATORS: transaction state, obsoleting old packages +#: ../lib/packagekit-glib2/pk-console-shared.c:303 +msgid "Obsoleting packages" +msgstr "" + +#. TRANSLATORS: transaction state, checking the transaction before we do it +#: ../lib/packagekit-glib2/pk-console-shared.c:307 +msgid "Resolving dependencies" +msgstr "" + +#. TRANSLATORS: transaction state, checking if we have all the security keys +#. for the operation +#: ../lib/packagekit-glib2/pk-console-shared.c:311 +msgid "Checking signatures" +msgstr "" + +#. TRANSLATORS: transaction state, when we return to a previous system state +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:315 +#: ../lib/packagekit-glib2/pk-console-shared.c:621 +msgid "Rolling back" +msgstr "" + +#. TRANSLATORS: transaction state, when we're doing a test transaction +#: ../lib/packagekit-glib2/pk-console-shared.c:319 +msgid "Testing changes" +msgstr "" + +#. TRANSLATORS: transaction state, when we're writing to the system package +#. database +#: ../lib/packagekit-glib2/pk-console-shared.c:323 +msgid "Committing changes" +msgstr "" + +#. TRANSLATORS: transaction state, requesting data from a server +#: ../lib/packagekit-glib2/pk-console-shared.c:327 +msgid "Requesting data" +msgstr "" + +#. TRANSLATORS: transaction state, all done! +#: ../lib/packagekit-glib2/pk-console-shared.c:331 +msgid "Finished" +msgstr "" + +#. TRANSLATORS: transaction state, in the process of cancelling +#: ../lib/packagekit-glib2/pk-console-shared.c:335 +msgid "Cancelling" +msgstr "" + +#. TRANSLATORS: transaction state, downloading metadata +#: ../lib/packagekit-glib2/pk-console-shared.c:339 +msgid "Downloading repository information" +msgstr "" + +#. TRANSLATORS: transaction state, downloading metadata +#: ../lib/packagekit-glib2/pk-console-shared.c:343 +msgid "Downloading list of packages" +msgstr "" + +#. TRANSLATORS: transaction state, downloading metadata +#: ../lib/packagekit-glib2/pk-console-shared.c:347 +msgid "Downloading file lists" +msgstr "" + +#. TRANSLATORS: transaction state, downloading metadata +#: ../lib/packagekit-glib2/pk-console-shared.c:351 +msgid "Downloading lists of changes" +msgstr "" + +#. TRANSLATORS: transaction state, downloading metadata +#: ../lib/packagekit-glib2/pk-console-shared.c:355 +msgid "Downloading groups" +msgstr "" + +#. TRANSLATORS: transaction state, downloading metadata +#: ../lib/packagekit-glib2/pk-console-shared.c:359 +msgid "Downloading update information" +msgstr "" + +#. TRANSLATORS: transaction state, repackaging delta files +#: ../lib/packagekit-glib2/pk-console-shared.c:363 +msgid "Repackaging files" +msgstr "" + +#. TRANSLATORS: transaction state, loading databases +#: ../lib/packagekit-glib2/pk-console-shared.c:367 +msgid "Loading cache" +msgstr "" + +#. TRANSLATORS: transaction state, scanning for running processes +#: ../lib/packagekit-glib2/pk-console-shared.c:371 +msgid "Scanning applications" +msgstr "" + +#. TRANSLATORS: transaction state, generating a list of packages installed on +#. the system +#: ../lib/packagekit-glib2/pk-console-shared.c:375 +msgid "Generating package lists" +msgstr "" + +#. TRANSLATORS: transaction state, when we're waiting for the native tools to +#. exit +#: ../lib/packagekit-glib2/pk-console-shared.c:379 +msgid "Waiting for package manager lock" +msgstr "" + +#. TRANSLATORS: transaction state, waiting for user to type in a password +#: ../lib/packagekit-glib2/pk-console-shared.c:383 +msgid "Waiting for authentication" +msgstr "" + +#. TRANSLATORS: transaction state, we are updating the list of processes +#: ../lib/packagekit-glib2/pk-console-shared.c:387 +msgid "Updating running applications" +msgstr "" + +#. TRANSLATORS: transaction state, we are checking executable files currently +#. in use +#: ../lib/packagekit-glib2/pk-console-shared.c:391 +msgid "Checking applications in use" +msgstr "" + +#. TRANSLATORS: transaction state, we are checking for libraries currently in +#. use +#: ../lib/packagekit-glib2/pk-console-shared.c:395 +msgid "Checking libraries in use" +msgstr "" + +#. TRANSLATORS: transaction state, we are copying package files before or +#. after the transaction +#: ../lib/packagekit-glib2/pk-console-shared.c:399 +msgid "Copying files" +msgstr "" + +#. TRANSLATORS: The type of update +#: ../lib/packagekit-glib2/pk-console-shared.c:417 +msgid "Trivial" +msgstr "" + +#. TRANSLATORS: The type of update +#: ../lib/packagekit-glib2/pk-console-shared.c:421 +msgid "Normal" +msgstr "" + +#. TRANSLATORS: The type of update +#: ../lib/packagekit-glib2/pk-console-shared.c:425 +msgid "Important" +msgstr "" + +#. TRANSLATORS: The type of update +#: ../lib/packagekit-glib2/pk-console-shared.c:429 +msgid "Security" +msgstr "" + +#. TRANSLATORS: The type of update +#: ../lib/packagekit-glib2/pk-console-shared.c:433 +msgid "Bug fix " +msgstr "" + +#. TRANSLATORS: The type of update +#: ../lib/packagekit-glib2/pk-console-shared.c:437 +msgid "Enhancement" +msgstr "" + +#. TRANSLATORS: The type of update +#: ../lib/packagekit-glib2/pk-console-shared.c:441 +msgid "Blocked" +msgstr "" + +#. TRANSLATORS: The state of a package +#. TRANSLATORS: The action of the package, in past tense +#: ../lib/packagekit-glib2/pk-console-shared.c:446 +#: ../lib/packagekit-glib2/pk-console-shared.c:519 +msgid "Installed" +msgstr "" + +#. TRANSLATORS: The state of a package, i.e. not installed +#: ../lib/packagekit-glib2/pk-console-shared.c:451 +msgid "Available" +msgstr "" + +#. TRANSLATORS: The action of the package, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:469 +msgid "Downloading" +msgstr "" + +#. TRANSLATORS: The action of the package, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:473 +msgid "Updating" +msgstr "" + +#. TRANSLATORS: The action of the package, in present tense +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:477 +#: ../lib/packagekit-glib2/pk-console-shared.c:597 +msgid "Installing" +msgstr "" + +#. TRANSLATORS: The action of the package, in present tense +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:481 +#: ../lib/packagekit-glib2/pk-console-shared.c:593 +msgid "Removing" +msgstr "" + +#. TRANSLATORS: The action of the package, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:485 +msgid "Cleaning up" +msgstr "" + +#. TRANSLATORS: The action of the package, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:489 +msgid "Obsoleting" +msgstr "" + +#. TRANSLATORS: The action of the package, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:493 +msgid "Reinstalling" +msgstr "" + +#. TRANSLATORS: The action of the package, in past tense +#: ../lib/packagekit-glib2/pk-console-shared.c:511 +msgid "Downloaded" +msgstr "" + +#. TRANSLATORS: The action of the package, in past tense +#: ../lib/packagekit-glib2/pk-console-shared.c:523 +msgid "Removed" +msgstr "" + +#. TRANSLATORS: The action of the package, in past tense +#: ../lib/packagekit-glib2/pk-console-shared.c:527 +msgid "Cleaned up" +msgstr "" + +#. TRANSLATORS: The action of the package, in past tense +#: ../lib/packagekit-glib2/pk-console-shared.c:531 +msgid "Obsoleted" +msgstr "" + +#. TRANSLATORS: The action of the package, in past tense +#: ../lib/packagekit-glib2/pk-console-shared.c:535 +msgid "Reinstalled" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:553 +msgid "Unknown role type" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:557 +msgid "Getting dependencies" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:561 +msgid "Getting update details" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:565 +msgid "Getting details" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:569 +msgid "Getting requires" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:573 +msgid "Getting updates" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:577 +msgid "Searching by details" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:581 +msgid "Searching by file" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:585 +msgid "Searching groups" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:589 +msgid "Searching by name" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:601 +msgid "Installing files" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:605 +msgid "Refreshing cache" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:609 +msgid "Updating packages" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:613 +msgid "Updating system" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:617 +msgid "Canceling" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:625 +msgid "Getting repositories" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:629 +msgid "Enabling repository" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:633 +msgid "Setting data" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:637 +msgid "Resolving" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:641 +msgid "Getting file list" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:645 +msgid "Getting provides" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:649 +msgid "Installing signature" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:653 +msgid "Getting packages" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:657 +msgid "Accepting EULA" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:665 +msgid "Getting upgrades" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:669 +msgid "Getting categories" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:673 +msgid "Getting transactions" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:677 +#: ../lib/packagekit-glib2/pk-console-shared.c:681 +msgid "Simulating install" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:685 +msgid "Simulating remove" +msgstr "" + +#. TRANSLATORS: The role of the transaction, in present tense +#: ../lib/packagekit-glib2/pk-console-shared.c:689 +msgid "Simulating update" +msgstr "" + +#. TRANSLATORS: turn on all debugging +#: ../lib/packagekit-glib2/pk-debug.c:133 +msgid "Show debugging information for all files" +msgstr "" + +#: ../lib/packagekit-glib2/pk-debug.c:201 +msgid "Debugging Options" +msgstr "" + +#: ../lib/packagekit-glib2/pk-debug.c:201 +msgid "Show debugging options" +msgstr "" + +#. TRANSLATORS: ask the user if they are comfortable installing insecure +#. packages +#: ../lib/packagekit-glib2/pk-task-text.c:67 +msgid "Do you want to allow installing of unsigned software?" +msgstr "" + +#. TRANSLATORS: tell the user we've not done anything +#: ../lib/packagekit-glib2/pk-task-text.c:72 +msgid "The unsigned software will not be installed." +msgstr "" + +#. TRANSLATORS: the package repository is signed by a key that is not +#. recognised +#: ../lib/packagekit-glib2/pk-task-text.c:121 +msgid "Software source signature required" +msgstr "" + +#. TRANSLATORS: the package repository name +#: ../lib/packagekit-glib2/pk-task-text.c:127 +msgid "Software source name" +msgstr "" + +#. TRANSLATORS: the key URL +#: ../lib/packagekit-glib2/pk-task-text.c:130 +msgid "Key URL" +msgstr "" + +#. TRANSLATORS: the username of the key +#: ../lib/packagekit-glib2/pk-task-text.c:133 +msgid "Key user" +msgstr "" + +#. TRANSLATORS: the key ID, usually a few hex digits +#: ../lib/packagekit-glib2/pk-task-text.c:136 +msgid "Key ID" +msgstr "" + +#. TRANSLATORS: the key fingerprint, again, yet more hex +#: ../lib/packagekit-glib2/pk-task-text.c:139 +msgid "Key fingerprint" +msgstr "" + +#. TRANSLATORS: the timestamp (a bit like a machine readable time) +#: ../lib/packagekit-glib2/pk-task-text.c:142 +msgid "Key Timestamp" +msgstr "" + +#. TRANSLATORS: ask the user if they want to import +#: ../lib/packagekit-glib2/pk-task-text.c:155 +msgid "Do you accept this signature?" +msgstr "" + +#. TRANSLATORS: tell the user we've not done anything +#: ../lib/packagekit-glib2/pk-task-text.c:160 +msgid "The signature was not accepted." +msgstr "" + +#. TRANSLATORS: this is another name for a software licence that has to be +#. read before installing +#: ../lib/packagekit-glib2/pk-task-text.c:203 +msgid "End user licence agreement required" +msgstr "" + +#. TRANSLATORS: the EULA text itself (long and boring) +#: ../lib/packagekit-glib2/pk-task-text.c:212 +msgid "Agreement" +msgstr "" + +#. TRANSLATORS: ask the user if they've read and accepted the EULA +#: ../lib/packagekit-glib2/pk-task-text.c:221 +msgid "Do you accept this agreement?" +msgstr "" + +#. TRANSLATORS: tell the user we've not done anything +#: ../lib/packagekit-glib2/pk-task-text.c:226 +msgid "The agreement was not accepted." +msgstr "" + +#. TRANSLATORS: the user needs to change media inserted into the computer +#: ../lib/packagekit-glib2/pk-task-text.c:265 +msgid "Media change required" +msgstr "" + +#. TRANSLATORS: the type, e.g. DVD, CD, etc +#: ../lib/packagekit-glib2/pk-task-text.c:268 +msgid "Media type" +msgstr "" + +#. TRANSLATORS: the media label, usually like 'disk-1of3' +#: ../lib/packagekit-glib2/pk-task-text.c:271 +msgid "Media label" +msgstr "" + +#. TRANSLATORS: the media description, usually like 'Fedora 12 disk 5' +#: ../lib/packagekit-glib2/pk-task-text.c:274 +msgid "Text" +msgstr "" + +#. TRANSLATORS: ask the user to insert the media +#: ../lib/packagekit-glib2/pk-task-text.c:280 +msgid "Please insert the correct media" +msgstr "" + +#. TRANSLATORS: tell the user we've not done anything as they are lazy +#: ../lib/packagekit-glib2/pk-task-text.c:285 +msgid "The correct media was not inserted." +msgstr "" + +#. TRANSLATORS: When processing, we might have to remove other dependencies +#: ../lib/packagekit-glib2/pk-task-text.c:300 +msgid "The following packages have to be removed:" +msgstr "" + +#. TRANSLATORS: When processing, we might have to install other dependencies +#: ../lib/packagekit-glib2/pk-task-text.c:305 +msgid "The following packages have to be installed:" +msgstr "" + +#. TRANSLATORS: When processing, we might have to update other dependencies +#: ../lib/packagekit-glib2/pk-task-text.c:310 +msgid "The following packages have to be updated:" +msgstr "" + +#. TRANSLATORS: When processing, we might have to reinstall other dependencies +#: ../lib/packagekit-glib2/pk-task-text.c:315 +msgid "The following packages have to be reinstalled:" +msgstr "" + +#. TRANSLATORS: When processing, we might have to downgrade other dependencies +#: ../lib/packagekit-glib2/pk-task-text.c:320 +msgid "The following packages have to be downgraded:" +msgstr "" + +#. TRANSLATORS: ask the user if the proposed changes are okay +#: ../lib/packagekit-glib2/pk-task-text.c:380 +msgid "Proceed with changes?" +msgstr "" + +#. TRANSLATORS: tell the user we didn't do anything +#: ../lib/packagekit-glib2/pk-task-text.c:385 +msgid "The transaction did not proceed." +msgstr "" + +#. SECURITY: +#. - Normal users do not require admin authentication to accept new +#. licence agreements. +#. - Change this to 'auth_admin' for environments where users should not +#. be given the option to make legal decisions. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:7 +msgid "Accept EULA" +msgstr "" + +#: ../policy/org.freedesktop.packagekit.policy.in.h:8 +msgid "Authentication is required to accept a EULA" +msgstr "" + +#: ../policy/org.freedesktop.packagekit.policy.in.h:9 +msgid "" +"Authentication is required to cancel a task that was not started by yourself" +msgstr "" + +#: ../policy/org.freedesktop.packagekit.policy.in.h:10 +msgid "Authentication is required to change software source parameters" +msgstr "" + +#: ../policy/org.freedesktop.packagekit.policy.in.h:11 +msgid "" +"Authentication is required to change the location used to decompress " +"packages" +msgstr "" + +#: ../policy/org.freedesktop.packagekit.policy.in.h:12 +msgid "" +"Authentication is required to consider a key used for signing packages as " +"trusted" +msgstr "" + +#: ../policy/org.freedesktop.packagekit.policy.in.h:13 +msgid "Authentication is required to install a signed package" +msgstr "" + +#: ../policy/org.freedesktop.packagekit.policy.in.h:14 +msgid "Authentication is required to install an untrusted package" +msgstr "" + +#: ../policy/org.freedesktop.packagekit.policy.in.h:15 +msgid "Authentication is required to refresh the system sources" +msgstr "" + +#: ../policy/org.freedesktop.packagekit.policy.in.h:16 +msgid "Authentication is required to reload the device with a new driver" +msgstr "" + +#: ../policy/org.freedesktop.packagekit.policy.in.h:17 +msgid "Authentication is required to remove packages" +msgstr "" + +#: ../policy/org.freedesktop.packagekit.policy.in.h:18 +msgid "Authentication is required to rollback a transaction" +msgstr "" + +#: ../policy/org.freedesktop.packagekit.policy.in.h:19 +msgid "" +"Authentication is required to set the network proxy used for downloading " +"packages" +msgstr "" + +#: ../policy/org.freedesktop.packagekit.policy.in.h:20 +msgid "Authentication is required to update packages" +msgstr "" + +#: ../policy/org.freedesktop.packagekit.policy.in.h:21 +msgid "Authentication is required to upgrade the operating system" +msgstr "" + +#. SECURITY: +#. - Normal users are allowed to cancel their own task without +#. authentication, but a different user id needs the admin password +#. to cancel another users task. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:27 +msgid "Cancel foreign task" +msgstr "" + +#. SECURITY: +#. - This is used when users want to install to a different prefix, for +#. instance to a LTSP image or a virtual machine. +#. - This could be used to overwrite files not owned by the user using +#. a carefully created package file. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:34 +msgid "Change location that packages are installed" +msgstr "" + +#. SECURITY: +#. - Normal users require admin authentication to enable or disable +#. software sources as this can be used to enable new updates or +#. install different versions of software. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:40 +msgid "Change software source parameters" +msgstr "" + +#. SECURITY: +#. - Normal users do not need authentication to install signed packages +#. from signed repositories, as this cannot exploit a system. +#. - Paranoid users (or parents!) can change this to 'auth_admin' or +#. 'auth_admin_keep'. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:47 +msgid "Install signed package" +msgstr "" + +#. SECURITY: +#. - Normal users require admin authentication to install untrusted or +#. unrecognised packages, as allowing users to do this without a +#. password would be a massive security hole. +#. - This is not retained as each package should be authenticated. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:54 +msgid "Install untrusted local file" +msgstr "" + +#. SECURITY: +#. - Normal users do not require admin authentication to refresh the +#. cache, as this doesn't actually install or remove software. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:59 +msgid "Refresh system sources" +msgstr "" + +#. SECURITY: +#. - Normal users require admin authentication to rebind a driver +#. so that it works after we install firmware. +#. - This should not be set to 'yes' as unprivileged users could then +#. try to rebind drivers in use, for instance security authentication +#. devices. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:67 +msgid "Reload a device" +msgstr "" + +#. SECURITY: +#. - Normal users require admin authentication to remove packages as +#. this can make the system unbootable or stop other applications from +#. working. +#. - Be sure to close the tool used to remove the packages after the +#. admin authentication has been obtained, otherwise packages can still +#. be removed. If this is not possible, change this authentication to +#. 'auth_admin'. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:77 +msgid "Remove package" +msgstr "" + +#. SECURITY: +#. - Normal users require admin authentication to rollback system state +#. as this will change a large number of packages, and could expose the +#. system to previously patched security vulnerabilities. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:83 +msgid "Rollback to a previous transaction" +msgstr "" + +#. SECURITY: +#. - Normal users do not require admin authentication to set the proxy +#. used for downloading packages. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:88 +msgid "Set network proxy" +msgstr "" + +#. SECURITY: +#. - Normal users require admin authentication to add signing keys. +#. - This implies adding an explicit trust, and should not be granted +#. without a secure authentication. +#. - This is not kept as each package should be authenticated. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:95 +msgid "Trust a key used for signing packages" +msgstr "" + +#. SECURITY: +#. - Normal users do not require admin authentication to update the +#. system as the packages will be signed, and the action is required +#. to update the system when unattended. +#. - Changing this to anything other than 'yes' will break unattended +#. updates. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:103 +msgid "Update packages" +msgstr "" + +#. SECURITY: +#. - Normal users require admin authentication to upgrade the disto as +#. this can make the system unbootable or stop other applications from +#. working. +#. +#: ../policy/org.freedesktop.packagekit.policy.in.h:109 +msgid "Upgrade System" +msgstr "" + +#. TRANSLATORS: failed due to DBus security +#: ../src/pk-main.c:87 +msgid "Startup failed due to security policies on this machine." +msgstr "" + +#. TRANSLATORS: only two ways this can fail... +#: ../src/pk-main.c:89 +msgid "This can happen for two reasons:" +msgstr "" + +#. TRANSLATORS: only allowed to be owned by root +#: ../src/pk-main.c:91 +msgid "The correct user is not launching the executable (usually root)" +msgstr "" + +#. TRANSLATORS: or we are installed in a prefix +#: ../src/pk-main.c:93 +msgid "" +"The org.freedesktop.PackageKit.conf file is not installed in the system " +"directory:" +msgstr "" + +#. TRANSLATORS: a backend is the system package tool, e.g. yum, apt +#: ../src/pk-main.c:200 +msgid "Packaging backend to use, e.g. dummy" +msgstr "" + +#. TRANSLATORS: if we should run in the background +#: ../src/pk-main.c:203 +msgid "Daemonize and detach from the terminal" +msgstr "" + +#. TRANSLATORS: if we should not monitor how long we are inactive for +#: ../src/pk-main.c:206 +msgid "Disable the idle timer" +msgstr "" + +#. TRANSLATORS: show version +#: ../src/pk-main.c:209 +msgid "Show version and exit" +msgstr "" + +#. TRANSLATORS: exit after we've started up, used for user profiling +#: ../src/pk-main.c:212 +msgid "Exit after a small delay" +msgstr "" + +#. TRANSLATORS: exit straight away, used for automatic profiling +#: ../src/pk-main.c:215 +msgid "Exit after the engine has loaded" +msgstr "" + +#. TRANSLATORS: describing the service that is running +#: ../src/pk-main.c:230 +msgid "PackageKit service" +msgstr "" + +#. TRANSLATORS: fatal error, dbus is not running +#: ../src/pk-main.c:267 +msgid "Cannot connect to the system bus" +msgstr "" + +#. TRANSLATORS: cannot register on system bus, unknown reason -- geeky error +#. follows +#: ../src/pk-main.c:316 +msgid "Error trying to start:" +msgstr "" + +#: ../src/pk-polkit-action-lookup.c:150 +msgid "To install debugging packages, extra sources need to be enabled" +msgstr "" + +#. TRANSLATORS: is not GPG signed +#: ../src/pk-polkit-action-lookup.c:171 ../src/pk-polkit-action-lookup.c:190 +msgid "The software is not from a trusted source." +msgstr "" + +#: ../src/pk-polkit-action-lookup.c:176 +msgid "Do not update this package unless you are sure it is safe to do so." +msgstr "" + +#: ../src/pk-polkit-action-lookup.c:177 +msgid "Do not update these packages unless you are sure it is safe to do so." +msgstr "" + +#: ../src/pk-polkit-action-lookup.c:195 +msgid "Do not install this package unless you are sure it is safe to do so." +msgstr "" + +#: ../src/pk-polkit-action-lookup.c:196 +msgid "Do not install these packages unless you are sure it is safe to do so." +msgstr "" + +#. TRANSLATORS: too many packages to list each one +#: ../src/pk-polkit-action-lookup.c:273 +msgid "Many packages" +msgstr "" + +#. TRANSLATORS: if the transaction is forced to install only trusted packages +#: ../src/pk-polkit-action-lookup.c:339 +msgid "Only trusted" +msgstr "" diff --git a/src/pk-main.c b/src/pk-main.c index 7c9824a46..f15f64b71 100644 --- a/src/pk-main.c +++ b/src/pk-main.c @@ -33,6 +33,10 @@ #include <dbus/dbus-glib-lowlevel.h> #include <packagekit-glib2/pk-debug.h> +#if GLIB_CHECK_VERSION(2,28,7) + #include <glib-unix.h> +#endif + #include "egg-dbus-monitor.h" #include "pk-conf.h" @@ -155,6 +159,21 @@ pk_main_quit_cb (PkEngine *engine, GMainLoop *mainloop) g_main_loop_quit (mainloop); } +#if GLIB_CHECK_VERSION(2,28,7) + +/** + * pk_main_sigint_cb: + **/ +static gboolean +pk_main_sigint_cb (gpointer user_data) +{ + g_debug ("Handling SIGINT"); + g_main_loop_quit (loop); + return FALSE; +} + +#else + /** * pk_main_sigint_handler: **/ @@ -170,6 +189,8 @@ pk_main_sigint_handler (int sig) g_main_loop_quit (loop); } +#endif + /** * main: **/ @@ -250,8 +271,16 @@ main (int argc, char *argv[]) goto exit_program; } +#if GLIB_CHECK_VERSION(2,28,7) /* do stuff on ctrl-c */ + g_unix_signal_add_watch_full (SIGINT, + G_PRIORITY_DEFAULT, + pk_main_sigint_cb, + loop, + NULL); +#else signal (SIGINT, pk_main_sigint_handler); +#endif /* we need to daemonize before we get a system connection */ if (use_daemon && daemon (0, 0)) { diff --git a/src/pk-transaction-db.c b/src/pk-transaction-db.c index c8a8f4b66..a3d179db2 100644 --- a/src/pk-transaction-db.c +++ b/src/pk-transaction-db.c @@ -587,9 +587,21 @@ pk_transaction_sqlite_proxy_cb (void *data, gint argc, gchar **argv, gchar **col if (g_strcmp0 (col_name[i], "proxy_http") == 0) { item->proxy_http = g_strdup (argv[i]); item->set = TRUE; + } else if (g_strcmp0 (col_name[i], "proxy_https") == 0) { + item->proxy_https = g_strdup (argv[i]); + item->set = TRUE; } else if (g_strcmp0 (col_name[i], "proxy_ftp") == 0) { item->proxy_ftp = g_strdup (argv[i]); item->set = TRUE; + } else if (g_strcmp0 (col_name[i], "proxy_socks") == 0) { + item->proxy_socks = g_strdup (argv[i]); + item->set = TRUE; + } else if (g_strcmp0 (col_name[i], "no_proxy") == 0) { + item->no_proxy = g_strdup (argv[i]); + item->set = TRUE; + } else if (g_strcmp0 (col_name[i], "pac") == 0) { + item->pac = g_strdup (argv[i]); + item->set = TRUE; } else { g_warning ("%s = %s\n", col_name[i], argv[i]); } @@ -646,7 +658,7 @@ pk_transaction_db_get_proxy (PkTransactionDb *tdb, guint uid, const gchar *sessi /* get existing data */ item = g_new0 (PkTransactionDbProxyItem, 1); - statement = g_strdup_printf ("SELECT proxy_http, proxy_ftp FROM proxy WHERE uid = '%i' AND session = '%s' LIMIT 1", + statement = g_strdup_printf ("SELECT proxy_http, proxy_https, proxy_ftp, proxy_socks, no_proxy, pac FROM proxy WHERE uid = '%i' AND session = '%s' LIMIT 1", uid, session); rc = sqlite3_exec (tdb->priv->db, statement, pk_transaction_sqlite_proxy_cb, @@ -671,7 +683,7 @@ pk_transaction_db_get_proxy (PkTransactionDb *tdb, guint uid, const gchar *sessi if (proxy_http != NULL) *proxy_http = g_strdup (item->proxy_http); if (proxy_https != NULL) - *proxy_http = g_strdup (item->proxy_https); + *proxy_https = g_strdup (item->proxy_https); if (proxy_ftp != NULL) *proxy_ftp = g_strdup (item->proxy_ftp); if (proxy_socks != NULL) @@ -928,7 +940,15 @@ pk_transaction_db_init (PkTransactionDb *tdb) } /* session proxy saving (since 0.5.1) */ - rc = sqlite3_exec (tdb->priv->db, "SELECT proxy_https FROM proxy LIMIT 1", NULL, NULL, &error_msg); + rc = sqlite3_exec (tdb->priv->db, "SELECT * FROM proxy LIMIT 1", NULL, NULL, &error_msg); + if (rc != SQLITE_OK) { + g_debug ("adding table proxy: %s", error_msg); + statement = "CREATE TABLE proxy (created TEXT, proxy_http TEXT, proxy_https TEXT, proxy_ftp TEXT, proxy_socks TEXT, no_proxy TEXT, pac TEXT, uid INTEGER, session TEXT);"; + sqlite3_exec (tdb->priv->db, statement, NULL, NULL, NULL); + } + + /* session no_proxy proxy */ + rc = sqlite3_exec (tdb->priv->db, "SELECT no_proxy FROM proxy LIMIT 1", NULL, NULL, &error_msg); if (rc != SQLITE_OK) { g_debug ("altering table to repair: %s", error_msg); sqlite3_free (error_msg); @@ -942,14 +962,6 @@ pk_transaction_db_init (PkTransactionDb *tdb) sqlite3_exec (tdb->priv->db, statement, NULL, NULL, NULL); } - /* session no_proxy proxy */ - rc = sqlite3_exec (tdb->priv->db, "SELECT no_proxy FROM proxy LIMIT 1", NULL, NULL, &error_msg); - if (rc != SQLITE_OK) { - g_debug ("adding table proxy: %s", error_msg); - statement = "CREATE TABLE proxy (created TEXT, proxy_http TEXT, proxy_ftp TEXT, uid INTEGER, session TEXT);"; - sqlite3_exec (tdb->priv->db, statement, NULL, NULL, NULL); - } - /* transaction root (since 0.6.4) */ rc = sqlite3_exec (tdb->priv->db, "SELECT * FROM root LIMIT 1", NULL, NULL, &error_msg); if (rc != SQLITE_OK) { |