add md5 sum check for Voro++ download via Install.py

This commit is contained in:
Axel Kohlmeyer 2019-01-14 15:03:29 -05:00
parent 4eb141391b
commit 718428df68
1 changed files with 11 additions and 1 deletions

View File

@ -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))