commit: 7857c1cae45c3cbd51f6eb0827ccc9bd17ff7269 Author: Michał Górny <mgorny <AT> gentoo <DOT> org> AuthorDate: Mon Nov 6 07:08:53 2017 +0000 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> CommitDate: Mon Nov 6 14:33:01 2017 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=7857c1ca
Replace static MANIFEST2_HASH_FUNCTIONS with dynamic list Remove the MANIFEST2_HASH_FUNCTIONS const and replace it with (deduplicated) calls to get_valid_checksum_keys(). We want Portage to always complain whenever one of the hashes is not available even if it is technically supported by the specific Portage version. Closes: https://bugs.gentoo.org/634812 Reviewed-by: Zac Medico <zmedico <AT> gentoo.org> man/portage.5 | 4 ++-- pym/portage/const.py | 3 --- pym/portage/manifest.py | 6 +++--- pym/portage/repository/config.py | 5 +++-- repoman/pym/repoman/repos.py | 3 ++- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/man/portage.5 b/man/portage.5 index 89dc8ce44..7605d7cfa 100644 --- a/man/portage.5 +++ b/man/portage.5 @@ -1261,8 +1261,8 @@ for every file), "true" (if an entry exists for a file, enforce it), or "false" .TP .BR manifest\-hashes List of hashes to generate/check in Manifest files. Valid hashes depend on the -current version of portage; see the portage.const.MANIFEST2_HASH_FUNCTIONS -constant for the current list. +current version of portage; see the portage.checksum module for the current +list. .TP .BR update\-changelog " = [true|" false "]" The default setting for repoman's --echangelog option. diff --git a/pym/portage/const.py b/pym/portage/const.py index 11e94b0a2..98b7c88c9 100644 --- a/pym/portage/const.py +++ b/pym/portage/const.py @@ -207,9 +207,6 @@ EAPI = 6 HASHING_BLOCKSIZE = 32768 MANIFEST1_HASH_FUNCTIONS = ("MD5", "SHA256", "RMD160") -MANIFEST2_HASH_FUNCTIONS = ("SHA256", "SHA512", "WHIRLPOOL", - "BLAKE2B", "BLAKE2S", "SHA3_256", "SHA3_512", - "STREEBOG256", "STREEBOG512") MANIFEST2_HASH_DEFAULTS = frozenset(["SHA256", "SHA512", "WHIRLPOOL"]) MANIFEST2_REQUIRED_HASH = "SHA512" diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py index 28a77ba87..0a68aa653 100644 --- a/pym/portage/manifest.py +++ b/pym/portage/manifest.py @@ -27,7 +27,7 @@ from portage.exception import DigestException, FileNotFound, \ InvalidDataType, MissingParameter, PermissionDenied, \ PortageException, PortagePackageException from portage.const import (MANIFEST1_HASH_FUNCTIONS, MANIFEST2_HASH_DEFAULTS, - MANIFEST2_HASH_FUNCTIONS, MANIFEST2_IDENTIFIERS, MANIFEST2_REQUIRED_HASH) + MANIFEST2_IDENTIFIERS, MANIFEST2_REQUIRED_HASH) from portage.localization import _ _manifest_re = re.compile( @@ -152,7 +152,7 @@ class Manifest(object): if hashes is None: hashes = MANIFEST2_HASH_DEFAULTS - self.hashes.update(hashes.intersection(MANIFEST2_HASH_FUNCTIONS)) + self.hashes.update(hashes) self.hashes.difference_update(hashname for hashname in \ list(self.hashes) if hashname not in get_valid_checksum_keys()) self.hashes.add("size") @@ -251,7 +251,7 @@ class Manifest(object): return myhashdict def _createManifestEntries(self): - valid_hashes = set(MANIFEST2_HASH_FUNCTIONS) + valid_hashes = set(get_valid_checksum_keys()) valid_hashes.add('size') mytypes = list(self.fhashdict) mytypes.sort() diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py index 902213014..3be0e8bda 100644 --- a/pym/portage/repository/config.py +++ b/pym/portage/repository/config.py @@ -11,7 +11,8 @@ import re import portage from portage import eclass_cache, os -from portage.const import (MANIFEST2_HASH_FUNCTIONS, MANIFEST2_REQUIRED_HASH, +from portage.checksum import get_valid_checksum_keys +from portage.const import (MANIFEST2_REQUIRED_HASH, PORTAGE_BASE_PATH, REPO_NAME_LOC, USER_CONFIG_PATH) from portage.eapi import eapi_allows_directories_on_profile_level_and_repository_level from portage.env.loaders import KeyValuePairFileLoader @@ -1060,7 +1061,7 @@ def parse_layout_conf(repo_location, repo_name=None): "layout_filename":layout_filename}), DeprecationWarning) unsupported_hashes = manifest_hashes.difference( - MANIFEST2_HASH_FUNCTIONS) + get_valid_checksum_keys()) if unsupported_hashes: repo_name = _get_repo_name(repo_location, cached=repo_name) warnings.warn((_("Repository named '%(repo_name)s' has a " diff --git a/repoman/pym/repoman/repos.py b/repoman/pym/repoman/repos.py index 39f53c180..11a6231de 100644 --- a/repoman/pym/repoman/repos.py +++ b/repoman/pym/repoman/repos.py @@ -13,6 +13,7 @@ from repoman._portage import portage from portage import os from portage import _encodings from portage import _unicode_encode +from portage.checksum import get_valid_checksum_keys from repoman.errors import err from repoman.profile import ProfileDesc, valid_profile_types @@ -116,7 +117,7 @@ class RepoSettings(object): sys.exit(1) unsupported_hashes = manifest_hashes.difference( - portage.const.MANIFEST2_HASH_FUNCTIONS) + get_valid_checksum_keys()) if unsupported_hashes: msg = ( "The 'manifest-hashes' setting in the '%s' repository's "