mirror of
https://git.rtems.org/rtems-source-builder
synced 2024-10-09 07:15:10 +08:00
sb: Send only one mail when building a BSP
- Add support to email a single report if configured to do so.
This commit is contained in:
parent
61ce77bcb5
commit
cdd5aef6a9
@ -9,6 +9,8 @@
|
|||||||
# - Packages
|
# - Packages
|
||||||
#
|
#
|
||||||
|
|
||||||
|
%define mail_single_report 1
|
||||||
|
|
||||||
%define with_rtems_bsp beagleboneblack
|
%define with_rtems_bsp beagleboneblack
|
||||||
%define rtems_target arm-rtems5
|
%define rtems_target arm-rtems5
|
||||||
%define rtems_host %{rtems_target}
|
%define rtems_host %{rtems_target}
|
||||||
|
@ -129,6 +129,25 @@ class buildset:
|
|||||||
def get_mail_report(self):
|
def get_mail_report(self):
|
||||||
return self.mail_report
|
return self.mail_report
|
||||||
|
|
||||||
|
def mail_single_report(self):
|
||||||
|
return self.macros.get('%{mail_single_report}') != 0
|
||||||
|
|
||||||
|
def mail_active(self, mail, nesting_count = 1):
|
||||||
|
return mail is not None and not (self.mail_single_report() and nesting_count > 1)
|
||||||
|
|
||||||
|
def mail_send(self, mail):
|
||||||
|
if True: #not self.opts.dry_run():
|
||||||
|
mail_subject = '%s on %s' % (self.bset, self.macros.expand('%{_host}'))
|
||||||
|
if mail['failure'] is not None:
|
||||||
|
mail_subject = 'FAILED %s (%s)' % (mail_subject, mail['failure'])
|
||||||
|
else:
|
||||||
|
mail_subject = 'PASSED %s' % (mail_subject)
|
||||||
|
mail_subject = 'Build %s: %s' % (reports.platform(mode = 'system'),
|
||||||
|
mail_subject)
|
||||||
|
body = mail['log']
|
||||||
|
body += (os.linesep * 2).join(mail['reports'])
|
||||||
|
mail['mail'].send(mail['to'], mail_subject, body)
|
||||||
|
|
||||||
def copy(self, src, dst):
|
def copy(self, src, dst):
|
||||||
log.output('copy: %s => %s' % (path.host(src), path.host(dst)))
|
log.output('copy: %s => %s' % (path.host(src), path.host(dst)))
|
||||||
if not self.opts.dry_run():
|
if not self.opts.dry_run():
|
||||||
@ -360,27 +379,25 @@ class buildset:
|
|||||||
|
|
||||||
nesting_count += 1
|
nesting_count += 1
|
||||||
|
|
||||||
if mail:
|
if self.mail_active(mail, nesting_count):
|
||||||
mail['output'].clear()
|
mail['output'].clear()
|
||||||
|
mail['log'] = ''
|
||||||
|
mail['reports'] = []
|
||||||
|
mail['failure'] = None
|
||||||
|
|
||||||
log.trace('_bset: %2d: %s: make' % (nesting_count, self.bset))
|
log.trace('_bset: %2d: %s: make' % (nesting_count, self.bset))
|
||||||
log.notice('Build Set: %s' % (self.bset))
|
log.notice('Build Set: %s' % (self.bset))
|
||||||
|
|
||||||
mail_subject = '%s on %s' % (self.bset,
|
|
||||||
self.macros.expand('%{_host}'))
|
|
||||||
|
|
||||||
current_path = os.environ['PATH']
|
current_path = os.environ['PATH']
|
||||||
|
|
||||||
start = datetime.datetime.now()
|
start = datetime.datetime.now()
|
||||||
|
|
||||||
mail_report = False
|
mail_report = False
|
||||||
have_errors = False
|
have_errors = False
|
||||||
|
interrupted = False
|
||||||
if mail:
|
|
||||||
mail['output'].clear()
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# If this is the outter most buildset it's files installed. Nested
|
# If this is the outter most buildset it's files are installed. Nested
|
||||||
# build sets staged their installed file. The staged files are install
|
# build sets staged their installed file. The staged files are install
|
||||||
# when the outtter most build finishes.
|
# when the outtter most build finishes.
|
||||||
#
|
#
|
||||||
@ -585,49 +602,51 @@ class buildset:
|
|||||||
log.stderr(str(gerr))
|
log.stderr(str(gerr))
|
||||||
raise
|
raise
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
mail_report = False
|
interrupted = True
|
||||||
raise
|
raise
|
||||||
except:
|
except:
|
||||||
self.build_failure = 'RSB general failure'
|
self.build_failure = 'RSB general failure'
|
||||||
|
interrupted = True
|
||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
end = datetime.datetime.now()
|
end = datetime.datetime.now()
|
||||||
os.environ['PATH'] = current_path
|
os.environ['PATH'] = current_path
|
||||||
build_time = str(end - start)
|
build_time = str(end - start)
|
||||||
if mail_report and not self.macros.defined('mail_disable'):
|
if self.mail_single_report() and nesting_count == 1:
|
||||||
|
mail_report = True
|
||||||
|
if interrupted or self.macros.defined('mail_disable'):
|
||||||
|
mail_report = False
|
||||||
|
if mail_report:
|
||||||
|
if self.installing():
|
||||||
self.write_mail_header('Build Time: %s' % (build_time), True)
|
self.write_mail_header('Build Time: %s' % (build_time), True)
|
||||||
self.write_mail_header('', True)
|
self.write_mail_header('', True)
|
||||||
if self.build_failure is not None:
|
|
||||||
mail_subject = 'FAILED %s (%s)' % \
|
|
||||||
(mail_subject, self.build_failure)
|
|
||||||
else:
|
|
||||||
mail_subject = 'PASSED %s' % (mail_subject)
|
|
||||||
mail_subject = 'Build %s: %s' % (reports.platform(mode = 'system'),
|
|
||||||
mail_subject)
|
|
||||||
self.write_mail_header(mail['header'], True)
|
self.write_mail_header(mail['header'], True)
|
||||||
self.write_mail_header('')
|
self.write_mail_header('')
|
||||||
log.notice('Mailing report: %s' % (mail['to']))
|
log.notice('Mailing report: %s' % (mail['to']))
|
||||||
body = self.get_mail_header()
|
mail['log'] += self.get_mail_header()
|
||||||
body += 'Sizes' + os.linesep
|
|
||||||
body += '=====' + os.linesep + os.linesep
|
|
||||||
if sizes_valid:
|
if sizes_valid:
|
||||||
body += 'Maximum build usage: ' + build_max_size_human + os.linesep
|
mail['log'] += 'Sizes' + os.linesep
|
||||||
body += 'Total size: ' + build_total_size_human + os.linesep
|
mail['log'] += '=====' + os.linesep + os.linesep
|
||||||
body += 'Installed : ' + build_installed_size_human + os.linesep
|
mail['log'] += \
|
||||||
body += 'Sources: ' + build_sources_size_human + os.linesep
|
'Maximum build usage: ' + build_max_size_human + os.linesep
|
||||||
body += 'Patches: ' + build_patches_size_human + os.linesep
|
mail['log'] += \
|
||||||
else:
|
'Total size: ' + build_total_size_human + os.linesep
|
||||||
body += 'No packages built'
|
mail['log'] += \
|
||||||
body += os.linesep
|
'Installed : ' + build_installed_size_human + os.linesep
|
||||||
body += 'Output' + os.linesep
|
mail['log'] += 'Sources: ' + build_sources_size_human + os.linesep
|
||||||
body += '======' + os.linesep + os.linesep
|
mail['log'] += 'Patches: ' + build_patches_size_human + os.linesep
|
||||||
body += os.linesep.join(mail['output'].get())
|
mail['log'] += os.linesep
|
||||||
body += os.linesep + os.linesep
|
mail['log'] += 'Output' + os.linesep
|
||||||
body += 'Report' + os.linesep
|
mail['log'] += '======' + os.linesep + os.linesep
|
||||||
body += '======' + os.linesep + os.linesep
|
mail['log'] += os.linesep.join(mail['output'].get())
|
||||||
body += self.get_mail_report()
|
mail['log'] += os.linesep + os.linesep
|
||||||
if not opts.dry_run():
|
mail['log'] += 'Report' + os.linesep
|
||||||
mail['mail'].send(mail['to'], mail_subject, body)
|
mail['log'] += '======' + os.linesep + os.linesep
|
||||||
|
mail['reports'] += [self.get_mail_report()]
|
||||||
|
if self.build_failure is not None:
|
||||||
|
mail['failure'] = self.build_failure
|
||||||
|
if self.mail_active(mail, nesting_count):
|
||||||
|
self.mail_send(mail)
|
||||||
log.notice('Build Set: Time %s' % (build_time))
|
log.notice('Build Set: Time %s' % (build_time))
|
||||||
|
|
||||||
def list_bset_cfg_files(opts, configs):
|
def list_bset_cfg_files(opts, configs):
|
||||||
@ -662,7 +681,10 @@ def run():
|
|||||||
opts = options.load(sys.argv, optargs)
|
opts = options.load(sys.argv, optargs)
|
||||||
if opts.get_arg('--mail'):
|
if opts.get_arg('--mail'):
|
||||||
mail = { 'mail' : mailer.mail(opts),
|
mail = { 'mail' : mailer.mail(opts),
|
||||||
'output': log_capture() }
|
'output' : log_capture(),
|
||||||
|
'log' : '',
|
||||||
|
'reports': [],
|
||||||
|
'failure': None }
|
||||||
to_addr = opts.get_arg('--mail-to')
|
to_addr = opts.get_arg('--mail-to')
|
||||||
if to_addr is not None:
|
if to_addr is not None:
|
||||||
mail['to'] = to_addr[1]
|
mail['to'] = to_addr[1]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user