extras-buildsys/builder builder.py,1.16,1.17
Daniel Williams (dcbw)
fedora-extras-commits at redhat.com
Sat Jul 16 15:47:44 UTC 2005
Author: dcbw
Update of /cvs/fedora/extras-buildsys/builder
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv10181/builder
Modified Files:
builder.py
Log Message:
2005-07-16 Dan Williams <dcbw at redhat.com>
* builder/builder.py
server/Builder.py
server/BuilderManager.py
- Make the builder aware of what mock targets & arches it can actually
build, and expose that information to the build server
- On the server, make sure that we ask the builder to only build for
arches that it supports for the target we request
(This makes noarch jobs work correctly everywhere)
Index: builder.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/builder/builder.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- builder.py 14 Jul 2005 21:13:20 -0000 1.16
+++ builder.py 16 Jul 2005 15:47:42 -0000 1.17
@@ -452,25 +452,25 @@
def getArchBuilder(uniqid, target, buildarch, srpm_url, localarches):
"""hand it an arch it hands you back the builder instance you need"""
- if not builder_dict.has_key(buildarch):
- # raise an exception here bitching about no place to build for that arch
- pass
+ if buildarch != 'noarch' and not builder_dict.has_key(buildarch):
+ return None
- if buildarch == 'noarch':
- if len(localarches) > 0:
- builder = builder_dict[localarches[0]]
+ builder = None
+ if buildarch == 'noarch' and len(localarches) > 0:
+ builder = builder_dict[localarches[0]]
else:
if buildarch in localarches:
builder = builder_dict[buildarch]
-
- bcp = builder(uniqid, target, buildarch, srpm_url)
- return bcp
+
+ if builder:
+ return builder(uniqid, target, buildarch, srpm_url)
+ return None
class XMLRPCBuilderServer:
- def __init__(self, localarches):
+ def __init__(self, target_arch_dict):
self.ids = {} # unique id => awclass instance
- self.localarches = localarches
+ self.target_arch_dict = target_arch_dict
self.cur_job = 0
def log(self, string):
@@ -486,19 +486,26 @@
jobid = uniqid
self.cur_job = jobid # Update current job
+ def _get_uniqid(self, target, arch, srpm_url):
+ check = '%d %s %s %s' % (time.time(), target, arch, srpm_url)
+ sum = sha.new()
+ sum.update(check)
+ return sum.hexdigest()
+
def start(self, target, arch, srpm_url):
+ # Sanity check the request
if self.cur_job != 0:
self.log("Tried to build '%s' when already buiding something" % srpm_url)
return 0
+ if not self.target_arch_dict.has_key(target) or len(self.target_arch_dict[target]) == 0:
+ self.log("Tried to build '%s' on target %s which isn't supported" % (srpm_url, target))
+ return 0
+ if arch != 'noarch' and not arch in self.target_arch_dict[target]:
+ self.log("Tried to build '%s' on target %s which doesn't support arch %s" % (srpm_url, target, arch))
+ return 0
- cur_time = time.time()
- check = '%d %s %s %s' % (cur_time, target, arch, srpm_url)
- sum = sha.new()
- sum.update(check)
- uniqid = sum.hexdigest()
- if target == 'devel':
- target = 'development'
- job = getArchBuilder(uniqid, target, arch, srpm_url, self.localarches)
+ uniqid = self._get_uniqid(target, arch, srpm_url)
+ job = getArchBuilder(uniqid, target, arch, srpm_url, self.target_arch_dict[target])
if job != None:
self.ids[uniqid] = job
job.start()
@@ -537,8 +544,8 @@
status = 'idle'
return (self.cur_job, status)
- def supported_arches(self):
- return self.localarches
+ def supported_target_arches(self):
+ return self.target_arch_dict
def drop_privs():
@@ -595,6 +602,31 @@
return 0
+def read_mock_configs(allowed_arches):
+ MOCK_CONFIG_DIR = "/etc/mock/"
+ tmp_list = os.listdir(MOCK_CONFIG_DIR)
+ target_arches = {}
+ for f in tmp_list:
+ if not f.endswith(".cfg"):
+ continue
+ try:
+ t = f.index("-")
+ except ValueError:
+ continue
+ cfg_name = f[:len(f)-4]
+ try:
+ (distro, target, arch, repo) = cfg_name.split('-')
+ except ValueError:
+ print "Unrecognized config %s, ignoring." % cfg_name
+ continue
+ if distro == config_opts['distro_name'] and repo == config_opts['repo_name']:
+ if arch in allowed_arches:
+ if not target_arches.has_key(target):
+ target_arches[target] = []
+ target_arches[target].append(arch)
+ return target_arches
+
+
if __name__ == '__main__':
state={'opts': True, 'host': None, 'archs': [],
'daemon': False, 'pidfile': None, 'logfile': None}
@@ -619,14 +651,9 @@
help="location of the builder config file")
(opts, args) = parser.parse_args()
- if not opts.configfile:
- print "Must specify the config file."
+ if not opts.configfile or not os.path.exists(opts.configfile):
+ print "Must specify a valid config file."
sys.exit(1)
-
- if not os.path.exists(opts.configfile):
- print "Could not find the config file %s" % opts.configfile
- sys.exit(1)
-
if not os.access(opts.configfile, os.R_OK):
print "Could not read the config file %s" % opts.configfile
sys.exit(1)
@@ -642,6 +669,16 @@
print "Arch '%s' must be one of [ %s ]" % (arch, archlist)
sys.exit(1)
+ for arch in config_opts['arches']:
+ if not arch in builder_dict.keys():
+ print "Arch '%s' specified in the config file is not supported." % arch
+ sys.exit(1)
+
+ target_arch_dict = read_mock_configs(config_opts['arches'])
+ if len(target_arch_dict) == 0:
+ print "No mock configuration files were found. Exiting."
+ sys.exit(1)
+
if opts.daemon:
ret=daemonize.createDaemon()
if ret:
@@ -702,7 +739,7 @@
print "Error: couldn't bind to address '%s:%s'. Is the builder already running?" % (config_opts['hostname'], xmlrpc_port)
os._exit(1)
- bcs = XMLRPCBuilderServer(config_opts['arches'])
+ bcs = XMLRPCBuilderServer(target_arch_dict)
xmlserver.register_instance(bcs)
last_time = time.time()
More information about the fedora-extras-commits
mailing list