summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/cmd/checksum.py9
-rw-r--r--lib/spack/spack/cmd/create.py2
-rw-r--r--lib/spack/spack/stage.py11
-rwxr-xr-xshare/spack/spack-completion.bash2
4 files changed, 19 insertions, 5 deletions
diff --git a/lib/spack/spack/cmd/checksum.py b/lib/spack/spack/cmd/checksum.py
index eaeaf5337f..97e7833af0 100644
--- a/lib/spack/spack/cmd/checksum.py
+++ b/lib/spack/spack/cmd/checksum.py
@@ -26,6 +26,9 @@ def setup_parser(subparser):
subparser.add_argument(
'--keep-stage', action='store_true',
help="don't clean up staging area when command completes")
+ subparser.add_argument(
+ '-b', '--batch', action='store_true',
+ help="don't ask which versions to checksum")
arguments.add_common_arguments(subparser, ['package'])
subparser.add_argument(
'versions', nargs=argparse.REMAINDER,
@@ -33,6 +36,11 @@ def setup_parser(subparser):
def checksum(parser, args):
+ # Did the user pass 'package@version' string?
+ if len(args.versions) == 0 and '@' in args.package:
+ args.versions = [args.package.split('@')[1]]
+ args.package = args.package.split('@')[0]
+
# Make sure the user provided a package and not a URL
if not valid_fully_qualified_module_name(args.package):
tty.die("`spack checksum` accepts package names, not URLs.")
@@ -57,6 +65,7 @@ def checksum(parser, args):
version_lines = spack.stage.get_checksums_for_versions(
url_dict, pkg.name, keep_stage=args.keep_stage,
+ batch=(args.batch or len(args.versions) > 0),
fetch_options=pkg.fetch_options)
print()
diff --git a/lib/spack/spack/cmd/create.py b/lib/spack/spack/cmd/create.py
index 304b531b49..7d12dc98a7 100644
--- a/lib/spack/spack/cmd/create.py
+++ b/lib/spack/spack/cmd/create.py
@@ -629,7 +629,7 @@ def get_versions(args, name):
versions = spack.stage.get_checksums_for_versions(
url_dict, name, first_stage_function=guesser,
- keep_stage=args.keep_stage)
+ keep_stage=args.keep_stage, batch=True)
else:
versions = unhashed_versions
diff --git a/lib/spack/spack/stage.py b/lib/spack/spack/stage.py
index 54d370a50d..5cac9e32a1 100644
--- a/lib/spack/spack/stage.py
+++ b/lib/spack/spack/stage.py
@@ -753,7 +753,7 @@ def purge():
def get_checksums_for_versions(
url_dict, name, first_stage_function=None, keep_stage=False,
- fetch_options=None):
+ fetch_options=None, batch=False):
"""Fetches and checksums archives from URLs.
This function is called by both ``spack checksum`` and ``spack
@@ -767,6 +767,8 @@ def get_checksums_for_versions(
first_stage_function (callable): function that takes a Stage and a URL;
this is run on the stage of the first URL downloaded
keep_stage (bool): whether to keep staging area when command completes
+ batch (bool): whether to ask user how many versions to fetch (false)
+ or fetch all versions (true)
fetch_options (dict): Options used for the fetcher (such as timeout
or cookies)
@@ -788,8 +790,11 @@ def get_checksums_for_versions(
for v in sorted_versions]))
print()
- archives_to_fetch = tty.get_number(
- "How many would you like to checksum?", default=1, abort='q')
+ if batch:
+ archives_to_fetch = len(sorted_versions)
+ else:
+ archives_to_fetch = tty.get_number(
+ "How many would you like to checksum?", default=1, abort='q')
if not archives_to_fetch:
tty.die("Aborted.")
diff --git a/share/spack/spack-completion.bash b/share/spack/spack-completion.bash
index 12d4c599b8..4b730499d2 100755
--- a/share/spack/spack-completion.bash
+++ b/share/spack/spack-completion.bash
@@ -455,7 +455,7 @@ _spack_cd() {
_spack_checksum() {
if $list_options
then
- SPACK_COMPREPLY="-h --help --keep-stage"
+ SPACK_COMPREPLY="-h --help --keep-stage -b --batch"
else
_all_packages
fi