diff options
author | Zac Medico <zmedico@gentoo.org> | 2010-12-28 13:44:57 -0800 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-12-28 13:44:57 -0800 |
commit | 55a08f1dfb9b52a2c608784132a936eace0b6028 (patch) | |
tree | df161439b775d2a794c5070cc539430d4db9e493 /pym/portage | |
parent | 80391bc70f75c8af863d08675adc69e441f12989 (diff) | |
download | portage-55a08f1dfb9b52a2c608784132a936eace0b6028.tar.gz portage-55a08f1dfb9b52a2c608784132a936eace0b6028.tar.bz2 portage-55a08f1dfb9b52a2c608784132a936eace0b6028.zip |
EbuildFetcher: bail out if missing digest
This will fix bug #348864.
Diffstat (limited to 'pym/portage')
-rw-r--r-- | pym/portage/package/ebuild/fetch.py | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/pym/portage/package/ebuild/fetch.py b/pym/portage/package/ebuild/fetch.py index 7e4365fb7..3e6326a49 100644 --- a/pym/portage/package/ebuild/fetch.py +++ b/pym/portage/package/ebuild/fetch.py @@ -26,7 +26,7 @@ portage.proxy.lazyimport.lazyimport(globals(), from portage import OrderedDict, os, selinux, _encodings, \ _shell_quote, _unicode_encode -from portage.checksum import perform_md5, verify_all +from portage.checksum import hashfunc_map, perform_md5, verify_all from portage.const import BASH_BINARY, CUSTOM_MIRRORS_FILE, \ GLOBAL_CONFIG_PATH from portage.data import portage_gid, portage_uid, secpass, userpriv_groups @@ -231,7 +231,8 @@ _size_suffix_map = { } def fetch(myuris, mysettings, listonly=0, fetchonly=0, - locks_in_subdir=".locks", use_locks=1, try_mirrors=1, digests=None): + locks_in_subdir=".locks", use_locks=1, try_mirrors=1, digests=None, + allow_missing_digests=True): "fetch files. Will use digest file if available." if not myuris: @@ -530,6 +531,34 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, fetched = 0 orig_digests = mydigests.get(myfile, {}) + + if not allow_missing_digests: + verifiable_hash_types = set(orig_digests).intersection(hashfunc_map) + verifiable_hash_types.discard("size") + if not verifiable_hash_types: + expected = set(hashfunc_map) + expected.discard("size") + expected = " ".join(sorted(expected)) + got = set(orig_digests) + got.discard("size") + got = " ".join(sorted(got)) + reason = (_("Insufficient data for checksum verification"), + got, expected) + writemsg(_("!!! Fetched file: %s VERIFY FAILED!\n") % myfile, + noiselevel=-1) + writemsg(_("!!! Reason: %s\n") % reason[0], + noiselevel=-1) + writemsg(_("!!! Got: %s\n!!! Expected: %s\n") % \ + (reason[1], reason[2]), noiselevel=-1) + + if listonly: + continue + elif fetchonly: + failed_files.add(myfile) + continue + else: + return 0 + size = orig_digests.get("size") if size == 0: # Zero-byte distfiles are always invalid, so discard their digests. |