From 621f1e224737bae86d449503fb0aec7abac9d197 Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Tue, 11 Apr 2017 14:46:38 +0200 Subject: [PATCH] Fix createrepo issue for modular compose when multiple threads tried to use the same tmp directory. Signed-off-by: Jan Kaluza --- pungi/phases/createrepo.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/pungi/phases/createrepo.py b/pungi/phases/createrepo.py index 6468229c..74087ebc 100644 --- a/pungi/phases/createrepo.py +++ b/pungi/phases/createrepo.py @@ -30,7 +30,7 @@ from kobo.shortcuts import run, relative_path from ..wrappers.scm import get_dir_from_scm from ..wrappers.createrepo import CreaterepoWrapper from .base import PhaseBase -from ..util import find_old_compose +from ..util import find_old_compose, temp_dir import productmd.rpms @@ -187,17 +187,16 @@ def create_variant_repo(compose, arch, variant, pkg_type): modules = {"modules": []} for mmd in variant.mmds: modules["modules"].append(yaml.safe_load(mmd.dumps())) - tmp_dir = compose.mkdtemp(prefix="pungi_") - modules_path = os.path.join(tmp_dir, "modules.yaml") - with open(modules_path, "w") as outfile: - outfile.write(yaml.safe_dump(modules)) - cmd = repo.get_modifyrepo_cmd(os.path.join(repo_dir, "repodata"), - modules_path, mdtype="modules", - compress_type="gz") - log_file = compose.paths.log.log_file( - arch, "modifyrepo-modules-%s" % variant) - run(cmd, logfile=log_file, show_cmd=True) - shutil.rmtree(tmp_dir) + with temp_dir() as tmp_dir: + modules_path = os.path.join(tmp_dir, "modules.yaml") + with open(modules_path, "w") as outfile: + outfile.write(yaml.safe_dump(modules)) + cmd = repo.get_modifyrepo_cmd(os.path.join(repo_dir, "repodata"), + modules_path, mdtype="modules", + compress_type="gz") + log_file = compose.paths.log.log_file( + arch, "modifyrepo-modules-%s" % variant) + run(cmd, logfile=log_file, show_cmd=True) compose.log_info("[DONE ] %s" % msg)