60b2cef9e22b4355226ea21d9f9b93854174e7e7
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 aclocal -I lib
44 autoheader
45 autoconf
46 automake --add-missing --copy
47 autoreconf
48 ./configure
50 # Make the Nagiosplug dist tarball
51 make dist
53 # End ssh
54 EOF
55 }
57 # Set working variables
58 PROJECT=nagiosplug
59 IN=${HOME}/tmp_snapshot
60 OUT_SERVER="shell.sf.net"
61 OUT="/home/groups/n/na/nagiosplug/htdocs/snapshot"
62 CF="usf-cf-x86-linux-2"
63 DS=`date -u +%Y%m%d%H%M`
65 # Make dists for HEAD and any others in command parameters
66 make_dist
67 for i in $* ; do
68 make_dist $i
69 done
71 # Check for *.gz files locally (expect NFS between cf shell server and $CF)
72 set -x
73 files=$(ls $IN/*/$PROJECT/*.gz 2>/dev/null)
74 [[ -z $files ]] && die "No files created"
75 ssh $OUT_SERVER "rm -f $OUT/*.gz"
76 scp $files $OUT_SERVER:$OUT
78 # Create MD5 sum
79 ssh $OUT_SERVER << EOF
80 cd $OUT
81 md5sum *.gz > MD5SUM
82 EOF
84 rm -f $files
86 # Work out success or failure
87 expected=$(($# + 1))
88 set -- $files
89 [[ $# -ne $expected ]] && die "Expected $expected, got $#"
90 exit 0