* 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 :/
This commit is contained in:
Eray Özkural
2005-12-15 13:23:05 +00:00
parent 588874f6f9
commit 47e8263b20
2 changed files with 13 additions and 1 deletions
+9
View File
@@ -104,6 +104,15 @@ def finalize():
ctx.ui.close() ctx.ui.close()
ctx.initialized = False 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(): def list_upgradable():
ignore_build = ctx.config.options and ctx.config.options.ignore_build_no ignore_build = ctx.config.options and ctx.config.options.ignore_build_no
+3
View File
@@ -37,6 +37,7 @@ class PackageDB(object):
"""PackageDB class provides an interface to the package database """PackageDB class provides an interface to the package database
using shelf objects""" using shelf objects"""
def __init__(self, id): def __init__(self, id):
self.id = id
self.d = shelve.LockedDBShelf('package-%s' % id ) self.d = shelve.LockedDBShelf('package-%s' % id )
self.dr = shelve.LockedDBShelf('revdep-%s' % id ) self.dr = shelve.LockedDBShelf('revdep-%s' % id )
@@ -102,6 +103,8 @@ class PackageDB(object):
package_info = self.d.get(name, txn) package_info = self.d.get(name, txn)
self.d.delete(name, txn) self.d.delete(name, txn)
#FIXME: what's happening to dr? #FIXME: what's happening to dr?
#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) ctx.componentdb.remove_package(package_info.partOf, package_info.name, txn)
self.d.txn_proc(proc, txn) self.d.txn_proc(proc, txn)