--- a/components/gd2/Makefile Tue Mar 15 09:38:10 2011 -0700
+++ b/components/gd2/Makefile Wed Mar 16 07:42:49 2011 -0700
@@ -27,7 +27,9 @@
COMPONENT_SRC= $(COMPONENT_NAME)-$(COMPONENT_VERSION)
COMPONENT_PROJECT_URL= http://www.libgd.org/
COMPONENT_ARCHIVE= $(COMPONENT_SRC).tar.gz
-COMPONENT_ARCHIVE_HASH= sha1:ad6b6ce72c83e513ef7c31b7f8a5c6f07a2e0143
+# this is the hash of the payload because it appears to be re-compressed
+# periodically causing it to have a new hash value.
+COMPONENT_ARCHIVE_HASH= sha1:eaa077067945956930f6d9258e130f1e043d9b39
COMPONENT_ARCHIVE_URL= http://www.libgd.org/releases/$(COMPONENT_ARCHIVE)
include ../../make-rules/prep.mk
--- a/tools/userland-fetch Tue Mar 15 09:38:10 2011 -0700
+++ b/tools/userland-fetch Wed Mar 16 07:42:49 2011 -0700
@@ -32,15 +32,9 @@
import sys
import shutil
from urllib import splittype, urlopen
-
-def validate(filename, hash):
- import hashlib
+import hashlib
- try:
- file = open(filename, 'r')
- except IOError:
- return False
-
+def validate(file, hash):
algorithm, hashvalue = hash.split(':')
try:
m = hashlib.new(algorithm)
@@ -55,6 +49,34 @@
return "%s:%s" % (algorithm, m.hexdigest())
+def validate_container(filename, hash):
+ try:
+ file = open(filename, 'r')
+ except IOError:
+ return False
+ return validate(file, hash)
+
+
+def validate_payload(filename, hash):
+ import re
+ import gzip
+ import bz2
+
+ expr_bz = re.compile('.+\.bz2$', re.IGNORECASE)
+ expr_gz = re.compile('.+\.gz$', re.IGNORECASE)
+
+ try:
+ if expr_bz.match(filename):
+ file = bz2.BZFile(filename, 'r')
+ elif expr_gz.match(filename):
+ file = gzip.GzipFile(filename, 'r')
+ else:
+ return False
+ except IOError:
+ return False
+ return validate(file, hash)
+
+
def download(url, filename = None):
src = None
@@ -178,14 +200,19 @@
print "skipping (no hash)"
sys.exit(0)
- realhash = validate(name, hash_arg)
+ realhash = validate_container(name, hash_arg)
if realhash == hash_arg:
print "ok"
sys.exit(0)
else:
+ payloadhash = validate_payload(name, hash_arg)
+ if payloadhash == hash_arg:
+ print "ok"
+ sys.exit(0)
print "corruption detected"
print " expected: %s" % hash_arg
print " actual: %s" % realhash
+ print " payload: %s" % payloadhash
try:
os.remove(name)