From: Zac Medico Date: Wed, 22 Aug 2012 04:01:24 +0000 (-0700) Subject: _apply_hash_filter: make hash_filter simpler X-Git-Tag: v2.2.0_alpha122~5 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a3185709c7e6fa576ffddac59a9b4ff7e5243e6b;p=portage.git _apply_hash_filter: make hash_filter simpler Now any callable object will work, which might be helpful for consumers of the Manifest.checkFileHashes() method. --- diff --git a/pym/_emerge/EbuildFetcher.py b/pym/_emerge/EbuildFetcher.py index bbcb6a9d2..2d9635af4 100644 --- a/pym/_emerge/EbuildFetcher.py +++ b/pym/_emerge/EbuildFetcher.py @@ -59,6 +59,8 @@ class EbuildFetcher(SpawnProcess): return False hash_filter = _hash_filter(settings.get("PORTAGE_CHECKSUM_FILTER", "")) + if hash_filter.transparent: + hash_filter = None stdout_orig = sys.stdout stderr_orig = sys.stderr global_havecolor = portage.output.havecolor diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py index de4cc668a..144e6336f 100644 --- a/pym/portage/checksum.py +++ b/pym/portage/checksum.py @@ -250,9 +250,13 @@ def _apply_hash_filter(digests, hash_filter): dict if no changes are necessary. This will always preserve at at least one digest, in order to ensure that they are not all discarded. + @param digests: dictionary of digests + @type digests: dict + @param hash_filter: A callable that takes a single hash name + argument, and returns True if the hash is to be used or + False otherwise + @type hash_filter: callable """ - if hash_filter.transparent: - return digests verifiable_hash_types = set(digests).intersection(hashfunc_map) verifiable_hash_types.discard("size") diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index a2fd5eabe..7f0943607 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -1465,7 +1465,8 @@ class binarytree(object): hash_filter = _hash_filter( self.settings.get("PORTAGE_CHECKSUM_FILTER", "")) - digests = _apply_hash_filter(digests, hash_filter) + if not hash_filter.transparent: + digests = _apply_hash_filter(digests, hash_filter) eout = EOutput() eout.quiet = self.settings.get("PORTAGE_QUIET") == "1" ok, st = _check_distfile(pkg_path, digests, eout, show_errors=0) diff --git a/pym/portage/package/ebuild/digestcheck.py b/pym/portage/package/ebuild/digestcheck.py index 1d59948d1..e207ba841 100644 --- a/pym/portage/package/ebuild/digestcheck.py +++ b/pym/portage/package/ebuild/digestcheck.py @@ -30,6 +30,8 @@ def digestcheck(myfiles, mysettings, strict=False, justmanifest=None, mf=None): return 1 pkgdir = mysettings["O"] hash_filter = _hash_filter(mysettings.get("PORTAGE_CHECKSUM_FILTER", "")) + if hash_filter.transparent: + hash_filter = None if mf is None: mf = mysettings.repositories.get_repo_for_location( os.path.dirname(os.path.dirname(pkgdir))) diff --git a/pym/portage/package/ebuild/fetch.py b/pym/portage/package/ebuild/fetch.py index 8365ad211..576a91239 100644 --- a/pym/portage/package/ebuild/fetch.py +++ b/pym/portage/package/ebuild/fetch.py @@ -358,6 +358,8 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, mymirrors += [x.rstrip("/") for x in mysettings["GENTOO_MIRRORS"].split() if x] hash_filter = _hash_filter(mysettings.get("PORTAGE_CHECKSUM_FILTER", "")) + if hash_filter.transparent: + hash_filter = None skip_manifest = mysettings.get("EBUILD_SKIP_MANIFEST") == "1" if skip_manifest: allow_missing_digests = True @@ -799,7 +801,8 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, continue else: digests = _filter_unaccelarated_hashes(mydigests[myfile]) - digests = _apply_hash_filter(digests, hash_filter) + if hash_filter is not None: + digests = _apply_hash_filter(digests, hash_filter) verified_ok, reason = verify_all(myfile_path, digests) if not verified_ok: writemsg(_("!!! Previously fetched" @@ -1057,7 +1060,8 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, # net connection. This way we have a chance to try to download # from another mirror... digests = _filter_unaccelarated_hashes(mydigests[myfile]) - digests = _apply_hash_filter(digests, hash_filter) + if hash_filter is not None: + digests = _apply_hash_filter(digests, hash_filter) verified_ok, reason = verify_all(myfile_path, digests) if not verified_ok: writemsg(_("!!! Fetched file: %s VERIFY FAILED!\n") % myfile,