[cvs] / gkb / gkb.py  

cvs: gkb/gkb.py


1 : tmcnulty 1.1 #!/usr/bin/python
2 :     #
3 :     # GKB - GNU Kernel Builder
4 : tmcnulty 1.2 # Copyright (C) 2003-2004 Tobias McNulty, Mark Guertin
5 : tmcnulty 1.1 #
6 :     # This program is free software; you can redistribute it and/or modify
7 :     # it under the terms of the GNU General Public License as published by
8 :     # the Free Software Foundation; either version 2 of the License, or
9 :     # (at your option) any later version.
10 :     #
11 :     # This program is distributed in the hope that it will be useful,
12 :     # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 :     # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 :     # GNU General Public License for more details.
15 :     #
16 :     # You should have received a copy of the GNU General Public License
17 :     # along with this program; if not, write to the Free Software
18 :     # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 :     #
20 :     # Ported from PHP version Copyright (c) Tobias McNulty 2000-2003
21 :    
22 : tmcnulty 1.20 import sys, os, ConfigParser, popen2
23 : tmcnulty 1.1 import xml.parsers.expat
24 : tmcnulty 1.21 import md5, string
25 : tmcnulty 1.1 from ftplib import FTP
26 :     from commands import getoutput
27 :     from shutil import copy, move
28 :     from string import split
29 :     from urllib2 import urlopen
30 :     from ClientForm import ParseResponse
31 :    
32 :     debug=0
33 : tmcnulty 1.22 clean=1
34 :     dont_build=0
35 : tmcnulty 1.1 verbose=1
36 :    
37 :     # parse host-specific configuration information from gkb.cfg
38 :     config = ConfigParser.ConfigParser()
39 :     config.readfp(open('gkb-host.cfg'))
40 :     buildroot=config.get("options","buildroot")
41 :     host=config.get("options","host")
42 :     passwd=config.get("options","passwd")
43 :    
44 :     # this one is passed verbatim before the make command. might be useful for alternate toolchains, etc
45 :     # example: premake="HOST=powerpc-unknown-linux-gnu"
46 :     premake=config.get("options","premake")
47 :     # make options, passed verbatim after make command
48 :     makeopts=config.get("options","makeopts")
49 :    
50 :     # parse manager-related configuration from gkb-manager.cfg
51 :     config.readfp(open('gkb-manager.cfg'))
52 :     msite=config.get('options','msite')
53 :    
54 :     # these values will likely stay fairly static across different builds
55 :     patchdir="%s/patches" % buildroot # full path to patch file dir
56 :     configdir="%s/configs" % buildroot # path to where configs are to be stored
57 :     logdir="%s/logs" % buildroot # the logs will go here
58 :     bindir="%s/bin" % buildroot # the directory that binaries built will be sent for pkging
59 :     workdir="%s/work" % buildroot # work directory, where builds take place
60 :    
61 :     # setup the global dicts to hold build data, imported from xml
62 :     mastertrees={}
63 :     builds={}
64 :    
65 : tmcnulty 1.7 class Error(Exception):
66 :     """Base class for exceptions in this module."""
67 :     pass
68 :    
69 :     class BuildError(Error):
70 :     """Exception raised for build-level errors.
71 :    
72 :     Attributes:
73 :     message -- explanation of the error
74 :     """
75 :    
76 :     def __init__(self, message):
77 :     self.message = message
78 :    
79 :     class FatalError(Error):
80 :     """Exception for fatal errors that prevent program continuation.
81 :    
82 :     Attributes:
83 :     message -- explanation of why the specific transition is not allowed
84 :     """
85 :    
86 : tmcnulty 1.12 def __init__(self, message):
87 : tmcnulty 1.7 self.message = message
88 :    
89 : tmcnulty 1.1 def printverbose(myoutput):
90 :     """Supporting method to output info to stdout if verbosity level is set"""
91 :     if verbose==1:
92 :     print myoutput
93 :    
94 : tmcnulty 1.21 def clean(text):
95 :     """clean a string of passwords, etc. to make it suitable for logging"""
96 :     result = string.replace(text,passwd,"XXXXXXXX")
97 :     return result
98 :    
99 : tmcnulty 1.16 def linkpipes(input, output):
100 : tmcnulty 1.21 """link two pipes together, writing all the data from input to output"""
101 : tmcnulty 1.16 data = input.read(2048)
102 :     while data:
103 :     output.write(data)
104 : tmcnulty 1.18 data = input.read(2048)
105 :    
106 : tmcnulty 1.22 def runcmd(cmd, kinfo=None, outfile=None, append=False, infile=None):
107 : tmcnulty 1.21 """run the specified command, with the optional input and output documents"""
108 : tmcnulty 1.25 log(" \_ running " + clean(cmd), kinfo)
109 : tmcnulty 1.16
110 : tmcnulty 1.20 p4obj = popen2.Popen4(cmd)
111 : tmcnulty 1.19
112 :     pin = p4obj.tochild
113 :     pouterr = p4obj.fromchild
114 : tmcnulty 1.16
115 :     if infile != None:
116 :     inobj = open(infile, "r")
117 :     linkpipes(inobj, pin)
118 :     inobj.close()
119 :    
120 :     if outfile != None:
121 :     if append:
122 :     mode = "a"
123 :     else:
124 :     mode = "w"
125 :    
126 :     outobj = open(outfile, mode)
127 : tmcnulty 1.18 linkpipes(pouterr,outobj)
128 : tmcnulty 1.16 outobj.close()
129 :    
130 : tmcnulty 1.19 err = p4obj.wait()
131 : tmcnulty 1.16
132 :     if err == None:
133 :     err = 0
134 : tmcnulty 1.17
135 : tmcnulty 1.25 log(" \_ exit code: %i" % err, kinfo)
136 : tmcnulty 1.21
137 : tmcnulty 1.14 return err
138 :    
139 : tmcnulty 1.1 def log(text,kinfo=0):
140 :     if kinfo:
141 :     printverbose(kinfo["name"] + " : " + text)
142 :     else:
143 :     printverbose("gkb : " + text)
144 :    
145 :     def verifydir(mydir,kinfo=0):
146 :     """Supporting method to verify a given exists, if not it will create it"""
147 :     log("verifying directory " + mydir,kinfo)
148 :     if not os.path.isdir(mydir):
149 : tmcnulty 1.25 log(" \_ %s doesn't exist, creating" % mydir,kinfo)
150 : tmcnulty 1.1 os.mkdir(mydir)
151 :     return mydir
152 :    
153 :     def chdir(mydir,kinfo):
154 :     verifydir(mydir,kinfo)
155 :     log("entering "+mydir,kinfo)
156 :     os.chdir(mydir)
157 :    
158 :     def verifyfile(myfile,kinfo):
159 :     """Supporting method to verify file exists, if not it will exit with error"""
160 :     if not os.path.isfile(myfile):
161 : tmcnulty 1.7 raise BuildError("cannot find file expected at %s, exiting" % myfile)
162 : tmcnulty 1.1 return myfile
163 :    
164 :     def md5sum(fileobj):
165 :     """calculates the md5sum for fileobj and returns it in hexadecimal"""
166 :     md = md5.new()
167 :     data = fileobj.read(8192)
168 :     while (data):
169 :     md.update(data)
170 :     data = fileobj.read(8192)
171 :    
172 :     digest = md.hexdigest()
173 :     return digest
174 :    
175 :     def krn_querymgr(command,kinfo):
176 :     """queries the build host manager with a variety of commands, such as checkout, checkin, etc."""
177 :     version=krn_localversion(kinfo)
178 :     log("querying distribution site manager with command '%s' (kernel version=%s)" % (command,version),kinfo)
179 :     result=getoutput("wget --quiet --output-document=- \"%s/manager.php?cmd=%s&host=%s&pass=%s&build=%s&version=%s\"" % (msite,command,host,passwd,kinfo["name"],version))
180 : tmcnulty 1.25 log(" \_ result: '"+result+"'",kinfo)
181 : tmcnulty 1.1 return result=="1"
182 :    
183 :     def krn_localversion(kinfo):
184 :     """Checks the version of the local source tree specified in kinfo"""
185 :     version=getoutput("""awk -F '=' '/^VERSION/{v=$2} /^PATCHLEVEL/{p=$2} /^SUBLEVEL/{s=$2} /^EXTRAVERSION/{e=$2} END { printf("%s.%s.%s%s\\n", v, p, s, e) }' """ + kinfo["workdir"] + """/Makefile | sed "s/ //g" """)
186 :     return version
187 :    
188 :     def gkb_build(root,kinfo):
189 :     """performs actual kernel builds given root, kinfo (tuple containing relevant data) , premake and makeopts"""
190 :    
191 :     # make sure needed directoriess (for this build) exist, if not create them
192 :    
193 :     verifydir("%s/%s" % (logdir, kinfo["name"]),kinfo)
194 :     verifydir("%s/%s" % (patchdir, kinfo["name"]),kinfo)
195 :    
196 :     # sync the source to make sure we are up to date ...
197 : tmcnulty 1.25 log("fetching latest source",kinfo)
198 : tmcnulty 1.1 gkb_getsource(kinfo)
199 :    
200 : tmcnulty 1.10 # go into the work directory
201 : tmcnulty 1.27 #chdir(workdir, kinfo)
202 : tmcnulty 1.10
203 :     # archive the clean source for later uploading
204 : tmcnulty 1.27 #log("archiving source to " + kinfo["mastertree"] + ".tar.bz2", kinfo)
205 :     #runcmd("tar cjf " + kinfo["mastertree"] + ".tar.bz2 " + kinfo["mastertree"], kinfo)
206 : tmcnulty 1.10
207 :     # now we'll go into the tree's work dir
208 : tmcnulty 1.1 chdir(kinfo["workdir"],kinfo)
209 :    
210 :     # check for patches and apply if necessary
211 :     gkb_patch(kinfo)
212 :    
213 :     if kinfo["type"] == "kernel24":
214 :     krn_build24(kinfo)
215 :     elif kinfo["type"] == "kernel26":
216 :     krn_build24(kinfo) #run kernel24 for now, change later
217 :    
218 :     # Gerk comment:
219 :     # Do we need to change this with 24/26? we probably don't ... I'd rather see us define the list of make targets
220 :     # i.e. "dep","clean","vmlinux","modules","modules_install" or "clean","all","modules_install" for 2.6
221 :     # also of note, make all is not what we will always want with 2.6 kernels ... i.e. zImage.prep, zImage.chrp, etc
222 :     # also for backward compat they will continue to support calling things individual .. the makefile just does
223 :     # this for us with 'all'
224 :    
225 :    
226 :     def krn_build24(kinfo):
227 :     """build a kernel, version 2.4.x"""
228 :    
229 :     if krn_querymgr("checkout",kinfo):
230 : tmcnulty 1.7 try:
231 :     myversion=krn_localversion(kinfo)
232 :    
233 :     # fetch and cp the config file to work/.config
234 :     krn_config(kinfo)
235 :    
236 :     # **Note** : we set the preprocessing command to premake inline instead
237 :     # of globally as it is only needed in this target
238 :     if dont_build==0:
239 :     gkb_runmake("oldconfig",kinfo,premake+" /bin/cat %s/newlines | " % buildroot,makeopts)
240 :    
241 :     # give option to only repackage for testing purposes, comment out clean=1 at top of this file to use this feature
242 :     if (clean==1 and dont_build==0):
243 :     gkb_runmake("clean", kinfo, premake, makeopts)
244 :    
245 :     if dont_build==0:
246 :     gkb_runmake("dep", kinfo, premake, makeopts)
247 :     gkb_runmake(kinfo["binname"], kinfo, premake, makeopts)
248 :    
249 :     # We should check to see if binary built ok, if not bail out
250 :     mybindir=bindir+"/linux-"+kinfo["name"]+"-"+myversion
251 :     verifydir(mybindir,kinfo)
252 :     verifydir(mybindir+"/boot",kinfo)
253 :    
254 :     kbinloc=kinfo["workdir"]+"/"+kinfo["binpath"]+"/"+kinfo["binname"]
255 :     if verifyfile(kbinloc,kinfo):
256 :     # the binary exists, so let's cp it to bin...
257 :     copy(kbinloc,mybindir+"/boot/"+kinfo["binname"]+"-"+myversion)
258 :     else:
259 :     # the binary is not there, inform user and bail out with error
260 :     raise BuildError("%s is not present, assuming build failure and exiting. See log for details." % kbinloc)
261 :    
262 :     # now that we know he binary built, let's continue
263 :     if dont_build==0:
264 :     gkb_runmake("modules",kinfo, premake, makeopts)
265 :    
266 :     # **Note** : we prepend the INSTALL_MOD_PATH to the makeopts inline instead
267 :     # of globally as it is only needed in this target
268 :     gkb_runmake("modules_install", kinfo, premake, "INSTALL_MOD_PATH=%s %s" % (mybindir, makeopts))
269 :    
270 : tmcnulty 1.10 # compress and upload source archive
271 :     chdir(kinfo["workdir"]+"/..",kinfo)
272 :     archive_name = "src-%s.tar.bz2" % kinfo["mastertree"],
273 :    
274 :     # compress and upload kernel binary
275 : tmcnulty 1.7 chdir(bindir,kinfo)
276 :     archive_name = "linux-%s-%s.tar.bz2" % (kinfo["name"], myversion)
277 :    
278 :     log("compressing binary archive "+archive_name,kinfo)
279 :    
280 : tmcnulty 1.21 if runcmd("tar cjf "+archive_name+" "+os.path.basename(mybindir), kinfo):
281 : tmcnulty 1.7 raise BuildError("failed to `tar cjf %s`" % archive_name)
282 :    
283 : tmcnulty 1.21 runcmd("rm -rf %s" % mybindir, kinfo)
284 : tmcnulty 1.7
285 : tmcnulty 1.10 krn_upload(archive_name,"kernel",myversion,kinfo)
286 :     krn_querymgr("checkin",kinfo)
287 :    
288 : tmcnulty 1.26 #if os.fork() == 0:
289 : tmcnulty 1.10 #in child
290 : tmcnulty 1.27
291 :     # sync the source to make sure we are up to date ...
292 :     log("re-fetching latest source",kinfo)
293 :     gkb_getsource(kinfo)
294 :    
295 :     # go into the work directory
296 :     chdir(workdir, kinfo)
297 :    
298 :     # archive the clean source for later uploading
299 :     log("archiving source to " + kinfo["mastertree"] + ".tar.bz2", kinfo)
300 :     runcmd("tar cjf " + kinfo["mastertree"] + ".tar.bz2 " + kinfo["mastertree"], kinfo)
301 :    
302 : tmcnulty 1.26 krn_upload(workdir + "/" + kinfo["mastertree"] + ".tar.bz2", "source", myversion, kinfo)
303 : tmcnulty 1.27
304 : tmcnulty 1.26 #sys.exit(0)
305 : tmcnulty 1.10
306 : tmcnulty 1.7 except BuildError, e:
307 :     log(e.message, kinfo)
308 :     krn_querymgr("checkin",kinfo)
309 : tmcnulty 1.8 except:
310 :     krn_querymgr("checkin",kinfo)
311 :     raise
312 :    
313 : tmcnulty 1.1 def krn_build26(kinfo):
314 :     """build a kernel, version 2.6"""
315 :    
316 :     # source get routines
317 :     def gkb_getsource(kinfo):
318 :     """method to perform source sync on demand, currenty only supports rsync, but others can be added"""
319 :    
320 :     method=mastertrees[kinfo["mastertree"]]["method"]
321 :    
322 :     if method == "rsync":
323 :     get_rsync(kinfo)
324 :     elif method == "wget":
325 :     get_wget(kinfo)
326 :     elif method == "vanilla":
327 :     get_vanilla(kinfo)
328 :    
329 :     def get_rsync(kinfo):
330 :     """sync the source using rsync"""
331 :     args=mastertrees[kinfo["mastertree"]]["args"]
332 :    
333 :     if clean==1:
334 :     syncoptions="rsync -azv --delete"
335 :     else:
336 :     syncoptions="rsync -azv"
337 :    
338 :     syncline=args+" "+kinfo["workdir"]
339 :    
340 : tmcnulty 1.23 #logging now in runcmd
341 :     #log("running rsync : %s %s" % (syncoptions, syncline),kinfo)
342 : tmcnulty 1.21 if runcmd("%s %s" % (syncoptions, syncline), kinfo, "%s/%s/rsync.log" % (logdir, kinfo["name"])):
343 : tmcnulty 1.7 raise BuildError("sync failed, tried %s. See log for details." % syncline)
344 : tmcnulty 1.1
345 :     def get_wget(kinfo):
346 :     #needs work
347 :     """sync the source using wget and a tar.bz2"""
348 :     args=mastertrees[kinfo["mastertree"]]["args"]
349 :    
350 :     log("fetching source archive " % args,kinfo)
351 :     mysourcefile="%s/%s.tar.bz2" % (kinfo["workdir"],kinfo["name"])
352 :    
353 : tmcnulty 1.21 if runcmd("wget --quiet --output-document=%s %s/configs/%s" % (myconfigfile,msite,kinfo["name"]), kinfo):
354 : tmcnulty 1.7 raise BuildError("unable to download configfile, aborting.")
355 : tmcnulty 1.1
356 :     log("decompressing source file",kinfo)
357 : tmcnulty 1.21 if runcmd("tar xjf " % (myconfigfile,msite,kinfo["name"]), kinfo):
358 : tmcnulty 1.7 raise BuildError("unable to decompress source file, aborting.")
359 : tmcnulty 1.1
360 :     def get_vanilla(kinfo):
361 :     args=mastertrees[kinfo["mastertree"]]["args"]
362 :    
363 :     log("fetching source archive %s" % args)
364 :     mysourcefile="%s/%s.tar.bz2" % (workdir,kinfo["name"])
365 :    
366 : tmcnulty 1.21 if runcmd("wget -c --output-document=%s %s" % (mysourcefile,args), kinfo):
367 : tmcnulty 1.7 raise BuildError("unable to download source file %s, aborting." % args)
368 : tmcnulty 1.1
369 :     log("decompressing source file %s" % mysourcefile,kinfo)
370 :    
371 :     #save the current working ectory
372 :     cwd=getoutput("pwd")
373 :    
374 :     chdir(workdir,kinfo)
375 :     pfd=os.popen("tar vxjf %s" % mysourcefile,"r")
376 :     trash=data=pfd.read(255)
377 :    
378 :     while trash:
379 :     trash=pfd.read(4096)
380 :    
381 :     if pfd.close():
382 : tmcnulty 1.7 raise BuildError("unable to decompress source file, aborting.")
383 : tmcnulty 1.1
384 :     fnames=split(data)
385 :     name=fnames[0]
386 :    
387 : tmcnulty 1.21 runcmd("rm -rf %s" % kinfo["workdir"], kinfo)
388 : tmcnulty 1.1 move(work + "/" + dirname, kinfo["workdir"])
389 :    
390 :     #restore the previous working ectory
391 :     chdir(cwd,kinfo)
392 :    
393 :     def gkb_patch(kinfo):
394 :     """method that applies patch found in kinfo config files for running kernel build"""
395 :     if kinfo["patches"]:
396 :     patches=split(kinfo["patches"],";")
397 :    
398 :     for patch in patches:
399 :     log("downloading patch %s" % patch,kinfo)
400 :    
401 :     #set a name for this patch file
402 :     mypatchfile="%s/%s/%s.patch" % (patchdir,kinfo["name"],patch)
403 :    
404 :     # download pathfile or bail
405 : tmcnulty 1.21 if runcmd("wget --quiet --output-document=%s %s/patches/%s/%s" % (mypatchfile,msite,kinfo["name"],patch), kinfo):
406 : tmcnulty 1.7 raise BuildError("unable to download patchfile %s, aborting." % patch)
407 : tmcnulty 1.1
408 :     # we have a patch file, apply it or bail
409 :     log("perfoming patch with %s" % patch,kinfo)
410 : tmcnulty 1.16
411 :     # former patchcommand was:
412 :     #patchcommand="patch -p1 < %s > %s/%s/patch-%s.log 2>&1" % (mypatchfile,logdir,kinfo["name"],patch)
413 :     #log("using %s from %s" % (patchcommand,kinfo["workdir"]),kinfo)
414 :    
415 : tmcnulty 1.1 chdir(kinfo["workdir"],kinfo)
416 : tmcnulty 1.21 if runcmd("patch -p1", kinfo, "%s/%s/patch-%s.log" % (logdir,kinfo["name"],patch), False, mypatchfile):
417 : tmcnulty 1.7 raise BuildError("patchfile %s failed, aborting. See patch log for details." % patch)
418 : tmcnulty 1.1 else:
419 :     log("no patchfiles, continuing",kinfo)
420 :    
421 :     def krn_config(kinfo):
422 :     """method to fetch and place config file for running kernel build"""
423 :    
424 :     if kinfo["config"]==1:
425 :     log("fetching config file",kinfo)
426 :     myconfigfile="%s/%s.config" % (configdir,kinfo["name"])
427 :    
428 : tmcnulty 1.21 if runcmd("wget --quiet --output-document=%s %s/configs/%s" % (myconfigfile,msite,kinfo["name"]), kinfo):
429 : tmcnulty 1.7 raise BuildError("unable to download configfile, aborting.")
430 : tmcnulty 1.1
431 :     log("copying config file to %s/.config" % kinfo["workdir"],kinfo)
432 :     copy(verifyfile(myconfigfile,kinfo),"%s/.config" % kinfo["workdir"])
433 :    
434 :     # Methods to support build()
435 :     def gkb_runmake(command, kinfo, premake, makeopts):
436 :     """Supporting method for build() ... a stub to run a make target and auto log it, given make target (command) and name (kernel name)"""
437 :     log("running make %s" % command,kinfo)
438 : tmcnulty 1.21 if runcmd("%s make %s %s" % (premake, makeopts, command), kinfo, "%s/%s/make-%s.log" % (logdir, kinfo["name"], command)):
439 : tmcnulty 1.7 raise BuildError("unable to run make %s, aborting." % command)
440 : tmcnulty 1.1
441 :     def gkb_parsexml(name):
442 :     """parse the xml build file into mastertrees and builds"""
443 :     def start_element(name, attrs):
444 :     #print "In start_element: %s %s" % (name, attrs)
445 :     if name=="mastertree":
446 :     mastertrees[attrs["name"]]=attrs
447 :     elif name=="build":
448 :     builds[attrs["name"]]=attrs
449 :    
450 :     p = xml.parsers.expat.ParserCreate()
451 :     p.StartElementHandler = start_element
452 :     p.ParseFile(open(name))
453 : tmcnulty 1.3
454 : tmcnulty 1.10 def krn_upload(file, type, version, kinfo):
455 : tmcnulty 1.3 """upload the indicated file to the distribution site (kernel archives)"""
456 : tmcnulty 1.10
457 :     if type=="kernel":
458 :     log("uploading kernel version "+version+" to "+msite,kinfo)
459 :     elif type=="source":
460 :     log("uploading source "+kinfo["mastertree"]+" to "+msite,kinfo)
461 :     else:
462 :     raise BuildException, "invalid file upload type: " + type
463 :    
464 :     forms = ParseResponse(urlopen(msite+"/upload.html"))
465 : tmcnulty 1.3 form = forms[0]
466 :    
467 :     form["host"] = host
468 :     form["pass"] = passwd
469 : tmcnulty 1.10 form["type"] = type
470 :     form["tree"] = kinfo["mastertree"]
471 : tmcnulty 1.3 form["build"] = kinfo["name"]
472 :     form["version"] = version
473 :    
474 : tmcnulty 1.5 form.add_file(open(file), "application/x-bzip2", os.path.basename(file))
475 : tmcnulty 1.10
476 : tmcnulty 1.3 # form.click() returns a urllib2.Request object
477 :     # (see HTMLForm.click.__doc__ if you don't have urllib2)
478 : tmcnulty 1.10 response = urlopen(form.click("cmd"))
479 : tmcnulty 1.3
480 : tmcnulty 1.10 if debug:
481 :     print response.geturl()
482 :     print response.info() # headers
483 :     print response.read() # body
484 :    
485 :     log("response: " + response.read(),kinfo)
486 : tmcnulty 1.3
487 : tmcnulty 1.10 response.close()
488 :    
489 : tmcnulty 1.1 def main():
490 :     """ main program gets executed here """
491 :    
492 :     # get our working ectory
493 :     root=getoutput("pwd")
494 :    
495 :     today=getoutput("date +%D")
496 :     buildtime=getoutput("date +'%R:%S %Z'")
497 :    
498 : tmcnulty 1.25 print "GNU Kernel Builder started %s %s" % (today,buildtime)
499 : tmcnulty 1.1
500 :     # verify the existence important directories, and create if necessary
501 :     verifydir(logdir)
502 :     verifydir(configdir)
503 :     verifydir(patchdir)
504 :     verifydir(bindir)
505 :     verifydir("%s/work" % buildroot) # build dir, make sure it exists
506 :    
507 :     # download the build jobs from the master site
508 : tmcnulty 1.25 log("fetching build jobs from master site")
509 : tmcnulty 1.22 if runcmd("wget --quiet --output-document=gkb.xml \"%s/manager.php?cmd=getjobs&host=%s&pass=%s\"" % (msite,host,passwd)):
510 : tmcnulty 1.25 raise FatalError, "Unable to download build jobs from master site %s, aborting." % msite
511 : tmcnulty 1.1
512 :     # sets up 'mastertrees' and 'builds' dicts
513 :     gkb_parsexml('gkb.xml')
514 :    
515 :     for bdict in builds.values():
516 :     myworkdir="%s/%s" % (workdir,bdict["mastertree"])
517 :     bdict["workdir"]=myworkdir
518 :    
519 : tmcnulty 1.9 try:
520 :     # for now just call the build
521 :     gkb_build(root, bdict)
522 :     except BuildError, e:
523 :     log(e.message, bdict)
524 : tmcnulty 1.12 except KeyboardInterrupt, e:
525 :     log("Caught keyboard interrupt, exiting...")
526 :     break
527 : tmcnulty 1.13
528 : tmcnulty 1.1 endtime=getoutput("date +'%R:%S %Z'")
529 :    
530 :     print "GKB finished %s %s" % (today,endtime)
531 :    
532 :     # and finally, call the mainloop to execute
533 :     main()

Tobias McNulty

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help