Skip to content

Commit b9fe48e

Browse files
committed
connecting mirrors to builder.py
1 parent 9ef113d commit b9fe48e

File tree

4 files changed

+17
-19
lines changed

4 files changed

+17
-19
lines changed

stackinator/builder.py

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

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

1616

1717
def install(src, dst, *, ignore=None, symlinks=False):
@@ -231,7 +231,7 @@ def generate(self, recipe):
231231
pre_install_hook=recipe.pre_install_hook,
232232
spack_version=spack_version,
233233
spack_meta=spack_meta,
234-
mirrors=recipe.mirrors
234+
mirrors=recipe.mirrors,
235235
exclude_from_cache=["nvhpc", "cuda", "perl"],
236236
verbose=False,
237237
)
@@ -312,11 +312,12 @@ def generate(self, recipe):
312312
fid.write(global_packages_yaml)
313313

314314
# generate a mirrors.yaml file if build caches have been configured
315+
key_store = self.path / ".gnupg"
315316
if recipe.mirrors:
317+
mirror.key_setup(recipe.mirrors, config_path, key_store)
316318
dst = config_path / "mirrors.yaml"
317319
self._logger.debug(f"generate the spack mirrors.yaml: {dst}")
318-
with dst.open("w") as fid:
319-
fid.write(cache.generate_mirrors_yaml(recipe.mirrors))
320+
mirror.spack_yaml_setup(recipe.mirrors, dst)
320321

321322
# Add custom spack package recipes, configured via Spack repos.
322323
# Step 1: copy Spack repos to store_path where they will be used to

stackinator/mirror.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import pathlib
33
import urllib.request
4-
from typing import Optional
4+
from typing import Optional, List, Dict
55
import magic
66

77
import yaml
@@ -74,19 +74,18 @@ def configuration_from_file(system_config_root: pathlib.Path, cmdline_cache: Opt
7474
f"Could not reach the mirror url '{url}'. "
7575
f"Check the url listed in mirrors.yaml in system config. \n{e.reason}")
7676

77-
if mirror["bootstrap"]:
77+
#if mirror["bootstrap"]:
7878
#make bootstrap dirs
7979
#bootstrap/<mirror name>/metadata.yaml
8080

8181
return mirrors
8282

8383

84-
def yaml_setup(mirrors, config_path):
84+
def spack_yaml_setup(mirrors, config_path):
8585
"""Generate the mirrors.yaml for spack"""
8686

8787
dst = config_path / "mirrors.yaml"
8888

89-
self._logger.debug(f"generate the spack mirrors.yaml: {dst}")
9089
yaml = {"mirrors": {}}
9190

9291
for m in mirrors:
@@ -120,7 +119,7 @@ def key_setup(mirrors: List[Dict], system_config_path: pathlib.Path, key_store:
120119
if not path.is_absolute():
121120
#try prepending system config path
122121
path = system_config_path + path
123-
if not.path.is_file()
122+
if not path.is_file():
124123
raise FileNotFoundError(
125124
f"The key path '{path}' is not a file. "
126125
f"Check the key listed in mirrors.yaml in system config.")

stackinator/recipe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def __init__(self, args):
174174
# mirrors specified on the command line.
175175
self._mirrors = None
176176
self._logger.debug("Configuring mirrors.")
177-
self._mirrors = mirror.configuration_from_file(self.system_config_path/"mirrors.yaml", args.cache)
177+
self._mirrors = mirror.configuration_from_file(self.system_config_path, args.cache)
178178

179179
# optional post install hook
180180
if self.post_install_hook is not None:

stackinator/schema/mirror.json

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
1-
# This config handles source mirrors, binary caches, and bootstrap mirrors (of both forms)
21
{
3-
# Order matters, so we need an array.
42
"type" : "array",
53
"items": {
64
"type": "object",
7-
"required": ["name", "url"]
5+
"required": ["name", "url"],
86
"properties": {
97
"name": {
108
"type": "string",
11-
"description": "The name of this mirror. Should be follow standard variable naming syntax.",
9+
"description": "The name of this mirror. Should be follow standard variable naming syntax."
1210
},
1311
"url": {
1412
"type": "string",
15-
"description": "URL to the mirror. Can be a simple path, or any protocol Spack supports (https, OCI).",
13+
"description": "URL to the mirror. Can be a simple path, or any protocol Spack supports (https, OCI)."
1614
},
1715
"enabled": {
1816
"type": "boolean",
1917
"default": true,
20-
"description": "Whether this mirror is enabled.",
18+
"description": "Whether this mirror is enabled."
2119
},
2220
"bootstrap": {
2321
"type": "boolean",
2422
"default": false,
25-
"description": "Whether to use as a mirror for bootstrapping. Will also use as a regular mirror.",
23+
"description": "Whether to use as a mirror for bootstrapping. Will also use as a regular mirror."
2624
},
2725
"buildcache": {
2826
"type": "boolean",
@@ -31,12 +29,12 @@
3129
},
3230
"public_key": {
3331
"type": "string",
34-
"description": "Public PGP key for validating binary cache packages.",
32+
"description": "Public PGP key for validating binary cache packages."
3533
},
3634
"description": {
3735
"type": "string",
3836
"description": "What this mirror is for."
3937
}
4038
}
4139
}
42-
}
40+
}

0 commit comments

Comments
 (0)