From 535034ef91d6d7055af8800da46e259b3cfc9d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Mon, 8 Mar 2021 11:57:48 +0100 Subject: [PATCH] image_container: Fix incorrect arch processing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit OSBS will reject no scratch builds with arch_override. When the option is not specified in Pungi, it would do `"".split(" ")` to get list of arches, which returns a list with empty string instead of an empty list. With this fixed, it might be possible to have multiple images match the spec (unless arch is used in the filter). To fix that, we can replace arch with $basearch variable. JIRA: RHELCMP-3824 Signed-off-by: Lubomír Sedlář --- pungi/phases/image_container.py | 4 ++-- tests/test_image_container_phase.py | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/pungi/phases/image_container.py b/pungi/phases/image_container.py index cb72161f..0e656335 100644 --- a/pungi/phases/image_container.py +++ b/pungi/phases/image_container.py @@ -53,7 +53,7 @@ class ImageContainerThread(WorkerThread): self._get_repo( compose, variant, - config.get("arch_override", "").split(" "), + config.get("arch_override", "").split(), config.pop("image_spec"), ) ] @@ -95,7 +95,7 @@ class ImageContainerThread(WorkerThread): if not re.match(value, getattr(image, key)): break else: - image_paths.add(image.path) + image_paths.add(image.path.replace(arch, "$basearch")) if len(image_paths) != 1: raise RuntimeError( diff --git a/tests/test_image_container_phase.py b/tests/test_image_container_phase.py index eaea2d24..b76d761c 100644 --- a/tests/test_image_container_phase.py +++ b/tests/test_image_container_phase.py @@ -130,7 +130,6 @@ class ImageContainerThreadTest(helpers.PungiTestCase): "target": "f24-docker-candidate", "git_branch": "f24-docker", "image_spec": {"type": "qcow2"}, - "arch_override": "x86_64", } self.compose.im.images["Server"] = { "x86_64": [ @@ -150,7 +149,7 @@ class ImageContainerThreadTest(helpers.PungiTestCase): repo_content = list(f) self.assertIn("[image-to-include]\n", repo_content) self.assertIn( - "baseurl=http://root/compose/Server/x86_64/images/image.qcow2\n", + "baseurl=http://root/compose/Server/$basearch/images/image.qcow2\n", repo_content, ) self.assertIn("enabled=0\n", repo_content) @@ -158,7 +157,6 @@ class ImageContainerThreadTest(helpers.PungiTestCase): def assertKojiCalls(self, cfg, scratch=False): opts = { "git_branch": cfg["git_branch"], - "arch_override": cfg["arch_override"], "yum_repourls": ["http://root/" + self.repofile_path], } if scratch: