diff --git a/lib/spack/spack/cmd/mirror.py b/lib/spack/spack/cmd/mirror.py index 512931e11b4..62e1cdcb317 100644 --- a/lib/spack/spack/cmd/mirror.py +++ b/lib/spack/spack/cmd/mirror.py @@ -514,17 +514,18 @@ def extend_with_dependencies(specs): def concrete_specs_from_cli_or_file(args): - tty.msg("Concretizing input specs") if args.specs: - specs = spack.cmd.parse_specs(args.specs, concretize=True) + specs = spack.cmd.parse_specs(args.specs, concretize=False) if not specs: raise SpackError("unable to parse specs from command line") if args.file: - specs = specs_from_text_file(args.file, concretize=True) + specs = specs_from_text_file(args.file, concretize=False) if not specs: raise SpackError("unable to parse specs from file '{}'".format(args.file)) - return specs + + concrete_specs = spack.cmd.matching_specs_from_env(specs) + return concrete_specs class IncludeFilter: @@ -607,11 +608,6 @@ def process_mirror_stats(present, mirrored, error): def mirror_create(args): """create a directory to be used as a spack mirror, and fill it with package archives""" - if args.specs and args.all: - raise SpackError( - "cannot specify specs on command line if you chose to mirror all specs with '--all'" - ) - if args.file and args.all: raise SpackError( "cannot specify specs with a file if you chose to mirror all specs with '--all'" diff --git a/lib/spack/spack/test/cmd/mirror.py b/lib/spack/spack/test/cmd/mirror.py index cd1fe699986..a5fe982abe6 100644 --- a/lib/spack/spack/test/cmd/mirror.py +++ b/lib/spack/spack/test/cmd/mirror.py @@ -61,6 +61,26 @@ def test_mirror_from_env(mutable_mock_env_path, tmp_path, mock_packages, mock_fe assert mirror_res == expected +# Test for command line-specified spec in concretized environment +def test_mirror_spec_from_env(mutable_mock_env_path, tmp_path, mock_packages, mock_fetch): + mirror_dir = str(tmp_path / "mirror-B") + env_name = "test" + + env("create", env_name) + with ev.read(env_name): + add("simple-standalone-test@0.9") + concretize() + with spack.config.override("config:checksum", False): + mirror("create", "-d", mirror_dir, "simple-standalone-test") + + e = ev.read(env_name) + assert set(os.listdir(mirror_dir)) == set([s.name for s in e.user_specs]) + spec = e.concrete_roots()[0] + mirror_res = os.listdir(os.path.join(mirror_dir, spec.name)) + expected = ["%s.tar.gz" % spec.format("{name}-{version}")] + assert mirror_res == expected + + @pytest.fixture def source_for_pkg_with_hash(mock_packages, tmpdir): s = spack.concretize.concretize_one("trivial-pkg-with-valid-hash") @@ -401,8 +421,7 @@ def test_all_specs_with_all_versions_dont_concretize(self): @pytest.mark.parametrize( "cli_args,error_str", [ - # Passed more than one among -f --all and specs - ({"specs": "hdf5", "file": None, "all": True}, "cannot specify specs on command line"), + # Passed more than one among -f --all ( {"specs": None, "file": "input.txt", "all": True}, "cannot specify specs with a file if",