choose a better arch for noarch builds

When builder receives a noarch build, choose an arch that the host
can handle AND that the build tag can support.
This commit is contained in:
Mike McLean 2008-09-12 15:21:18 -04:00
parent 00044616bd
commit 117ac78c1e

View file

@ -1697,11 +1697,27 @@ class BuildArchTask(BaseTaskHandler):
#noarch is funny
if arch == "noarch":
#use any arch this host can handle
host = session.host.getHost()
if host['arches'] is None:
#we need a buildroot arch. Pick one that:
# a) this host can handle
# b) the build tag can support
# c) is canonical
host_arches = session.host.getHost()['arches']
if not host_arches:
raise koji.BuildError, "No arch list for this host"
br_arch = host['arches'].split()[0]
tag_arches = session.getBuildConfig(root)['arches']
if not tag_arches:
raise koji.BuildError, "No arch list for tag: %s" % build_tag
#index canonical host arches
host_arches = dict([(koji.canonArch(a),1) for a in host_arches.split()])
#pick the first suitable match from tag's archlist
for br_arch in tag_arches.split():
br_arch = koji.canonArch(br_arch)
if host_arches.has_key(br_arch):
#we're done
break
else:
#no overlap
raise koji.BuildError, "host does not match tag arches: %s (%s)" % (root, tag_arches)
else:
br_arch = arch