From cb0399238e097c6917ffa847f546ff01fdff7599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Mon, 24 Feb 2025 15:00:38 +0100 Subject: [PATCH] extra_isos: Mention all extra files in the manifest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When container-images are downloaded, they would be skipped from the extra_files.json manifest. This patch fixes that by enumerating all files rather than relying on the getter to return a list. JIRA: RHELCMP-14406 Signed-off-by: Lubomír Sedlář --- pungi/phases/extra_isos.py | 13 +++++++------ tests/test_extra_isos_phase.py | 20 +++++++++++++++++--- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/pungi/phases/extra_isos.py b/pungi/phases/extra_isos.py index 55e9b473..35beaf0d 100644 --- a/pungi/phases/extra_isos.py +++ b/pungi/phases/extra_isos.py @@ -342,23 +342,24 @@ def get_extra_files(compose, variant, arch, extra_files): included in the ISO. """ extra_files_dir = compose.paths.work.extra_iso_extra_files_dir(arch, variant) - filelist = [] for scm_dict in extra_files: getter = get_file_from_scm if "file" in scm_dict else get_dir_from_scm target = scm_dict.get("target", "").lstrip("/") target_path = os.path.join(extra_files_dir, target).rstrip("/") - filelist.extend( - os.path.join(target, f) - for f in getter(scm_dict, target_path, compose=compose, arch=arch) - ) + getter(scm_dict, target_path, compose=compose, arch=arch) + filelist = [ + os.path.relpath(os.path.join(root, f), extra_files_dir) + for root, _, files in os.walk(extra_files_dir) + for f in files + ] if filelist: metadata.populate_extra_files_metadata( ExtraFiles(), variant, arch, extra_files_dir, - filelist, + sorted(filelist), compose.conf["media_checksums"], ) diff --git a/tests/test_extra_isos_phase.py b/tests/test_extra_isos_phase.py index a02e1cde..82487e39 100644 --- a/tests/test_extra_isos_phase.py +++ b/tests/test_extra_isos_phase.py @@ -524,7 +524,11 @@ class GetExtraFilesTest(helpers.PungiTestCase): self.assertEqual(populate_md.call_args_list, []) def test_get_file(self, get_dir, get_file, populate_md): - get_file.return_value = ["GPL"] + def mock_get_file(scm_dict, target_path, compose, arch): + helpers.touch(os.path.join(target_path, scm_dict["file"])) + return [scm_dict["file"]] + + get_file.side_effect = mock_get_file cfg = { "scm": "git", "repo": "https://pagure.io/pungi.git", @@ -560,7 +564,13 @@ class GetExtraFilesTest(helpers.PungiTestCase): ) def test_get_dir(self, get_dir, get_file, populate_md): - get_dir.return_value = ["a", "b"] + def mock_get_dir(scm_dict, target_path, compose, arch): + files = ["a", "b"] + for f in files: + helpers.touch(os.path.join(target_path, f)) + return files + + get_dir.side_effect = mock_get_dir cfg = { "scm": "git", "repo": "https://pagure.io/pungi.git", @@ -596,7 +606,11 @@ class GetExtraFilesTest(helpers.PungiTestCase): ) def test_get_multiple_files(self, get_dir, get_file, populate_md): - get_file.side_effect = [["GPL"], ["setup.py"]] + def mock_get_file(scm_dict, target_path, compose, arch): + helpers.touch(os.path.join(target_path, scm_dict["file"])) + return [scm_dict["file"]] + + get_file.side_effect = mock_get_file cfg1 = { "scm": "git", "repo": "https://pagure.io/pungi.git",