2004-07-15 09:28:07 +04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2005-11-05 22:57:48 +03:00
|
|
|
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
# University Research and Technology
|
|
|
|
# Corporation. All rights reserved.
|
|
|
|
# Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
# of Tennessee Research Foundation. All rights
|
|
|
|
# reserved.
|
2014-10-02 03:32:52 +04:00
|
|
|
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
2004-11-28 23:09:25 +03:00
|
|
|
# University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
# Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
# All rights reserved.
|
2014-10-02 03:32:52 +04:00
|
|
|
# Copyright (c) 2006-2014 Cisco Systems, Inc. All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
# $COPYRIGHT$
|
2014-10-02 03:32:52 +04:00
|
|
|
#
|
2004-11-22 04:38:40 +03:00
|
|
|
# Additional copyrights may follow
|
2014-10-02 03:32:52 +04:00
|
|
|
#
|
2004-07-15 09:28:07 +04:00
|
|
|
# $HEADER$
|
|
|
|
#
|
2005-03-24 18:07:32 +03:00
|
|
|
# This script is used to create a nightly snapshot tarball of Open MPI.
|
2004-07-15 09:28:07 +04:00
|
|
|
#
|
|
|
|
# $1: scratch root
|
|
|
|
# $2: e-mail address for destination
|
2014-10-03 18:29:56 +04:00
|
|
|
# $3: dest dir
|
|
|
|
# $4: git URL
|
2014-10-02 03:32:52 +04:00
|
|
|
# $5: git branch
|
2004-07-15 09:28:07 +04:00
|
|
|
#
|
|
|
|
|
2014-10-02 03:32:52 +04:00
|
|
|
scratch_root=$1
|
|
|
|
email=$2
|
|
|
|
destdir=$3
|
|
|
|
giturl=$4
|
|
|
|
gitbranch=$5
|
2004-07-15 09:28:07 +04:00
|
|
|
|
|
|
|
# Set this to any value for additional output; typically only when
|
|
|
|
# debugging
|
2010-09-18 13:23:11 +04:00
|
|
|
debug=1
|
2004-07-15 09:28:07 +04:00
|
|
|
|
2004-07-15 15:36:17 +04:00
|
|
|
# do you want a success mail?
|
|
|
|
want_success_mail=1
|
|
|
|
|
2004-08-23 10:35:28 +04:00
|
|
|
# max length of logfile to send in an e-mail
|
|
|
|
max_log_len=50
|
|
|
|
|
2004-07-15 15:36:17 +04:00
|
|
|
# how many snapshots to keep in the destdir?
|
2004-07-15 23:16:24 +04:00
|
|
|
max_snapshots=5
|
2004-07-15 15:36:17 +04:00
|
|
|
|
|
|
|
############################################################################
|
|
|
|
# Shouldn't need to change below this line
|
|
|
|
############################################################################
|
|
|
|
|
2004-07-15 09:28:07 +04:00
|
|
|
start_time="`date`"
|
|
|
|
|
|
|
|
# Sanity checks
|
2014-10-02 03:32:52 +04:00
|
|
|
if test -z "$scratch_root" -o -z "$email" -o -z "$giturl" -o -z "$gitbranch" \
|
2004-07-15 09:28:07 +04:00
|
|
|
-o -z "$destdir"; then
|
2014-10-02 03:32:52 +04:00
|
|
|
echo "$0 scratch_root email_addr dest_dir git_url git_branch"
|
2004-07-15 09:28:07 +04:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2014-10-02 03:32:52 +04:00
|
|
|
# Use the branch name as the "version" string (for if there is an
|
|
|
|
# error). This version string will be replaced upon successful "make
|
|
|
|
# distcheck" with the real version.
|
|
|
|
version=$gitbranch
|
2008-07-26 17:31:06 +04:00
|
|
|
|
2004-07-15 09:28:07 +04:00
|
|
|
# send a mail
|
2004-07-15 23:16:24 +04:00
|
|
|
# should only be called after logdir is set
|
2004-07-15 17:53:44 +04:00
|
|
|
send_error_mail() {
|
2004-07-15 09:57:03 +04:00
|
|
|
outfile="$scratch_root/output.txt"
|
|
|
|
rm -f "$outfile"
|
|
|
|
touch "$outfile"
|
2004-07-15 23:16:24 +04:00
|
|
|
for file in `/bin/ls $logdir/* | sort`; do
|
2004-08-23 10:35:28 +04:00
|
|
|
len="`wc -l $file | awk '{ print $1}'`"
|
|
|
|
if test "`expr $len \> $max_log_len`" = "1"; then
|
|
|
|
echo "[... previous lines snipped ...]" >> "$outfile"
|
2004-11-17 14:31:22 +03:00
|
|
|
tail -n $max_log_len "$file" >> "$outfile"
|
2004-08-23 10:35:28 +04:00
|
|
|
else
|
|
|
|
cat "$file" >> "$outfile"
|
|
|
|
fi
|
2004-07-15 09:57:03 +04:00
|
|
|
done
|
2008-07-26 18:13:20 +04:00
|
|
|
Mail -s "=== CREATE FAILURE ($version) ===" "$email" < "$outfile"
|
2004-07-15 09:57:03 +04:00
|
|
|
rm -f "$outfile"
|
2004-07-15 09:28:07 +04:00
|
|
|
}
|
|
|
|
|
2004-07-15 17:53:44 +04:00
|
|
|
# send output error message
|
|
|
|
die() {
|
|
|
|
msg="$*"
|
2004-07-15 23:16:24 +04:00
|
|
|
cat > "$logdir/00_announce.txt" <<EOF
|
2004-07-15 17:53:44 +04:00
|
|
|
Creating the nightly tarball ended in error:
|
|
|
|
|
|
|
|
$msg
|
|
|
|
EOF
|
|
|
|
send_error_mail
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2004-07-15 09:28:07 +04:00
|
|
|
# do the work
|
2004-07-15 23:16:24 +04:00
|
|
|
# should only be called after logdir is set
|
2004-07-15 09:28:07 +04:00
|
|
|
do_command() {
|
|
|
|
cmd="$*"
|
2004-07-15 23:16:24 +04:00
|
|
|
logfile="$logdir/20-command.txt"
|
2004-07-15 09:28:07 +04:00
|
|
|
rm -f "$logfile"
|
|
|
|
if test -n "$debug"; then
|
|
|
|
echo "*** Running command: $cmd"
|
2004-07-15 23:16:24 +04:00
|
|
|
eval $cmd > "$logfile" 2>&1
|
2004-07-15 09:28:07 +04:00
|
|
|
st=$?
|
|
|
|
echo "*** Command complete: exit status: $st"
|
|
|
|
else
|
|
|
|
eval $cmd > "$logfile" 2>&1
|
|
|
|
st=$?
|
|
|
|
fi
|
|
|
|
if test "$st" != "0"; then
|
2004-07-15 23:16:24 +04:00
|
|
|
cat > "$logdir/15-error.txt" <<EOF
|
2004-07-15 09:28:07 +04:00
|
|
|
|
2008-07-26 18:13:20 +04:00
|
|
|
ERROR: Command returned a non-zero exist status ($version):
|
2004-07-15 09:28:07 +04:00
|
|
|
$cmd
|
|
|
|
|
|
|
|
Start time: $start_time
|
|
|
|
End time: `date`
|
|
|
|
|
|
|
|
=======================================================================
|
|
|
|
EOF
|
2004-07-15 23:16:24 +04:00
|
|
|
cat > "$logdir/25-error.txt" <<EOF
|
2004-07-15 09:28:07 +04:00
|
|
|
=======================================================================
|
|
|
|
|
|
|
|
Your friendly daemon,
|
|
|
|
Cyrador
|
|
|
|
EOF
|
2004-07-15 17:53:44 +04:00
|
|
|
send_error_mail
|
|
|
|
exit 1
|
2004-07-15 09:28:07 +04:00
|
|
|
fi
|
|
|
|
rm -f "$logfile"
|
|
|
|
}
|
|
|
|
|
|
|
|
# see if the destination directory exists
|
|
|
|
if test ! -d "$destdir"; then
|
|
|
|
mkdir -p "$destdir"
|
|
|
|
fi
|
|
|
|
if test ! -d "$destdir"; then
|
2004-07-15 17:53:44 +04:00
|
|
|
die "Could not cd to dest dir: $destdir"
|
2004-07-15 09:28:07 +04:00
|
|
|
fi
|
|
|
|
|
2011-06-06 23:09:32 +04:00
|
|
|
# make sure we can write to the destdir
|
|
|
|
file="$destdir/test-write.$$"
|
|
|
|
touch "$file"
|
|
|
|
if test ! -f "$file"; then
|
|
|
|
die "Could not write to the dest dir: $destdir"
|
|
|
|
fi
|
|
|
|
rm -f "$file"
|
|
|
|
|
2004-07-15 23:16:24 +04:00
|
|
|
# move into the scratch directory and ensure we have an absolute
|
|
|
|
# pathname for it
|
2004-07-15 09:28:07 +04:00
|
|
|
if test ! -d "$scratch_root"; then
|
|
|
|
mkdir -p "$scratch_root"
|
|
|
|
fi
|
|
|
|
if test ! -d "$scratch_root"; then
|
2004-07-15 17:53:44 +04:00
|
|
|
die "Could not cd to scratch root: $scratch_root"
|
2004-07-15 09:28:07 +04:00
|
|
|
fi
|
|
|
|
cd "$scratch_root"
|
2004-07-15 23:16:24 +04:00
|
|
|
scratch_root="`pwd`"
|
2004-07-15 09:28:07 +04:00
|
|
|
|
2014-10-02 03:32:52 +04:00
|
|
|
# setup target directory where clone+logs will go
|
2014-10-02 23:53:25 +04:00
|
|
|
clone_root="$scratch_root/ompi-`date +%Y-%m-%d-%H%M%S`"
|
2014-10-02 03:32:52 +04:00
|
|
|
rm -rf $clone_root
|
|
|
|
mkdir -p $clone_root
|
|
|
|
|
|
|
|
# startup the logfile (must be before do_command)
|
|
|
|
logdir="$clone_root/logs"
|
|
|
|
mkdir "$logdir"
|
|
|
|
|
|
|
|
# Get a fresh git clone
|
|
|
|
cd $clone_root
|
2014-10-02 23:53:25 +04:00
|
|
|
do_command "git clone $giturl ompi"
|
|
|
|
cd ompi
|
2014-10-02 03:32:52 +04:00
|
|
|
do_command "git checkout $gitbranch"
|
|
|
|
|
2014-10-02 23:53:25 +04:00
|
|
|
# Find the "git describe" string for this branch (remove a leading "ompi-"
|
2014-10-02 03:32:52 +04:00
|
|
|
# prefix, if there is one).
|
2014-10-02 23:53:25 +04:00
|
|
|
describe=`git describe --tags --always | sed -e s/^ompi-//`
|
2006-08-27 17:53:35 +04:00
|
|
|
if test -n "$debug"; then
|
2014-10-02 03:32:52 +04:00
|
|
|
echo "** found $gitbranch describe: $describe"
|
2006-08-27 17:53:35 +04:00
|
|
|
fi
|
2014-10-02 03:32:52 +04:00
|
|
|
version=$describe
|
2004-07-15 23:16:24 +04:00
|
|
|
|
2014-10-02 03:32:52 +04:00
|
|
|
# if there's a $destdir/latest_snapshot.txt, see if anything has
|
|
|
|
# happened since the describe listed in that file
|
|
|
|
if test -f "$destdir/latest_snapshot.txt"; then
|
|
|
|
snapshot_describe=`cat $destdir/latest_snapshot.txt`
|
|
|
|
if test -n "$debug"; then
|
|
|
|
echo "** last snapshot describe: $snapshot_describe"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Do we need a new snapshot?
|
|
|
|
if test "$describe" = "$snapshot_describe"; then
|
|
|
|
if test -n "$debug"; then
|
|
|
|
echo "** git $gitbranch describe is same as latest_snapshot -- not doing anything"
|
|
|
|
fi
|
|
|
|
# Since we didn't do anything, there's no point in leaving the clone we
|
|
|
|
# just created
|
|
|
|
cd ..
|
|
|
|
rm -rf $clone_root
|
2004-07-15 09:28:07 +04:00
|
|
|
|
2014-10-02 03:32:52 +04:00
|
|
|
# All done... nothing to see here...
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test -n "$debug"; then
|
|
|
|
echo "** making snapshot for describe: $describe"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Ensure that VERSION is set to indicate that it wants a snapshot, and
|
2014-10-02 23:53:25 +04:00
|
|
|
# insert the actual value that we want (so that ompi_get_version.sh
|
2014-10-02 03:32:52 +04:00
|
|
|
# will report exactly that version).
|
2014-10-03 18:29:56 +04:00
|
|
|
sed -e 's/^repo_rev=.*/repo_rev='$describe/ \
|
|
|
|
-e 's/^tarball_version=.*/tarball_version='$describe/ \
|
2014-10-02 03:32:52 +04:00
|
|
|
VERSION > VERSION.new
|
|
|
|
cp -f VERSION.new VERSION
|
|
|
|
rm -f VERSION.new
|
2004-07-15 09:28:07 +04:00
|
|
|
|
2005-04-07 03:54:53 +04:00
|
|
|
# lie about our username in $USER so that autogen will skip all
|
2014-10-02 03:32:52 +04:00
|
|
|
# .ompi_ignore'ed directories (i.e., so that we won't get
|
2005-04-07 03:54:53 +04:00
|
|
|
# .ompi_unignore'ed)
|
|
|
|
USER="ompibuilder"
|
|
|
|
export USER
|
2005-04-01 05:14:13 +04:00
|
|
|
|
2004-07-15 09:28:07 +04:00
|
|
|
# autogen is our friend
|
2010-09-18 03:04:06 +04:00
|
|
|
do_command "./autogen.pl"
|
2004-07-15 09:28:07 +04:00
|
|
|
|
|
|
|
# do config
|
2014-10-03 18:29:56 +04:00
|
|
|
do_command "./configure"
|
2004-07-15 09:28:07 +04:00
|
|
|
|
2014-10-02 03:32:52 +04:00
|
|
|
# Do make distcheck (which will invoke config/distscript.csh to set
|
|
|
|
# the right values in VERSION). distcheck does many things; we need
|
|
|
|
# to ensure it doesn't pick up any other installs via LD_LIBRARY_PATH.
|
|
|
|
# It may be a bit Draconian to totally clean LD_LIBRARY_PATH (i.e., we
|
|
|
|
# may need something in there), but at least in the current building
|
|
|
|
# setup, we don't. But be advised that this may need to change in the
|
|
|
|
# future...
|
2005-10-01 14:18:55 +04:00
|
|
|
save=$LD_LIBRARY_PATH
|
|
|
|
LD_LIBRARY_PATH=
|
2014-04-19 19:47:32 +04:00
|
|
|
do_command "make -j 8 distcheck"
|
2005-10-01 14:18:55 +04:00
|
|
|
LD_LIBRARY_PATH=$save
|
|
|
|
save=
|
2004-07-15 09:28:07 +04:00
|
|
|
|
2014-10-02 03:32:52 +04:00
|
|
|
# chmod the whole directory, so that core files are accessible by others
|
|
|
|
chmod a+rX -R .
|
|
|
|
|
2004-07-15 09:28:07 +04:00
|
|
|
# move the resulting tarballs to the destdir
|
|
|
|
gz="`/bin/ls openmpi*tar.gz`"
|
|
|
|
bz2="`/bin/ls openmpi*tar.bz2`"
|
|
|
|
mv $gz $bz2 $destdir
|
2011-06-06 23:09:32 +04:00
|
|
|
if test "$?" != "0"; then
|
|
|
|
cat <<EOF
|
|
|
|
ERROR -- move final tarballs to web tree failed!
|
|
|
|
|
|
|
|
From: `pwd`
|
|
|
|
Files: $gz $bz2
|
|
|
|
To: $destdir
|
|
|
|
|
|
|
|
The nightly snapshots are therefore not available on the web!
|
|
|
|
EOF
|
|
|
|
die "Could not move final tarballs to web dir: $destdir"
|
|
|
|
fi
|
2004-07-15 09:28:07 +04:00
|
|
|
cd $destdir
|
2004-07-15 17:53:44 +04:00
|
|
|
|
|
|
|
# make the latest_snapshot.txt file containing the last version
|
|
|
|
version="`echo $gz | sed -e 's/openmpi-\(.*\)\.tar\.gz/\1/g'`"
|
|
|
|
rm -f latest_snapshot.txt
|
|
|
|
echo $version > latest_snapshot.txt
|
|
|
|
|
|
|
|
# trim the destdir to $max_snapshots
|
2004-07-15 23:16:24 +04:00
|
|
|
for ext in gz bz2; do
|
|
|
|
count="`ls openmpi*.tar.$ext | wc -l | awk '{ print $1 }'`"
|
|
|
|
if test "`expr $count \> $max_snapshots`" = "1"; then
|
|
|
|
num_old="`expr $count - $max_snapshots`"
|
2004-12-02 06:37:46 +03:00
|
|
|
old="`ls -rt openmpi*.tar.$ext | head -n $num_old`"
|
2004-07-15 23:16:24 +04:00
|
|
|
rm -f $old
|
|
|
|
fi
|
|
|
|
done
|
2004-07-15 09:28:07 +04:00
|
|
|
|
|
|
|
# generate md5 and sha1 sums
|
|
|
|
rm -f md5sums.txt sha1sums.txt
|
|
|
|
touch md5sums.txt sha1sums.txt
|
|
|
|
for file in `/bin/ls *gz *bz2 | grep -v latest`; do
|
|
|
|
md5sum $file >> md5sums.txt
|
|
|
|
sha1sum $file >> sha1sums.txt
|
|
|
|
done
|
|
|
|
|
2004-07-15 09:57:03 +04:00
|
|
|
# remove temp dirs
|
2004-07-15 23:16:24 +04:00
|
|
|
cd "$scratch_root"
|
|
|
|
rm -rf "$root"
|
2004-07-15 09:57:03 +04:00
|
|
|
|
2004-07-15 09:28:07 +04:00
|
|
|
# send success mail
|
2004-07-15 15:36:17 +04:00
|
|
|
if test "$want_success_mail" = "1"; then
|
2014-10-03 19:14:46 +04:00
|
|
|
Mail -s "Create success ($version)" "$email" <<EOF
|
|
|
|
Creating nightly snapshot tarball was a success.
|
2004-07-15 09:28:07 +04:00
|
|
|
|
2004-07-15 17:53:44 +04:00
|
|
|
Snapshot: $version
|
2004-07-15 09:28:07 +04:00
|
|
|
Start time: $start_time
|
|
|
|
End time: `date`
|
|
|
|
|
|
|
|
Your friendly daemon,
|
|
|
|
Cyrador
|
|
|
|
EOF
|
2004-07-15 15:36:17 +04:00
|
|
|
fi
|