[image-build] Refactoring

* 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ář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2016-01-11 09:06:13 +01:00
parent d2ea1dd288
commit af11bebf1b
1 changed files with 11 additions and 10 deletions

View File

@ -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)