diff --git a/lib/spack/spack/cmd/mirror.py b/lib/spack/spack/cmd/mirror.py index e97a4ddefa7..b641f0b052d 100644 --- a/lib/spack/spack/cmd/mirror.py +++ b/lib/spack/spack/cmd/mirror.py @@ -134,6 +134,15 @@ def setup_parser(subparser): default=None, dest="signed", ) + add_parser.add_argument( + "--include-file", + help="specs which Spack should always try to add to a mirror" + " (listed in a file, one per line)", + ) + add_parser.add_argument( + "--include-specs", + help="specs which Spack should always try to add to a mirror (specified on command line)", + ) add_parser.add_argument( "--exclude-file", help="specs which Spack should not try to add to a mirror" @@ -378,6 +387,15 @@ def mirror_add(args): else: mirror = spack.mirrors.mirror.Mirror(args.url, name=args.name) + include_specs = [] + if args.include_file: + include_specs.extend(specs_from_text_file(args.include_file, concretize=False)) + if args.include_specs: + include_specs.extend(spack.cmd.parse_specs(str(args.include_specs).split())) + if include_specs: + # round trip specs to assure they are valid + mirror.update({"include": [str(s) for s in include_specs]}) + exclude_specs = [] if args.exclude_file: exclude_specs.extend(specs_from_text_file(args.exclude_file, concretize=False)) diff --git a/share/spack/spack-completion.bash b/share/spack/spack-completion.bash index e6dd1634086..fee89c84a64 100644 --- a/share/spack/spack-completion.bash +++ b/share/spack/spack-completion.bash @@ -1459,7 +1459,7 @@ _spack_mirror_destroy() { _spack_mirror_add() { if $list_options then - SPACK_COMPREPLY="-h --help --scope --type --autopush --unsigned --signed --exclude-file --exclude-specs --s3-access-key-id --s3-access-key-id-variable --s3-access-key-secret --s3-access-key-secret-variable --s3-access-token --s3-access-token-variable --s3-profile --s3-endpoint-url --oci-username --oci-username-variable --oci-password --oci-password-variable" + SPACK_COMPREPLY="-h --help --scope --type --autopush --unsigned --signed --include-file --include-specs --exclude-file --exclude-specs --s3-access-key-id --s3-access-key-id-variable --s3-access-key-secret --s3-access-key-secret-variable --s3-access-token --s3-access-token-variable --s3-profile --s3-endpoint-url --oci-username --oci-username-variable --oci-password --oci-password-variable" else _mirrors fi diff --git a/share/spack/spack-completion.fish b/share/spack/spack-completion.fish index c2588139bd0..210170f3a2b 100644 --- a/share/spack/spack-completion.fish +++ b/share/spack/spack-completion.fish @@ -2301,7 +2301,7 @@ complete -c spack -n '__fish_spack_using_command mirror destroy' -l mirror-url - complete -c spack -n '__fish_spack_using_command mirror destroy' -l mirror-url -r -d 'find mirror to destroy by url' # spack mirror add -set -g __fish_spack_optspecs_spack_mirror_add h/help scope= type= autopush unsigned signed exclude-file= exclude-specs= s3-access-key-id= s3-access-key-id-variable= s3-access-key-secret= s3-access-key-secret-variable= s3-access-token= s3-access-token-variable= s3-profile= s3-endpoint-url= oci-username= oci-username-variable= oci-password= oci-password-variable= +set -g __fish_spack_optspecs_spack_mirror_add h/help scope= type= autopush unsigned signed include-file= include-specs= exclude-file= exclude-specs= s3-access-key-id= s3-access-key-id-variable= s3-access-key-secret= s3-access-key-secret-variable= s3-access-token= s3-access-token-variable= s3-profile= s3-endpoint-url= oci-username= oci-username-variable= oci-password= oci-password-variable= complete -c spack -n '__fish_spack_using_command_pos 0 mirror add' -f complete -c spack -n '__fish_spack_using_command mirror add' -s h -l help -f -a help complete -c spack -n '__fish_spack_using_command mirror add' -s h -l help -d 'show this help message and exit' @@ -2315,6 +2315,10 @@ complete -c spack -n '__fish_spack_using_command mirror add' -l unsigned -f -a s complete -c spack -n '__fish_spack_using_command mirror add' -l unsigned -d 'do not require signing and signature verification when pushing and installing from this build cache' complete -c spack -n '__fish_spack_using_command mirror add' -l signed -f -a signed complete -c spack -n '__fish_spack_using_command mirror add' -l signed -d 'require signing and signature verification when pushing and installing from this build cache' +complete -c spack -n '__fish_spack_using_command mirror add' -l include-file -r -f -a include_file +complete -c spack -n '__fish_spack_using_command mirror add' -l include-file -r -d 'specs which Spack should always try to add to a mirror (listed in a file, one per line)' +complete -c spack -n '__fish_spack_using_command mirror add' -l include-specs -r -f -a include_specs +complete -c spack -n '__fish_spack_using_command mirror add' -l include-specs -r -d 'specs which Spack should always try to add to a mirror (specified on command line)' complete -c spack -n '__fish_spack_using_command mirror add' -l exclude-file -r -f -a exclude_file complete -c spack -n '__fish_spack_using_command mirror add' -l exclude-file -r -d 'specs which Spack should not try to add to a mirror (listed in a file, one per line)' complete -c spack -n '__fish_spack_using_command mirror add' -l exclude-specs -r -f -a exclude_specs