Skip to content

Commit 798a216

Browse files
committed
preserve cache for makefile
1 parent e2ee9ba commit 798a216

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

stackinator/builder.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ def generate(self, recipe):
227227
with (self.path / "Makefile").open("w") as f:
228228
f.write(
229229
makefile_template.render(
230+
cache = recipe.cache,
230231
modules=recipe.with_modules,
231232
post_install_hook=recipe.post_install_hook,
232233
pre_install_hook=recipe.pre_install_hook,

stackinator/recipe.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ def __init__(self, args):
174174
# mirrors specified on the command line.
175175
self._logger.debug("Configuring mirrors.")
176176
self._mirrors = mirror.Mirrors(self.system_config_path, args.cache)
177+
self._cache = [mirror for mirror in self.mirrors if mirror["buildcache"]]
177178

178179
# optional post install hook
179180
if self.post_install_hook is not None:
@@ -235,6 +236,10 @@ def pre_install_hook(self):
235236
@property
236237
def mirrors(self):
237238
return self._mirrors
239+
240+
@property
241+
def cache(self):
242+
return self._cache
238243

239244
@property
240245
def config(self):
@@ -515,7 +520,7 @@ def compiler_files(self):
515520
)
516521

517522
makefile_template = env.get_template("Makefile.compilers")
518-
push_to_cache = self.mirrors
523+
push_to_cache = self.cache
519524
files["makefile"] = makefile_template.render(
520525
compilers=self.compilers,
521526
push_to_cache=push_to_cache,
@@ -546,7 +551,7 @@ def environment_files(self):
546551
jenv.filters["py2yaml"] = schema.py2yaml
547552

548553
makefile_template = jenv.get_template("Makefile.environments")
549-
push_to_cache = self.mirror is not None
554+
push_to_cache = self.cache is not None
550555
files["makefile"] = makefile_template.render(
551556
environments=self.environments,
552557
push_to_cache=push_to_cache,

stackinator/schema.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,4 @@ def check_module_paths(instance):
121121
EnvironmentsValidator = SchemaValidator(prefix / "schema/environments.json")
122122
CacheValidator = SchemaValidator(prefix / "schema/cache.json")
123123
ModulesValidator = SchemaValidator(prefix / "schema/modules.json", check_module_paths)
124+
MirrorsValidator = SchemaValidator(prefix / "schema/mirror.json")

stackinator/templates/Makefile

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,20 @@ pre-install: spack-setup
3232
$(SANDBOX) $(STORE)/pre-install-hook
3333

3434
mirror-setup: spack-setup{% if pre_install_hook %} pre-install{% endif %}
35+
3536
{% if cache %}
36-
# The old way of managing mirrors
3737
$(SANDBOX) $(SPACK) buildcache keys --install --trust
38-
{% if cache.key %}
39-
$(SANDBOX) $(SPACK) gpg trust {{ cache.key }}
40-
{% endif %}
4138
{% endif %}
4239
{% if mirrors %}
43-
@echo "Adding mirrors and gpg keys."
44-
{% for mirror_info in mirrors | reverse %}
45-
$(SANDBOX) $(SPACK) mirror add --scope=site {{ mirror_info.name }} {{ mirror_info.url }}
46-
$(SANDBOX) $(SPACK) gpg trust {{ mirror_info.key_path }}
40+
@echo "Adding mirror gpg keys."
41+
{% for mirror in mirrors | reverse %}
42+
{% if mirror.public_key %}
43+
$(SANDBOX) $(SPACK) gpg trust {{ mirror.public_key }}
44+
{% endif %}
4745
{% endfor %}
4846
@echo "Current mirror list:"
4947
$(SANDBOX) $(SPACK) mirror list
5048
{% endif %}
51-
{% for mirror_info in filter(lambda m: m['bootstrap'], mirrors) | filter() %}
52-
$(SANDBOX) $(SPACK) bootstrap add --scope=site {{ mirror_info.name }} bootstrap/{{ mirror_info.name }}
53-
{% endfor %}
5449
touch mirror-setup
5550

5651
compilers: mirror-setup
@@ -89,14 +84,14 @@ store.squashfs: post-install
8984

9085
# Force push all built packages to the build cache
9186
cache-force: mirror-setup
92-
{% if cache.key %}
87+
{% if cache %}
9388
$(warning ================================================================================)
9489
$(warning Generate the config in order to force push partially built compiler environments)
9590
$(warning if this step is performed with partially built compiler envs, you will)
9691
$(warning likely have to start a fresh build (but that's okay, because build caches FTW))
9792
$(warning ================================================================================)
9893
$(SANDBOX) $(MAKE) -C generate-config
99-
$(SANDBOX) $(SPACK) --color=never -C $(STORE)/config buildcache create --rebuild-index --only=package alpscache \
94+
$(SANDBOX) $(SPACK) --color=never -C $(STORE)/config buildcache create --rebuild-index --only=package cache.name \
10095
$$($(SANDBOX) $(SPACK_HELPER) -C $(STORE)/config find --format '{name};{/hash};version={version}' \
10196
| grep -v -E '^({% for p in exclude_from_cache %}{{ pipejoiner() }}{{ p }}{% endfor %});'\
10297
| grep -v -E 'version=git\.'\

0 commit comments

Comments
 (0)