Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: repoman/pym/repoman/, pym/portage/, pym/portage/repository/, man/
Date: Mon, 06 Nov 2017 14:33:52
Message-Id: 1509978781.7857c1cae45c3cbd51f6eb0827ccc9bd17ff7269.mgorny@gentoo
1 commit: 7857c1cae45c3cbd51f6eb0827ccc9bd17ff7269
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Mon Nov 6 07:08:53 2017 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Mon Nov 6 14:33:01 2017 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=7857c1ca
7
8 Replace static MANIFEST2_HASH_FUNCTIONS with dynamic list
9
10 Remove the MANIFEST2_HASH_FUNCTIONS const and replace it with
11 (deduplicated) calls to get_valid_checksum_keys(). We want Portage
12 to always complain whenever one of the hashes is not available even
13 if it is technically supported by the specific Portage version.
14
15 Closes: https://bugs.gentoo.org/634812
16 Reviewed-by: Zac Medico <zmedico <AT> gentoo.org>
17
18 man/portage.5 | 4 ++--
19 pym/portage/const.py | 3 ---
20 pym/portage/manifest.py | 6 +++---
21 pym/portage/repository/config.py | 5 +++--
22 repoman/pym/repoman/repos.py | 3 ++-
23 5 files changed, 10 insertions(+), 11 deletions(-)
24
25 diff --git a/man/portage.5 b/man/portage.5
26 index 89dc8ce44..7605d7cfa 100644
27 --- a/man/portage.5
28 +++ b/man/portage.5
29 @@ -1261,8 +1261,8 @@ for every file), "true" (if an entry exists for a file, enforce it), or "false"
30 .TP
31 .BR manifest\-hashes
32 List of hashes to generate/check in Manifest files. Valid hashes depend on the
33 -current version of portage; see the portage.const.MANIFEST2_HASH_FUNCTIONS
34 -constant for the current list.
35 +current version of portage; see the portage.checksum module for the current
36 +list.
37 .TP
38 .BR update\-changelog " = [true|" false "]"
39 The default setting for repoman's --echangelog option.
40
41 diff --git a/pym/portage/const.py b/pym/portage/const.py
42 index 11e94b0a2..98b7c88c9 100644
43 --- a/pym/portage/const.py
44 +++ b/pym/portage/const.py
45 @@ -207,9 +207,6 @@ EAPI = 6
46 HASHING_BLOCKSIZE = 32768
47 MANIFEST1_HASH_FUNCTIONS = ("MD5", "SHA256", "RMD160")
48
49 -MANIFEST2_HASH_FUNCTIONS = ("SHA256", "SHA512", "WHIRLPOOL",
50 - "BLAKE2B", "BLAKE2S", "SHA3_256", "SHA3_512",
51 - "STREEBOG256", "STREEBOG512")
52 MANIFEST2_HASH_DEFAULTS = frozenset(["SHA256", "SHA512", "WHIRLPOOL"])
53 MANIFEST2_REQUIRED_HASH = "SHA512"
54
55
56 diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
57 index 28a77ba87..0a68aa653 100644
58 --- a/pym/portage/manifest.py
59 +++ b/pym/portage/manifest.py
60 @@ -27,7 +27,7 @@ from portage.exception import DigestException, FileNotFound, \
61 InvalidDataType, MissingParameter, PermissionDenied, \
62 PortageException, PortagePackageException
63 from portage.const import (MANIFEST1_HASH_FUNCTIONS, MANIFEST2_HASH_DEFAULTS,
64 - MANIFEST2_HASH_FUNCTIONS, MANIFEST2_IDENTIFIERS, MANIFEST2_REQUIRED_HASH)
65 + MANIFEST2_IDENTIFIERS, MANIFEST2_REQUIRED_HASH)
66 from portage.localization import _
67
68 _manifest_re = re.compile(
69 @@ -152,7 +152,7 @@ class Manifest(object):
70 if hashes is None:
71 hashes = MANIFEST2_HASH_DEFAULTS
72
73 - self.hashes.update(hashes.intersection(MANIFEST2_HASH_FUNCTIONS))
74 + self.hashes.update(hashes)
75 self.hashes.difference_update(hashname for hashname in \
76 list(self.hashes) if hashname not in get_valid_checksum_keys())
77 self.hashes.add("size")
78 @@ -251,7 +251,7 @@ class Manifest(object):
79 return myhashdict
80
81 def _createManifestEntries(self):
82 - valid_hashes = set(MANIFEST2_HASH_FUNCTIONS)
83 + valid_hashes = set(get_valid_checksum_keys())
84 valid_hashes.add('size')
85 mytypes = list(self.fhashdict)
86 mytypes.sort()
87
88 diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py
89 index 902213014..3be0e8bda 100644
90 --- a/pym/portage/repository/config.py
91 +++ b/pym/portage/repository/config.py
92 @@ -11,7 +11,8 @@ import re
93
94 import portage
95 from portage import eclass_cache, os
96 -from portage.const import (MANIFEST2_HASH_FUNCTIONS, MANIFEST2_REQUIRED_HASH,
97 +from portage.checksum import get_valid_checksum_keys
98 +from portage.const import (MANIFEST2_REQUIRED_HASH,
99 PORTAGE_BASE_PATH, REPO_NAME_LOC, USER_CONFIG_PATH)
100 from portage.eapi import eapi_allows_directories_on_profile_level_and_repository_level
101 from portage.env.loaders import KeyValuePairFileLoader
102 @@ -1060,7 +1061,7 @@ def parse_layout_conf(repo_location, repo_name=None):
103 "layout_filename":layout_filename}),
104 DeprecationWarning)
105 unsupported_hashes = manifest_hashes.difference(
106 - MANIFEST2_HASH_FUNCTIONS)
107 + get_valid_checksum_keys())
108 if unsupported_hashes:
109 repo_name = _get_repo_name(repo_location, cached=repo_name)
110 warnings.warn((_("Repository named '%(repo_name)s' has a "
111
112 diff --git a/repoman/pym/repoman/repos.py b/repoman/pym/repoman/repos.py
113 index 39f53c180..11a6231de 100644
114 --- a/repoman/pym/repoman/repos.py
115 +++ b/repoman/pym/repoman/repos.py
116 @@ -13,6 +13,7 @@ from repoman._portage import portage
117 from portage import os
118 from portage import _encodings
119 from portage import _unicode_encode
120 +from portage.checksum import get_valid_checksum_keys
121
122 from repoman.errors import err
123 from repoman.profile import ProfileDesc, valid_profile_types
124 @@ -116,7 +117,7 @@ class RepoSettings(object):
125 sys.exit(1)
126
127 unsupported_hashes = manifest_hashes.difference(
128 - portage.const.MANIFEST2_HASH_FUNCTIONS)
129 + get_valid_checksum_keys())
130 if unsupported_hashes:
131 msg = (
132 "The 'manifest-hashes' setting in the '%s' repository's "