1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
#!/bin/bash -
# libguestfs autobuild script
# Copyright (C) 2009-2012 Red Hat Inc.
#
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# This script is used to download and test the latest tarball on
# Debian and other platforms. It runs from a cron job and sends email
# to the mailing list about the status.
set -e
# Subject line of email prefix.
prefix="${1:-[autobuild]}"
# Where we send mail.
mailto="rjones@redhat.com"
# Move to temporary directory for building.
tmpdir="$(mktemp -d --tmpdir=/var/tmp)"
cd "$tmpdir"
# The libguestfs index page contains some hidden fields to help us
# find the latest version programmatically.
version=$(wget --no-cache -O- -q http://libguestfs.org |
grep '^LATEST-VERSION:' | awk '{print $2}')
url=$(wget --no-cache -O- -q http://libguestfs.org |
grep '^LATEST-URL:' | awk '{print $2}')
filename=$(basename "$url")
directory=$(basename "$url" .tar.gz)
echo "--------------------------------------------------"
echo "prefix $prefix"
echo "libguestfs $version"
echo "url $url"
echo "build dir $tmpdir/$directory"
echo "--------------------------------------------------"
# Grab the latest tarball from upstream.
wget "$url"
# Unpack the tarball.
tar zxf "$filename"
# Enter directory.
cd "$directory"
# This function is called if any step fails.
failed ()
{
tail -100 ../build.log > ../build.log.tail
mutt -s "$prefix libguestfs $version FAILED $1" "$mailto" -a ../build.log.tail <<EOF
Autobuild failed. The last 100 lines of the build log are
attached.
For the full log see the build machine, in
$tmpdir/build.log
EOF
rm ../build.log.tail
}
# This function is called if the build is successful.
ok ()
{
mutt -s "$prefix libguestfs $version ok" "$mailto" <<EOF
Autobuild was successful.
For the full log see the build machine, in
$tmpdir/build.log
EOF
}
# Ensure that we get full debugging output.
export LIBGUESTFS_DEBUG=1
export LIBGUESTFS_TRACE=1
# Configure and build.
echo "configure"
./configure > ../build.log 2>&1 || {
failed "configure"
exit 1
}
echo "make"
make >> ../build.log 2>&1 || {
failed "make"
exit 1
}
# Run the tests.
echo "make check"
make check >> ../build.log 2>&1 || {
failed "make check"
exit 1
}
echo "finished"
ok
|