init: replace global spack.do_checksum with config option

This commit is contained in:
Todd Gamblin 2018-04-15 19:06:53 -07:00 committed by scheibelp
parent 73ab0e5dd7
commit 77bd2dd706
13 changed files with 64 additions and 68 deletions

View File

@ -50,11 +50,6 @@
template_dirs = [canonicalize_path(x) for x in template_dirs] template_dirs = [canonicalize_path(x) for x in template_dirs]
#: Whether spack should allow installation of unsafe versions of software.
#: "Unsafe" versions are ones it doesn't have a checksum for.
do_checksum = spack.config.get('config:checksum', True)
# If this is True, spack will not clean the environment to remove # If this is True, spack will not clean the environment to remove
# potentially harmful variables before builds. # potentially harmful variables before builds.
dirty = spack.config.get('config:dirty', False) dirty = spack.config.get('config:dirty', False)

View File

@ -42,9 +42,7 @@ def setup_parser(subparser):
subparser.add_argument( subparser.add_argument(
'--keep-stage', action='store_true', dest='keep_stage', '--keep-stage', action='store_true', dest='keep_stage',
help="don't remove the build stage if installation succeeds") help="don't remove the build stage if installation succeeds")
subparser.add_argument( arguments.add_common_arguments(subparser, ['no_checksum'])
'-n', '--no-checksum', action='store_true', dest='no_checksum',
help="do not check packages against checksum")
subparser.add_argument( subparser.add_argument(
'-v', '--verbose', action='store_true', dest='verbose', '-v', '--verbose', action='store_true', dest='verbose',
help="display verbose build output while installing") help="display verbose build output while installing")

View File

@ -123,16 +123,14 @@ def __call__(self, parser, namespace, values, option_string=None):
dest='dirty', dest='dirty',
help='sanitize the environment from variables that can affect how ' + help='sanitize the environment from variables that can affect how ' +
' packages find libraries or headers', ' packages find libraries or headers',
nargs=0 nargs=0)
)
_arguments['dirty'] = Args( _arguments['dirty'] = Args(
'--dirty', '--dirty',
action=CleanOrDirtyAction, action=CleanOrDirtyAction,
dest='dirty', dest='dirty',
help='maintain the current environment without trying to sanitize it', help='maintain the current environment without trying to sanitize it',
nargs=0 nargs=0)
)
_arguments['long'] = Args( _arguments['long'] = Args(
'-l', '--long', action='store_true', '-l', '--long', action='store_true',
@ -149,3 +147,7 @@ def __call__(self, parser, namespace, values, option_string=None):
_arguments['tags'] = Args( _arguments['tags'] = Args(
'-t', '--tags', action='append', '-t', '--tags', action='append',
help='filter a package query by tags') help='filter a package query by tags')
_arguments['no_checksum'] = Args(
'-n', '--no-checksum', action='store_true', default=False,
help="do not use checksums to verify downloadeded files (unsafe)")

View File

@ -29,6 +29,7 @@
import llnl.util.tty as tty import llnl.util.tty as tty
import spack import spack
import spack.config
import spack.cmd import spack.cmd
import spack.cmd.common.arguments as arguments import spack.cmd.common.arguments as arguments
from spack.stage import DIYStage from spack.stage import DIYStage
@ -46,6 +47,7 @@ def setup_parser(subparser):
subparser.add_argument( subparser.add_argument(
'-i', '--ignore-dependencies', action='store_true', dest='ignore_deps', '-i', '--ignore-dependencies', action='store_true', dest='ignore_deps',
help="don't try to install dependencies of requested packages") help="don't try to install dependencies of requested packages")
arguments.add_common_arguments(subparser, ['no_checksum'])
subparser.add_argument( subparser.add_argument(
'--keep-prefix', action='store_true', '--keep-prefix', action='store_true',
help="do not remove the install prefix if installation fails") help="do not remove the install prefix if installation fails")
@ -101,8 +103,9 @@ def diy(self, args):
# Forces the build to run out of the current directory. # Forces the build to run out of the current directory.
package.stage = DIYStage(source_path) package.stage = DIYStage(source_path)
# TODO: make this an argument, not a global. # disable checksumming if requested
spack.do_checksum = False if args.no_checksum:
spack.config.set('config:checksum', False, scope='command_line')
package.do_install( package.do_install(
make_jobs=args.jobs, make_jobs=args.jobs,

View File

@ -28,6 +28,7 @@
import spack import spack
import spack.cmd import spack.cmd
import spack.cmd.common.arguments as arguments
description = "fetch archives for packages" description = "fetch archives for packages"
section = "build" section = "build"
@ -35,9 +36,7 @@
def setup_parser(subparser): def setup_parser(subparser):
subparser.add_argument( arguments.add_common_arguments(subparser, ['no_checksum'])
'-n', '--no-checksum', action='store_true', dest='no_checksum',
help="do not check packages against checksum")
subparser.add_argument( subparser.add_argument(
'-m', '--missing', action='store_true', '-m', '--missing', action='store_true',
help="fetch only missing (not yet installed) dependencies") help="fetch only missing (not yet installed) dependencies")
@ -54,7 +53,7 @@ def fetch(parser, args):
tty.die("fetch requires at least one package argument") tty.die("fetch requires at least one package argument")
if args.no_checksum: if args.no_checksum:
spack.do_checksum = False spack.config.set('config:checksum', False, scope='command_line')
specs = spack.cmd.parse_specs(args.packages, concretize=True) specs = spack.cmd.parse_specs(args.packages, concretize=True)
for spec in specs: for spec in specs:

View File

@ -77,9 +77,7 @@ def setup_parser(subparser):
subparser.add_argument( subparser.add_argument(
'--source', action='store_true', dest='install_source', '--source', action='store_true', dest='install_source',
help="install source files in prefix") help="install source files in prefix")
subparser.add_argument( arguments.add_common_arguments(subparser, ['no_checksum'])
'-n', '--no-checksum', action='store_true',
help="do not check packages against checksum")
subparser.add_argument( subparser.add_argument(
'-v', '--verbose', action='store_true', '-v', '--verbose', action='store_true',
help="display verbose build output while installing") help="display verbose build output while installing")
@ -176,7 +174,7 @@ def install(parser, args, **kwargs):
tty.die("The -j option must be a positive integer!") tty.die("The -j option must be a positive integer!")
if args.no_checksum: if args.no_checksum:
spack.do_checksum = False # TODO: remove this global. spack.config.set('config:checksum', False, scope='command_line')
# Parse cli arguments and construct a dictionary # Parse cli arguments and construct a dictionary
# that will be passed to Package.do_install API # that will be passed to Package.do_install API

View File

@ -33,6 +33,7 @@
import spack.cmd import spack.cmd
import spack.config import spack.config
import spack.mirror import spack.mirror
import spack.cmd.common.arguments as arguments
from spack.spec import Spec from spack.spec import Spec
from spack.error import SpackError from spack.error import SpackError
from spack.util.spack_yaml import syaml_dict from spack.util.spack_yaml import syaml_dict
@ -43,9 +44,7 @@
def setup_parser(subparser): def setup_parser(subparser):
subparser.add_argument( arguments.add_common_arguments(subparser, ['no_checksum'])
'-n', '--no-checksum', action='store_true', dest='no_checksum',
help="do not check fetched packages against checksum")
sp = subparser.add_subparsers( sp = subparser.add_subparsers(
metavar='SUBCOMMAND', dest='mirror_command') metavar='SUBCOMMAND', dest='mirror_command')

View File

@ -25,8 +25,11 @@
import argparse import argparse
import llnl.util.tty as tty import llnl.util.tty as tty
import spack.cmd
import spack import spack
import spack.cmd
import spack.cmd.common.arguments as arguments
description = "patch expanded archive sources in preparation for install" description = "patch expanded archive sources in preparation for install"
@ -35,9 +38,7 @@
def setup_parser(subparser): def setup_parser(subparser):
subparser.add_argument( arguments.add_common_arguments(subparser, ['no_checksum'])
'-n', '--no-checksum', action='store_true', dest='no_checksum',
help="do not check downloaded packages against checksum")
subparser.add_argument( subparser.add_argument(
'packages', nargs=argparse.REMAINDER, 'packages', nargs=argparse.REMAINDER,
help="specs of packages to stage") help="specs of packages to stage")
@ -48,7 +49,7 @@ def patch(parser, args):
tty.die("patch requires at least one package argument") tty.die("patch requires at least one package argument")
if args.no_checksum: if args.no_checksum:
spack.do_checksum = False spack.config.set('config:checksum', False, scope='command_line')
specs = spack.cmd.parse_specs(args.packages, concretize=True) specs = spack.cmd.parse_specs(args.packages, concretize=True)
for spec in specs: for spec in specs:

View File

@ -47,6 +47,7 @@ def setup_parser(subparser):
subparser.add_argument( subparser.add_argument(
'-i', '--ignore-dependencies', action='store_true', dest='ignore_deps', '-i', '--ignore-dependencies', action='store_true', dest='ignore_deps',
help="do not try to install dependencies of requested packages") help="do not try to install dependencies of requested packages")
arguments.add_common_arguments(subparser, ['no_checksum'])
subparser.add_argument( subparser.add_argument(
'-v', '--verbose', action='store_true', dest='verbose', '-v', '--verbose', action='store_true', dest='verbose',
help="display verbose build output while installing") help="display verbose build output while installing")
@ -147,17 +148,16 @@ def setup(self, args):
if not isinstance(package, spack.CMakePackage): if not isinstance(package, spack.CMakePackage):
tty.die( tty.die(
'Support for {0} derived packages not yet implemented'.format( 'Support for {0} derived packages not yet implemented'.format(
package.build_system_class package.build_system_class))
)
)
# It's OK if the package is already installed. # It's OK if the package is already installed.
# Forces the build to run out of the current directory. # Forces the build to run out of the current directory.
package.stage = DIYStage(os.getcwd()) package.stage = DIYStage(os.getcwd())
# TODO: make this an argument, not a global. # disable checksumming if requested
spack.do_checksum = False if args.no_checksum:
spack.config.set('config:checksum', False, scope='command_line')
# Install dependencies if requested to do so # Install dependencies if requested to do so
if not args.ignore_deps: if not args.ignore_deps:
@ -169,12 +169,14 @@ def setup(self, args):
namespace=inst_args namespace=inst_args
) )
install.install(parser, inst_args) install.install(parser, inst_args)
# Generate spconfig.py # Generate spconfig.py
tty.msg( tty.msg(
'Generating spconfig.py [{0}]'.format(package.spec.cshort_spec) 'Generating spconfig.py [{0}]'.format(package.spec.cshort_spec)
) )
dirty = args.dirty dirty = args.dirty
write_spconfig(package, dirty) write_spconfig(package, dirty)
# Install this package to register it in the DB and permit # Install this package to register it in the DB and permit
# module file regeneration # module file regeneration
inst_args = copy.deepcopy(args) inst_args = copy.deepcopy(args)

View File

@ -25,8 +25,10 @@
import argparse import argparse
import llnl.util.tty as tty import llnl.util.tty as tty
import spack import spack
import spack.cmd import spack.cmd
import spack.cmd.common.arguments as arguments
description = "expand downloaded archive in preparation for install" description = "expand downloaded archive in preparation for install"
section = "build" section = "build"
@ -34,9 +36,7 @@
def setup_parser(subparser): def setup_parser(subparser):
subparser.add_argument( arguments.add_common_arguments(subparser, ['no_checksum'])
'-n', '--no-checksum', action='store_true', dest='no_checksum',
help="do not check downloaded packages against checksum")
subparser.add_argument( subparser.add_argument(
'-p', '--path', dest='path', '-p', '--path', dest='path',
help="path to stage package, does not add to spack tree") help="path to stage package, does not add to spack tree")
@ -50,7 +50,7 @@ def stage(parser, args):
tty.die("stage requires at least one package argument") tty.die("stage requires at least one package argument")
if args.no_checksum: if args.no_checksum:
spack.do_checksum = False spack.config.set('config:checksum', False, scope='command_line')
specs = spack.cmd.parse_specs(args.specs, concretize=True) specs = spack.cmd.parse_specs(args.specs, concretize=True)
for spec in specs: for spec in specs:

View File

@ -1014,7 +1014,8 @@ def do_fetch(self, mirror_only=False):
raise ValueError("Can only fetch concrete packages.") raise ValueError("Can only fetch concrete packages.")
start_time = time.time() start_time = time.time()
if spack.do_checksum and self.version not in self.versions: checksum = spack.config.get('config:checksum')
if checksum and self.version not in self.versions:
tty.warn("There is no checksum on file to fetch %s safely." % tty.warn("There is no checksum on file to fetch %s safely." %
self.spec.cformat('$_$@')) self.spec.cformat('$_$@'))
@ -1036,7 +1037,7 @@ def do_fetch(self, mirror_only=False):
self.stage.fetch(mirror_only) self.stage.fetch(mirror_only)
self._fetch_time = time.time() - start_time self._fetch_time = time.time() - start_time
if spack.do_checksum and self.version in self.versions: if checksum and self.version in self.versions:
self.stage.check() self.stage.check()
self.stage.cache_local() self.stage.cache_local()

View File

@ -28,8 +28,6 @@
import shutil import shutil
import re import re
import spack.util.ordereddict
import py import py
import pytest import pytest
@ -37,6 +35,7 @@
import spack import spack
import spack.architecture import spack.architecture
import spack.config
import spack.caches import spack.caches
import spack.database import spack.database
import spack.directory_layout import spack.directory_layout
@ -44,6 +43,7 @@
import spack.platforms.test import spack.platforms.test
import spack.repository import spack.repository
import spack.stage import spack.stage
import spack.util.ordereddict
import spack.util.executable import spack.util.executable
import spack.util.pattern import spack.util.pattern
from spack.dependency import Dependency from spack.dependency import Dependency
@ -380,11 +380,10 @@ def install_mockery(tmpdir, config, builtin_mock):
new_opt, spack.store.layout) new_opt, spack.store.layout)
spack.store.db = spack.database.Database(new_opt) spack.store.db = spack.database.Database(new_opt)
# We use a fake package, so skip the checksum. # We use a fake package, so temporarily disable checksumming
spack.do_checksum = False with spack.config.override('config:checksum', False):
yield yield
# Turn checksumming back on
spack.do_checksum = True
# Restore Spack's layout. # Restore Spack's layout.
spack.store.layout = layout spack.store.layout = layout
spack.store.extensions = extensions spack.store.extensions = extensions

View File

@ -88,29 +88,28 @@ def check_mirror():
spec = Spec(name).concretized() spec = Spec(name).concretized()
pkg = spec.package pkg = spec.package
saved_checksum_setting = spack.do_checksum with spack.config.override('config:checksum', False):
with pkg.stage: with pkg.stage:
# Stage the archive from the mirror and cd to it. pkg.do_stage(mirror_only=True)
spack.do_checksum = False
pkg.do_stage(mirror_only=True)
# Compare the original repo with the expanded archive # Compare the original repo with the expanded archive
original_path = mock_repo.path original_path = mock_repo.path
if 'svn' in name: if 'svn' in name:
# have to check out the svn repo to compare. # have to check out the svn repo to compare.
original_path = join_path( original_path = join_path(
mock_repo.path, 'checked_out') mock_repo.path, 'checked_out')
svn = which('svn', required=True) svn = which('svn', required=True)
svn('checkout', mock_repo.url, original_path) svn('checkout', mock_repo.url, original_path)
dcmp = filecmp.dircmp(original_path, pkg.stage.source_path) dcmp = filecmp.dircmp(
# make sure there are no new files in the expanded original_path, pkg.stage.source_path)
# tarball
assert not dcmp.right_only # make sure there are no new files in the expanded
# and that all original files are present. # tarball
assert all(l in exclude for l in dcmp.left_only) assert not dcmp.right_only
spack.do_checksum = saved_checksum_setting # and that all original files are present.
assert all(l in exclude for l in dcmp.left_only)
@pytest.mark.usefixtures('config', 'refresh_builtin_mock') @pytest.mark.usefixtures('config', 'refresh_builtin_mock')