1 |
Author: zmedico |
2 |
Date: 2009-10-27 22:56:07 +0000 (Tue, 27 Oct 2009) |
3 |
New Revision: 14742 |
4 |
|
5 |
Modified: |
6 |
main/branches/2.1.7/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. (trunk r14735) |
11 |
|
12 |
Modified: main/branches/2.1.7/pym/portage/dbapi/vartree.py |
13 |
=================================================================== |
14 |
--- main/branches/2.1.7/pym/portage/dbapi/vartree.py 2009-10-27 22:55:54 UTC (rev 14741) |
15 |
+++ main/branches/2.1.7/pym/portage/dbapi/vartree.py 2009-10-27 22:56:07 UTC (rev 14742) |
16 |
@@ -52,6 +52,7 @@ |
17 |
import logging |
18 |
import os as _os |
19 |
import sys |
20 |
+import time |
21 |
import warnings |
22 |
|
23 |
try: |
24 |
@@ -133,6 +134,19 @@ |
25 |
rValue = _os.path.join(rValue, filename) |
26 |
return rValue |
27 |
|
28 |
+ def _bump_mtime(self, cpv): |
29 |
+ """ |
30 |
+ This is called before an after any modifications, so that consumers |
31 |
+ can use directory mtimes to validate caches. See bug #290428. |
32 |
+ """ |
33 |
+ base = self.root + _os.sep + VDB_PATH |
34 |
+ cat = catsplit(cpv)[0] |
35 |
+ catdir = base + _os.sep + cat |
36 |
+ t = time.time() |
37 |
+ t = (t, t) |
38 |
+ for x in (catdir, base): |
39 |
+ os.utime(x, t) |
40 |
+ |
41 |
def cpv_exists(self, mykey): |
42 |
"Tells us whether an actual ebuild exists on disk (no masking)" |
43 |
return os.path.exists(self.getpath(mykey)) |
44 |
@@ -585,6 +599,7 @@ |
45 |
return results |
46 |
|
47 |
def aux_update(self, cpv, values): |
48 |
+ self._bump_mtime(cpv) |
49 |
cat, pkg = catsplit(cpv) |
50 |
mylink = dblink(cat, pkg, self.root, self.settings, |
51 |
treetype="vartree", vartree=self.vartree) |
52 |
@@ -598,6 +613,7 @@ |
53 |
os.unlink(os.path.join(self.getpath(cpv), k)) |
54 |
except EnvironmentError: |
55 |
pass |
56 |
+ self._bump_mtime(cpv) |
57 |
|
58 |
def counter_tick(self, myroot, mycpv=None): |
59 |
return self.counter_tick_core(myroot, incrementing=1, mycpv=mycpv) |
60 |
@@ -719,9 +735,11 @@ |
61 |
removed += 1 |
62 |
|
63 |
if removed: |
64 |
+ self._bump_mtime(pkg.mycpv) |
65 |
f = atomic_ofstream(os.path.join(pkg.dbdir, "CONTENTS")) |
66 |
write_contents(new_contents, root, f) |
67 |
f.close() |
68 |
+ self._bump_mtime(pkg.mycpv) |
69 |
pkg._clear_contents_cache() |
70 |
|
71 |
class _owners_cache(object): |
72 |
@@ -1350,6 +1368,7 @@ |
73 |
The caller must ensure that lockdb() and unlockdb() are called |
74 |
before and after this method. |
75 |
""" |
76 |
+ self.vartree.dbapi._bump_mtime(self.mycpv) |
77 |
showMessage = self._display_merge |
78 |
if self.vartree.dbapi._categories is not None: |
79 |
self.vartree.dbapi._categories = None |
80 |
@@ -1459,6 +1478,7 @@ |
81 |
writemsg(_("!!! FAILED postrm: %s\n") % retval, noiselevel=-1) |
82 |
|
83 |
finally: |
84 |
+ self.vartree.dbapi._bump_mtime(self.mycpv) |
85 |
if builddir_lock: |
86 |
try: |
87 |
if myebuildpath: |
88 |
@@ -3198,6 +3218,7 @@ |
89 |
mydbapi=None, prev_mtimes=None): |
90 |
retval = -1 |
91 |
self.lockdb() |
92 |
+ self.vartree.dbapi._bump_mtime(self.mycpv) |
93 |
try: |
94 |
retval = self.treewalk(mergeroot, myroot, inforoot, myebuild, |
95 |
cleanup=cleanup, mydbapi=mydbapi, prev_mtimes=prev_mtimes) |
96 |
@@ -3220,6 +3241,7 @@ |
97 |
self, mydbapi, myebuild, "clean") |
98 |
finally: |
99 |
self.unlockdb() |
100 |
+ self.vartree.dbapi._bump_mtime(self.mycpv) |
101 |
return retval |
102 |
|
103 |
def getstring(self,name): |