From 718428df6887dbfe7a526a41a05e34c3d4c8f218 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 14 Jan 2019 15:03:29 -0500 Subject: [PATCH] add md5 sum check for Voro++ download via Install.py --- lib/voronoi/Install.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/voronoi/Install.py b/lib/voronoi/Install.py index 38f051d6b5..2312d22ea4 100644 --- a/lib/voronoi/Install.py +++ b/lib/voronoi/Install.py @@ -6,7 +6,7 @@ from __future__ import print_function import sys,os,re,subprocess,shutil sys.path.append('..') -from install_helpers import get_cpus,fullpath,geturl +from install_helpers import get_cpus,fullpath,geturl,checkmd5sum from argparse import ArgumentParser parser = ArgumentParser(prog='Install.py', @@ -17,6 +17,11 @@ parser = ArgumentParser(prog='Install.py', version = "voro++-0.4.6" url = "http://math.lbl.gov/voro++/download/dir/%s.tar.gz" % version +# known checksums for different Voro++ versions. used to validate the download. +checksums = { \ + 'voro++-0.4.6' : '2338b824c3b7b25590e18e8df5d68af9' \ + } + # extra help message help = """ @@ -69,6 +74,11 @@ if buildflag: print("Downloading Voro++ ...") geturl(url,"%s/%s.tar.gz" % (homepath,version)) + # verify downloaded archive integrity via md5 checksum, if known. + if version in checksums: + if not checkmd5sum(checksums[version],'%s/%s.tar.gz' % (homepath,version)): + sys.exit("Checksum for Voro++ library does not match") + print("Unpacking Voro++ tarball ...") if os.path.exists("%s/%s" % (homepath,version)): shutil.rmtree("%s/%s" % (homepath,version))