Code

checkins for internationalization
[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} [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
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
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 the Nagiosplug dist tarball
47         make dist
49         # End ssh
50         EOF
51 }
53 # Set working variables
54 PROJECT=nagiosplug
55 IN=${HOME}/tmp_snapshot
56 OUT_SERVER="shell.sf.net"
57 OUT="/home/groups/n/na/nagiosplug/htdocs/snapshot"
58 CF="usf-cf-x86-linux-2"
59 DS=`date -u +%Y%m%d%H%M`
61 # Make dists for HEAD and any others in command parameters
62 make_dist
63 for i in $* ; do
64         make_dist $i
65 done
67 # Check for *.gz files locally (expect NFS between cf shell server and $CF)
68 set -x
69 files=$(ls $IN/*/$PROJECT/*.gz 2>/dev/null)
70 [[ -z $files ]] && die "No files created"
71 ssh $OUT_SERVER "rm -f $OUT/*.gz"
72 scp $files $OUT_SERVER:$OUT
74 # Create MD5 sum
75 ssh $OUT_SERVER << EOF
76 cd $OUT
77 cat <<-END_README > README
78 This is the daily CVS snapshot of nagiosplug, consisting of the CVS HEAD
79 and any other branches
80 The MD5SUM is:
81 END_README
82 md5sum *.gz | tee -a README > MD5SUM
83 EOF
85 rm -f $files
87 # Work out success or failure
88 expected=$(($# + 1))
89 set -- $files
90 [[ $# -ne $expected ]] && die "Expected $expected, got $#"
91 exit 0