summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-10-27 22:56:07 +0000
committerZac Medico <zmedico@gentoo.org>2009-10-27 22:56:07 +0000
commite9c6cfda54eb331a00c93631349a9e433596ac50 (patch)
tree48568f96cd1619b3f2fa7264c83f792a0bc31f64
parentBug #290625 - Manually encode output to stdout in python3, in order to avoid (diff)
downloadportage-multirepo-e9c6cfda54eb331a00c93631349a9e433596ac50.tar.gz
portage-multirepo-e9c6cfda54eb331a00c93631349a9e433596ac50.tar.bz2
portage-multirepo-e9c6cfda54eb331a00c93631349a9e433596ac50.zip
Bug #290428 - Update mtime of /var/db/pkg and category subdirectories whenv2.1.7.2
stuff inside is modified, so that consumers can use directory mtimes to validate caches. (trunk r14735) svn path=/main/branches/2.1.7/; revision=14742
-rw-r--r--pym/portage/dbapi/vartree.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index 23e170ab..400eab8b 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -52,6 +52,7 @@ import re, shutil, stat, errno, copy, subprocess
import logging
import os as _os
import sys
+import time
import warnings
try:
@@ -133,6 +134,19 @@ class vardbapi(dbapi):
rValue = _os.path.join(rValue, filename)
return rValue
+ def _bump_mtime(self, cpv):
+ """
+ This is called before an after any modifications, so that consumers
+ can use directory mtimes to validate caches. See bug #290428.
+ """
+ base = self.root + _os.sep + VDB_PATH
+ cat = catsplit(cpv)[0]
+ catdir = base + _os.sep + cat
+ t = time.time()
+ t = (t, t)
+ for x in (catdir, base):
+ os.utime(x, t)
+
def cpv_exists(self, mykey):
"Tells us whether an actual ebuild exists on disk (no masking)"
return os.path.exists(self.getpath(mykey))
@@ -585,6 +599,7 @@ class vardbapi(dbapi):
return results
def aux_update(self, cpv, values):
+ self._bump_mtime(cpv)
cat, pkg = catsplit(cpv)
mylink = dblink(cat, pkg, self.root, self.settings,
treetype="vartree", vartree=self.vartree)
@@ -598,6 +613,7 @@ class vardbapi(dbapi):
os.unlink(os.path.join(self.getpath(cpv), k))
except EnvironmentError:
pass
+ self._bump_mtime(cpv)
def counter_tick(self, myroot, mycpv=None):
return self.counter_tick_core(myroot, incrementing=1, mycpv=mycpv)
@@ -719,9 +735,11 @@ class vardbapi(dbapi):
removed += 1
if removed:
+ self._bump_mtime(pkg.mycpv)
f = atomic_ofstream(os.path.join(pkg.dbdir, "CONTENTS"))
write_contents(new_contents, root, f)
f.close()
+ self._bump_mtime(pkg.mycpv)
pkg._clear_contents_cache()
class _owners_cache(object):
@@ -1350,6 +1368,7 @@ class dblink(object):
The caller must ensure that lockdb() and unlockdb() are called
before and after this method.
"""
+ self.vartree.dbapi._bump_mtime(self.mycpv)
showMessage = self._display_merge
if self.vartree.dbapi._categories is not None:
self.vartree.dbapi._categories = None
@@ -1459,6 +1478,7 @@ class dblink(object):
writemsg(_("!!! FAILED postrm: %s\n") % retval, noiselevel=-1)
finally:
+ self.vartree.dbapi._bump_mtime(self.mycpv)
if builddir_lock:
try:
if myebuildpath:
@@ -3198,6 +3218,7 @@ class dblink(object):
mydbapi=None, prev_mtimes=None):
retval = -1
self.lockdb()
+ self.vartree.dbapi._bump_mtime(self.mycpv)
try:
retval = self.treewalk(mergeroot, myroot, inforoot, myebuild,
cleanup=cleanup, mydbapi=mydbapi, prev_mtimes=prev_mtimes)
@@ -3220,6 +3241,7 @@ class dblink(object):
self, mydbapi, myebuild, "clean")
finally:
self.unlockdb()
+ self.vartree.dbapi._bump_mtime(self.mycpv)
return retval
def getstring(self,name):