diff options
author | Zac Medico <zmedico@gentoo.org> | 2012-07-12 12:48:49 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2012-07-12 12:48:49 -0700 |
commit | 63e25313d785f40abff3197fe0f3a3eeaa617f7d (patch) | |
tree | 95e5a3ca49c944b905b48bff7234a92b6fe9db40 /pym/portage/checksum.py | |
parent | 48497bca12ac8b52740681a7a10200f0a58345ea (diff) | |
download | portage-63e25313d785f40abff3197fe0f3a3eeaa617f7d.tar.gz portage-63e25313d785f40abff3197fe0f3a3eeaa617f7d.tar.bz2 portage-63e25313d785f40abff3197fe0f3a3eeaa617f7d.zip |
Skip whirlpool digest check when unaccelerated.
If multiple digests are available and whirlpool is unaccelerated, then
skip it. This allows extreme performance problems like bug #425046 to
be avoided whenever practical, especially for cases like stage builds
where acceleration may not be available for some hashes due to
minimization of dependencies.
Diffstat (limited to 'pym/portage/checksum.py')
-rw-r--r-- | pym/portage/checksum.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py index bd416ac12..daf4a0cbf 100644 --- a/pym/portage/checksum.py +++ b/pym/portage/checksum.py @@ -137,8 +137,10 @@ try: except ImportError: pass +_whirlpool_unaccelerated = False if "WHIRLPOOL" not in hashfunc_map: # Bundled WHIRLPOOL implementation + _whirlpool_unaccelerated = True from portage.util.whirlpool import new as _new_whirlpool whirlpoolhash = _generate_hash_function("WHIRLPOOL", _new_whirlpool, origin="bundled") @@ -197,6 +199,24 @@ def get_hash_origin(hashtype): raise KeyError(hashtype) return hashorigin_map.get(hashtype, "unknown") +def _filter_unaccelarated_hashes(digests): + """ + If multiple digests are available and some are unaccelerated, + then return a new dict that omits the unaccelerated ones. This + allows extreme performance problems like bug #425046 to be + avoided whenever practical, especially for cases like stage + builds where acceleration may not be available for some hashes + due to minimization of dependencies. + """ + if _whirlpool_unaccelerated and "WHIRLPOOL" in digests: + verifiable_hash_types = set(digests).intersection(hashfunc_map) + verifiable_hash_types.discard("size") + if len(verifiable_hash_types) > 1: + digests = dict(digests) + digests.pop("WHIRLPOOL") + + return digests + def verify_all(filename, mydict, calc_prelink=0, strict=0): """ Verify all checksums against a file. |