add md5 sum check for Voro++ download via Install.py
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import sys,os,re,subprocess,shutil
|
import sys,os,re,subprocess,shutil
|
||||||
sys.path.append('..')
|
sys.path.append('..')
|
||||||
from install_helpers import get_cpus,fullpath,geturl
|
from install_helpers import get_cpus,fullpath,geturl,checkmd5sum
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
|
|
||||||
parser = ArgumentParser(prog='Install.py',
|
parser = ArgumentParser(prog='Install.py',
|
||||||
@ -17,6 +17,11 @@ parser = ArgumentParser(prog='Install.py',
|
|||||||
version = "voro++-0.4.6"
|
version = "voro++-0.4.6"
|
||||||
url = "http://math.lbl.gov/voro++/download/dir/%s.tar.gz" % version
|
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
|
# extra help message
|
||||||
|
|
||||||
help = """
|
help = """
|
||||||
@ -69,6 +74,11 @@ if buildflag:
|
|||||||
print("Downloading Voro++ ...")
|
print("Downloading Voro++ ...")
|
||||||
geturl(url,"%s/%s.tar.gz" % (homepath,version))
|
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 ...")
|
print("Unpacking Voro++ tarball ...")
|
||||||
if os.path.exists("%s/%s" % (homepath,version)):
|
if os.path.exists("%s/%s" % (homepath,version)):
|
||||||
shutil.rmtree("%s/%s" % (homepath,version))
|
shutil.rmtree("%s/%s" % (homepath,version))
|
||||||
|
|||||||
Reference in New Issue
Block a user