1 # tbox.sh - Shell functions to manage tinderbox build reporting
2 # Copyright (C) 2002 Cluster File Systems, Inc.
3 # Gord Eagle <gord@clusterfs.com>, 2002-08-22
6 PROGNAME=`echo "$0" | sed -e 's%^.*/%%'`
7 MAILPROG="${MAILPROG-mail}"
9 TBOX_PHASE=build # or test
10 TBOX_STARTTIME=`date +%s`
11 TBOX_LOG="${TBOX_LOG-/tmp/tbox.$$.$TBOX_STARTTIME.log}"
12 TBOX_BUILDMAIL=tinderbox_builds@lustre.org
13 TBOX_BUILDNAME="${TBOX_BUILDNAME-$PROGNAME-$HOSTNAME}"
15 # Send a status message to the list.
17 [ -n "$TBOX_BUILDNAME" -a -n "$TBOX_BUILDMAIL" ] || return 0
18 [ "$#" -ge 4 ] || return 1
19 if [ "$#" -gt 4 ]; then
31 echo "sending tinderbox mail to $TBOX_BUILDMAIL: $TREE $SUBJECT $STATUS"
33 TMPFILE="/tmp/tinderbox.boilerplate.$$.$TIMENOW"
36 tinderbox: tree: $TREE
37 tinderbox: starttime: $TBOX_STARTTIME
38 tinderbox: timenow: $TIMENOW
39 tinderbox: builddate: $TBOX_STARTTIME
40 tinderbox: status: $STATUS
41 tinderbox: buildname: $TBOX_BUILDNAME
42 tinderbox: errorparser: unix
47 cat $TMPFILE $log | $MAILPROG -s "build $SUBJECT ($TBOX_BUILDNAME)" $TBOX_BUILDMAIL
51 # Send out the failure or success message based on exit status.
56 if [ $CODE -eq 0 ]; then
61 STATUS="${TBOX_PHASE}_failed"
64 # Send off the status message.
66 tbox_status "$TREE" "$SUBJECT" "$STATUS"
69 # Wait for tail to display all output, then finish it.
75 # Run a subprogram, but stop it from sending its own tinderbox
78 # This probably doesn't do what you think it does... it only prepends
79 # TBOX_LOG= to our arguments.
82 # Now evaluate the command.
86 # Start the log for a given tree.
90 # Send status messages to stdout, stderr.
93 [ -n "$TBOX_LOG" ] || return 0
95 # Initialize the output log file.
98 # Send all our output to the log.
101 # Monitor it on the old stdout.
102 tail -f $TBOX_LOG 1>&6 &
104 # Allow tail to print our last output before exiting.
105 trap "tbox_exit \"$TREE\" $! 1" 1 2 10 15
106 trap "tbox_exit \"$TREE\" $!" 0
110 # Begin writing to the log and send out the initial status.
114 tbox_start_log "$TREE"
115 tbox_status "$TREE" starting building "$TBOX_STARTTIME"