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