|
|
55e633 |
From a15ce85d03ba9babc2cbe100204c12f08500134c Mon Sep 17 00:00:00 2001
|
|
|
55e633 |
From: Richard Hughes <richard@hughsie.com>
|
|
|
55e633 |
Date: Wed, 5 Aug 2015 17:24:03 +0100
|
|
|
55e633 |
Subject: [PATCH] yum: Add support for GetDetailsLocal
|
|
|
55e633 |
|
|
|
55e633 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1249998
|
|
|
55e633 |
---
|
|
|
55e633 |
backends/yum/pk-backend-yum.c | 15 +++++++++++++++
|
|
|
55e633 |
backends/yum/yumBackend.py | 29 +++++++++++++++++++++++++++--
|
|
|
55e633 |
client/pk-console.c | 10 ++++++++++
|
|
|
55e633 |
lib/python/packagekit/backend.py | 11 +++++++++++
|
|
|
55e633 |
4 files changed, 63 insertions(+), 2 deletions(-)
|
|
|
55e633 |
|
|
|
55e633 |
diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c
|
|
|
55e633 |
index 5e9da25..c4b714f 100644
|
|
|
55e633 |
--- a/backends/yum/pk-backend-yum.c
|
|
|
55e633 |
+++ b/backends/yum/pk-backend-yum.c
|
|
|
55e633 |
@@ -355,6 +355,7 @@ pk_backend_get_roles (PkBackend *backend)
|
|
|
55e633 |
PK_ROLE_ENUM_CANCEL,
|
|
|
55e633 |
PK_ROLE_ENUM_DEPENDS_ON,
|
|
|
55e633 |
PK_ROLE_ENUM_GET_DETAILS,
|
|
|
55e633 |
+ PK_ROLE_ENUM_GET_DETAILS_LOCAL,
|
|
|
55e633 |
PK_ROLE_ENUM_GET_FILES,
|
|
|
55e633 |
PK_ROLE_ENUM_REQUIRED_BY,
|
|
|
55e633 |
PK_ROLE_ENUM_GET_PACKAGES,
|
|
|
55e633 |
@@ -450,6 +451,20 @@ pk_backend_get_details (PkBackend *backend, PkBackendJob *job, gchar **package_i
|
|
|
55e633 |
}
|
|
|
55e633 |
|
|
|
55e633 |
/**
|
|
|
55e633 |
+ * pk_backend_get_details_local:
|
|
|
55e633 |
+ */
|
|
|
55e633 |
+void
|
|
|
55e633 |
+pk_backend_get_details_local (PkBackend *backend, PkBackendJob *job, gchar **filenames)
|
|
|
55e633 |
+{
|
|
|
55e633 |
+ _cleanup_free_ gchar *tmp = NULL;
|
|
|
55e633 |
+ tmp = pk_package_ids_to_string (filenames);
|
|
|
55e633 |
+ pk_backend_spawn_helper (priv->spawn, job,
|
|
|
55e633 |
+ "yumBackend.py",
|
|
|
55e633 |
+ "get-details-local",
|
|
|
55e633 |
+ tmp, NULL);
|
|
|
55e633 |
+}
|
|
|
55e633 |
+
|
|
|
55e633 |
+/**
|
|
|
55e633 |
* pk_backend_get_distro_upgrades:
|
|
|
55e633 |
*/
|
|
|
55e633 |
void
|
|
|
55e633 |
diff --git a/backends/yum/yumBackend.py b/backends/yum/yumBackend.py
|
|
|
55e633 |
index f097034..a0b2132 100755
|
|
|
55e633 |
--- a/backends/yum/yumBackend.py
|
|
|
55e633 |
+++ b/backends/yum/yumBackend.py
|
|
|
55e633 |
@@ -2476,7 +2476,32 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
|
|
|
55e633 |
self.message('COULD_NOT_FIND_PACKAGE', 'Package %s was not found' % _format_package_id(package_id))
|
|
|
55e633 |
continue
|
|
|
55e633 |
|
|
|
55e633 |
- def _show_details_pkg(self, pkg):
|
|
|
55e633 |
+ def get_details_local(self, files):
|
|
|
55e633 |
+ '''
|
|
|
55e633 |
+ Print a detailed details for a given file
|
|
|
55e633 |
+ '''
|
|
|
55e633 |
+ try:
|
|
|
55e633 |
+ self._check_init(lazy_cache=True)
|
|
|
55e633 |
+ except PkError, e:
|
|
|
55e633 |
+ self.error(e.code, e.details, exit=False)
|
|
|
55e633 |
+ return
|
|
|
55e633 |
+ self.yumbase.conf.cache = 0 # Allow new files
|
|
|
55e633 |
+ self.allow_cancel(True)
|
|
|
55e633 |
+ self.percentage(None)
|
|
|
55e633 |
+ self.status(STATUS_INFO)
|
|
|
55e633 |
+ for f in files:
|
|
|
55e633 |
+ try:
|
|
|
55e633 |
+ pkg = YumLocalPackage(ts=self.yumbase.rpmdb.readOnlyTS(), filename=f)
|
|
|
55e633 |
+ except PkError, e:
|
|
|
55e633 |
+ if e.code == ERROR_PACKAGE_NOT_FOUND:
|
|
|
55e633 |
+ self.message('COULD_NOT_FIND_PACKAGE', e.details)
|
|
|
55e633 |
+ continue
|
|
|
55e633 |
+ self.error(e.code, e.details, exit=True)
|
|
|
55e633 |
+ return
|
|
|
55e633 |
+ if pkg:
|
|
|
55e633 |
+ self._show_details_pkg(pkg, False)
|
|
|
55e633 |
+
|
|
|
55e633 |
+ def _show_details_pkg(self, pkg, verify_local=True):
|
|
|
55e633 |
|
|
|
55e633 |
pkgver = _get_package_ver(pkg)
|
|
|
55e633 |
package_id = self.get_package_id(pkg.name, pkgver, pkg.arch, pkg.repo)
|
|
|
55e633 |
@@ -2494,7 +2519,7 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
|
|
|
55e633 |
|
|
|
55e633 |
# if we are remote and in the cache, our size is zero
|
|
|
55e633 |
size = pkg.size
|
|
|
55e633 |
- if not pkg.repo.id.startswith('installed') and pkg.verifyLocalPkg():
|
|
|
55e633 |
+ if verify_local and not pkg.repo.id.startswith('installed') and pkg.verifyLocalPkg():
|
|
|
55e633 |
size = 0
|
|
|
55e633 |
|
|
|
55e633 |
group = self.comps.get_group(pkg.name)
|
|
|
55e633 |
diff --git a/client/pk-console.c b/client/pk-console.c
|
|
|
55e633 |
index 203458e..52bbb65 100644
|
|
|
55e633 |
--- a/client/pk-console.c
|
|
|
55e633 |
+++ b/client/pk-console.c
|
|
|
55e633 |
@@ -1282,6 +1282,16 @@ pk_console_get_details (PkConsoleCtx *ctx, gchar **packages, GError **error)
|
|
|
55e633 |
_cleanup_error_free_ GError *error_local = NULL;
|
|
|
55e633 |
_cleanup_strv_free_ gchar **package_ids = NULL;
|
|
|
55e633 |
|
|
|
55e633 |
+ /* local file */
|
|
|
55e633 |
+ if (g_file_test (packages[0], G_FILE_TEST_EXISTS)) {
|
|
|
55e633 |
+ pk_client_get_details_local_async (PK_CLIENT (ctx->task),
|
|
|
55e633 |
+ packages,
|
|
|
55e633 |
+ ctx->cancellable,
|
|
|
55e633 |
+ pk_console_progress_cb, ctx,
|
|
|
55e633 |
+ pk_console_finished_cb, ctx);
|
|
|
55e633 |
+ return TRUE;
|
|
|
55e633 |
+ }
|
|
|
55e633 |
+
|
|
|
55e633 |
package_ids = pk_console_resolve_packages (ctx, packages, &error_local);
|
|
|
55e633 |
if (package_ids == NULL) {
|
|
|
55e633 |
g_set_error (error,
|
|
|
55e633 |
diff --git a/lib/python/packagekit/backend.py b/lib/python/packagekit/backend.py
|
|
|
55e633 |
index 4b9eedc..9ff693d 100644
|
|
|
55e633 |
--- a/lib/python/packagekit/backend.py
|
|
|
55e633 |
+++ b/lib/python/packagekit/backend.py
|
|
|
55e633 |
@@ -467,6 +467,13 @@ class PackageKitBaseBackend:
|
|
|
55e633 |
'''
|
|
|
55e633 |
self.error(ERROR_NOT_SUPPORTED, "This function is not implemented in this backend", exit=False)
|
|
|
55e633 |
|
|
|
55e633 |
+ def get_details_local(self, files):
|
|
|
55e633 |
+ '''
|
|
|
55e633 |
+ Implement the {backend}-get-details-local functionality
|
|
|
55e633 |
+ Needed to be implemented in a sub class
|
|
|
55e633 |
+ '''
|
|
|
55e633 |
+ self.error(ERROR_NOT_SUPPORTED, "This function is not implemented in this backend", exit=False)
|
|
|
55e633 |
+
|
|
|
55e633 |
def get_files(self, package_ids):
|
|
|
55e633 |
'''
|
|
|
55e633 |
Implement the {backend}-get-files functionality
|
|
|
55e633 |
@@ -581,6 +588,10 @@ class PackageKitBaseBackend:
|
|
|
55e633 |
package_ids = args[0].split(PACKAGE_IDS_DELIM)
|
|
|
55e633 |
self.get_details(package_ids)
|
|
|
55e633 |
self.finished()
|
|
|
55e633 |
+ elif cmd == 'get-details-local':
|
|
|
55e633 |
+ files = args[0].split(PACKAGE_IDS_DELIM)
|
|
|
55e633 |
+ self.get_details_local(files)
|
|
|
55e633 |
+ self.finished()
|
|
|
55e633 |
elif cmd == 'get-files':
|
|
|
55e633 |
package_ids = args[0].split(PACKAGE_IDS_DELIM)
|
|
|
55e633 |
self.get_files(package_ids)
|
|
|
55e633 |
--
|
|
|
55e633 |
2.4.3
|
|
|
55e633 |
|