Skip to content

Commit b4741e0

Browse files
authored
copy user-provided meta data to store/meta/extra (#105)
1 parent 54b910f commit b4741e0

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

stackinator/builder.py

+10
Original file line numberDiff line numberDiff line change
@@ -326,3 +326,13 @@ def generate(self, recipe):
326326
shutil.copytree(
327327
recipe.path, meta_recipe_path, ignore=shutil.ignore_patterns(".git")
328328
)
329+
330+
# create the meta/extra path and copy recipe meta data if it exists
331+
meta_extra_path = meta_path / "extra"
332+
meta_extra_path.mkdir(exist_ok=True)
333+
if meta_extra_path.exists():
334+
shutil.rmtree(meta_extra_path)
335+
if recipe.user_extra is not None:
336+
self._logger.debug(f"copying extra recipe meta data to {meta_extra_path}")
337+
shutil.copytree(recipe.user_extra, meta_extra_path)
338+

stackinator/recipe.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,16 @@ def __init__(self, args):
108108

109109
self.mirror = (args.cache, self.config["store"])
110110

111+
# Returns:
112+
# Path: of the recipe extra path if it exists
113+
# None: if there is no user-provided extra path in the recipe
114+
@property
115+
def user_extra(self):
116+
extra_path = self.path / 'extra'
117+
if extra_path.exists() and extra_path.is_dir():
118+
return extra_path
119+
return None
120+
111121
# Returns a dictionary with the following fields
112122
#
113123
# root: /path/to/cache
@@ -127,9 +137,8 @@ def mirror(self, configuration):
127137

128138
file, mount = configuration
129139

130-
mirror_config_path = pathlib.Path(file)
131-
132-
if mirror_config_path is not None:
140+
if file is not None:
141+
mirror_config_path = pathlib.Path(file)
133142
if not mirror_config_path.is_file():
134143
raise FileNotFoundError(f"The cache configuration '{file}' is not a file")
135144

0 commit comments

Comments
 (0)