@@ -276,11 +276,17 @@ def build_cache_mirror(self) -> Optional[str]:
276276 def push_to_build_cache (self ) -> Optional [str ]:
277277 """The build cache mirror name to push built packages to, or None.
278278
279- Pushing requires a private signing key; a build cache configured without one
280- is read-only - fetched from but never pushed to.
279+ Pushing requires a private signing key or an access pair for an S3 bucket;
280+ a build cache configured without one is read-only - fetched from but never pushed to.
281281 """
282282
283- if self .buildcache is not None and self .buildcache ["private_key" ] is not None :
283+ if (
284+ self .buildcache is not None
285+ and (
286+ self .buildcache .get ("private_key" ) is not None
287+ or self .buildcache .get ("access_pair" ) is not None
288+ )
289+ ):
284290 return self .buildcache ["name" ]
285291 return None
286292
@@ -403,20 +409,51 @@ def config_files(self, config_root: pathlib.Path) -> Dict[pathlib.Path, bytes]:
403409 # point needs its own cache to avoid relocation issues.
404410 if self .buildcache ["mount_specific" ]:
405411 url = url .rstrip ("/" ) + "/" + self ._mount_path .as_posix ().lstrip ("/" )
406- entry = {"fetch" : {"url" : url }}
407- # only a build cache with a signing key is pushed to
408- if self .buildcache ["private_key" ] is not None :
409- entry ["push" ] = {"url" : url }
410- spack_mirrors ["mirrors" ][self .buildcache ["name" ]] = entry
411-
412- # source mirrors are read-only and provide sources only: fetch url, no push.
413- for name , mirror in self .source_mirrors .items ():
414- spack_mirrors ["mirrors" ][name ] = {
415- "source" : True ,
416- "binary" : False ,
412+ if self .buildcache ["access_pair" ] and self .buildcache ["endpoint_url" ]:
413+ spack_mirrors ["mirrors" ][self .buildcache ["name" ]] = {
414+ "fetch" : {
415+ "url" : mirror ["url" ],
416+ "access_pair" : mirror ["access_pair" ],
417+ "endpoint_url" : mirror ["url" ]
418+ },
419+ "push" : {
420+ "url" : mirror ["url" ],
421+ "access_pair" : mirror ["access_pair" ],
422+ "endpoint_url" : mirror ["url" ]
423+ },
424+ }
425+ else :
426+ spack_mirrors ["mirrors" ][self .buildcache ["name" ]] = {
417427 "fetch" : {"url" : mirror ["url" ]},
428+ "push" : {"url" : mirror ["url" ]},
418429 }
419430
431+
432+ # source mirrors are read-only and provide sources only. Push url is required but never used
433+ for name , mirror in self .source_mirrors .items ():
434+ if mirror ["access_pair" ] and mirror ["endpoint_url" ]:
435+ spack_mirrors ["mirrors" ][name ] = {
436+ "source" : True ,
437+ "binary" : False ,
438+ "fetch" : {
439+ "url" : mirror ["url" ],
440+ "access_pair" : mirror ["access_pair" ],
441+ "endpoint_url" : mirror ["url" ]
442+ },
443+ "push" : {
444+ "url" : mirror ["url" ],
445+ "access_pair" : mirror ["access_pair" ],
446+ "endpoint_url" : mirror ["url" ]
447+ },
448+ }
449+ else :
450+ spack_mirrors ["mirrors" ][name ] = {
451+ "source" : True ,
452+ "binary" : False ,
453+ "fetch" : {"url" : mirror ["url" ]},
454+ "push" : {"url" : mirror ["url" ]},
455+ }
456+
420457 files [config_root / self .MIRRORS_YAML ] = yaml .dump (
421458 spack_mirrors , default_flow_style = False , sort_keys = False
422459 ).encode ()
0 commit comments