Merge branch 'develop' of https://github.com/LLNL/spack into packages/petsc
This commit is contained in:
commit
24fe8699ea
@ -177,8 +177,6 @@ def set_module_variables_for_package(pkg, m):
|
|||||||
"""Populate the module scope of install() with some useful functions.
|
"""Populate the module scope of install() with some useful functions.
|
||||||
This makes things easier for package writers.
|
This makes things easier for package writers.
|
||||||
"""
|
"""
|
||||||
m = pkg.module
|
|
||||||
|
|
||||||
# number of jobs spack will to build with.
|
# number of jobs spack will to build with.
|
||||||
jobs = multiprocessing.cpu_count()
|
jobs = multiprocessing.cpu_count()
|
||||||
if not pkg.parallel:
|
if not pkg.parallel:
|
||||||
|
@ -22,16 +22,10 @@
|
|||||||
# along with this program; if not, write to the Free Software Foundation,
|
# along with this program; if not, write to the Free Software Foundation,
|
||||||
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
##############################################################################
|
##############################################################################
|
||||||
import os
|
|
||||||
import re
|
|
||||||
import argparse
|
import argparse
|
||||||
import hashlib
|
import hashlib
|
||||||
from pprint import pprint
|
|
||||||
from subprocess import CalledProcessError
|
|
||||||
|
|
||||||
import llnl.util.tty as tty
|
import llnl.util.tty as tty
|
||||||
from llnl.util.tty.colify import colify
|
|
||||||
|
|
||||||
import spack
|
import spack
|
||||||
import spack.cmd
|
import spack.cmd
|
||||||
import spack.util.crypto
|
import spack.util.crypto
|
||||||
@ -40,6 +34,7 @@
|
|||||||
|
|
||||||
description = "Checksum available versions of a package."
|
description = "Checksum available versions of a package."
|
||||||
|
|
||||||
|
|
||||||
def setup_parser(subparser):
|
def setup_parser(subparser):
|
||||||
subparser.add_argument(
|
subparser.add_argument(
|
||||||
'package', metavar='PACKAGE', help='Package to list versions for')
|
'package', metavar='PACKAGE', help='Package to list versions for')
|
||||||
@ -60,30 +55,23 @@ def get_checksums(versions, urls, **kwargs):
|
|||||||
hashes = []
|
hashes = []
|
||||||
i = 0
|
i = 0
|
||||||
for url, version in zip(urls, versions):
|
for url, version in zip(urls, versions):
|
||||||
stage = Stage(url)
|
|
||||||
try:
|
try:
|
||||||
|
with Stage(url, keep=keep_stage) as stage:
|
||||||
stage.fetch()
|
stage.fetch()
|
||||||
if i == 0 and first_stage_function:
|
if i == 0 and first_stage_function:
|
||||||
first_stage_function(stage)
|
first_stage_function(stage)
|
||||||
|
|
||||||
hashes.append((version,
|
hashes.append((version,
|
||||||
spack.util.crypto.checksum(hashlib.md5, stage.archive_file)))
|
spack.util.crypto.checksum(hashlib.md5, stage.archive_file)))
|
||||||
except FailedDownloadError, e:
|
|
||||||
tty.msg("Failed to fetch %s" % url)
|
|
||||||
continue
|
|
||||||
except Exception, e:
|
|
||||||
tty.msg('Something failed on %s, skipping.\n (%s)' % (url, e))
|
|
||||||
continue
|
|
||||||
|
|
||||||
finally:
|
|
||||||
if not keep_stage:
|
|
||||||
stage.destroy()
|
|
||||||
i += 1
|
i += 1
|
||||||
|
except FailedDownloadError as e:
|
||||||
|
tty.msg("Failed to fetch %s" % url)
|
||||||
|
except Exception as e:
|
||||||
|
tty.msg('Something failed on %s, skipping.\n (%s)' % (url, e))
|
||||||
|
|
||||||
return hashes
|
return hashes
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def checksum(parser, args):
|
def checksum(parser, args):
|
||||||
# get the package we're going to generate checksums for
|
# get the package we're going to generate checksums for
|
||||||
pkg = spack.repo.get(args.package)
|
pkg = spack.repo.get(args.package)
|
||||||
|
@ -45,6 +45,9 @@ def setup_parser(subparser):
|
|||||||
subparser.add_argument(
|
subparser.add_argument(
|
||||||
'--skip-patch', action='store_true',
|
'--skip-patch', action='store_true',
|
||||||
help="Skip patching for the DIY build.")
|
help="Skip patching for the DIY build.")
|
||||||
|
subparser.add_argument(
|
||||||
|
'-q', '--quiet', action='store_true', dest='quiet',
|
||||||
|
help="Do not display verbose build output while installing.")
|
||||||
subparser.add_argument(
|
subparser.add_argument(
|
||||||
'spec', nargs=argparse.REMAINDER,
|
'spec', nargs=argparse.REMAINDER,
|
||||||
help="specs to use for install. Must contain package AND verison.")
|
help="specs to use for install. Must contain package AND verison.")
|
||||||
@ -92,4 +95,5 @@ def diy(self, args):
|
|||||||
package.do_install(
|
package.do_install(
|
||||||
keep_prefix=args.keep_prefix,
|
keep_prefix=args.keep_prefix,
|
||||||
ignore_deps=args.ignore_deps,
|
ignore_deps=args.ignore_deps,
|
||||||
|
verbose=not args.quiet,
|
||||||
keep_stage=True) # don't remove source dir for DIY.
|
keep_stage=True) # don't remove source dir for DIY.
|
||||||
|
@ -22,51 +22,51 @@
|
|||||||
# along with this program; if not, write to the Free Software Foundation,
|
# along with this program; if not, write to the Free Software Foundation,
|
||||||
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
##############################################################################
|
##############################################################################
|
||||||
import os
|
|
||||||
import argparse
|
import argparse
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import os
|
||||||
from contextlib import contextmanager
|
|
||||||
|
|
||||||
import llnl.util.tty as tty
|
import llnl.util.tty as tty
|
||||||
from llnl.util.filesystem import *
|
|
||||||
|
|
||||||
import spack.util.crypto
|
import spack.util.crypto
|
||||||
from spack.stage import Stage, FailedDownloadError
|
from spack.stage import Stage, FailedDownloadError
|
||||||
|
|
||||||
description = "Calculate md5 checksums for files/urls."
|
description = "Calculate md5 checksums for files/urls."
|
||||||
|
|
||||||
@contextmanager
|
|
||||||
def stager(url):
|
|
||||||
_cwd = os.getcwd()
|
|
||||||
_stager = Stage(url)
|
|
||||||
try:
|
|
||||||
_stager.fetch()
|
|
||||||
yield _stager
|
|
||||||
except FailedDownloadError:
|
|
||||||
tty.msg("Failed to fetch %s" % url)
|
|
||||||
finally:
|
|
||||||
_stager.destroy()
|
|
||||||
os.chdir(_cwd) # the Stage class changes the current working dir so it has to be restored
|
|
||||||
|
|
||||||
def setup_parser(subparser):
|
def setup_parser(subparser):
|
||||||
setup_parser.parser = subparser
|
setup_parser.parser = subparser
|
||||||
subparser.add_argument('files', nargs=argparse.REMAINDER,
|
subparser.add_argument('files', nargs=argparse.REMAINDER,
|
||||||
help="Files to checksum.")
|
help="Files to checksum.")
|
||||||
|
|
||||||
|
|
||||||
|
def compute_md5_checksum(url):
|
||||||
|
if not os.path.isfile(url):
|
||||||
|
with Stage(url) as stage:
|
||||||
|
stage.fetch()
|
||||||
|
value = spack.util.crypto.checksum(hashlib.md5, stage.archive_file)
|
||||||
|
else:
|
||||||
|
value = spack.util.crypto.checksum(hashlib.md5, url)
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
def md5(parser, args):
|
def md5(parser, args):
|
||||||
if not args.files:
|
if not args.files:
|
||||||
setup_parser.parser.print_help()
|
setup_parser.parser.print_help()
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
for f in args.files:
|
results = []
|
||||||
if not os.path.isfile(f):
|
for url in args.files:
|
||||||
with stager(f) as stage:
|
try:
|
||||||
checksum = spack.util.crypto.checksum(hashlib.md5, stage.archive_file)
|
checksum = compute_md5_checksum(url)
|
||||||
print "%s %s" % (checksum, f)
|
results.append((checksum, url))
|
||||||
else:
|
except FailedDownloadError as e:
|
||||||
if not can_access(f):
|
tty.warn("Failed to fetch %s" % url)
|
||||||
tty.die("Cannot read file: %s" % f)
|
tty.warn("%s" % e)
|
||||||
|
except IOError as e:
|
||||||
|
tty.warn("Error when reading %s" % url)
|
||||||
|
tty.warn("%s" % e)
|
||||||
|
|
||||||
checksum = spack.util.crypto.checksum(hashlib.md5, f)
|
# Dump the MD5s at last without interleaving them with downloads
|
||||||
print "%s %s" % (checksum, f)
|
tty.msg("%d MD5 checksums:" % len(results))
|
||||||
|
for checksum, url in results:
|
||||||
|
print "%s %s" % (checksum, url)
|
||||||
|
@ -441,6 +441,7 @@ def __enter__(self):
|
|||||||
|
|
||||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||||
for item in reversed(self):
|
for item in reversed(self):
|
||||||
|
item.keep = getattr(self, 'keep', None)
|
||||||
item.__exit__(exc_type, exc_val, exc_tb)
|
item.__exit__(exc_type, exc_val, exc_tb)
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -476,10 +477,14 @@ def chdir(self):
|
|||||||
else:
|
else:
|
||||||
raise ChdirError("Setup failed: no such directory: " + self.path)
|
raise ChdirError("Setup failed: no such directory: " + self.path)
|
||||||
|
|
||||||
|
# DIY stages do nothing as context managers.
|
||||||
|
def __enter__(self): pass
|
||||||
|
def __exit__(self, exc_type, exc_val, exc_tb): pass
|
||||||
|
|
||||||
def chdir_to_source(self):
|
def chdir_to_source(self):
|
||||||
self.chdir()
|
self.chdir()
|
||||||
|
|
||||||
def fetch(self):
|
def fetch(self, mirror_only):
|
||||||
tty.msg("No need to fetch for DIY.")
|
tty.msg("No need to fetch for DIY.")
|
||||||
|
|
||||||
def check(self):
|
def check(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user