From af11bebf1bd4d6cd20c94cb40d1dc496bbafe124 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Mon, 11 Jan 2016 09:06:13 +0100 Subject: [PATCH] [image-build] Refactoring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Move getting arches to separate method. * Modify git url only if there is going to be a build. This is not very likely to happen, but could save a bit of time if it really does happen. Signed-off-by: Lubomír Sedlář --- pungi/phases/image_build.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/pungi/phases/image_build.py b/pungi/phases/image_build.py index 07970756..7c503d28 100644 --- a/pungi/phases/image_build.py +++ b/pungi/phases/image_build.py @@ -71,6 +71,11 @@ class ImageBuildPhase(PhaseBase): return ",".join(repo) + def _get_arches(self, image_conf, arches): + if 'arches' in image_conf: + arches = set(image_conf.get('arches', [])) & arches + return ','.join(sorted(arches)) + def run(self): for variant in self.compose.get_variants(): arches = set([x for x in variant.arches if x != 'src']) @@ -81,20 +86,16 @@ class ImageBuildPhase(PhaseBase): # value is needed. image_conf = copy.deepcopy(image_conf) + # image_conf is passed to get_image_build_cmd as dict + + image_conf['arches'] = self._get_arches(image_conf, arches) + if not image_conf['arches']: + continue + # Replace possible ambiguous ref name with explicit hash. if 'ksurl' in image_conf: image_conf['ksurl'] = resolve_git_url(image_conf['ksurl']) - # image_conf is passed to get_image_build_cmd as dict - - if 'arches' in image_conf: - image_conf["arches"] = ','.join(sorted(set(image_conf.get('arches', [])) & arches)) - else: - image_conf['arches'] = ','.join(sorted(arches)) - - if not image_conf['arches']: - continue - image_conf["variant"] = variant image_conf["install_tree"] = self._get_install_tree(image_conf, variant)