From 47e8263b20b786a4e6f6dd91bb7b768ff48e40a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Thu, 15 Dec 2005 13:23:05 +0000 Subject: [PATCH] * implement an API to find all available packages in repos * fix: do not remove package from component if we are not removing a package from repository! this is a workaround. the design of packagedb somehow does not look very good :/ --- pisi/api.py | 9 +++++++++ pisi/packagedb.py | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/pisi/api.py b/pisi/api.py index f7e83250..080e58c8 100644 --- a/pisi/api.py +++ b/pisi/api.py @@ -104,6 +104,15 @@ def finalize(): ctx.ui.close() ctx.initialized = False +def list_available(): + '''returns a set of available package names''' + + available = set() + for repo in pisi.context.repodb.list(): + pkg_db = pisi.packagedb.get_db(repo) + available.update(pkg_db.list_packages()) + return available + def list_upgradable(): ignore_build = ctx.config.options and ctx.config.options.ignore_build_no diff --git a/pisi/packagedb.py b/pisi/packagedb.py index 1abc7e4c..85d8d997 100644 --- a/pisi/packagedb.py +++ b/pisi/packagedb.py @@ -37,6 +37,7 @@ class PackageDB(object): """PackageDB class provides an interface to the package database using shelf objects""" def __init__(self, id): + self.id = id self.d = shelve.LockedDBShelf('package-%s' % id ) self.dr = shelve.LockedDBShelf('revdep-%s' % id ) @@ -102,7 +103,9 @@ class PackageDB(object): package_info = self.d.get(name, txn) self.d.delete(name, txn) #FIXME: what's happening to dr? - ctx.componentdb.remove_package(package_info.partOf, package_info.name, txn) + #WORKAROUND: do not remove component if it is not in repo + if self.id.startswith('repo'): + ctx.componentdb.remove_package(package_info.partOf, package_info.name, txn) self.d.txn_proc(proc, txn) packagedbs = {}