From 2dfb1cd4c8f30da612cc621f5b90a3afe77b35d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Tue, 16 Jul 2019 09:02:49 +0200 Subject: [PATCH] pkgset: Skip adding modulemd if there is none MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When libmodulemd is available, but the compose contains no modules, we don't want to add the modular metadata anywhere. This patch actually avoids a crash as `ModuleIndex.dump_to_string()` will return `None` if there is no data. JIRA: COMPOSE-3662 Signed-off-by: Lubomír Sedlář --- pungi/phases/createrepo.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pungi/phases/createrepo.py b/pungi/phases/createrepo.py index 197d7e8d..570f482e 100644 --- a/pungi/phases/createrepo.py +++ b/pungi/phases/createrepo.py @@ -233,8 +233,12 @@ def add_modular_metadata(repo, repo_path, mod_index, log_file): """Add modular metadata into a repository.""" with temp_dir() as tmp_dir: modules_path = os.path.join(tmp_dir, "modules.yaml") + data = mod_index.dump_to_string() + if not data: + # No data to include... + return with open(modules_path, "w") as f: - f.write(mod_index.dump_to_string()) + f.write(data) cmd = repo.get_modifyrepo_cmd( os.path.join(repo_path, "repodata"),