aboutsummaryrefslogtreecommitdiff
path: root/tools/sfsnapshot
blob: b50cf22e2581ca1cec3e07cd4c734d3432915a05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#! /bin/bash

# Butchered version of snapshot
# Can only run on the shell compile farm server
# Will always create a snapshot of HEAD
# If want multiple snapshots, just run with "sfsnapshot {branch} [branch2 ...]"
# Assumes:
#  ssh setup to send to shell.sf.net and $CF without password prompt
#  autconf and automake installed on shell cf at v 2.57 & 1.72 and in PATH
# Install in cron with something like:
#  47 * * * * $HOME/bin/mail_error -o $HOME/sfsnapshot.out -m tonvoon@users.sf.net sfsnapshot r1_3_0

function die { echo $1; exit 1; }

# This makes the distribution. Expects $1 as CVS tag, otherwise uses HEAD
function make_dist {
	if [[ -n $1 ]] ; then
		cvs_rel=$1
		v="$1-"
	else
		cvs_rel="HEAD"
		v=""
	fi
	
	# Get compile server to do the work
	# Variables will be expanded locally before being run on $CF
	ssh $CF <<EOF
	set -x
	PATH=$PATH
	[[ ! -d $IN/$cvs_rel ]] && mkdir -p $IN/$cvs_rel
	cd $IN/$cvs_rel
	rm -f $PROJECT/configure.in
	cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/nagiosplug co -r $cvs_rel nagiosplug
	cd $PROJECT
	sed 's/^VER=.*/VER=$v$DS/;s/^REL=.*/REL=snapshot/' configure.in > configure.tmp
	mv configure.tmp configure.in
	tools/setup
	./configure

	# Make the Nagiosplug dist tarball
	make dist

	# End ssh
EOF
}

# Set working variables
PROJECT=nagiosplug
IN=${HOME}/tmp_snapshot
OUT_SERVER="shell.sf.net"
OUT="/home/groups/n/na/nagiosplug/htdocs/snapshot"
CF="usf-cf-x86-linux-2"
DS=`date -u +%Y%m%d%H%M`

# Make dists for HEAD and any others in command parameters
make_dist
for i in $* ; do
	make_dist $i
done

# Check for *.gz files locally (expect NFS between cf shell server and $CF)
set -x
files=$(ls $IN/*/$PROJECT/*.gz 2>/dev/null)
[[ -z $files ]] && die "No files created"
ssh $OUT_SERVER "rm -f $OUT/*.gz"
scp $files $OUT_SERVER:$OUT

# Create MD5 sum
ssh $OUT_SERVER << EOF
cd $OUT
cat <<-END_README > README
This is the daily CVS snapshot of nagiosplug, consisting of the CVS HEAD
and any other branches
The MD5SUM is:
END_README
md5sum *.gz | tee -a README > MD5SUM
EOF

rm -f $files

# Work out success or failure
expected=$(($# + 1))
set -- $files
[[ $# -ne $expected ]] && die "Expected $expected, got $#"
exit 0