* make rebuild-db a single easy to use API

This commit is contained in:
Eray Özkural
2006-03-17 15:17:01 +00:00
parent 60b21c7370
commit fbcab492cc
2 changed files with 29 additions and 15 deletions
+28
View File
@@ -66,6 +66,7 @@ def init(database = True, options = None, ui = None, comar = True):
pisi.context.ui = ui
# initialize repository databases
ctx.database = database
if database:
shelve.init_dbenv()
ctx.repodb = pisi.repodb.init()
@@ -319,3 +320,30 @@ def delete_cache():
util.clean_dir(ctx.config.packages_dir())
util.clean_dir(ctx.config.archives_dir())
util.clean_dir(ctx.config.tmp_dir())
def rebuild_db():
def destroy():
#FIXME: how good is deleting *all* databases?
for db in os.listdir(ctx.config.db_dir()):
os.unlink(pisi.util.join_path(ctx.config.db_dir(), db))
def reload():
import os
for package_fn in os.listdir( pisi.util.join_path( ctx.config.lib_dir(),
'package' ) ):
if not package_fn == "scripts":
ctx.ui.debug('Resurrecting %s' % package_fn)
pisi.api.resurrect_package(package_fn)
# save parameters and shutdown pisi
options = ctx.config.options
ui = ctx.ui
comar = ctx.comar
finalize()
destroy() # bye bye
# construct new database version
init(database=True, options=options, ui=ui, comar=comar)
reload()
+1 -15
View File
@@ -755,24 +755,10 @@ If package specs are given, they should be the names of package dirs under /var/
else:
self.init(database=False)
if ctx.ui.confirm(_('Rebuild PISI databases?')):
self.finalize()
import os
#FIXME: how good is deleting *all* databases?
for db in os.listdir(ctx.config.db_dir()):
os.unlink(pisi.util.join_path(ctx.config.db_dir(), db))
# construct new database version
self.init(database=True)
self.rebuild_db()
pisi.api.rebuild_db()
self.finalize()
def rebuild_db(self):
import os
for package_fn in os.listdir( pisi.util.join_path( ctx.config.lib_dir(),
'package' ) ):
if not package_fn == "scripts":
ctx.ui.debug('Resurrecting %s' % package_fn)
pisi.api.resurrect_package(package_fn)
class UpdateRepo(Command):
"""Update repository databases