Code

Adds MD5SUM file, creates multiple branch snapshots and doesn't
[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
11 function die { echo $1; exit 1; }
13 # This makes the distribution. Expects $1 as CVS tag, otherwise uses HEAD
14 function make_dist {
15         if [[ -n $1 ]] ; then
16                 cvs_rel=$1
17                 v="$1-"
18         else
19                 cvs_rel="HEAD"
20                 v=""
21         fi
22         
23         # Get compile server to do the work
24         # Variables will be expanded locally before being run on $CF
25         ssh $CF <<-EOF
26         set -x
27         PATH=$PATH
28         [[ ! -d $IN/$cvs_rel ]] && mkdir -p $IN/$cvs_rel
29         cd $IN/$cvs_rel
30         if [[ -d $PROJECT ]] ; then
31                 cd $PROJECT 
32                 cvs update -r $cvs_rel
33         else
34                 cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/nagiosplug co -r $cvs_rel nagiosplug
35                 cd $PROJECT
36                 aclocal
37                 autoheader
38                 autoconf
39                 automake
40                 autoreconf
41                 ./configure
42         fi
44         # Make the Nagiosplug dist tarball
45         VER=$v$DS VERSION=$v$DS REL=snapshot make -e dist
47         # End ssh
48         EOF
49 }
51 # Set working variables
52 PROJECT=nagiosplug
53 IN=${HOME}/tmp_snapshot
54 OUT_SERVER="shell.sf.net"
55 #OUT="/home/groups/n/na/nagiosplug/htdocs/snapshot"
56 OUT="~/test"
57 CF="usf-cf-x86-linux-2"
58 DS=`date -u +%Y%m%d%H%M`
60 # Make dists for HEAD and any others in command parameters
61 make_dist
62 for i in $* ; do
63         make_dist $i
64 done
66 # Check for *.gz files locally (expect NFS between cf shell server and $CF)
67 set -x
68 files=$(ls $IN/*/$PROJECT/*.gz 2>/dev/null)
69 [[ -z $files ]] && die "No files created"
70 ssh $OUT_SERVER "rm -f $OUT/*.gz"
71 scp $files $OUT_SERVER:$OUT
73 # Create MD5 sum
74 ssh $OUT_SERVER << EOF
75 cd $OUT
76 md5sum *.gz > MD5SUM
77 EOF
79 rm -f $files