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/portage/repository/, pym/portage/
Date: Mon, 03 Oct 2011 09:47:42
Message-Id: d9d0606fe01618cc81fb0b862ada91149dad3746.zmedico@gentoo
1 commit: d9d0606fe01618cc81fb0b862ada91149dad3746
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Mon Oct 3 09:42:53 2011 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Mon Oct 3 09:42:53 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=d9d0606f
7
8 GLEP 59: use manifest-hashes list in layout.conf
9
10 The manifest-hashes layout.conf setting simply overrides the hashes
11 that are generated. When unspecified, the MANIFEST2_HASH_DEFAULTS
12 constant is used instead (current value contains SHA1, SHA256, and
13 RMD160).
14
15 In order to enable SHA512 and WHIRLPOOL, and drop RMD160 and SHA1,
16 simply set "manifest-hashes = SHA256 SHA512 WHIRLPOOL" in layout.conf.
17 As with the previous boolean flags approach, manifest-hashes settings
18 become redundant and can be removed from layout.conf after a version
19 of portage with equivalent defaults is stable.
20
21 ---
22 pym/portage/const.py | 11 +++++++----
23 pym/portage/manifest.py | 14 +++++---------
24 pym/portage/repository/config.py | 25 +++++++------------------
25 3 files changed, 19 insertions(+), 31 deletions(-)
26
27 diff --git a/pym/portage/const.py b/pym/portage/const.py
28 index e7eac62..e3627ea 100644
29 --- a/pym/portage/const.py
30 +++ b/pym/portage/const.py
31 @@ -114,20 +114,23 @@ MANIFEST1_REQUIRED_HASH = "MD5"
32 # Future events:
33 #
34 # After WHIRLPOOL is supported in stable portage:
35 -# - Add WHIRLPOOL to MANIFEST2_HASH_DEFAULTS.
36 +# - Add SHA256 and WHIRLPOOL to MANIFEST2_HASH_DEFAULTS.
37 # - Remove SHA1 and RMD160 from MANIFEST2_HASH_*.
38 -# - Toggle gentoo-x86/metadata/layout.conf settings to match.
39 +# - Set manifest-hashes in gentoo-x86/metadata/layout.conf as follows:
40 +# manifest-hashes = SHA256 SHA512 WHIRLPOOL
41 #
42 # After WHIRLPOOL is supported in stable portage for at least 1 year:
43 # - Change MANIFEST2_REQUIRED_HASH to WHIRLPOOL.
44 # - Remove SHA256 from MANIFEST2_HASH_*.
45 -# - Toggle gentoo-x86/metadata/layout.conf settings to match.
46 +# - Set manifest-hashes in gentoo-x86/metadata/layout.conf as follows:
47 +# manifest-hashes = SHA512 WHIRLPOOL
48 #
49 # After SHA-3 is approved:
50 # - Add new hashes to MANIFEST2_HASH_*.
51 #
52 # After SHA-3 is supported in stable portage:
53 -# - Toggle gentoo-x86/metadata/layout.conf settings to match.
54 +# - Set manifest-hashes in gentoo-x86/metadata/layout.conf as follows:
55 +# manifest-hashes = SHA3 SHA512 WHIRLPOOL
56 #
57 # After layout.conf settings correspond to defaults in stable portage:
58 # - Remove redundant settings from gentoo-x86/metadata/layout.conf.
59
60 diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
61 index eaea0bd..78153c0 100644
62 --- a/pym/portage/manifest.py
63 +++ b/pym/portage/manifest.py
64 @@ -103,7 +103,7 @@ class Manifest(object):
65 parsers = (parseManifest2,)
66 def __init__(self, pkgdir, distdir, fetchlist_dict=None,
67 manifest1_compat=DeprecationWarning, from_scratch=False, thin=False,
68 - allow_missing=False, allow_create=True, hash_flags=None):
69 + allow_missing=False, allow_create=True, hashes=None):
70 """ Create new Manifest instance for package in pkgdir.
71 Do not parse Manifest file if from_scratch == True (only for internal use)
72 The fetchlist_dict parameter is required only for generation of
73 @@ -120,14 +120,10 @@ class Manifest(object):
74 self.fhashdict = {}
75 self.hashes = set()
76
77 - if hash_flags is None:
78 - hash_flags = {}
79 - self.hash_flags = hash_flags
80 - for hash_type in MANIFEST2_HASH_FUNCTIONS:
81 - default_state = hash_type in MANIFEST2_HASH_DEFAULTS
82 - if hash_flags.get(hash_type, default_state):
83 - self.hashes.add(hash_type)
84 + if hashes is None:
85 + hashes = MANIFEST2_HASH_DEFAULTS
86
87 + self.hashes.update(hashes.intersection(MANIFEST2_HASH_FUNCTIONS))
88 self.hashes.difference_update(hashname for hashname in \
89 list(self.hashes) if hashname not in hashfunc_map)
90 self.hashes.add("size")
91 @@ -360,7 +356,7 @@ class Manifest(object):
92 self.__init__(self.pkgdir, self.distdir,
93 fetchlist_dict=self.fetchlist_dict, from_scratch=True,
94 thin=self.thin, allow_missing=self.allow_missing,
95 - allow_create=self.allow_create, hash_flags=self.hash_flags)
96 + allow_create=self.allow_create, hashes=self.hashes)
97 pn = os.path.basename(self.pkgdir.rstrip(os.path.sep))
98 cat = self._pkgdir_category()
99
100
101 diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py
102 index c201fe7..779d432 100644
103 --- a/pym/portage/repository/config.py
104 +++ b/pym/portage/repository/config.py
105 @@ -44,7 +44,7 @@ class RepoConfig(object):
106 __slots__ = ['aliases', 'eclass_overrides', 'eclass_locations', 'location', 'user_location', 'masters', 'main_repo',
107 'missing_repo_name', 'name', 'priority', 'sync', 'format', 'sign_manifest', 'thin_manifest',
108 'allow_missing_manifest', 'create_manifest', 'disable_manifest', 'cache_is_authoritative',
109 - 'trust_authoritative_cache', 'manifest_hash_flags']
110 + 'trust_authoritative_cache', 'manifest_hashes']
111
112 def __init__(self, name, repo_opts):
113 """Build a RepoConfig with options in repo_opts
114 @@ -118,7 +118,7 @@ class RepoConfig(object):
115 self.allow_missing_manifest = False
116 self.create_manifest = True
117 self.disable_manifest = False
118 - self.manifest_hash_flags = {}
119 + self.manifest_hashes = None
120
121 self.cache_is_authoritative = False
122
123 @@ -131,7 +131,7 @@ class RepoConfig(object):
124 kwds['thin'] = self.thin_manifest
125 kwds['allow_missing'] = self.allow_missing_manifest
126 kwds['allow_create'] = self.create_manifest
127 - kwds['hash_flags'] = self.manifest_hash_flags
128 + kwds['hashes'] = self.manifest_hashes
129 if self.disable_manifest:
130 kwds['from_scratch'] = True
131 return manifest.Manifest(*args, **kwds)
132 @@ -382,21 +382,10 @@ class RepoConfigLoader(object):
133 repo.create_manifest = manifest_policy != 'false'
134 repo.disable_manifest = manifest_policy == 'false'
135
136 - if 'manifest-rmd160' in layout_data:
137 - repo.manifest_hash_flags["RMD160"] = \
138 - layout_data['manifest-rmd160'].lower() == 'true'
139 -
140 - if 'manifest-sha1' in layout_data:
141 - repo.manifest_hash_flags["SHA1"] = \
142 - layout_data['manifest-sha1'].lower() == 'true'
143 -
144 - if 'manifest-sha256' in layout_data:
145 - repo.manifest_hash_flags["SHA256"] = \
146 - layout_data['manifest-sha256'].lower() == 'true'
147 -
148 - if 'manifest-whirlpool' in layout_data:
149 - repo.manifest_hash_flags["WHIRLPOOL"] = \
150 - layout_data['manifest-whirlpool'].lower() == 'true'
151 + manifest_hashes = layout_data.get('manifest-hashes')
152 + if manifest_hashes is not None:
153 + manifest_hashes = frozenset(manifest_hashes.upper().split())
154 + repo.manifest_hashes = manifest_hashes
155
156 repo.cache_is_authoritative = layout_data.get('authoritative-cache', 'false').lower() == 'true'
157 if not repo.trust_authoritative_cache: