[PackageKit-commit] packagekit: Branch 'master' - 8 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Tue Apr 15 15:13:28 PDT 2008
backends/poldek/pk-backend-poldek.c | 84 +++++++++++-
backends/yum/helpers/yumBackend.py | 223 ++++++++++++++++----------------
backends/yum2/helpers/yumDBUSBackend.py | 12 -
docs/html/pk-faq.html | 12 -
docs/spec/pk-concepts.xml | 7 +
libpackagekit/pk-enum.c | 1
libpackagekit/pk-enum.h | 1
7 files changed, 215 insertions(+), 125 deletions(-)
New commits:
commit e2b7302863b6a942b5cc94509507a8583737ccac
Author: Marcin Banasiak <megabajt at pld-linux.org>
Date: Tue Apr 15 23:16:18 2008 +0200
update poldek status
diff --git a/docs/html/pk-faq.html b/docs/html/pk-faq.html
index 084a5d8..06ef195 100644
--- a/docs/html/pk-faq.html
+++ b/docs/html/pk-faq.html
@@ -114,7 +114,7 @@
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- conary -->
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- opkg -->
<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-good.png" alt="[yes]"/></td><!-- poldek -->
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- smart -->
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- yum -->
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- yum2 -->
@@ -369,7 +369,7 @@
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- conary -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg -->
<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-good.png" alt="[yes]"/></td><!-- poldek -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- smart -->
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- yum -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- yum2 -->
@@ -391,7 +391,7 @@
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- zypp -->
</tr>
<tr>
-<td><b>WhatRequires</b></td>
+<td><b>WhatProvides</b></td>
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- apt -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- apt2 -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- alpm -->
@@ -406,7 +406,7 @@
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- zypp -->
</tr>
<tr>
-<td><b>GetFiles</b></td>
+<td><b>GetPackages</b></td>
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- apt -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- apt2 -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- alpm -->
@@ -414,7 +414,7 @@
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg -->
<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><!-- poldek -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- smart -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- yum -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- yum2 -->
@@ -538,7 +538,7 @@
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg -->
<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><!-- poldek -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- smart -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- yum -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- yum2 -->
commit 08d9e7dd85beff1074de7e91c7cf9bd4f820c8d2
Author: Marcin Banasiak <megabajt at pld-linux.org>
Date: Tue Apr 15 23:05:55 2008 +0200
poldek: add backend_get_cancel(). Currently not working for all methods, but it's a good start.
diff --git a/backends/poldek/pk-backend-poldek.c b/backends/poldek/pk-backend-poldek.c
index d5565be..3c5a3e3 100644
--- a/backends/poldek/pk-backend-poldek.c
+++ b/backends/poldek/pk-backend-poldek.c
@@ -35,6 +35,7 @@
#include <pkgmisc.h>
#include <pm/pm.h>
#include <vfile/vfile.h>
+#include <sigint/sigint.h>
static gchar* poldek_pkg_evr (const struct pkg *pkg);
static void poldek_backend_package (const struct pkg *pkg, gint status);
@@ -1036,6 +1037,9 @@ search_package (PkBackendThread *thread, gpointer data)
for (i = 0; i < n_array_size (pkgs); i++) {
struct pkg *pkg = n_array_nth (pkgs, i);
+ if (sigint_reached ())
+ break;
+
/* check if we have to do development filtering
* (devel or ~devel in filters) */
if (pk_enums_contain (d->filters, PK_FILTER_ENUM_DEVELOPMENT) ||
@@ -1075,6 +1079,19 @@ search_package (PkBackendThread *thread, gpointer data)
poclidek_rcmd_free (cmd);
}
+ if (sigint_reached ()) {
+ switch (d->mode) {
+ case SEARCH_ENUM_NAME:
+ case SEARCH_ENUM_GROUP:
+ case SEARCH_ENUM_DETAILS:
+ case SEARCH_ENUM_FILE:
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "Search cancelled.");
+ break;
+ default:
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "Transaction cancelled.");
+ }
+ }
+
g_free (search_cmd);
g_free (d->search);
g_free (d);
@@ -1106,6 +1123,17 @@ poldek_backend_log (void *data, int pri, char *message)
}
static void
+poldek_backend_set_allow_cancel (PkBackend *backend, gboolean allow_cancel, gboolean reset)
+{
+ g_return_if_fail (backend != NULL);
+
+ if (reset)
+ sigint_reset ();
+
+ pk_backend_set_allow_cancel (backend, allow_cancel);
+}
+
+static void
do_poldek_init (void) {
poldeklib_init ();
@@ -1131,10 +1159,18 @@ do_poldek_init (void) {
poldek_configure (ctx, POLDEK_CONF_OPT, POLDEK_OP_CONFIRM_UNINST, 1);
/* (...), but we don't need choose_equiv callback */
poldek_configure (ctx, POLDEK_CONF_OPT, POLDEK_OP_EQPKG_ASKUSER, 0);
+
+ /* load information about installed and available packages */
+ poclidek_load_packages (cctx, POCLIDEK_LOAD_ALL);
+
+ sigint_init ();
}
static void
-do_poldek_destroy (void) {
+do_poldek_destroy (void)
+{
+ sigint_destroy ();
+
poclidek_free (cctx);
poldek_free (ctx);
@@ -1188,6 +1224,7 @@ static PkFilterEnum
backend_get_filters (PkBackend *backend)
{
g_return_val_if_fail (backend != NULL, PK_FILTER_ENUM_UNKNOWN);
+
return (PK_FILTER_ENUM_NEWEST |
PK_FILTER_ENUM_GUI |
PK_FILTER_ENUM_INSTALLED |
@@ -1195,6 +1232,19 @@ backend_get_filters (PkBackend *backend)
}
/**
+ * backend_get_cancel:
+ **/
+static void
+backend_get_cancel (PkBackend *backend)
+{
+ g_return_if_fail (backend != NULL);
+
+ pk_backend_set_status (backend, PK_STATUS_ENUM_CANCEL);
+
+ sigint_emit ();
+}
+
+/**
* backend_get_depends:
*/
static gboolean
@@ -1249,6 +1299,7 @@ backend_get_depends (PkBackend *backend, PkFilterEnum filters, const gchar *pack
g_return_if_fail (backend != NULL);
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+ poldek_backend_set_allow_cancel (backend, FALSE, TRUE);
data->package_id = g_strdup (package_id);
data->filters = filters;
@@ -1312,6 +1363,7 @@ backend_get_description (PkBackend *backend, const gchar *package_id)
g_return_if_fail (backend != NULL);
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+ poldek_backend_set_allow_cancel (backend, FALSE, TRUE);
pk_backend_thread_create (thread,
(PkBackendThreadFunc)backend_get_description_thread,
@@ -1390,6 +1442,7 @@ backend_get_files (PkBackend *backend, const gchar *package_id)
g_return_if_fail (backend != NULL);
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+ poldek_backend_set_allow_cancel (backend, FALSE, TRUE);
pk_backend_thread_create (thread,
(PkBackendThreadFunc)backend_get_files_thread,
@@ -1407,6 +1460,7 @@ backend_get_packages (PkBackend *backend, PkFilterEnum filters)
g_return_if_fail (backend != NULL);
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+ poldek_backend_set_allow_cancel (backend, TRUE, TRUE);
data->mode = SEARCH_ENUM_NONE;
data->filters = filters;
@@ -1466,6 +1520,7 @@ backend_get_requires (PkBackend *backend, PkFilterEnum filters, const gchar *pac
g_return_if_fail (backend != NULL);
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+ poldek_backend_set_allow_cancel (backend, FALSE, TRUE);
data->package_id = g_strdup (package_id);
data->filters = filters;
@@ -1554,6 +1609,7 @@ backend_get_update_detail (PkBackend *backend, const gchar *package_id)
g_return_if_fail (backend != NULL);
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+ poldek_backend_set_allow_cancel (backend, FALSE, TRUE);
pk_backend_thread_create (thread,
(PkBackendThreadFunc)backend_get_update_detail_thread,
@@ -1588,6 +1644,9 @@ backend_get_updates_thread (PkBackendThread *thread, gpointer data)
for (i = 0; i < n_array_size (pkgs); i++) {
struct pkg *pkg = n_array_nth (pkgs, i);
+ if (sigint_reached ())
+ break;
+
/* mark held packages as blocked */
if (pkg->flags & PKG_HELD)
poldek_backend_package (pkg, PK_INFO_ENUM_BLOCKED);
@@ -1600,6 +1659,9 @@ backend_get_updates_thread (PkBackendThread *thread, gpointer data)
poclidek_rcmd_free (rcmd);
+ if (sigint_reached ())
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "Action cancelled.");
+
pk_backend_finished (backend);
return TRUE;
@@ -1611,6 +1673,7 @@ backend_get_updates (PkBackend *backend, PkFilterEnum filters)
g_return_if_fail (backend != NULL);
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+ poldek_backend_set_allow_cancel (backend, TRUE, TRUE);
pk_backend_thread_create (thread, backend_get_updates_thread, NULL);
}
@@ -1683,6 +1746,8 @@ backend_install_package (PkBackend *backend, const gchar *package_id)
return;
}
+ poldek_backend_set_allow_cancel (backend, FALSE, TRUE);
+
data->package_id = g_strdup (package_id);
data->pd = g_new0 (PercentageData, 1);
pk_backend_thread_create (thread, backend_install_package_thread, data);
@@ -1758,6 +1823,7 @@ backend_refresh_cache (PkBackend *backend, gboolean force)
g_return_if_fail (backend != NULL);
pk_backend_set_status (backend, PK_STATUS_ENUM_REFRESH_CACHE);
+ poldek_backend_set_allow_cancel (backend, FALSE, TRUE);
if (pk_network_is_online (network) == FALSE) {
pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot refresh cache when offline!");
@@ -1800,8 +1866,6 @@ backend_remove_package_thread (PkBackendThread *thread, gpointer data)
pk_backend_error_code (backend, PK_ERROR_ENUM_CANNOT_REMOVE_SYSTEM_PACKAGE, "Package can't be removed!");
}
- poclidek_load_packages (cctx, POCLIDEK_LOAD_RELOAD);
-
g_free (nvra);
g_free (command);
@@ -1823,6 +1887,8 @@ backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean al
g_return_if_fail (backend != NULL);
+ poldek_backend_set_allow_cancel (backend, FALSE, TRUE);
+
data->package_id = g_strdup (package_id);
data->allow_deps = allow_deps;
pk_backend_thread_create (thread, backend_remove_package_thread, data);
@@ -1839,6 +1905,7 @@ backend_resolve (PkBackend *backend, PkFilterEnum filters, const gchar *package)
g_return_if_fail (backend != NULL);
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+ poldek_backend_set_allow_cancel (backend, TRUE, TRUE);
data->mode = SEARCH_ENUM_NAME;
data->filters = filters;
@@ -1857,6 +1924,7 @@ backend_search_details (PkBackend *backend, PkFilterEnum filters, const gchar *s
g_return_if_fail (backend != NULL);
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+ poldek_backend_set_allow_cancel (backend, TRUE, TRUE);
data->mode = SEARCH_ENUM_DETAILS;
data->filters = filters;
@@ -1875,6 +1943,7 @@ backend_search_file (PkBackend *backend, PkFilterEnum filters, const gchar *sear
g_return_if_fail (backend != NULL);
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+ poldek_backend_set_allow_cancel (backend, TRUE, TRUE);
data->mode = SEARCH_ENUM_FILE;
data->filters = filters;
@@ -1893,6 +1962,7 @@ backend_search_group (PkBackend *backend, PkFilterEnum filters, const gchar *sea
g_return_if_fail (backend != NULL);
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+ poldek_backend_set_allow_cancel (backend, TRUE, TRUE);
data->mode = SEARCH_ENUM_GROUP;
data->filters = filters;
@@ -1911,6 +1981,7 @@ backend_search_name (PkBackend *backend, PkFilterEnum filters, const gchar *sear
g_return_if_fail (backend != NULL);
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+ poldek_backend_set_allow_cancel (backend, TRUE, TRUE);
data->mode = SEARCH_ENUM_NAME;
data->filters = filters;
@@ -2020,6 +2091,8 @@ backend_update_packages (PkBackend *backend, gchar **package_ids)
return;
}
+ poldek_backend_set_allow_cancel (backend, FALSE, TRUE);
+
data->package_ids = g_strdupv (package_ids);
data->pd = g_new0 (PercentageData, 1);
data->type = TS_TYPE_ENUM_UPDATE;
@@ -2147,6 +2220,8 @@ backend_update_system (PkBackend *backend)
return;
}
+ poldek_backend_set_allow_cancel (backend, FALSE, TRUE);
+
data->pd = g_new0 (PercentageData, 1);
data->type = TS_TYPE_ENUM_UPDATE;
@@ -2164,6 +2239,7 @@ backend_get_repo_list (PkBackend *backend, PkFilterEnum filters)
g_return_if_fail (backend != NULL);
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+ poldek_backend_set_allow_cancel (backend, FALSE, TRUE);
sources = poldek_get_sources (ctx);
@@ -2193,7 +2269,7 @@ PK_BACKEND_OPTIONS (
backend_destroy, /* destroy */
NULL, /* get_groups */
backend_get_filters, /* get_filters */
- NULL, /* cancel */
+ backend_get_cancel, /* cancel */
backend_get_depends, /* get_depends */
backend_get_description, /* get_description */
backend_get_files, /* get_files */
commit 749808d6b9917768899251845802bea7b0462650
Merge: e90cd11... 9940602...
Author: Robin Norwood <rnorwood at redhat.com>
Date: Tue Apr 15 16:58:09 2008 -0400
Merge branch 'master' of git+ssh://rnorwood@git.packagekit.org/srv/git/PackageKit
commit e90cd111313c9990cf385c99c75b883972b5b1ed
Author: Robin Norwood <rnorwood at redhat.com>
Date: Tue Apr 15 16:57:40 2008 -0400
Change from network error to repo error when we cannot connect to a repository.
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index e30c683..e4a7580 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -1393,7 +1393,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
'''
if issubclass(tb, (yum.Errors.RepoError, IOError)):
# Unhandled Repo error, can be network problems
- self.error(ERROR_NO_NETWORK,"Problem with loading repository metadata, this can be caused by network problems or repository misconfigurations")
+ self.error(ERROR_REPO_NOT_AVAILABLE, "Problem connecting to repository, this can be caused by network problems or a misconfigured repository")
return True
else: # Do the default stuff
return False
diff --git a/docs/spec/pk-concepts.xml b/docs/spec/pk-concepts.xml
index 9dd0823..50c11c9 100644
--- a/docs/spec/pk-concepts.xml
+++ b/docs/spec/pk-concepts.xml
@@ -297,6 +297,13 @@
<entry><literal>repo-configuration-error</literal></entry>
<entry>One of the enabled repositories has invalid configuration</entry>
</row>
+ <row>
+ <entry><literal>repo-not-available</literal></entry>
+ <entry>
+ There was a (possibly transient) problem connecting to a
+ repository
+ </entry>
+ </row>
<row>
<entry><literal>cannot-remove-system-package</literal></entry>
<entry>
diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index be3fc27..559c431 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -139,6 +139,7 @@ static PkEnumMatch enum_error[] = {
{PK_ERROR_ENUM_REPO_CONFIGURATION_ERROR, "repo-configuration-error"},
{PK_ERROR_ENUM_NO_LICENSE_AGREEMENT, "no-license-agreement"},
{PK_ERROR_ENUM_FILE_CONFLICTS, "file-conflicts"},
+ {PK_ERROR_ENUM_REPO_NOT_AVAILABLE, "repo-not-available"},
{0, NULL}
};
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index f4a2020..fcd5460 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -228,6 +228,7 @@ typedef enum {
PK_ERROR_ENUM_REPO_CONFIGURATION_ERROR,
PK_ERROR_ENUM_NO_LICENSE_AGREEMENT,
PK_ERROR_ENUM_FILE_CONFLICTS,
+ PK_ERROR_ENUM_REPO_NOT_AVAILABLE,
PK_ERROR_ENUM_UNKNOWN
} PkErrorCodeEnum;
commit 99406023bf8e16b04da26fc4956efbf2c2117568
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Apr 15 20:19:11 2008 +0100
go on a whitespace binge
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index e30c683..2f83071 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -228,7 +228,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
func(*args, **kwargs)
except yum.Errors.RepoError,e:
self._refresh_yum_cache()
-
+
try:
func(*args, **kwargs)
except yum.Errors.RepoError, e:
@@ -633,11 +633,11 @@ class PackageKitYumBackend(PackageKitBaseBackend):
if len(id.split(';')) > 1:
# Split up the id
(n,idver,a,d) = self.get_package_from_id(id)
- # get e,v,r from package id version
+ # get e,v,r from package id version
e,v,r = self._getEVR(idver)
else:
n = id
- e = v = r = a = None
+ e = v = r = a = None
# search the rpmdb for the nevra
pkgs = self.yumbase.rpmdb.searchNevra(name=n,epoch=e,ver=v,rel=r,arch=a)
# if the package is found, then return it
@@ -653,15 +653,13 @@ class PackageKitYumBackend(PackageKitBaseBackend):
def _get_pkg_requirements(self,pkg,reqlist=[] ):
pkgs = self.yumbase.rpmdb.searchRequires(pkg.name)
- print
reqlist.extend(pkgs)
- print "DEBUG: ", reqlist
if pkgs:
for po in pkgs:
self._get_pkg_requirements(po,reqlist)
else:
return reqlist
-
+
def get_requires(self,filters,package,recursive):
'''
Print a list of requires for a given package
@@ -906,8 +904,6 @@ class PackageKitYumBackend(PackageKitBaseBackend):
#TODO Add code to send a message here
self.message(MESSAGE_WARNING,"Newer version of %s, exist in the repositories " % po.name)
-
-
def install_file (self, inst_file):
'''
Implement the {backend}-install_file functionality
@@ -936,7 +932,6 @@ class PackageKitYumBackend(PackageKitBaseBackend):
self.error(ERROR_PACKAGE_ALREADY_INSTALLED,msgs)
else:
self.error(ERROR_PACKAGE_ALREADY_INSTALLED,"Can't install %s " % inst_file)
-
def update(self, packages):
'''
@@ -972,7 +967,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
break
def _format_msgs(self,msgs):
- if isinstance(msgs, basestring):
+ if isinstance(msgs, basestring):
msgs = msgs.split('\n')
return ";".join(msgs)
@@ -1065,7 +1060,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
else:
self.error(ERROR_PACKAGE_NOT_FOUND,'Package was not found')
- def _show_description(self,pkg):
+ def _show_description(self,pkg):
pkgver = self._get_package_ver(pkg)
id = self.get_package_id(pkg.name, pkgver, pkg.arch, pkg.repo)
desc = pkg.description
@@ -1255,7 +1250,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
_updateMetadata = None
updateMetadata = property(fget=_get_update_metadata)
-
+
def _format_str(self,str):
"""
Convert a multi line string to a list separated by ';'
@@ -1295,7 +1290,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
urls[typ].append("%s;%s" % (href,title))
else:
urls['vendor'].append("%s;%s" % (ref['href'],ref['title']))
-
+
# Reboot flag
if notice.get_metadata().has_key('reboot_suggested') and notice['reboot_suggested']:
reboot = 'system'
@@ -1417,7 +1412,7 @@ class DownloadCallback( BaseMeter ):
self.numPkgs = float(len(self.pkgs))
self.bump = numPct/self.numPkgs
self.totalPct = startPct
-
+
def _getPackage(self,name):
if self.pkgs:
for pkg in self.pkgs:
@@ -1497,7 +1492,7 @@ class DownloadCallback( BaseMeter ):
else:
typ = 'unknown'
self.base.metadata(typ,name)
- self.base.sub_percentage(0)
+ self.base.sub_percentage(0)
else:
if self.lastPct != pct and pct != 0 and pct != 100:
self.lastPct = pct
@@ -1584,7 +1579,6 @@ class ProcessTransPackageKitCallback:
self.base.percentage(50)
pass
-
class DepSolveCallback(object):
# XXX takes a PackageKitBackend so we can call StatusChanged on it.
@@ -1605,7 +1599,6 @@ class DepSolveCallback(object):
def __getattr__(self, x):
return self._do_nothing
-
class PackageKitYumBase(yum.YumBase):
"""
Subclass of YumBase. Needed so we can overload _checkSignatures
diff --git a/backends/yum2/helpers/yumDBUSBackend.py b/backends/yum2/helpers/yumDBUSBackend.py
index 41ec362..e74434c 100755
--- a/backends/yum2/helpers/yumDBUSBackend.py
+++ b/backends/yum2/helpers/yumDBUSBackend.py
@@ -374,7 +374,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
self._cancelled.clear()
return True
return False
-
+
@threaded
@async
def doSearchName(self, filters, search):
@@ -840,7 +840,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
self.ErrorCode(ERROR_CANNOT_INSTALL_SOURCE_PACKAGE,'Backend will not install a src rpm file')
self.Finished(EXIT_FAILED)
return
-
+
self._check_init()
self._lock_yum()
self.AllowCancel(True)
@@ -1344,7 +1344,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
self.AllowCancel(True)
self.NoPercentageUpdates()
self.StatusChanged(STATUS_INFO)
-
+
fltlist = filters.split(';')
if not FILTER_NOT_INSTALLED in fltlist:
@@ -1356,7 +1356,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
if self._do_extra_filtering(result, fltlist):
self._show_package(result,INFO_AVAILABLE)
-
+
if not FILTER_INSTALLED in fltlist:
results = self.yumbase.rpmdb.searchProvides(search)
for result in results:
@@ -1595,8 +1595,8 @@ class PackageKitYumBackend(PackageKitBaseBackend):
def _is_inst(self,pkg):
return self.yumbase.rpmdb.installed(po=pkg)
-
-
+
+
def _installable(self, pkg, ematch=False):
commit 342374cf9b396427ead6225bd9931937cc9d478a
Author: Robin Norwood <rnorwood at redhat.com>
Date: Tue Apr 15 14:34:57 2008 -0400
Set default throttle to 90%
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 7bc8044..e30c683 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -797,12 +797,18 @@ class PackageKitYumBackend(PackageKitBaseBackend):
self.percentage(0)
self.status(STATUS_RUNNING)
+ old_throttle = self.yumbase.conf.throttle
+ self.yumbase.conf.throttle = "60%" # Set bandwidth throttle to 60%
+ # to avoid taking all the system's bandwidth.
+
txmbr = self.yumbase.update() # Add all updates to Transaction
if txmbr:
self._runYumTransaction()
else:
self.error(ERROR_NO_PACKAGES_TO_UPDATE,"Nothing to do")
+ self.yumbase.conf.throttle = old_throttle
+
def refresh_cache(self):
'''
Implement the {backend}-refresh_cache functionality
@@ -1372,7 +1378,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
def _setup_yum(self):
self.yumbase.doConfigSetup(errorlevel=0,debuglevel=0) # Setup Yum Config
- self.yumbase.conf.throttle = "40%" # Set bandwidth throttle to 40%
+ self.yumbase.conf.throttle = "90%" # Set bandwidth throttle to 40%
self.dnlCallback = DownloadCallback(self,showNames=True) # Download callback
self.yumbase.repos.setProgressBar( self.dnlCallback ) # Setup the download callback class
commit 39560bbbc8b362c7a95f3f6f14a0d68c059b0e00
Merge: 12cc5ab... 8ed5a03...
Author: Robin Norwood <rnorwood at redhat.com>
Date: Tue Apr 15 14:12:58 2008 -0400
Merge diffs.
diff --cc backends/yum/helpers/yumBackend.py
index e8611d4,0c5a55e..7bc8044
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@@ -316,24 -299,38 +316,32 @@@ class PackageKitYumBackend(PackageKitBa
@param filters: package types to search (all,installed,available)
@param key: key to seach for
'''
- self.yumbase.doConfigSetup(errorlevel=0,debuglevel=0)# Setup Yum Config
- try:
- res = self.yumbase.searchGenerator(searchlist, [key])
- fltlist = filters.split(';')
- installed_nevra = [] # yum returns packages as available even when installed
- pkg_list = [] # only do the second iteration on not installed pkgs
- package_list = [] #we can't do emitting as found if we are post-processing
-
- for (pkg,values) in res:
- if pkg.repo.id == 'installed':
- if self._do_extra_filtering(pkg,fltlist):
- package_list.append((pkg,INFO_INSTALLED))
- installed_nevra.append(self._get_nevra(pkg))
- else:
- pkg_list.append(pkg)
- for pkg in pkg_list:
- nevra = self._get_nevra(pkg)
- if nevra not in installed_nevra:
- if self._do_extra_filtering(pkg,fltlist):
- package_list.append((pkg,INFO_AVAILABLE))
+ res = self.yumbase.searchGenerator(searchlist, [key])
+ fltlist = filters.split(';')
+ installed_nevra = [] # yum returns packages as available even when installed
+ pkg_list = [] # only do the second iteration on not installed pkgs
++ package_list = [] #we can't do emitting as found if we are post-processing
- except yum.Errors.RepoError,e:
- self._refresh_yum_cache()
- self.error(ERROR_NO_CACHE,"Package cache was invalid and has been rebuilt.")
+ for (pkg,values) in res:
+ if pkg.repo.id == 'installed':
+ if self._do_extra_filtering(pkg,fltlist):
- self._show_package(pkg, INFO_INSTALLED)
++ package_list.append((pkg,INFO_INSTALLED))
+ installed_nevra.append(self._get_nevra(pkg))
+ else:
+ pkg_list.append(pkg)
+ for pkg in pkg_list:
+ nevra = self._get_nevra(pkg)
+ if nevra not in installed_nevra:
+ if self._do_extra_filtering(pkg,fltlist):
- self._show_package(pkg, INFO_AVAILABLE)
++ package_list.append((pkg,INFO_AVAILABLE))
+ # basename filter if specified
+ if FILTER_BASENAME in fltlist:
+ for (pkg,status) in self._basename_filter(package_list):
+ self._show_package(pkg,status)
+ else:
+ for (pkg,status) in package_list:
+ self._show_package(pkg,status)
def _do_extra_filtering(self,pkg,filterList):
''' do extra filtering (gui,devel etc) '''
@@@ -528,8 -490,18 +507,16 @@@
except yum.Errors.GroupsError,e:
self.error(ERROR_GROUP_NOT_FOUND,e)
- except yum.Errors.RepoError,e:
- self._refresh_yum_cache()
- self.error(ERROR_NO_CACHE,"Package cache was invalid and has been rebuilt.")
+ # basename filter if specified
+ if FILTER_BASENAME in fltlist:
+ for (pkg,status) in self._basename_filter(package_list):
+ self._show_package(pkg,status)
+ else:
+ for (pkg,status) in package_list:
+ self._show_package(pkg,status)
+
+ @handle_repo_error
def get_packages(self,filters):
'''
Search for yum packages
@@@ -541,22 -513,33 +528,31 @@@
self.allow_cancel(True)
self.yumbase.doConfigSetup(errorlevel=0,debuglevel=0)# Setup Yum Config
self.yumbase.conf.cache = 1 # Only look in cache.
+
+ package_list = [] #we can't do emitting as found if we are post-processing
fltlist = filters.split(';')
- available = []
- count = 1
+
- try:
- # Now show installed packages.
- if FILTER_NOT_INSTALLED not in fltlist:
- for pkg in self.yumbase.rpmdb:
- if self._do_extra_filtering(pkg,fltlist):
- package_list.append((pkg,INFO_INSTALLED))
-
- # Now show available packages.
- if FILTER_INSTALLED not in fltlist:
- for pkg in self.yumbase.pkgSack.returnNewestByNameArch():
- if self._do_extra_filtering(pkg,fltlist):
- package_list.append((pkg,INFO_AVAILABLE))
- except yum.Errors.RepoError,e:
- self._refresh_yum_cache()
- self.error(ERROR_NO_CACHE,"Package cache was invalid and has been rebuilt.")
++ # Now show installed packages.
+ if FILTER_NOT_INSTALLED not in fltlist:
+ for pkg in self.yumbase.rpmdb:
+ if self._do_extra_filtering(pkg,fltlist):
- self._show_package(pkg, INFO_INSTALLED)
++ package_list.append((pkg,INFO_INSTALLED))
+
+ # Now show available packages.
+ if FILTER_INSTALLED not in fltlist:
+ for pkg in self.yumbase.pkgSack.returnNewestByNameArch():
+ if self._do_extra_filtering(pkg,fltlist):
- self._show_package(pkg, INFO_AVAILABLE)
++ package_list.append((pkg,INFO_AVAILABLE))
+
+ # basename filter if specified
+ if FILTER_BASENAME in fltlist:
+ for (pkg,status) in self._basename_filter(package_list):
+ self._show_package(pkg,status)
+ else:
+ for (pkg,status) in package_list:
+ self._show_package(pkg,status)
+ @handle_repo_error
def search_file(self,filters,key):
'''
Implement the {backend}-search-file functionality
@@@ -1120,18 -1144,31 +1154,27 @@@
self.status(STATUS_INFO)
fltlist = filters.split(';')
+ package_list = []
- try:
- ygl = self.yumbase.doPackageLists(pkgnarrow='updates')
- md = self.updateMetadata
- for pkg in ygl.updates:
- if self._do_extra_filtering(pkg, fltlist):
- # Get info about package in updates info
- notice = md.get_notice((pkg.name, pkg.version, pkg.release))
- if notice:
- status = self._get_status(notice)
- package_list.append((pkg,status))
- else:
- package_list.append((pkg,INFO_NORMAL))
- except yum.Errors.RepoError,e:
- self._refresh_yum_cache()
- self.error(ERROR_NO_CACHE,"Package cache was invalid and has been rebuilt.")
+ ygl = self.yumbase.doPackageLists(pkgnarrow='updates')
+ md = self.updateMetadata
+ for pkg in ygl.updates:
+ if self._do_extra_filtering(pkg, fltlist):
+ # Get info about package in updates info
+ notice = md.get_notice((pkg.name, pkg.version, pkg.release))
+ if notice:
+ status = self._get_status(notice)
- self._show_package(pkg,status)
++ package_list.append((pkg,status))
+ else:
- self._show_package(pkg,INFO_NORMAL)
++ package_list.append((pkg,INFO_NORMAL))
+
+ # basename filter if specified
+ if FILTER_BASENAME in fltlist:
+ for (pkg,status) in self._basename_filter(package_list):
+ self._show_package(pkg,status)
+ else:
+ for (pkg,status) in package_list:
+ self._show_package(pkg,status)
def repo_enable(self, repoid, enable):
'''
commit 12cc5abc950af7cc0079a729b5bf317981db50bb
Author: Robin Norwood <rnorwood at redhat.com>
Date: Tue Apr 15 13:41:37 2008 -0400
Handle cache errors for yum backend by rebuilding the cache and trying again.
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 11d3c11..e8611d4 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -220,6 +220,22 @@ class PackageKitYumBackend(PackageKitBaseBackend):
"kernel-xen0", "kernel-xenU", "kernel-xen", "kernel-xen-guest",
"glibc", "hal", "dbus", "xen")
+ def handle_repo_error(func):
+ def wrapper(*args, **kwargs):
+ self = args[0]
+
+ try:
+ func(*args, **kwargs)
+ except yum.Errors.RepoError,e:
+ self._refresh_yum_cache()
+
+ try:
+ func(*args, **kwargs)
+ except yum.Errors.RepoError, e:
+ self.error(ERROR_NO_CACHE,"Package cache is invalid and could not be rebuilt .")
+
+ return wrapper
+
def __init__(self,args,lock=True):
signal.signal(signal.SIGQUIT, sigquit)
PackageKitBaseBackend.__init__(self,args)
@@ -292,6 +308,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
''' gets the NEVRA for a pkg '''
return "%s-%s:%s-%s.%s" % (pkg.name,pkg.epoch,pkg.version,pkg.release,pkg.arch);
+ @handle_repo_error
def _do_search(self,searchlist,filters,key):
'''
Search for yum packages
@@ -299,29 +316,24 @@ class PackageKitYumBackend(PackageKitBaseBackend):
@param filters: package types to search (all,installed,available)
@param key: key to seach for
'''
- self.yumbase.doConfigSetup(errorlevel=0,debuglevel=0)# Setup Yum Config
- try:
- res = self.yumbase.searchGenerator(searchlist, [key])
- fltlist = filters.split(';')
- installed_nevra = [] # yum returns packages as available even when installed
- pkg_list = [] # only do the second iteration on not installed pkgs
+ res = self.yumbase.searchGenerator(searchlist, [key])
+ fltlist = filters.split(';')
+ installed_nevra = [] # yum returns packages as available even when installed
+ pkg_list = [] # only do the second iteration on not installed pkgs
- for (pkg,values) in res:
- if pkg.repo.id == 'installed':
- if self._do_extra_filtering(pkg,fltlist):
- self._show_package(pkg, INFO_INSTALLED)
- installed_nevra.append(self._get_nevra(pkg))
- else:
- pkg_list.append(pkg)
- for pkg in pkg_list:
- nevra = self._get_nevra(pkg)
- if nevra not in installed_nevra:
- if self._do_extra_filtering(pkg,fltlist):
- self._show_package(pkg, INFO_AVAILABLE)
+ for (pkg,values) in res:
+ if pkg.repo.id == 'installed':
+ if self._do_extra_filtering(pkg,fltlist):
+ self._show_package(pkg, INFO_INSTALLED)
+ installed_nevra.append(self._get_nevra(pkg))
+ else:
+ pkg_list.append(pkg)
+ for pkg in pkg_list:
+ nevra = self._get_nevra(pkg)
+ if nevra not in installed_nevra:
+ if self._do_extra_filtering(pkg,fltlist):
+ self._show_package(pkg, INFO_AVAILABLE)
- except yum.Errors.RepoError,e:
- self._refresh_yum_cache()
- self.error(ERROR_NO_CACHE,"Package cache was invalid and has been rebuilt.")
def _do_extra_filtering(self,pkg,filterList):
''' do extra filtering (gui,devel etc) '''
@@ -363,15 +375,11 @@ class PackageKitYumBackend(PackageKitBaseBackend):
def _check_for_gui(self,pkg):
''' Check if the GUI_KEYS regex matches any package requirements'''
- try:
- for req in pkg.requires:
- reqname = req[0]
- if GUI_KEYS.search(reqname):
- return True
- return False
- except yum.Errors.RepoError,e:
- self._refresh_yum_cache()
- self.error(ERROR_NO_CACHE,"Package cache was invalid and has been rebuilt.")
+ for req in pkg.requires:
+ reqname = req[0]
+ if GUI_KEYS.search(reqname):
+ return True
+ return False
def _do_devel_filtering(self,flt,pkg):
isDevel = False
@@ -432,7 +440,12 @@ class PackageKitYumBackend(PackageKitBaseBackend):
searchlist = ['name']
self.status(STATUS_QUERY)
- self._do_search(searchlist, filters, key)
+ self.yumbase.doConfigSetup(errorlevel=0,debuglevel=0)# Setup Yum Config
+
+ try:
+ self._do_search(searchlist, filters, key)
+ except RefreshYumCacheFailed, e:
+ return
def search_details(self,filters,key):
'''
@@ -444,7 +457,11 @@ class PackageKitYumBackend(PackageKitBaseBackend):
searchlist = ['name', 'summary', 'description', 'group']
self.status(STATUS_QUERY)
- self._do_search(searchlist, filters, key)
+
+ try:
+ self._do_search(searchlist, filters, key)
+ except RefreshYumCacheFailed, e:
+ return
def _buildGroupDict(self):
pkgGroups= {}
@@ -464,6 +481,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
pkgGroups[pkg] = "%s;%s" % (cat.categoryid,group.groupid)
return pkgGroups
+ @handle_repo_error
def search_group(self,filters,key):
'''
Implement the {backend}-search-group functionality
@@ -510,10 +528,8 @@ class PackageKitYumBackend(PackageKitBaseBackend):
except yum.Errors.GroupsError,e:
self.error(ERROR_GROUP_NOT_FOUND,e)
- except yum.Errors.RepoError,e:
- self._refresh_yum_cache()
- self.error(ERROR_NO_CACHE,"Package cache was invalid and has been rebuilt.")
+ @handle_repo_error
def get_packages(self,filters):
'''
Search for yum packages
@@ -525,24 +541,22 @@ class PackageKitYumBackend(PackageKitBaseBackend):
self.allow_cancel(True)
self.yumbase.doConfigSetup(errorlevel=0,debuglevel=0)# Setup Yum Config
self.yumbase.conf.cache = 1 # Only look in cache.
- try:
- fltlist = filters.split(';')
- available = []
- count = 1
- if FILTER_NOT_INSTALLED not in fltlist:
- for pkg in self.yumbase.rpmdb:
- if self._do_extra_filtering(pkg,fltlist):
- self._show_package(pkg, INFO_INSTALLED)
- # Now show available packages.
- if FILTER_INSTALLED not in fltlist:
- for pkg in self.yumbase.pkgSack.returnNewestByNameArch():
- if self._do_extra_filtering(pkg,fltlist):
- self._show_package(pkg, INFO_AVAILABLE)
- except yum.Errors.RepoError,e:
- self._refresh_yum_cache()
- self.error(ERROR_NO_CACHE,"Package cache was invalid and has been rebuilt.")
-
+ fltlist = filters.split(';')
+ available = []
+ count = 1
+ if FILTER_NOT_INSTALLED not in fltlist:
+ for pkg in self.yumbase.rpmdb:
+ if self._do_extra_filtering(pkg,fltlist):
+ self._show_package(pkg, INFO_INSTALLED)
+
+ # Now show available packages.
+ if FILTER_INSTALLED not in fltlist:
+ for pkg in self.yumbase.pkgSack.returnNewestByNameArch():
+ if self._do_extra_filtering(pkg,fltlist):
+ self._show_package(pkg, INFO_AVAILABLE)
+
+ @handle_repo_error
def search_file(self,filters,key):
'''
Implement the {backend}-search-file functionality
@@ -573,6 +587,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
self._show_package(pkg, INFO_AVAILABLE)
found[str(pkg)] = 1
+ @handle_repo_error
def what_provides(self, filters, provides_type, search):
'''
Implement the {backend}-what-provides functionality
@@ -651,8 +666,6 @@ class PackageKitYumBackend(PackageKitBaseBackend):
else:
return reqlist
-
-
def get_requires(self,filters,package,recursive):
'''
Print a list of requires for a given package
@@ -831,6 +844,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
except yum.Errors.YumBaseError, e:
self.error(ERROR_UNKNOWN,str(e))
+ @handle_repo_error
def resolve(self, filters, name):
'''
Implement the {backend}-resolve functionality
@@ -843,28 +857,25 @@ class PackageKitYumBackend(PackageKitBaseBackend):
self.status(STATUS_QUERY)
fltlist = filters.split(';')
- try:
- # Get installed packages
- installedByKey = self.yumbase.rpmdb.searchNevra(name=name)
- if FILTER_NOT_INSTALLED not in fltlist:
- for pkg in installedByKey:
- self._show_package(pkg,INFO_INSTALLED)
- # Get available packages
- if FILTER_INSTALLED not in fltlist:
- for pkg in self.yumbase.pkgSack.returnNewestByNameArch():
- if pkg.name == name:
- show = True
- for instpo in installedByKey:
- # Check if package have a smaller & equal EVR to a inst pkg
- if pkg.EVR < instpo.EVR or pkg.EVR == instpo.EVR:
- show = False
- if show:
- self._show_package(pkg,INFO_AVAILABLE)
- break
- except yum.Errors.RepoError,e:
- self._refresh_yum_cache()
- self.error(ERROR_NO_CACHE,"Package cache was invalid and has been rebuilt.")
-
+ # Get installed packages
+ installedByKey = self.yumbase.rpmdb.searchNevra(name=name)
+ if FILTER_NOT_INSTALLED not in fltlist:
+ for pkg in installedByKey:
+ self._show_package(pkg,INFO_INSTALLED)
+ # Get available packages
+ if FILTER_INSTALLED not in fltlist:
+ for pkg in self.yumbase.pkgSack.returnNewestByNameArch():
+ if pkg.name == name:
+ show = True
+ for instpo in installedByKey:
+ # Check if package have a smaller & equal EVR to a inst pkg
+ if pkg.EVR < instpo.EVR or pkg.EVR == instpo.EVR:
+ show = False
+ if show:
+ self._show_package(pkg,INFO_AVAILABLE)
+ break
+
+ @handle_repo_error
def install(self, packages):
'''
Implement the {backend}-install functionality
@@ -1097,6 +1108,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
else:
return INFO_UNKNOWN
+ @handle_repo_error
def get_updates(self, filters):
'''
Implement the {backend}-get-updates functionality
@@ -1109,22 +1121,17 @@ class PackageKitYumBackend(PackageKitBaseBackend):
fltlist = filters.split(';')
- try:
- ygl = self.yumbase.doPackageLists(pkgnarrow='updates')
- md = self.updateMetadata
- for pkg in ygl.updates:
- if self._do_extra_filtering(pkg, fltlist):
- # Get info about package in updates info
- notice = md.get_notice((pkg.name, pkg.version, pkg.release))
- if notice:
- status = self._get_status(notice)
- self._show_package(pkg,status)
- else:
- self._show_package(pkg,INFO_NORMAL)
- except yum.Errors.RepoError,e:
- self._refresh_yum_cache()
- self.error(ERROR_NO_CACHE,"Package cache was invalid and has been rebuilt.")
-
+ ygl = self.yumbase.doPackageLists(pkgnarrow='updates')
+ md = self.updateMetadata
+ for pkg in ygl.updates:
+ if self._do_extra_filtering(pkg, fltlist):
+ # Get info about package in updates info
+ notice = md.get_notice((pkg.name, pkg.version, pkg.release))
+ if notice:
+ status = self._get_status(notice)
+ self._show_package(pkg,status)
+ else:
+ self._show_package(pkg,INFO_NORMAL)
def repo_enable(self, repoid, enable):
'''
More information about the PackageKit-commit
mailing list