Skip to content

Commit c60fc53

Browse files
committed
refactor mirror configuration
- resolve and validate all mirror inputs (urls, gpg keys) in Mirrors.__init__ - builder writes mirror artifacts instead of computing them - store buildcache, bootstrap and source_caches as separate members - decode gpg keys to in-memory bytes; expose config_files()/gpg_key_paths() - fix always-true magic gpg key check; reject non-key data - fix build cache mirror name mismatch in cache-force and --cache pushes - keep file:// urls as strings
1 parent cfa74e2 commit c60fc53

7 files changed

Lines changed: 320 additions & 330 deletions

File tree

docs/cluster-config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ On air-gapped systems, Spack is unable to reach its default mirror to fetch pack
101101

102102
`mirrors.yaml` may include source mirrors, bootstrap mirrors, and buildcaches. Any number of source mirrors can be added, but only one bootstrap mirror and buildcache can be specified. Spack will search the source mirrors in order from first to last, and will append the default Spack mirror to the bottom of the list when the Spack mirror config is generated.
103103

104-
If using a buildcache, a private key must be provided for signing packages. An optional public key may be specified with any type of mirror to verify packages.
104+
If using a buildcache, a private key must be provided for signing packages. An optional public key may be specified with any type of mirror to verify packages. The buildcache is registered with Spack under the name `buildcache`, which can be overridden with an optional `name` field.
105105

106106
To stop using a mirror, remove (or comment out) its entry from `mirrors.yaml`.
107107

stackinator/builder.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import jinja2
1212
import yaml
1313

14-
from . import VERSION, root_logger, spack_util, mirror
14+
from . import VERSION, root_logger, spack_util
1515

1616

1717
def install(src, dst, *, ignore=None, symlinks=False):
@@ -224,6 +224,15 @@ def generate(self, recipe):
224224
lstrip_blocks=True,
225225
)
226226

227+
# Write the spack mirror config artifacts (mirrors.yaml, bootstrap config,
228+
# and the relocated gpg keys) into the config scope. These were fully
229+
# resolved and validated by the recipe, so we just write the bytes. This
230+
# must precede the Makefile render, which references the gpg key paths.
231+
self._logger.debug(f"Writing the spack mirror configs to '{config_path}'")
232+
for dest, content in recipe.mirrors.config_files(config_path).items():
233+
dest.parent.mkdir(parents=True, exist_ok=True)
234+
dest.write_bytes(content)
235+
227236
# generate top level makefiles
228237
makefile_template = jinja_env.get_template("Makefile")
229238

@@ -235,7 +244,7 @@ def generate(self, recipe):
235244
pre_install_hook=recipe.pre_install_hook,
236245
spack_version=spack_version,
237246
spack_meta=spack_meta,
238-
gpg_keys=recipe.mirrors.keys,
247+
gpg_keys=recipe.mirrors.gpg_key_paths(config_path),
239248
cache=recipe.build_cache_mirror,
240249
exclude_from_cache=["nvhpc", "cuda", "perl"],
241250
verbose=False,
@@ -314,14 +323,6 @@ def generate(self, recipe):
314323
with global_packages_path.open("w") as fid:
315324
fid.write(global_packages_yaml)
316325

317-
# generate a mirrors.yaml file if build caches have been configured
318-
self._logger.debug(f"Generating the spack mirror configs in '{config_path}'")
319-
try:
320-
recipe.mirrors.setup_configs(config_path)
321-
except mirror.MirrorError as err:
322-
self._logger.error(f"Could not set up mirrors.\n{err}")
323-
return 1
324-
325326
# Add custom spack package recipes, configured via Spack repos.
326327
# Step 1: copy Spack repos to store_path where they will be used to
327328
# build the stack, and then be part of the upstream provided

0 commit comments

Comments
 (0)