diff --git a/pisi/atomicoperations.py b/pisi/atomicoperations.py index e8afa1e3..fbd3fb01 100644 --- a/pisi/atomicoperations.py +++ b/pisi/atomicoperations.py @@ -243,6 +243,7 @@ class Install(AtomicOperation): self.metadata.package.release, self.metadata.package.build, self.metadata.package.distribution, + False, txn) # filesdb @@ -432,6 +433,7 @@ def virtual_install(metadata, files, txn): metadata.package.release, metadata.package.build, metadata.package.distribution, + True, txn) # filesdb diff --git a/pisi/installdb.py b/pisi/installdb.py index 75b14f08..8491ef8c 100644 --- a/pisi/installdb.py +++ b/pisi/installdb.py @@ -40,14 +40,13 @@ class InstallInfo: # we store as an object, hey, we can waste O(1) space. # this is also easier to modify in the future, without # requiring database upgrades! wow! - def __init__(self, state, version, release, build, distribution): + def __init__(self, state, version, release, build, distribution, time): self.state = state self.version = version self.release = release self.build = build self.distribution = distribution - import time - self.time = time.localtime() + self.time = time def one_liner(self): import time @@ -146,7 +145,7 @@ class InstallDB: else: return False - def install(self, pkg, version, release, build, distro = "", txn = None): + def install(self, pkg, version, release, build, distro = "", rebuild=False, txn = None): """install package with specific version, release, build""" pkg = str(pkg) def proc(txn): @@ -157,7 +156,15 @@ class InstallDB: self.dp.put(pkg, True, txn) else: state = 'i' - self.d.put(pkg, InstallInfo(state, version, release, build, distro), txn) + + if not rebuild: + import time + ctime = time.localtime() + else: + files_xml = self.files_name(pkg, version, release) + ctime = util.creation_time(files_xml) + + self.d.put(pkg, InstallInfo(state, version, release, build, distro, ctime), txn) self.d.txn_proc(proc,txn) diff --git a/pisi/util.py b/pisi/util.py index 7ad8fea7..44b88015 100644 --- a/pisi/util.py +++ b/pisi/util.py @@ -254,6 +254,13 @@ def clean_dir(path): if os.path.exists(path): shutil.rmtree(path) +def creation_time(file): + """returns the creation time of the given file""" + if check_file(file): + import time + st = os.stat(file) + return time.localtime(st.st_ctime) + def dir_size(dir): """ calculate the size of files under a dir based on the os module example"""