From f7daaab8283fafb420ed0dd5e8ab21db5ed8bb61 Mon Sep 17 00:00:00 2001 From: Faik Uygur Date: Tue, 18 Mar 2008 10:05:00 +0000 Subject: [PATCH] Make it simple... Snapshot packages' config files will also be loaded package by package --- pisi/db/historydb.py | 18 ++++-------------- pisi/operations/history.py | 17 +++++++++++------ 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/pisi/db/historydb.py b/pisi/db/historydb.py index 2166f4f7..dd04c513 100644 --- a/pisi/db/historydb.py +++ b/pisi/db/historydb.py @@ -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) diff --git a/pisi/operations/history.py b/pisi/operations/history.py index ef3ab0be..4dfedb92 100644 --- a/pisi/operations/history.py +++ b/pisi/operations/history.py @@ -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)