Yay! A milestone for pisi history
This commit is contained in:
@@ -54,7 +54,8 @@ class AtomicOperation(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
# possible paths of install operation
|
# 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):
|
class Install(AtomicOperation):
|
||||||
"Install class, provides install routines for pisi packages"
|
"Install class, provides install routines for pisi packages"
|
||||||
@@ -425,6 +426,8 @@ class Install(AtomicOperation):
|
|||||||
|
|
||||||
# installed packages
|
# installed packages
|
||||||
self.installdb.add_package(self.pkginfo)
|
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):
|
def install_single(pkg, upgrade = False):
|
||||||
"""install a single package from URI or ID"""
|
"""install a single package from URI or ID"""
|
||||||
@@ -478,7 +481,7 @@ class Remove(AtomicOperation):
|
|||||||
for fileinfo in self.files.list:
|
for fileinfo in self.files.list:
|
||||||
self.remove_file(fileinfo, self.package_name)
|
self.remove_file(fileinfo, self.package_name)
|
||||||
|
|
||||||
self.remove_db()
|
self.update_databases()
|
||||||
|
|
||||||
self.remove_pisi_files()
|
self.remove_pisi_files()
|
||||||
ctx.ui.close()
|
ctx.ui.close()
|
||||||
@@ -541,6 +544,10 @@ class Remove(AtomicOperation):
|
|||||||
os.path.join(self.package.pkg_dir(), ctx.const.files_xml),
|
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):
|
def remove_pisi_files(self):
|
||||||
util.clean_dir(self.package.pkg_dir())
|
util.clean_dir(self.package.pkg_dir())
|
||||||
|
|
||||||
|
|||||||
+8
-2
@@ -72,19 +72,25 @@ class History(xmlfile.XmlFile):
|
|||||||
|
|
||||||
def add(self, pkgBefore=None, pkgAfter=None, operation=None):
|
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")
|
raise Exception("Unknown package operation")
|
||||||
|
|
||||||
package = Package()
|
package = Package()
|
||||||
package.operation = operation
|
package.operation = operation
|
||||||
package.name = (pkgAfter and pkgAfter.name) or (pkgBefore and pkgBefore.name)
|
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)]:
|
for histInfo, pkgInfo in [(package.before, pkgBefore), (package.after, pkgAfter)]:
|
||||||
if pkgInfo:
|
if pkgInfo:
|
||||||
histInfo.version = str(pkgInfo.version)
|
histInfo.version = str(pkgInfo.version)
|
||||||
histInfo.release = str(pkgInfo.release)
|
histInfo.release = str(pkgInfo.release)
|
||||||
histInfo.build = pkgInfo.build and str(pkgInfo.build)
|
histInfo.build = pkgInfo.build and str(pkgInfo.build)
|
||||||
|
|
||||||
self.operation.packages.append(package)
|
self.operation.packages.append(package)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user