1#!/bin/sh
2#
3# Script used to send all the packages on the FTP sites
4# Written by Alexis Wilke for Made to Order Software Corp. (c) 2004-2009
5#
6# Copyright (c) 2004-2009 Made to Order Software Corp.
7#
8# Permission is hereby granted, free of charge, to any
9# person obtaining a copy of this software and
10# associated documentation files (the "Software"), to
11# deal in the Software without restriction, including
12# without limitation the rights to use, copy, modify,
13# merge, publish, distribute, sublicense, and/or sell
14# copies of the Software, and to permit persons to whom
15# the Software is furnished to do so, subject to the
16# following conditions:
17#
18# The above copyright notice and this permission notice
19# shall be included in all copies or substantial
20# portions of the Software.
21#
22# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
23# ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24# LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
25# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
26# EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
28# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
29# ARISING FROM, OUT OF OR IN CONNECTION WITH THE
30# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31# SOFTWARE.
32#
33
34set -e
35
36
37
38BETA=false
39CURRENT=false
40SF=false
41#SFWEB=false
42#NOWEB=false
43NOBETA=false
44ERR=false
45while test ! -z "$1"
46do
47	case "$1" in
48	"-help"|"-h"|"--help")
49		echo "Usage: $0 -<opts>"
50		echo "where -<opts> are:"
51		echo "  -beta      send out this version as a beta version"
52		echo "  -current   send this version out as a current version"
53		echo "  -help      print out this help screen"
54		echo "  -sf        send everything also on SourceForge"
55		#echo "  -noweb     don't update the web pages"
56		#echo "  -sfweb     publish the web pages also on SourceForge"
57		echo "  -nobeta    don't update the beta soft link"
58		exit 1
59		;;
60	"-beta")
61		BETA=true
62		;;
63	"-current")
64		CURRENT=true
65		;;
66	"-sf")
67		SF=true
68		;;
69	#"-noweb")
70	#	NOWEB=true
71	#	;;
72	#"-sfweb")
73	#	SFWEB=true
74	#	;;
75	"-nobeta")
76		NOBETA=true;
77		;;
78	*)
79		echo "ERROR: Unkown option '$1'"
80		ERR=true
81		;;
82	esac
83	shift 1
84done
85
86if $ERR
87then
88	echo "Errors occured while checking the parameters. Nothing will happen."
89	exit 1
90fi
91
92if ! $BETA && ! $CURRENT
93then
94	echo "ERROR: one of -beta or -current is necessary."
95	exit 1
96fi
97
98
99##############################
100# Get the current packages version
101##############################
102VERSION=`grep "^.define.*\\<SSWF_VERSION\\>" include/sswf/libsswf-version.h | sed -e 's/.*\\([0-9]\\+\\.[0-9]\\+\\.[0-9]\\+\\).*/\\1/'`
103
104
105PACKAGES=../packages/sswf-$VERSION
106
107
108##############################
109# Copy all the packages on the m2osw.com FTP server
110##############################
111SSWF_FTP=/var/ftp/pub/sswf
112M2OSW_FTP=$SSWF_FTP/sswf-$VERSION
113rm -rf $M2OSW_FTP
114mkdir -p $M2OSW_FTP
115chmod 770 $M2OSW_FTP
116chown $USER.ftp $M2OSW_FTP
117cp -f $PACKAGES/* $M2OSW_FTP
118chmod 640 $M2OSW_FTP/*
119chown $USER.ftp $M2OSW_FTP/*
120chmod 710 $M2OSW_FTP
121cp doc/CHANGES.txt $SSWF_FTP
122cp doc/NOTES.txt $SSWF_FTP
123
124if $CURRENT
125then
126	rm -f $SSWF_FTP/current
127	ln -s sswf-$VERSION $SSWF_FTP/current
128fi;
129if $NOBETA
130then
131	echo "NOTE: beta link not updated"
132else
133	rm -f $SSWF_FTP/beta
134	ln -s sswf-$VERSION $SSWF_FTP/beta
135fi
136
137
138
139##############################
140# Create the MD5 file now
141##############################
142(
143	cd $M2OSW_FTP
144	rm -f md5.txt
145	md5sum -b * >/tmp/md5.txt
146	mv /tmp/md5.txt .
147)
148
149
150##############################
151# Copy all the packages on SourceForge
152##############################
153if $SF
154then
155	(
156		cd ../packages/sswf-$VERSION
157		#ncftpput upload.sourceforge.net incoming *
158		rsync -avP -e ssh * alexis_wilke@frs.sourceforge.net:uploads/
159	)
160else
161	echo "WARNING: modules not published to SourceForge, use -sf"
162fi
163
164
165
166##############################
167# Send the web page too
168##############################
169# This is now on our corporate website (http://www.m2osw.com/sswf)
170#if $NOWEB
171#then
172#	echo "NOTE: not sending the web page"
173#else
174#	if $SF || $SFWEB
175#	then
176#		dev/sendweb -sf
177#	else
178#		dev/sendweb
179#	fi
180#fi
181
182
183