Save changed configs in snapshots
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
@@ -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'):
|
||||
|
||||
@@ -42,7 +42,6 @@ class SourceDB(lazydb.LazyDB):
|
||||
self.rvdb = pisi.db.itembyrepo.ItemByRepo(self.__revdeps)
|
||||
|
||||
def __generate_sources(self, doc):
|
||||
|
||||
sources = {}
|
||||
pkgstosrc = {}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user