[Libreoffice-commits] .: 3 commits - bin/tinbuild
Jan Holesovsky
kendy at kemper.freedesktop.org
Thu Feb 17 04:40:19 PST 2011
bin/tinbuild | 149 ++++++++++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 123 insertions(+), 26 deletions(-)
New commits:
commit 32a42cfab37b1f7d153bebe057aa326a661463cd
Author: Jan Holesovsky <kendy at suse.cz>
Date: Thu Feb 17 13:31:57 2011 +0100
tinbuild: Include all the logs in the mails.
diff --git a/bin/tinbuild b/bin/tinbuild
index 529de9c..819435f 100755
--- a/bin/tinbuild
+++ b/bin/tinbuild
@@ -161,19 +161,18 @@ sendTinderboxLog ()
GZLOG=
MESSAGE="
tinderbox: administrator: $OWNER
-tinderbox: builddate: deprecated
-tinderbox: starttime: `date '+%s' -d \"$STARTTIME\"`
tinderbox: buildname: $TINDERNAME
+tinderbox: tree: MASTER
+tinderbox: starttime: `date '+%s' -d \"$STARTTIME\"`
+tinderbox: timenow: `date '+%s'`
tinderbox: errorparser: unix
tinderbox: status: $STATUS
-tinderbox: timenow: `date '+%s'`
-tinderbox: tree: MASTER
tinderbox: END
"
- if [ -n "$3" -a -f "$3" ] ; then
- GZLOG="$LOG".gz
- ( echo "$MESSAGE" ; cat "$LOG" ) | gzip -c "$LOG" > "$GZLOG"
+ if [ "$LOG" = "yes" ] ; then
+ GZLOG="tinder.log.gz"
+ ( echo "$MESSAGE" ; cat autogen.log clean.log build.log smoketest.log install.log 2>/dev/null ) | gzip -c > "$GZLOG"
XTINDER=",'X-Tinder:'=>'gzookie'"
fi
@@ -234,8 +233,8 @@ while true; do
# try to build
build_status="build_failed"
- if ! err_msg=$(./autogen.sh 2>&1); then
- reportError committer "$rough_checkout_date" `printf "autogen.sh / configure failed - error is:\n\n$err_msg"`
+ if ! $NICE ./autogen.sh >autogen.log 2>&1 ; then
+ reportError committer "$rough_checkout_date" `printf "autogen.sh / configure failed - error is:\n\n"` "$(cat autogen.log)"
elif ! $NICE make clean >clean.log 2>&1 ; then
reportError committer "$rough_checkout_date" `printf "cleaning up failed - error is:\n\n"` "$(tail -n100 clean.log)"
elif ! $NICE make >build.log 2>&1 ; then
@@ -254,10 +253,10 @@ while true; do
fi
# send tinderbox mail
- sendTinderboxLog "$rough_checkout_date" "$build_status" "build.log"
+ sendTinderboxLog "$rough_checkout_date" "$build_status" "yes"
# save the old logs
- for I in clean.log build.log smoketest.log install.log ; do
+ for I in autogen.log clean.log build.log smoketest.log install.log ; do
mv $I prev-$I 2>/dev/null
done
commit 1dea17b6def808b29fdababb68c5b61bc81d3859
Author: Jan Holesovsky <kendy at suse.cz>
Date: Wed Feb 16 14:43:42 2011 +0100
tinbuild: Use MIME::Lite instead of direct Net::SMTP.
We need to send the build logs as gzipped attachments, otherwise they are too
big to be accepted by tinderbox.
diff --git a/bin/tinbuild b/bin/tinbuild
index 2b5c6b2..529de9c 100755
--- a/bin/tinbuild
+++ b/bin/tinbuild
@@ -31,7 +31,7 @@ getCommitters ()
{
from_date="$1"
- ./g -s log '--pretty=tformat:%ce' --after="$from_date" | sort | uniq | tr '\n' ' '
+ ./g -s log '--pretty=tformat:%ce' --after="$from_date" | sort | uniq | tr '\n' ','
}
sendMailMsg ()
@@ -39,36 +39,37 @@ sendMailMsg ()
TO="$1"
SUBJECT="$2"
HEADERS="$3"
+ LOG="$4"
perl -e "
+use MIME::Lite;
use Net::SMTP;
-\$smtp = Net::SMTP->new('$SMTP');
-
-# from
-\$smtp->mail('$OWNER');
-
-# to
- at to = split(' ', '$TO');
-print 'Sending mail to \"' . join(',', @to) . '\", subject \"$SUBJECT\"' . \"\n\";
-\$smtp->recipient(@to, { SkipBad => 1 });
-
-# headers
-\$smtp->data;
-
-\$smtp->datasend('From: $OWNER' . \"\n\");
-\$smtp->datasend('To: ' . join(',', @to) . \"\n\");
-\$smtp->datasend('Subject: $SUBJECT' . \"\n\");
-\$smtp->datasend('$HEADERS' . \"\n\") if (\"$HEADERS\" ne \"\");
-\$smtp->datasend(\"\n\");
-
-# body
+my \$text;
while (<>) {
- \$smtp->datasend(\$_);
+ \$text .= \$_;
+}
+
+\$msg = MIME::Lite->new(
+ From => '$OWNER',
+ To => '$TO',
+ Subject => '$SUBJECT',
+ Type => 'TEXT',
+ Data => \$text
+ $HEADERS
+) or die \"Error creating multipart container: \$!\n\";
+
+if ('$LOG' ne '' && -f '$LOG') {
+ \$msg->attach (
+ Type => 'application/x-gzip',
+ Path => '$LOG',
+ Filename => '$LOG',
+ Disposition => 'attachment'
+ ) or die \"Error adding $LOG: \$!\n\";
}
-# end
-\$smtp->dataend;
-\$smtp->quit;
+MIME::Lite->send('smtp', '$SMTP', Timeout=>60);
+\$msg->send;
+print 'Sent a mail to \"$TO\" with subject \"$SUBJECT\".' . \"\n\";
"
}
@@ -99,16 +100,22 @@ reportError ()
echo "$*" 1>&2
echo "Last success: $rough_time" 1>&2
if test -n "$to_mail" ; then
- cat <<EOF | sendMailMsg "$to_mail" "Tinderbox failure, $message" ""
+ TINDER1=
+ TINDER2=
+ if test "$SEND_MAIL" -eq 1 -a -n "$TINDERNAME" ; then
+ TINDER1=`echo -e "Full log available at http://tinderbox.go-oo.org/MASTER/status.html\n"`
+ TINDER2=`echo " Box name: $TINDERNAME"`
+ fi
+ cat <<EOF | sendMailMsg "$to_mail" "Tinderbox failure, $message"
Hi folks,
One of you broke the build of LibreOffice master with your commit :-(
Please commit and push a fix ASAP!
-Tinderbox info:
+${TINDER1}Tinderbox info:
- `uname -a`
-`grep '\$ \.\/configure' config.log`
+${TINDER2} `uname -a`
+ Configured with `cat autogen.lastrun`
Commits since the last success:
@@ -150,22 +157,27 @@ sendTinderboxLog ()
STATUS="$2"
LOG="$3"
- (
- cat <<EOF
-
+ XTINDER=",'X-Tinder:'=>'cookie'"
+ GZLOG=
+ MESSAGE="
tinderbox: administrator: $OWNER
tinderbox: builddate: deprecated
-tinderbox: starttime: `date '+%s' -d "$STARTTIME"`
+tinderbox: starttime: `date '+%s' -d \"$STARTTIME\"`
tinderbox: buildname: $TINDERNAME
tinderbox: errorparser: unix
tinderbox: status: $STATUS
tinderbox: timenow: `date '+%s'`
tinderbox: tree: MASTER
tinderbox: END
+"
-EOF
- [ -f "$LOG" ] && cat "$LOG"
- ) | sendMailMsg "tinderbox at gimli.documentfoundation.org" "tinderbox gzipped logfile" "X-Tinder: cookie"
+ if [ -n "$3" -a -f "$3" ] ; then
+ GZLOG="$LOG".gz
+ ( echo "$MESSAGE" ; cat "$LOG" ) | gzip -c "$LOG" > "$GZLOG"
+ XTINDER=",'X-Tinder:'=>'gzookie'"
+ fi
+
+ echo "$MESSAGE" | sendMailMsg "tinderbox at gimli.documentfoundation.org" "tinderbox gzipped logfile" "$XTINDER" "$GZLOG"
}
## code
@@ -234,7 +246,7 @@ while true; do
reportError committer "$rough_checkout_date" `printf "dev installation failed - error is:\n\n"` "$(tail -n100 install.log)"
else
echo "Build done - checkout from $rough_checkout_date successful."
- gitHeads > build/git-heads.txt
+ gitHeads > prev-git-heads.txt
prev_success=$last_success
last_success=$rough_checkout_date
commit 6f62ab120bb379ddb5220259bddff4a8a0824142
Author: Jan Holesovsky <kendy at suse.cz>
Date: Wed Feb 16 09:58:25 2011 +0100
tinbuild: Plug into http://tinderbox.go-oo.org/MASTER/status.html
And also rewrite the mail sending code, to be cross-platform [hopefully ;-)] -
using Perl Net::SMTP module.
diff --git a/bin/tinbuild b/bin/tinbuild
index 802de44..2b5c6b2 100755
--- a/bin/tinbuild
+++ b/bin/tinbuild
@@ -9,25 +9,67 @@ SEND_MAIL=0
NICE=
OWNER=
MACHINE=`uname`
+SMTP=
+TINDERNAME=
## subroutines
usage ()
{
echo "Usage: $0 [options]"
echo "Options:"
- echo "-w <N> specify timeout in secs between subsequent pull requests"
- echo "-i when given: run with ionice -c3, can be combined with -n"
- echo "-l when given: write html build log"
- echo "-m <owner> when given: mail errors to the committer, general errors to the <owner>"
- echo "-n when given: run with nice, can be combined with -i"
echo "-h this help"
+ echo "-i run with ionice -c3, can be combined with -n"
+ echo "-l write html build log"
+ echo "-m <owner> mail errors to the committer, general errors to the <owner>"
+ echo "-n run with nice, can be combined with -i"
+ echo "-s <host> SMTP server"
+ echo "-t <name> send tinderbox mails, identify self as <name>"
+ echo "-w <N> specify timeout in secs between subsequent pull requests"
}
getCommitters ()
{
from_date="$1"
- ./g -s log '--pretty=tformat:%ce' --after="$from_date" | sort | uniq
+ ./g -s log '--pretty=tformat:%ce' --after="$from_date" | sort | uniq | tr '\n' ' '
+}
+
+sendMailMsg ()
+{
+ TO="$1"
+ SUBJECT="$2"
+ HEADERS="$3"
+ perl -e "
+use Net::SMTP;
+
+\$smtp = Net::SMTP->new('$SMTP');
+
+# from
+\$smtp->mail('$OWNER');
+
+# to
+ at to = split(' ', '$TO');
+print 'Sending mail to \"' . join(',', @to) . '\", subject \"$SUBJECT\"' . \"\n\";
+\$smtp->recipient(@to, { SkipBad => 1 });
+
+# headers
+\$smtp->data;
+
+\$smtp->datasend('From: $OWNER' . \"\n\");
+\$smtp->datasend('To: ' . join(',', @to) . \"\n\");
+\$smtp->datasend('Subject: $SUBJECT' . \"\n\");
+\$smtp->datasend('$HEADERS' . \"\n\") if (\"$HEADERS\" ne \"\");
+\$smtp->datasend(\"\n\");
+
+# body
+while (<>) {
+ \$smtp->datasend(\$_);
+}
+
+# end
+\$smtp->dataend;
+\$smtp->quit;
+"
}
reportError ()
@@ -35,7 +77,7 @@ reportError ()
error_kind="$1"
shift
- rough_time="$2"
+ rough_time="$1"
shift
to_mail=
@@ -57,9 +99,7 @@ reportError ()
echo "$*" 1>&2
echo "Last success: $rough_time" 1>&2
if test -n "$to_mail" ; then
- subject="Tinderbox failure, $message"
- (
- cat <<EOF
+ cat <<EOF | sendMailMsg "$to_mail" "Tinderbox failure, $message" ""
Hi folks,
One of you broke the build of LibreOffice master with your commit :-(
@@ -78,7 +118,6 @@ The error is:
$*
EOF
- ) | mail -r "$OWNER" -s "$subject" $to_mail
else
echo "$*" 1>&2
if test "$error_kind" = "owner" ; then
@@ -92,15 +131,54 @@ gitHeads ()
./g rev-parse --verify HEAD
}
+currentTime ()
+{
+ if [ "X$MACHINE" == "XDarwin" ] ; then
+ date -u '+%Y-%m-%d %H:%M:%S'
+ else
+ date --utc --rfc-3339=seconds
+ fi
+}
+
+sendTinderboxLog ()
+{
+ if test "$SEND_MAIL" -ne 1 -o -z "$TINDERNAME" ; then
+ return 0
+ fi
+
+ STARTTIME="$1"
+ STATUS="$2"
+ LOG="$3"
+
+ (
+ cat <<EOF
+
+tinderbox: administrator: $OWNER
+tinderbox: builddate: deprecated
+tinderbox: starttime: `date '+%s' -d "$STARTTIME"`
+tinderbox: buildname: $TINDERNAME
+tinderbox: errorparser: unix
+tinderbox: status: $STATUS
+tinderbox: timenow: `date '+%s'`
+tinderbox: tree: MASTER
+tinderbox: END
+
+EOF
+ [ -f "$LOG" ] && cat "$LOG"
+ ) | sendMailMsg "tinderbox at gimli.documentfoundation.org" "tinderbox gzipped logfile" "X-Tinder: cookie"
+}
+
## code
-while getopts hilm:nw: opt ; do
+while getopts hilm:ns:t:w: opt ; do
case "$opt" in
- w) PAUSE_SECONDS="$OPTARG" ;;
+ h) usage; exit ;;
i) NICE="$NICE ionice -c3" ;;
l) HTML_OUTPUT=1 ;;
m) SEND_MAIL=1 ; OWNER="$OPTARG" ;;
n) NICE="$NICE nice" ;;
- h) usage; exit ;;
+ s) SMTP="$OPTARG" ;;
+ t) TINDERNAME="$OPTARG" ;;
+ w) PAUSE_SECONDS="$OPTARG" ;;
?) usage; exit ;;
esac
done
@@ -116,6 +194,10 @@ if test "$SEND_MAIL" -eq 1 ; then
echo "Owner not set."
exit 1
fi
+ if test -z "$SMTP" ; then
+ echo "SMTP server not set."
+ exit 1
+ fi
if test "$OWNER" = `echo ${OWNER} | sed 's/\@/_/g'` ; then
echo "The owner address '$OWNER' does not look like an email address."
exit 1
@@ -135,12 +217,11 @@ while true; do
$NICE make clean-local
# FIXME we need a more exact way to determine a 'good' date; this is not accurate
- if [ "X$MACHINE" == "XDarwin" ] ; then
- rough_checkout_date="`date -u '+%Y-%m-%d %H:%M:%S'`"
- else
- rough_checkout_date="`date --utc --rfc-3339=seconds`"
- fi
+ rough_checkout_date="`currentTime`"
+ sendTinderboxLog "$rough_checkout_date" "building"
+
# try to build
+ build_status="build_failed"
if ! err_msg=$(./autogen.sh 2>&1); then
reportError committer "$rough_checkout_date" `printf "autogen.sh / configure failed - error is:\n\n$err_msg"`
elif ! $NICE make clean >clean.log 2>&1 ; then
@@ -157,8 +238,13 @@ while true; do
prev_success=$last_success
last_success=$rough_checkout_date
+ build_status="success"
fi
+ # send tinderbox mail
+ sendTinderboxLog "$rough_checkout_date" "$build_status" "build.log"
+
+ # save the old logs
for I in clean.log build.log smoketest.log install.log ; do
mv $I prev-$I 2>/dev/null
done
More information about the Libreoffice-commits
mailing list