# jhbuild - a build script for GNOME 1.x and 2.x # Copyright (C) 2001-2006 James Henstridge # # tinderbox.py: build logic for a non-interactive reporting build # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import os import time import subprocess import locale from jhbuild.utils import cmds from jhbuild.errors import CommandError import buildscript index_header = '''
| Time | Module | Phases | Status |
|---|
')
if isinstance(command, (str, unicode)):
self.modulefp.write('%s\n'
% escape(command))
kws['shell'] = True
else:
self.modulefp.write('%s\n'
% escape(' '.join(command)))
kws['stdin'] = subprocess.PIPE
kws['stdout'] = subprocess.PIPE
kws['stderr'] = subprocess.PIPE
if hint == 'cvs':
def format_line(line, error_output, fp=self.modulefp):
if line[-1] == '\n': line = line[:-1]
if line.startswith('C '):
fp.write('%s\n'
% escape(line))
else:
fp.write('%s\n' % escape(line))
kws['stderr'] = subprocess.STDOUT
else:
def format_line(line, error_output, fp=self.modulefp):
if line[-1] == '\n': line = line[:-1]
if error_output:
fp.write('%s\n'
% escape(line))
else:
fp.write('%s\n' % escape(line))
if cwd is not None:
kws['cwd'] = cwd
if extra_env is not None:
kws['env'] = os.environ.copy()
kws['env'].update(extra_env)
try:
p = subprocess.Popen(command, **kws)
except OSError, e:
self.modulefp.write('Error: %s\n'
% escape(str(e)))
raise CommandError(str(e))
cmds.pprint_output(p, format_line)
self.modulefp.write('\n')
self.modulefp.flush()
if p.returncode != 0:
raise CommandError('Error running %s' % command, p.returncode)
def start_build(self):
assert self.outputdir
# close stdin
os.close(0)
info = []
import socket
un = os.uname()
info.append(('Build Host', socket.gethostname()))
info.append(('Architecture', '%s %s (%s)' % (un[0], un[2], un[4])))
distro = get_distro()
if distro:
info.append(('Distribution', distro))
info.append(('Module Set', self.config.moduleset))
info.append(('Start Time', self.timestamp()))
buildplatform = '| %s | %s |
|---|
%s: " % activity) infopath = "build/share/activities/%s/activity/activity.info" % activity info = open(infopath) for line in info.readlines(): if line.startswith("name = "): activityname = line if not activityname: raise CommandError, "%s has no name in activity.info!" % activity info.close() activityname = activityname.replace("name = ", "") activityname = activityname.rstrip() if activityname == "Journal": p1 = subprocess.Popen(['ps', 'ax'], stdout=subprocess.PIPE) p2 = subprocess.Popen(['grep', '-c', 'Journal.activity'], stdin=p1.stdout, stdout=subprocess.PIPE) numproc = p2.stdout.read() if int(numproc) > 1: self.modulefp.write("A journal is already running.") continue subtwo = subprocess.Popen(["sugar-activity", "%s" % activityname]) time.sleep(20) if not subtwo.poll() == None: runfailures.append(activityname) log = open("/home/cjb/.sugar/default/logs/%s.log" % activityname) logtext = log.readlines() self.modulefp.write("Failed:
%s" % "".join(logtext)) else: self.modulefp.write("Succeeded.") self.indexfp.write('
The following modules failed to build
\n' info += '\n' info += ', '.join(failures) info += '\n' else: info = '' self.indexfp.write(index_footer % { 'failures': info }) if runfailures: info = '
The following activities failed to run
\n' info += '\n' info += ', '.join(runfailures) info += '\n' else: info = '' self.indexfp.write(index_footer % { 'failures': info }) self.indexfp.close() self.indexfp = None def start_module(self, module): self.modulefilename='%s.html' % module.replace('/','_') self.indexfp.write('