Save changed configs in snapshots

This commit is contained in:
Faik Uygur
2008-03-10 19:28:24 +00:00
parent fdb1443700
commit 9afd73108f
4 changed files with 16 additions and 12 deletions
+4
View File
@@ -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()
+1 -11
View File
@@ -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'):
-1
View File
@@ -42,7 +42,6 @@ class SourceDB(lazydb.LazyDB):
self.rvdb = pisi.db.itembyrepo.ItemByRepo(self.__revdeps)
def __generate_sources(self, doc):
sources = {}
pkgstosrc = {}
+11
View File
@@ -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