Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/
Date: Sat, 29 Oct 2011 17:52:07
Message-Id: 412f6cc18ea06987fda0c6e4c05aee5e6d1a2f08.zmedico@gentoo
1 commit: 412f6cc18ea06987fda0c6e4c05aee5e6d1a2f08
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Sat Oct 29 17:48:30 2011 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Sat Oct 29 17:48:30 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=412f6cc1
7
8 emerge --metadata: support md5-dict
9
10 This adds support to action_metadata() for use of arbitrary validation
11 methods, which were introduced in commit
12 2ed1cb53cc4158af08c22d466b15b9a9a7767212.
13
14 ---
15 pym/_emerge/actions.py | 36 ++++++++++++++++++++++++++++++++----
16 1 files changed, 32 insertions(+), 4 deletions(-)
17
18 diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
19 index de5275d..610a6c4 100644
20 --- a/pym/_emerge/actions.py
21 +++ b/pym/_emerge/actions.py
22 @@ -5,6 +5,7 @@ from __future__ import print_function
23
24 import errno
25 import logging
26 +import operator
27 import platform
28 import pwd
29 import random
30 @@ -34,6 +35,7 @@ from portage.const import _ENABLE_DYN_LINK_MAP, _ENABLE_SET_CONFIG
31 from portage.dbapi.dep_expand import dep_expand
32 from portage.dbapi._expand_new_virt import expand_new_virt
33 from portage.dep import Atom, extended_cp_match
34 +from portage.eclass_cache import hashed_path
35 from portage.exception import InvalidAtom
36 from portage.output import blue, bold, colorize, create_color_func, darkgreen, \
37 red, yellow
38 @@ -1719,6 +1721,13 @@ def action_metadata(settings, portdb, myopts, porttrees=None):
39
40 for cp in cp_all:
41 for tree_data in porttrees_data:
42 +
43 + src_chf = tree_data.src_db.validation_chf
44 + src_chf_key = '_%s_' % src_chf
45 + dest_chf = tree_data.dest_db.validation_chf
46 + dest_chf_key = '_%s_' % dest_chf
47 + dest_chf_getter = operator.attrgetter(dest_chf)
48 +
49 for cpv in portdb.cp_list(cp, mytree=tree_data.path):
50 tree_data.valid_nodes.add(cpv)
51 try:
52 @@ -1726,6 +1735,11 @@ def action_metadata(settings, portdb, myopts, porttrees=None):
53 except (CacheError, KeyError):
54 continue
55
56 + ebuild_location = portdb.findname(cpv, mytree=tree_data.path)
57 + if ebuild_location is None:
58 + continue
59 + ebuild_hash = hashed_path(ebuild_location)
60 +
61 eapi = src.get('EAPI')
62 if not eapi:
63 eapi = '0'
64 @@ -1745,8 +1759,17 @@ def action_metadata(settings, portdb, myopts, porttrees=None):
65 if d is not None and d.get('EAPI') in ('', '0'):
66 del d['EAPI']
67
68 + if src_chf != 'mtime':
69 + # src may contain an irrelevant _mtime_ which corresponds
70 + # to the time that the cache entry was written
71 + src.pop('_mtime_', None)
72 +
73 + if src_chf != dest_chf:
74 + # populate src entry with dest_chf_key
75 + src[dest_chf_key] = dest_chf_getter(ebuild_hash)
76 +
77 if dest is not None:
78 - if not (dest['_mtime_'] == src['_mtime_'] and \
79 + if not (dest[dest_chf_key] == src[dest_chf_key] and \
80 tree_data.eclass_db.validate_and_rewrite_cache(
81 dest['_eclasses_'], tree_data.dest_db.validation_chf,
82 tree_data.dest_db.store_eclass_paths) is not None and \
83 @@ -1756,8 +1779,13 @@ def action_metadata(settings, portdb, myopts, porttrees=None):
84 # We don't want to skip the write unless we're really
85 # sure that the existing cache is identical, so don't
86 # trust _mtime_ and _eclasses_ alone.
87 - for k in set(chain(src, dest)).difference(
88 - ('_mtime_', '_eclasses_')):
89 + keys = set()
90 + keys.update(src)
91 + keys.update(dest)
92 + keys.discard('_eclasses_')
93 + keys.discard('_mtime_')
94 + keys.discard(src_chf_key)
95 + for k in keys:
96 if dest.get(k, '') != src.get(k, ''):
97 dest = None
98 break
99 @@ -1804,7 +1832,7 @@ def action_metadata(settings, portdb, myopts, porttrees=None):
100 if not eapi_supported:
101 src = {
102 'EAPI' : '-' + eapi,
103 - '_mtime_' : src['_mtime_'],
104 + dest_chf_key : src[dest_chf_key],
105 '_eclasses_' : src['_eclasses_'],
106 }