From b514e20833d470a598b51261d586959504d002da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Mon, 22 Jul 2019 08:54:44 +0200 Subject: [PATCH] pkgset: Check for empty module index MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of testing its return value. Future version of libmodulemd will raise an exception instead of returning empty data. Signed-off-by: Lubomír Sedlář --- pungi/phases/createrepo.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pungi/phases/createrepo.py b/pungi/phases/createrepo.py index 570f482e..060ba82a 100644 --- a/pungi/phases/createrepo.py +++ b/pungi/phases/createrepo.py @@ -231,14 +231,14 @@ def create_variant_repo(compose, arch, variant, pkg_type, modules_metadata=None) def add_modular_metadata(repo, repo_path, mod_index, log_file): """Add modular metadata into a repository.""" + # Dumping empty index fails, we need to check for that. + if not mod_index.get_module_names(): + return + 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(data) + f.write(mod_index.dump_to_string()) cmd = repo.get_modifyrepo_cmd( os.path.join(repo_path, "repodata"),