[packagekit] packagekit: Branch 'master' - 4 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Mon Nov 19 15:18:21 PST 2007
backends/yum/helpers/yumBackend.py | 46 ++++++++++-------
backends/zypp/pk-backend-zypp.cpp | 98 +++++++++++++++++++++++++++++++++++--
html/pk-faq.html | 2
3 files changed, 122 insertions(+), 24 deletions(-)
New commits:
commit 94843f68e4f7e243e9af01f0890535b070872a53
Author: Boyd Timothy <btimothy at gmail.com>
Date: Thu Nov 15 16:21:11 2007 -0700
Stubbing out backend_refresh_cache for zypp.
diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 9734a29..aaac563 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -40,6 +40,7 @@
#include <zypp/RepoManager.h>
#include <zypp/RepoInfo.h>
#include <zypp/repo/RepoException.h>
+#include <zypp/parser/ParseException.h>
enum PkgSearchType {
SEARCH_TYPE_NAME = 0,
@@ -59,6 +60,10 @@ typedef struct {
gint type;
} ThreadData;
+typedef struct {
+ gboolean force;
+} RefreshData;
+
// some typedefs and functions to shorten Zypp names
typedef zypp::ResPoolProxy ZyppPool;
inline ZyppPool zyppPool() { return zypp::getZYpp()->poolProxy(); }
@@ -133,6 +138,86 @@ backend_get_description (PkBackend *backend, const gchar *package_id)
}
}
+/*
+static gboolean
+backend_refresh_cache_thread (PkBackend *backend, gpointer data)
+{
+ RefreshData *d = (RefreshData*) data;
+ pk_backend_change_status (backend, PK_STATUS_ENUM_REFRESH_CACHE);
+ pk_backend_no_percentage_updates (backend);
+ unsigned processed = 0;
+ unsigned repo_count = 0;
+
+ zypp::RepoManager manager;
+ std::list <zypp::RepoInfo> repos;
+ try
+ {
+ repos = manager.knownRepositories();
+ }
+ catch ( const zypp::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() );
+ g_free (d);
+ return FALSE;
+ }
+
+ repo_count = repos.size ();
+
+ for (std::list <zypp::RepoInfo>::iterator it = repos.begin(); it != repos.end(); it++) {
+ if (it->enabled()) {
+ //refresh_raw_metadata (it, false);
+
+ // Build the Cache
+ try {
+ manager.buildCache (*it,
+ d->force ?
+ zypp::RepoManager::BuildForced :
+ zypp::RepoManager::BuildIfNeeded);
+ } catch (const zypp::parser::ParseException &ex) {
+ pk_backend_error_code (backend,
+ PK_ERROR_ENUM_INTERNAL_ERROR,
+ "Error parsing metadata for '%s'",
+ it->alias().c_str());
+ continue;
+ }
+
+ processed++;
+ pk_backend_change_percentage (backend, (int) ((processed / repo_count) * 100));
+ }
+ }
+
+ g_free (d);
+ pk_backend_finished (backend);
+
+ return TRUE;
+}
+
+//
+// backend_refresh_cache:
+//
+static void
+backend_refresh_cache (PkBackend *backend, gboolean force)
+{
+ g_return_if_fail (backend != NULL);
+ // check network state
+ if (pk_backend_network_is_online (backend) == FALSE) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot refresh cache whilst offline");
+ pk_backend_finished (backend);
+ return;
+ }
+
+ RefreshData *data = g_new0(RefreshData, 1);
+ if (data == NULL) {
+ pk_backend_error_code(backend, PK_ERROR_ENUM_OOM, "Failed to allocate memory in backend_refresh_cache");
+ pk_backend_finished (backend);
+ } else {
+ data->force = force;
+ pk_backend_thread_helper (backend, backend_refresh_cache_thread, data);
+ }
+}
+*/
+
/* TODO: this was taken directly from pk-backend-box.c. Perhaps this
* ought to be part of libpackagekit? */
static void
@@ -341,7 +426,7 @@ extern "C" PK_BACKEND_OPTIONS (
NULL, /* get_updates */
NULL, /* install_package */
NULL, /* install_file */
- NULL, /* refresh_cache */
+ NULL,//backend_refresh_cache, /* refresh_cache */
NULL, /* remove_package */
NULL, /* resolve */
NULL, /* rollback */
commit a66c689619a6723b8f7f13f430cbb0604a027b82
Author: Boyd Timothy <btimothy at gmail.com>
Date: Thu Nov 15 16:44:28 2007 -0700
Cleanup exception handling in zypp's backend_repo_enable call
diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index be7c046..9734a29 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -38,6 +38,8 @@
#include <zypp/Product.h>
#include <zypp/Repository.h>
#include <zypp/RepoManager.h>
+#include <zypp/RepoInfo.h>
+#include <zypp/repo/RepoException.h>
enum PkgSearchType {
SEARCH_TYPE_NAME = 0,
@@ -310,16 +312,13 @@ backend_repo_enable (PkBackend *backend, const gchar *rid, gboolean enabled)
try {
repo = manager.getRepositoryInfo (rid);
- } catch (...) { // FIXME: Don't just catch all exceptions
+ repo.setEnabled (enabled);
+ manager.modifyRepository (rid, repo);
+ } catch (const zypp::repo::RepoNotFoundException &ex) {
pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, "Couldn't find the specified repository");
pk_backend_finished (backend);
return;
- }
-
- try {
- repo.setEnabled (enabled);
- manager.modifyRepository (rid, repo);
- } catch (const zypp::Exception &e) {
+ } catch (const zypp::Exception &ex) {
pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Could not enable/disable the repo");
}
commit 4777720c9082cc46c4cd9c762efc65a2cbc1eafe
Author: Boyd Timothy <btimothy at gmail.com>
Date: Thu Nov 15 16:34:37 2007 -0700
Completed implementation of bckend_repo_enable for zypp backend.
diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index c21307a..be7c046 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -316,8 +316,12 @@ backend_repo_enable (PkBackend *backend, const gchar *rid, gboolean enabled)
return;
}
- // FIXME: Do we need to check for errors when calling repo.setEnabled ()?
- repo.setEnabled (enabled);
+ try {
+ repo.setEnabled (enabled);
+ manager.modifyRepository (rid, repo);
+ } catch (const zypp::Exception &e) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Could not enable/disable the repo");
+ }
pk_backend_finished (backend);
}
diff --git a/html/pk-faq.html b/html/pk-faq.html
index d71d503..ed0fe5a 100644
--- a/html/pk-faq.html
+++ b/html/pk-faq.html
@@ -43,7 +43,7 @@ get-description | X | X | X | X | | X | X | |
get-files | X | X | | X | | X | X | |
get-update-detail | | X | | | | | | |
get-repo-list | | X | | X | X | X | X | X |
-repo-enable | | X | | X | | X | | |
+repo-enable | | X | | X | | X | | X |
repo-set-data | | X | | X | | | X | |
cancel-transaction| X | X | | | | | X | |
</pre>
commit 99b6507bafd34fc7842c2e879de693f731426bd8
Author: Luke Macken <lmacken at redhat.com>
Date: Mon Nov 19 14:39:05 2007 -0500
Improved yum UpdateMetadata handling
- Create a PackageKitYumBackend.updateMetadata property, which parses the updateinfo.xml.gz from the repodata on the fly.
- Utilize the reboot_suggested field in the UpdateMetadata
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 5b8fe18..451d24e 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -836,11 +836,16 @@ class PackageKitYumBackend(PackageKitBaseBackend):
self.error(ERROR_PACKAGE_ALREADY_INSTALLED,"No available updates")
def _check_for_reboot(self):
+ md = self.updateMetadata
for txmbr in self.yumbase.tsInfo:
pkg = txmbr.po
- # check if package is in reboot list and is installed/updated etc
+ # check if package is in reboot list or flagged with reboot_suggested
+ # in the update metadata and is installed/updated etc
print pkg.name,txmbr.output_state
- if pkg.name in self.rebootpkgs and txmbr.ts_state in TS_INSTALL_STATES:
+ notice = md.get_notice((pkg.name, pkg.version, pkg.release))
+ if (pkg.name in self.rebootpkgs or (notice and
+ notice.has_key('reboot_suggested') and notice['reboot_suggested']))\
+ and txmbr.ts_state in TS_INSTALL_STATES:
self.require_restart(RESTART_SYSTEM,"")
break
@@ -982,14 +987,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
self.allow_interrupt(True)
self.percentage(None)
self.status(STATUS_INFO)
- md = UpdateMetadata()
- # Added extra Update Metadata
- for repo in self.yumbase.repos.listEnabled():
- try:
- md.add(repo)
- except:
- pass # No updateinfo.xml.gz in repo
-
+ md = self.updateMetadata
ygl = self.yumbase.doPackageLists(pkgnarrow='updates')
for pkg in ygl.updates:
# Get info about package in updates info
@@ -1043,15 +1041,27 @@ class PackageKitYumBackend(PackageKitBaseBackend):
else:
return ""
+ def _get_update_metadata(self):
+ if not self._updateMetadata:
+ self._updateMetadata = UpdateMetadata()
+ for repo in self.yumbase.repos.listEnabled():
+ try:
+ md.add(repo)
+ except:
+ pass # No updateinfo.xml.gz in repo
+ return self._updateMetadata
+
+ _updateMetadata = None
+ updateMetadata = property(fget=_get_update_metadata)
+
def _get_update_extras(self,pkg):
- md = UpdateMetadata()
- if md:
- notice = md.get_notice((pkg.name, pkg.version, pkg.release))
- if notice:
- desc = notice['description']
- url = notice['references']
- reboot = notice['reboot_suggested']
- return desc.replace('\n',';'),url,reboot
+ md = self.updateMetadata
+ notice = md.get_notice((pkg.name, pkg.version, pkg.release))
+ if notice:
+ desc = notice['description']
+ url = notice['references']
+ reboot = notice['reboot_suggested']
+ return desc.replace('\n',';'),url,reboot
return "","",""
def get_update_detail(self,package):
More information about the PackageKit
mailing list