Add package name between history operation no and config file path. Now it is like:
164
|-- apache
| `-- etc
| `-- conf.d
| `-- apache2
|-- baselayout
| `-- etc
| |-- modules.autoload.d
| | `-- kernel-2.6
| `-- skel
|-- iptables
| `-- etc
| `-- conf.d
| `-- iptables
`-- kdebase
`-- etc
`-- X11
`-- kdm
`-- kdmrc
This commit is contained in:
+1
-1
@@ -312,7 +312,7 @@ def 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.save_config(name, "/%s" % f.path)
|
||||
|
||||
historydb.update_history()
|
||||
|
||||
|
||||
@@ -292,7 +292,7 @@ class Install(AtomicOperation):
|
||||
fpath = pisi.util.join_path(ctx.config.dest_dir(), config.path)
|
||||
if pisi.util.config_changed(config):
|
||||
config_changed.append(fpath)
|
||||
self.historydb.save_config(fpath)
|
||||
self.historydb.save_config(self.pkginfo.name, fpath)
|
||||
if os.path.exists(fpath + '.old'):
|
||||
os.unlink(fpath + '.old')
|
||||
os.rename(fpath, fpath + '.old')
|
||||
@@ -513,7 +513,7 @@ class Remove(AtomicOperation):
|
||||
os.unlink(fpath)
|
||||
else:
|
||||
# keep changed file in history
|
||||
historydb.save_config(fpath)
|
||||
historydb.save_config(package_name, fpath)
|
||||
except pisi.util.FileError:
|
||||
pass
|
||||
else:
|
||||
|
||||
+17
-5
@@ -43,14 +43,24 @@ 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):
|
||||
def load_config(self, operation, package=None):
|
||||
def __load_config(path):
|
||||
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):
|
||||
import distutils.dir_util as dir_util
|
||||
dir_util.copy_tree(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, config_file):
|
||||
hist_dir = os.path.join(ctx.config.history_dir(), self.history.operation.no)
|
||||
def save_config(self, package, config_file):
|
||||
hist_dir = os.path.join(ctx.config.history_dir(), self.history.operation.no, package)
|
||||
if os.path.isdir(config_file):
|
||||
os.makedirs(os.path.join(hist_dir, config_file))
|
||||
return
|
||||
@@ -65,6 +75,7 @@ class HistoryDB(lazydb.LazyDB):
|
||||
for log in self.__logs:
|
||||
if log.startswith("%03d_" % operation):
|
||||
hist = pisi.history.History(os.path.join(ctx.config.history_dir(), log))
|
||||
hist.operation.no = int(log.split("_")[0])
|
||||
return hist.operation
|
||||
return None
|
||||
|
||||
@@ -77,6 +88,7 @@ class HistoryDB(lazydb.LazyDB):
|
||||
return
|
||||
|
||||
hist = pisi.history.History(os.path.join(ctx.config.history_dir(), log))
|
||||
hist.operation.no = int(log.split("_")[0])
|
||||
yield hist.operation
|
||||
|
||||
def get_last(self, count=0):
|
||||
|
||||
@@ -144,5 +144,3 @@ def takeback(operation):
|
||||
|
||||
if paths:
|
||||
pisi.operations.install.install_pkg_files(paths)
|
||||
|
||||
historydb.load_config(operation)
|
||||
|
||||
Reference in New Issue
Block a user