Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r14735 - main/trunk/pym/portage/dbapi
Date: Tue, 27 Oct 2009 22:48:34
Message-Id: E1N2uq8-0003E5-SO@stork.gentoo.org
1 Author: zmedico
2 Date: 2009-10-27 22:48:32 +0000 (Tue, 27 Oct 2009)
3 New Revision: 14735
4
5 Modified:
6 main/trunk/pym/portage/dbapi/vartree.py
7 Log:
8 Bug #290428 - Update mtime of /var/db/pkg and category subdirectories when
9 stuff inside is modified, so that consumers can use directory mtimes to
10 validate caches.
11
12
13 Modified: main/trunk/pym/portage/dbapi/vartree.py
14 ===================================================================
15 --- main/trunk/pym/portage/dbapi/vartree.py 2009-10-26 22:26:31 UTC (rev 14734)
16 +++ main/trunk/pym/portage/dbapi/vartree.py 2009-10-27 22:48:32 UTC (rev 14735)
17 @@ -52,6 +52,7 @@
18 import logging
19 import os as _os
20 import sys
21 +import time
22 import warnings
23
24 try:
25 @@ -849,6 +850,19 @@
26 rValue = _os.path.join(rValue, filename)
27 return rValue
28
29 + def _bump_mtime(self, cpv):
30 + """
31 + This is called before an after any modifications, so that consumers
32 + can use directory mtimes to validate caches. See bug #290428.
33 + """
34 + base = self.root + _os.sep + VDB_PATH
35 + cat = catsplit(cpv)[0]
36 + catdir = base + _os.sep + cat
37 + t = time.time()
38 + t = (t, t)
39 + for x in (catdir, base):
40 + os.utime(x, t)
41 +
42 def cpv_exists(self, mykey):
43 "Tells us whether an actual ebuild exists on disk (no masking)"
44 return os.path.exists(self.getpath(mykey))
45 @@ -1301,6 +1315,7 @@
46 return results
47
48 def aux_update(self, cpv, values):
49 + self._bump_mtime(cpv)
50 cat, pkg = catsplit(cpv)
51 mylink = dblink(cat, pkg, self.root, self.settings,
52 treetype="vartree", vartree=self.vartree)
53 @@ -1314,6 +1329,7 @@
54 os.unlink(os.path.join(self.getpath(cpv), k))
55 except EnvironmentError:
56 pass
57 + self._bump_mtime(cpv)
58
59 def counter_tick(self, myroot, mycpv=None):
60 return self.counter_tick_core(myroot, incrementing=1, mycpv=mycpv)
61 @@ -1435,9 +1451,11 @@
62 removed += 1
63
64 if removed:
65 + self._bump_mtime(pkg.mycpv)
66 f = atomic_ofstream(os.path.join(pkg.dbdir, "CONTENTS"))
67 write_contents(new_contents, root, f)
68 f.close()
69 + self._bump_mtime(pkg.mycpv)
70 pkg._clear_contents_cache()
71
72 class _owners_cache(object):
73 @@ -2067,6 +2085,7 @@
74 The caller must ensure that lockdb() and unlockdb() are called
75 before and after this method.
76 """
77 + self.vartree.dbapi._bump_mtime(self.mycpv)
78 showMessage = self._display_merge
79 if self.vartree.dbapi._categories is not None:
80 self.vartree.dbapi._categories = None
81 @@ -2208,6 +2227,7 @@
82 self.vartree.dbapi.plib_registry.pruneNonExisting()
83
84 finally:
85 + self.vartree.dbapi._bump_mtime(self.mycpv)
86 if builddir_lock:
87 try:
88 if myebuildpath:
89 @@ -4341,6 +4361,7 @@
90 mydbapi=None, prev_mtimes=None):
91 retval = -1
92 self.lockdb()
93 + self.vartree.dbapi._bump_mtime(self.mycpv)
94 try:
95 self.vartree.dbapi.plib_registry.load()
96 self.vartree.dbapi.plib_registry.pruneNonExisting()
97 @@ -4366,6 +4387,7 @@
98 finally:
99 self.vartree.dbapi.linkmap._clear_cache()
100 self.unlockdb()
101 + self.vartree.dbapi._bump_mtime(self.mycpv)
102 return retval
103
104 def getstring(self,name):