summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-02-23 14:17:13 +0000
committerZac Medico <zmedico@gentoo.org>2007-02-23 14:17:13 +0000
commitd21268c326e46a6a1dd5fe19b2feeb8cd8963314 (patch)
treec7da3840c32c9c97ae879ad1cca1c3b7c72604e9 /pym
parent650182115ab4eda424e94b05b20cbc082c128b3d (diff)
downloadportage-d21268c326e46a6a1dd5fe19b2feeb8cd8963314.tar.gz
portage-d21268c326e46a6a1dd5fe19b2feeb8cd8963314.tar.bz2
portage-d21268c326e46a6a1dd5fe19b2feeb8cd8963314.zip
Make verify_all() return an "insufficient data" error if there is not at least one supported hash type. Make fetch() bail out when this error occurs. (trunk r6054:6056)
svn path=/main/branches/2.1.2/; revision=6057
Diffstat (limited to 'pym')
-rw-r--r--pym/portage.py4
-rw-r--r--pym/portage_checksum.py18
2 files changed, 22 insertions, 0 deletions
diff --git a/pym/portage.py b/pym/portage.py
index ee7a4a806..6205d7315 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -2484,6 +2484,8 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
writemsg(("!!! Got: %s\n" + \
"!!! Expected: %s\n") % \
(reason[1], reason[2]), noiselevel=-1)
+ if reason[0] == "Insufficient data for checksum verification":
+ return 0
if can_fetch and not restrict_fetch:
writemsg("Refetching...\n\n",
noiselevel=-1)
@@ -2623,6 +2625,8 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
noiselevel=-1)
writemsg("!!! Got: %s\n!!! Expected: %s\n" % \
(reason[1], reason[2]), noiselevel=-1)
+ if reason[0] == "Insufficient data for checksum verification":
+ return 0
writemsg("Removing corrupt distfile...\n", noiselevel=-1)
os.unlink(mysettings["DISTDIR"]+"/"+myfile)
fetched=0
diff --git a/pym/portage_checksum.py b/pym/portage_checksum.py
index 7f1a89c8e..cd5e0cb31 100644
--- a/pym/portage_checksum.py
+++ b/pym/portage_checksum.py
@@ -3,6 +3,8 @@
# Distributed under the terms of the GNU General Public License v2
# $Id$
+if not hasattr(__builtins__, "set"):
+ from sets import Set as set
from portage_const import PRIVATE_PATH,PRELINK_BINARY,HASHING_BLOCKSIZE
import os
@@ -113,6 +115,22 @@ def verify_all(filename, mydict, calc_prelink=0, strict=0):
if e.errno == errno.ENOENT:
raise portage_exception.FileNotFound(filename)
return False, (str(e), None, None)
+
+ verifiable_hash_types = set(mydict).intersection(hashfunc_map)
+ verifiable_hash_types.discard("size")
+ if not verifiable_hash_types:
+ expected = set(hashfunc_map)
+ expected.discard("size")
+ expected = list(expected)
+ expected.sort()
+ expected = " ".join(expected)
+ got = set(mydict)
+ got.discard("size")
+ got = list(got)
+ got.sort()
+ got = " ".join(got)
+ return False, ("Insufficient data for checksum verification", got, expected)
+
for x in mydict.keys():
if x == "size":
continue