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): def add_package(self, pkgBefore=None, pkgAfter=None, operation=None):
self.history.add(pkgBefore, pkgAfter, operation) self.history.add(pkgBefore, pkgAfter, operation)
def load_config(self, operation, package=None): def load_config(self, operation, package):
def __load_config(path): 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 import distutils.dir_util as dir_util
dir_util.copy_tree(path, "/") dir_util.copy_tree(config_dir, "/")
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))
def save_config(self, package, config_file): def save_config(self, package, config_file):
hist_dir = os.path.join(ctx.config.history_dir(), self.history.operation.no, package) 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 = [] beinstalled = []
beremoved = [] beremoved = []
configs = []
for pkg in actions: for pkg in actions:
action, pkginfo = actions[pkg] action, pkginfo, operation = actions[pkg]
if action == "install": if action == "install":
if __pkg_already_installed(pkg, pkginfo): if __pkg_already_installed(pkg, pkginfo):
continue continue
beinstalled.append("%s-%s" % (pkg, pkginfo)) beinstalled.append("%s-%s" % (pkg, pkginfo))
configs.append((pkg, operation))
else: else:
if installdb.has_package(pkg): if installdb.has_package(pkg):
beremoved.append("%s" % pkg) beremoved.append("%s" % pkg)
return beinstalled, beremoved return beinstalled, beremoved, configs
def __getpackageurl(package): def __getpackageurl(package):
packagedb = pisi.db.packagedb.PackageDB() packagedb = pisi.db.packagedb.PackageDB()
@@ -84,10 +86,10 @@ def get_snapshot_actions(operation):
for pkg in operation.packages: for pkg in operation.packages:
snapshot_pkgs.add(pkg.name) 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: for pkg in set(installdb.list_installed()) - snapshot_pkgs:
actions[pkg] = ("remove", None) actions[pkg] = ("remove", None, None)
return actions return actions
@@ -100,7 +102,7 @@ def get_takeback_actions(operation):
for pkg in operation.packages: for pkg in operation.packages:
if pkg.operation in ["upgrade", "downgrade", "remove"]: 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": if pkg.operation == "install":
actions[pkg.name] = ("remove", None) actions[pkg.name] = ("remove", None)
@@ -114,7 +116,7 @@ def takeback(operation):
else: else:
actions = get_takeback_actions(operation) actions = get_takeback_actions(operation)
beinstalled, beremoved = __listactions(actions) beinstalled, beremoved, configs = __listactions(actions)
if beinstalled: if beinstalled:
ctx.ui.info(_("Following packages will be installed:\n") + pisi.util.strlist(beinstalled)) ctx.ui.info(_("Following packages will be installed:\n") + pisi.util.strlist(beinstalled))
@@ -144,3 +146,6 @@ def takeback(operation):
if paths: if paths:
pisi.operations.install.install_pkg_files(paths) pisi.operations.install.install_pkg_files(paths)
for pkg, operation in configs:
historydb.load_config(operation, pkg)