Clone module defaults into work/ directory

We can not rely on config_dir being writable, and should not modify
anything in there anyway.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2018-04-11 16:05:08 +02:00
parent 8b24c7cbf3
commit d1d074ce28
3 changed files with 10 additions and 3 deletions

View File

@ -340,6 +340,14 @@ class WorkPaths(object):
path = "%s.cfg" % path
return path
def module_defaults_dir(self, create_dir=True):
"""
"""
path = os.path.join(self.topdir(create_dir=create_dir), 'module_defaults')
if create_dir:
makedirs(path)
return path
class ComposePaths(object):
def __init__(self, compose):

View File

@ -219,7 +219,7 @@ def create_variant_repo(compose, arch, variant, pkg_type, modules_metadata=None)
modules.append(repo_mmd)
module_names = set([x.get_name() for x in modules])
for mmddeffile in glob.glob(os.path.join(compose.config_dir, "module_defaults", "*.yaml")):
for mmddeffile in glob.glob(os.path.join(compose.paths.work.module_defaults_dir(), "*.yaml")):
for mmddef in Modulemd.objects_from_file(mmddeffile):
if isinstance(mmddef, Modulemd.Defaults) and mmddef.peek_module_name() in module_names:
modules.append(mmddef)

View File

@ -160,5 +160,4 @@ def write_module_defaults(compose):
with temp_dir(prefix="moduledefaults_") as tmp_dir:
get_dir_from_scm(scm_dict, tmp_dir, logger=compose._logger)
compose.log_debug("Writing module defaults")
shutil.rmtree(os.path.join(compose.config_dir, "module_defaults"), ignore_errors=True)
shutil.copytree(tmp_dir, os.path.join(compose.config_dir, "module_defaults"))
shutil.copytree(tmp_dir, compose.paths.work.module_defaults_dir())