From 9afd73108f8feed5e430dbdaf473a9bdeb23a4e6 Mon Sep 17 00:00:00 2001 From: Faik Uygur Date: Mon, 10 Mar 2008 19:28:24 +0000 Subject: [PATCH] Save changed configs in snapshots --- pisi/api.py | 4 ++++ pisi/atomicoperations.py | 12 +----------- pisi/db/sourcedb.py | 1 - pisi/util.py | 11 +++++++++++ 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/pisi/api.py b/pisi/api.py index e17a2f79..e32cf818 100644 --- a/pisi/api.py +++ b/pisi/api.py @@ -309,6 +309,10 @@ def snapshot(): for name in installdb.list_installed(): package = installdb.get_package(name) historydb.add_package(pkgBefore=package, operation="snapshot") + # Save changed config files of the package in snapshot + for f in installdb.get_files(name).list: + if f.type == "config" and pisi.util.config_changed(f): + historydb.save_config("/%s" % f.path) historydb.update_history() diff --git a/pisi/atomicoperations.py b/pisi/atomicoperations.py index f3b51328..df4b786a 100644 --- a/pisi/atomicoperations.py +++ b/pisi/atomicoperations.py @@ -289,18 +289,8 @@ class Install(AtomicOperation): config_changed = [] def check_config_changed(config): - changed = False fpath = pisi.util.join_path(ctx.config.dest_dir(), config.path) - if os.path.exists(fpath) and not os.path.isdir(fpath): - if os.path.islink(fpath): - f = os.readlink(fpath) - if os.path.exists(f) and pisi.util.sha1_data(f) != config.hash: - changed = True - else: - if pisi.util.sha1_file(fpath) != config.hash: - changed = True - - if changed: + if pisi.util.config_changed(config): config_changed.append(fpath) self.historydb.save_config(fpath) if os.path.exists(fpath + '.old'): diff --git a/pisi/db/sourcedb.py b/pisi/db/sourcedb.py index c75be2da..50fe7b97 100644 --- a/pisi/db/sourcedb.py +++ b/pisi/db/sourcedb.py @@ -42,7 +42,6 @@ class SourceDB(lazydb.LazyDB): self.rvdb = pisi.db.itembyrepo.ItemByRepo(self.__revdeps) def __generate_sources(self, doc): - sources = {} pkgstosrc = {} diff --git a/pisi/util.py b/pisi/util.py index 808d5a70..2e9c3653 100644 --- a/pisi/util.py +++ b/pisi/util.py @@ -672,3 +672,14 @@ def colorize(msg, color): else: return msg +def config_changed(config_file): + fpath = pisi.util.join_path(ctx.config.dest_dir(), config_file.path) + if os.path.exists(fpath) and not os.path.isdir(fpath): + if os.path.islink(fpath): + f = os.readlink(fpath) + if os.path.exists(f) and pisi.util.sha1_data(f) != config_file.hash: + return True + else: + if pisi.util.sha1_file(fpath) != config_file.hash: + return True + return False