Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: bin/
Date: Sat, 29 Oct 2011 07:59:27
Message-Id: a058baf9ed238a1f260b6739ba7fc10c6472f6ee.zmedico@gentoo
1 commit: a058baf9ed238a1f260b6739ba7fc10c6472f6ee
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Sat Oct 29 07:59:02 2011 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Sat Oct 29 07:59:02 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=a058baf9
7
8 egencache: multiple cache-formats support
9
10 If layout.conf contains "cache-formats = md5-dict pms", egencache will
11 now write both formats.
12
13 ---
14 bin/egencache | 40 ++++++++++++++++++++++++++--------------
15 1 files changed, 26 insertions(+), 14 deletions(-)
16
17 diff --git a/bin/egencache b/bin/egencache
18 index dec10b1..477ba98 100755
19 --- a/bin/egencache
20 +++ b/bin/egencache
21 @@ -215,18 +215,22 @@ class GenCache(object):
22 max_jobs=max_jobs, max_load=max_load)
23 self.returncode = os.EX_OK
24 conf = portdb.repositories.get_repo_for_location(portdb.porttrees[0])
25 - self._trg_cache = conf.get_pregenerated_cache(portage.auxdbkeys[:],
26 - force=True, readonly=False)
27 - if self._trg_cache is None:
28 + self._trg_caches = tuple(conf.iter_pregenerated_caches(
29 + portage.auxdbkeys[:], force=True, readonly=False))
30 + if not self._trg_caches:
31 raise Exception("cache formats '%s' aren't supported" %
32 (" ".join(conf.cache_formats),))
33 if rsync:
34 - self._trg_cache.raise_stat_collision = True
35 - try:
36 - self._trg_cache.ec = \
37 - portdb._repo_info[portdb.porttrees[0]].eclass_db
38 - except AttributeError:
39 - pass
40 + from portage.cache.metadata import database as pms_database
41 + for trg_cache in self._trg_caches:
42 + if isinstance(trg_cache, pms_database):
43 + trg_cache.raise_stat_collision = True
44 + # Make _metadata_callback write this cache first, in case
45 + # it raises a StatCollision and triggers mtime
46 + # modification.
47 + self._trg_caches = tuple([trg_cache] +
48 + [x for x in self._trg_caches if x is not trg_cache])
49 +
50 self._existing_nodes = set()
51
52 def _metadata_callback(self, cpv, repo_path, metadata, ebuild_hash):
53 @@ -235,11 +239,16 @@ class GenCache(object):
54 if metadata is not None:
55 if metadata.get('EAPI') == '0':
56 del metadata['EAPI']
57 + for trg_cache in self._trg_caches:
58 + self._write_cache(trg_cache,
59 + cpv, repo_path, metadata, ebuild_hash)
60 +
61 + def _write_cache(self, trg_cache, cpv, repo_path, metadata, ebuild_hash):
62 try:
63 - chf = self._trg_cache.validation_chf
64 + chf = trg_cache.validation_chf
65 metadata['_%s_' % chf] = getattr(ebuild_hash, chf)
66 try:
67 - self._trg_cache[cpv] = metadata
68 + trg_cache[cpv] = metadata
69 except StatCollision as sc:
70 # If the content of a cache entry changes and neither the
71 # file mtime nor size changes, it will prevent rsync from
72 @@ -264,7 +273,7 @@ class GenCache(object):
73 level=logging.ERROR, noiselevel=-1)
74 else:
75 metadata['_mtime_'] = max_mtime
76 - self._trg_cache[cpv] = metadata
77 + trg_cache[cpv] = metadata
78 self._portdb.auxdb[repo_path][cpv] = metadata
79
80 except CacheError as ce:
81 @@ -303,9 +312,12 @@ class GenCache(object):
82 sys.exit(received_signal[0])
83
84 self.returncode |= self._regen.returncode
85 - cp_missing = self._cp_missing
86
87 - trg_cache = self._trg_cache
88 + for trg_cache in self._trg_caches:
89 + self._cleanse_cache(trg_cache)
90 +
91 + def _cleanse_cache(self, trg_cache):
92 + cp_missing = self._cp_missing
93 dead_nodes = set()
94 if self._global_cleanse:
95 try: