1 |
commit: a3185709c7e6fa576ffddac59a9b4ff7e5243e6b |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Aug 22 04:01:24 2012 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Aug 22 04:01:24 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=a3185709 |
7 |
|
8 |
_apply_hash_filter: make hash_filter simpler |
9 |
|
10 |
Now any callable object will work, which might be helpful for |
11 |
consumers of the Manifest.checkFileHashes() method. |
12 |
|
13 |
--- |
14 |
pym/_emerge/EbuildFetcher.py | 2 ++ |
15 |
pym/portage/checksum.py | 8 ++++++-- |
16 |
pym/portage/dbapi/bintree.py | 3 ++- |
17 |
pym/portage/package/ebuild/digestcheck.py | 2 ++ |
18 |
pym/portage/package/ebuild/fetch.py | 8 ++++++-- |
19 |
5 files changed, 18 insertions(+), 5 deletions(-) |
20 |
|
21 |
diff --git a/pym/_emerge/EbuildFetcher.py b/pym/_emerge/EbuildFetcher.py |
22 |
index bbcb6a9..2d9635a 100644 |
23 |
--- a/pym/_emerge/EbuildFetcher.py |
24 |
+++ b/pym/_emerge/EbuildFetcher.py |
25 |
@@ -59,6 +59,8 @@ class EbuildFetcher(SpawnProcess): |
26 |
return False |
27 |
|
28 |
hash_filter = _hash_filter(settings.get("PORTAGE_CHECKSUM_FILTER", "")) |
29 |
+ if hash_filter.transparent: |
30 |
+ hash_filter = None |
31 |
stdout_orig = sys.stdout |
32 |
stderr_orig = sys.stderr |
33 |
global_havecolor = portage.output.havecolor |
34 |
|
35 |
diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py |
36 |
index de4cc66..144e633 100644 |
37 |
--- a/pym/portage/checksum.py |
38 |
+++ b/pym/portage/checksum.py |
39 |
@@ -250,9 +250,13 @@ def _apply_hash_filter(digests, hash_filter): |
40 |
dict if no changes are necessary. This will always preserve at |
41 |
at least one digest, in order to ensure that they are not all |
42 |
discarded. |
43 |
+ @param digests: dictionary of digests |
44 |
+ @type digests: dict |
45 |
+ @param hash_filter: A callable that takes a single hash name |
46 |
+ argument, and returns True if the hash is to be used or |
47 |
+ False otherwise |
48 |
+ @type hash_filter: callable |
49 |
""" |
50 |
- if hash_filter.transparent: |
51 |
- return digests |
52 |
|
53 |
verifiable_hash_types = set(digests).intersection(hashfunc_map) |
54 |
verifiable_hash_types.discard("size") |
55 |
|
56 |
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py |
57 |
index a2fd5ea..7f09436 100644 |
58 |
--- a/pym/portage/dbapi/bintree.py |
59 |
+++ b/pym/portage/dbapi/bintree.py |
60 |
@@ -1465,7 +1465,8 @@ class binarytree(object): |
61 |
|
62 |
hash_filter = _hash_filter( |
63 |
self.settings.get("PORTAGE_CHECKSUM_FILTER", "")) |
64 |
- digests = _apply_hash_filter(digests, hash_filter) |
65 |
+ if not hash_filter.transparent: |
66 |
+ digests = _apply_hash_filter(digests, hash_filter) |
67 |
eout = EOutput() |
68 |
eout.quiet = self.settings.get("PORTAGE_QUIET") == "1" |
69 |
ok, st = _check_distfile(pkg_path, digests, eout, show_errors=0) |
70 |
|
71 |
diff --git a/pym/portage/package/ebuild/digestcheck.py b/pym/portage/package/ebuild/digestcheck.py |
72 |
index 1d59948..e207ba8 100644 |
73 |
--- a/pym/portage/package/ebuild/digestcheck.py |
74 |
+++ b/pym/portage/package/ebuild/digestcheck.py |
75 |
@@ -30,6 +30,8 @@ def digestcheck(myfiles, mysettings, strict=False, justmanifest=None, mf=None): |
76 |
return 1 |
77 |
pkgdir = mysettings["O"] |
78 |
hash_filter = _hash_filter(mysettings.get("PORTAGE_CHECKSUM_FILTER", "")) |
79 |
+ if hash_filter.transparent: |
80 |
+ hash_filter = None |
81 |
if mf is None: |
82 |
mf = mysettings.repositories.get_repo_for_location( |
83 |
os.path.dirname(os.path.dirname(pkgdir))) |
84 |
|
85 |
diff --git a/pym/portage/package/ebuild/fetch.py b/pym/portage/package/ebuild/fetch.py |
86 |
index 8365ad2..576a912 100644 |
87 |
--- a/pym/portage/package/ebuild/fetch.py |
88 |
+++ b/pym/portage/package/ebuild/fetch.py |
89 |
@@ -358,6 +358,8 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, |
90 |
mymirrors += [x.rstrip("/") for x in mysettings["GENTOO_MIRRORS"].split() if x] |
91 |
|
92 |
hash_filter = _hash_filter(mysettings.get("PORTAGE_CHECKSUM_FILTER", "")) |
93 |
+ if hash_filter.transparent: |
94 |
+ hash_filter = None |
95 |
skip_manifest = mysettings.get("EBUILD_SKIP_MANIFEST") == "1" |
96 |
if skip_manifest: |
97 |
allow_missing_digests = True |
98 |
@@ -799,7 +801,8 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, |
99 |
continue |
100 |
else: |
101 |
digests = _filter_unaccelarated_hashes(mydigests[myfile]) |
102 |
- digests = _apply_hash_filter(digests, hash_filter) |
103 |
+ if hash_filter is not None: |
104 |
+ digests = _apply_hash_filter(digests, hash_filter) |
105 |
verified_ok, reason = verify_all(myfile_path, digests) |
106 |
if not verified_ok: |
107 |
writemsg(_("!!! Previously fetched" |
108 |
@@ -1057,7 +1060,8 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, |
109 |
# net connection. This way we have a chance to try to download |
110 |
# from another mirror... |
111 |
digests = _filter_unaccelarated_hashes(mydigests[myfile]) |
112 |
- digests = _apply_hash_filter(digests, hash_filter) |
113 |
+ if hash_filter is not None: |
114 |
+ digests = _apply_hash_filter(digests, hash_filter) |
115 |
verified_ok, reason = verify_all(myfile_path, digests) |
116 |
if not verified_ok: |
117 |
writemsg(_("!!! Fetched file: %s VERIFY FAILED!\n") % myfile, |