Make it simple... Snapshot packages' config files will also be loaded package by package

This commit is contained in:
Faik Uygur
2008-03-18 10:05:00 +00:00
parent 02b94a862c
commit f7daaab828
2 changed files with 15 additions and 20 deletions
+4 -14
View File
@@ -43,21 +43,11 @@ class HistoryDB(lazydb.LazyDB):
def add_package(self, pkgBefore=None, pkgAfter=None, operation=None):
self.history.add(pkgBefore, pkgAfter, operation)
def load_config(self, operation, package=None):
def __load_config(path):
def load_config(self, operation, package):
config_dir = os.path.join(ctx.config.history_dir(), "%03d" % operation, package)
if os.path.exists(config_dir):
import distutils.dir_util as dir_util
dir_util.copy_tree(path, "/")
installdb = pisi.db.installdb.InstallDB()
hist_dir = os.path.join(ctx.config.history_dir(), "%03d" % operation)
if os.path.exists(hist_dir):
if not package:
for pkg in os.listdir(hist_dir):
if installdb.has_package(pkg):
__load_config(os.path.join(hist_dir, pkg))
else:
if installdb.has_package(pkg):
__load_config(os.path.join(hist_dir, pkg))
dir_util.copy_tree(config_dir, "/")
def save_config(self, package, config_file):
hist_dir = os.path.join(ctx.config.history_dir(), self.history.operation.no, package)
+11 -6
View File
@@ -37,18 +37,20 @@ def __listactions(actions):
beinstalled = []
beremoved = []
configs = []
for pkg in actions:
action, pkginfo = actions[pkg]
action, pkginfo, operation = actions[pkg]
if action == "install":
if __pkg_already_installed(pkg, pkginfo):
continue
beinstalled.append("%s-%s" % (pkg, pkginfo))
configs.append((pkg, operation))
else:
if installdb.has_package(pkg):
beremoved.append("%s" % pkg)
return beinstalled, beremoved
return beinstalled, beremoved, configs
def __getpackageurl(package):
packagedb = pisi.db.packagedb.PackageDB()
@@ -84,10 +86,10 @@ def get_snapshot_actions(operation):
for pkg in operation.packages:
snapshot_pkgs.add(pkg.name)
actions[pkg.name] = ("install", pkg.before)
actions[pkg.name] = ("install", pkg.before, operation.no)
for pkg in set(installdb.list_installed()) - snapshot_pkgs:
actions[pkg] = ("remove", None)
actions[pkg] = ("remove", None, None)
return actions
@@ -100,7 +102,7 @@ def get_takeback_actions(operation):
for pkg in operation.packages:
if pkg.operation in ["upgrade", "downgrade", "remove"]:
actions[pkg.name] = ("install", pkg.before)
actions[pkg.name] = ("install", pkg.before, operation.no)
if pkg.operation == "install":
actions[pkg.name] = ("remove", None)
@@ -114,7 +116,7 @@ def takeback(operation):
else:
actions = get_takeback_actions(operation)
beinstalled, beremoved = __listactions(actions)
beinstalled, beremoved, configs = __listactions(actions)
if beinstalled:
ctx.ui.info(_("Following packages will be installed:\n") + pisi.util.strlist(beinstalled))
@@ -144,3 +146,6 @@ def takeback(operation):
if paths:
pisi.operations.install.install_pkg_files(paths)
for pkg, operation in configs:
historydb.load_config(operation, pkg)