1 |
For forward-compatibility, add a flat_hash.mtime_md5_database cache |
2 |
module which is capable of validating cache entries containing either |
3 |
mtimes or md5 digests (only mtime validation was previously supported |
4 |
in /var/cache/edb/dep). Update the config class to use this cache |
5 |
module by default. |
6 |
|
7 |
X-Gentoo-Bug: 568934 |
8 |
X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=568934 |
9 |
--- |
10 |
pym/portage/cache/flat_hash.py | 5 +++++ |
11 |
pym/portage/cache/template.py | 35 ++++++++++++++++++++++++++++++----- |
12 |
pym/portage/package/ebuild/config.py | 6 +++--- |
13 |
3 files changed, 38 insertions(+), 8 deletions(-) |
14 |
|
15 |
diff --git a/pym/portage/cache/flat_hash.py b/pym/portage/cache/flat_hash.py |
16 |
index 5304296..cca0f10 100644 |
17 |
--- a/pym/portage/cache/flat_hash.py |
18 |
+++ b/pym/portage/cache/flat_hash.py |
19 |
@@ -160,3 +160,8 @@ class md5_database(database): |
20 |
|
21 |
validation_chf = 'md5' |
22 |
store_eclass_paths = False |
23 |
+ |
24 |
+ |
25 |
+class mtime_md5_database(database): |
26 |
+ validation_chf = 'mtime' |
27 |
+ chf_types = ('mtime', 'md5') |
28 |
diff --git a/pym/portage/cache/template.py b/pym/portage/cache/template.py |
29 |
index bc81b86..a942b36 100644 |
30 |
--- a/pym/portage/cache/template.py |
31 |
+++ b/pym/portage/cache/template.py |
32 |
@@ -47,8 +47,21 @@ class database(object): |
33 |
self.updates = 0 |
34 |
d=self._getitem(cpv) |
35 |
if self.serialize_eclasses and "_eclasses_" in d: |
36 |
- d["_eclasses_"] = reconstruct_eclasses(cpv, d["_eclasses_"], |
37 |
- self.validation_chf, paths=self.store_eclass_paths) |
38 |
+ try: |
39 |
+ chf_types = self.chf_types |
40 |
+ except AttributeError: |
41 |
+ chf_types = (self.validation_chf,) |
42 |
+ |
43 |
+ for chf_type in chf_types: |
44 |
+ try: |
45 |
+ d["_eclasses_"] = reconstruct_eclasses(cpv, d["_eclasses_"], |
46 |
+ chf_type, paths=self.store_eclass_paths) |
47 |
+ except cache_errors.CacheCorruption: |
48 |
+ if chf_type is chf_types[-1]: |
49 |
+ raise |
50 |
+ else: |
51 |
+ break |
52 |
+ |
53 |
elif "_eclasses_" not in d: |
54 |
d["_eclasses_"] = {} |
55 |
# Never return INHERITED, since portdbapi.aux_get() will |
56 |
@@ -204,15 +217,27 @@ class database(object): |
57 |
return x |
58 |
|
59 |
def validate_entry(self, entry, ebuild_hash, eclass_db): |
60 |
- hash_key = '_%s_' % self.validation_chf |
61 |
+ try: |
62 |
+ chf_types = self.chf_types |
63 |
+ except AttributeError: |
64 |
+ chf_types = (self.validation_chf,) |
65 |
+ |
66 |
+ for chf_type in chf_types: |
67 |
+ if self._validate_entry(chf_type, entry, ebuild_hash, eclass_db): |
68 |
+ return True |
69 |
+ |
70 |
+ return False |
71 |
+ |
72 |
+ def _validate_entry(self, chf_type, entry, ebuild_hash, eclass_db): |
73 |
+ hash_key = '_%s_' % chf_type |
74 |
try: |
75 |
entry_hash = entry[hash_key] |
76 |
except KeyError: |
77 |
return False |
78 |
else: |
79 |
- if entry_hash != getattr(ebuild_hash, self.validation_chf): |
80 |
+ if entry_hash != getattr(ebuild_hash, chf_type): |
81 |
return False |
82 |
- update = eclass_db.validate_and_rewrite_cache(entry['_eclasses_'], self.validation_chf, |
83 |
+ update = eclass_db.validate_and_rewrite_cache(entry['_eclasses_'], chf_type, |
84 |
self.store_eclass_paths) |
85 |
if update is None: |
86 |
return False |
87 |
diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py |
88 |
index d45c2a0..0bae55b 100644 |
89 |
--- a/pym/portage/package/ebuild/config.py |
90 |
+++ b/pym/portage/package/ebuild/config.py |
91 |
@@ -160,8 +160,8 @@ class config(object): |
92 |
'repository', 'RESTRICT', 'LICENSE',) |
93 |
|
94 |
_module_aliases = { |
95 |
- "cache.metadata_overlay.database" : "portage.cache.flat_hash.database", |
96 |
- "portage.cache.metadata_overlay.database" : "portage.cache.flat_hash.database", |
97 |
+ "cache.metadata_overlay.database" : "portage.cache.flat_hash.mtime_md5_database", |
98 |
+ "portage.cache.metadata_overlay.database" : "portage.cache.flat_hash.mtime_md5_database", |
99 |
} |
100 |
|
101 |
_case_insensitive_vars = special_env_vars.case_insensitive_vars |
102 |
@@ -444,7 +444,7 @@ class config(object): |
103 |
(user_auxdbmodule, modules_file)) |
104 |
|
105 |
self.modules["default"] = { |
106 |
- "portdbapi.auxdbmodule": "portage.cache.flat_hash.database", |
107 |
+ "portdbapi.auxdbmodule": "portage.cache.flat_hash.mtime_md5_database", |
108 |
} |
109 |
|
110 |
self.configlist=[] |
111 |
-- |
112 |
2.4.10 |