diff --git a/pisi/atomicoperations.py b/pisi/atomicoperations.py index 47d43b30..6641187a 100644 --- a/pisi/atomicoperations.py +++ b/pisi/atomicoperations.py @@ -54,7 +54,8 @@ class AtomicOperation(object): pass # possible paths of install operation -(INSTALL, REINSTALL, UPGRADE, DOWNGRADE) = range(4) +(INSTALL, REINSTALL, UPGRADE, DOWNGRADE, REMOVE) = range(5) +opttostr = {INSTALL:"install", REMOVE:"remove", REINSTALL:"reinstall", UPGRADE:"upgrade", DOWNGRADE:"downgrade"} class Install(AtomicOperation): "Install class, provides install routines for pisi packages" @@ -425,6 +426,8 @@ class Install(AtomicOperation): # installed packages self.installdb.add_package(self.pkginfo) + + self.historydb.update(pkgBefore=self.old_pkginfo, pkgAfter=self.pkginfo, operation=opttostr[self.operation]) def install_single(pkg, upgrade = False): """install a single package from URI or ID""" @@ -478,7 +481,7 @@ class Remove(AtomicOperation): for fileinfo in self.files.list: self.remove_file(fileinfo, self.package_name) - self.remove_db() + self.update_databases() self.remove_pisi_files() ctx.ui.close() @@ -541,6 +544,10 @@ class Remove(AtomicOperation): os.path.join(self.package.pkg_dir(), ctx.const.files_xml), ) + def update_databases(self): + self.remove_db() + self.historydb.update(pkgBefore=self.package, operation="remove") + def remove_pisi_files(self): util.clean_dir(self.package.pkg_dir()) diff --git a/pisi/history.py b/pisi/history.py index f6af42e0..77a1475b 100644 --- a/pisi/history.py +++ b/pisi/history.py @@ -72,19 +72,25 @@ class History(xmlfile.XmlFile): def add(self, pkgBefore=None, pkgAfter=None, operation=None): - if operation not in ["upgrade", "remove", "install"]: + if operation not in ["upgrade", "remove", "install", "reinstall", "downgrade"]: raise Exception("Unknown package operation") package = Package() package.operation = operation package.name = (pkgAfter and pkgAfter.name) or (pkgBefore and pkgBefore.name) + if not pkgBefore: + package.before = None + + if not pkgAfter: + package.after = None + for histInfo, pkgInfo in [(package.before, pkgBefore), (package.after, pkgAfter)]: if pkgInfo: histInfo.version = str(pkgInfo.version) histInfo.release = str(pkgInfo.release) histInfo.build = pkgInfo.build and str(pkgInfo.build) - + self.operation.packages.append(package) def update(self):