7714aef49f3dbd746e454048535ff1232e423cdb
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} [branch2 ...]"
7 # Assumes:
8 # ssh setup to send to shell.sf.net and $CF without password prompt
9 # autconf and automake installed on shell cf at v 2.57 & 1.72 and in PATH
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=""
23 fi
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
30 [[ ! -d $IN/$cvs_rel ]] && mkdir -p $IN/$cvs_rel
31 cd $IN/$cvs_rel
32 if [[ -d $PROJECT ]] ; then
33 cd $PROJECT
34 rm configure.in
35 cvs update -r $cvs_rel
36 else
37 cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/nagiosplug co -r $cvs_rel nagiosplug
38 cd $PROJECT
39 fi
41 sed 's/^VER=.*/VER=$v$DS/;s/^REL=.*/REL=snapshot/' configure.in > configure.tmp
42 mv configure.tmp configure.in
43 tools/setup
44 ./configure
46 make
48 # Make the Nagiosplug dist tarball
49 make dist
51 # End ssh
52 EOF
53 }
55 # Set working variables
56 PROJECT=nagiosplug
57 IN=${HOME}/tmp_snapshot
58 OUT_SERVER="shell.sf.net"
59 OUT="/home/groups/n/na/nagiosplug/htdocs/snapshot"
60 CF="usf-cf-x86-linux-2"
61 DS=`date -u +%Y%m%d%H%M`
63 # Make dists for HEAD and any others in command parameters
64 make_dist
65 for i in $* ; do
66 make_dist $i
67 done
69 # Check for *.gz files locally (expect NFS between cf shell server and $CF)
70 set -x
71 files=$(ls $IN/*/$PROJECT/*.gz 2>/dev/null)
72 [[ -z $files ]] && die "No files created"
73 ssh $OUT_SERVER "rm -f $OUT/*.gz"
74 scp $files $OUT_SERVER:$OUT
76 # Create MD5 sum
77 ssh $OUT_SERVER << EOF
78 cd $OUT
79 cat <<-END_README > README
80 This is the daily CVS snapshot of nagiosplug, consisting of the CVS HEAD
81 and any other branches
82 The MD5SUM is:
83 END_README
84 md5sum *.gz | tee -a README > MD5SUM
85 EOF
87 rm -f $files
89 # Work out success or failure
90 expected=$(($# + 1))
91 set -- $files
92 [[ $# -ne $expected ]] && die "Expected $expected, got $#"
93 exit 0