Code

Patch to workaround SFnot having libtool installed
[nagiosplug.git] / tools / sfsnapshot
1 #! /bin/bash
3 # Butchered version of snapshot
4 # Can only run on the shell compile farm server
5 # Will always create a snapshot of HEAD
6 # If want multiple snapshots, just run with "sfsnapshot [branch ...]"
7 # Assumes:
8 #  ssh setup to send to shell.sf.net and $CF without password prompt
9 #  the compile server has all the prerequisites stated at http://nagiosplug.sourceforge.net/developer-guidelines.html
10 # Install in cron with something like:
11 #  47 * * * * $HOME/bin/mail_error -o $HOME/sfsnapshot.out -m tonvoon@users.sf.net sfsnapshot r1_3_0
13 function die { echo $1; exit 1; }
15 # This makes the distribution. Expects $1 as CVS tag, otherwise uses HEAD
16 function make_dist {
17         if [[ -n $1 ]] ; then
18                 cvs_rel=$1
19                 v="$1-"
20         else
21                 cvs_rel="HEAD"
22                 v="HEAD-"
23         fi
24         
25         # Get compile server to do the work
26         # Variables will be expanded locally before being run on $CF
27         ssh $CF <<EOF
28         set -x
29         PATH=$PATH:/usr/local/bin
30         [[ ! -d $COMPILE_DIR/$cvs_rel ]] && mkdir -p $COMPILE_DIR/$cvs_rel
31         cd $COMPILE_DIR/$cvs_rel
33         # Cannot use cvs export due to conflicts on second run - think this is better for cvs server
34         CVS_RSH=ssh cvs -z3 -d:ext:tonvoon@cvs.sourceforge.net:/cvsroot/nagiosplug co -r $cvs_rel nagiosplug
36         cd $PROJECT
38         tools/setup
40         ./configure
42         # Make the Nagiosplug dist tarball
43         make dist VERSION=$v$DS RELEASE=snapshot
45         # May fail if file not generated - do not trap
46         mv *.gz $IN
48         rm -rf $COMPILE_DIR
49         # End ssh
50 EOF
51 }
53 # Set working variables
54 PROJECT=nagiosplug
56 # This is local to the compile server for faster compile
57 COMPILE_DIR=/tmp/tonvoon/tmp_snapshot
59 #  Needs to be on NFS so gz file can be read on the compile shell server
60 IN=${HOME}/tmp_snapshot
62 # Where to place the generated files
63 OUT_SERVER="shell.sf.net"
64 OUT="/home/groups/n/na/nagiosplug/htdocs/snapshot"
66 # Make sure prereqs are satisfied on server!
67 CF="amd64-linux2"
68 DS=`date -u +%Y%m%d%H%M`
70 # Setup home directory area
71 [[ ! -d $IN ]] && mkdir -p $IN
73 # Make dists for HEAD and any others in command parameters
74 make_dist
75 for i in $* ; do
76         make_dist $i
77 done
79 # Check for *.gz files locally (expect NFS between cf shell server and $CF)
80 set -x
81 files=$(ls $IN/*.gz 2>/dev/null)
82 [[ -z $files ]] && die "No files created"
83 head_file=$(cd $IN && ls *HEAD*.gz 2>/dev/null)
84 ssh -2 $OUT_SERVER "rm -f $OUT/*.gz"
85 scp -2 $files $OUT_SERVER:$OUT
86 if [[ -n $head_file ]] ; then
87         ssh -2 $OUT_SERVER "cd $OUT && ln -s $head_file nagios-plugins-HEAD.tar.gz"
88 fi
90 # Create MD5 sum
91 ssh -2 $OUT_SERVER << EOF
92 cd $OUT
93 cat <<-END_README > README
94 This is the daily CVS snapshot of nagiosplug, consisting of the CVS HEAD
95 and any other branches.
97 The nagios-plugins-HEAD.tar.gz link will always go to the latest HEAD snapshot.
99 The MD5SUM is:
100 END_README
101 md5sum *.gz | tee -a README > MD5SUM
102 EOF
104 rm -f $files
106 # Work out success or failure
107 expected=$(($# + 1))
108 set -- $files
109 [[ $# -ne $expected ]] && die "Expected $expected, got $#"
110 exit 0