comparison contrib/make_flys_release/make_release.sh @ 5251:8fa0c522bef3

Improve make_release script to optinally handle tagging and be more generic. It can now be used to prepare a fully configured version of flys. There are still some variables to set in the script or to be overwritten by environment variables.
author Andre Heinecke <aheinecke@intevation.de>
date Tue, 12 Mar 2013 16:52:55 +0100
parents 613d2f494728
children a859691ec4a0
comparison
equal deleted inserted replaced
5250:3ba2917e49d3 5251:8fa0c522bef3
1 #!/bin/bash 1 #!/bin/bash
2 # Release script for Flys
3 #
4 # Authors:
5 # Andre Heinecke <aheinecke@intevation.de>
6 #
7 # Copyright:
8 # Copyright (C) 2013 Intevation GmbH
9 #
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License
12 # as published by the Free Software Foundation; either version 2
13 # of the License, or (at your option) any later version.
14 #
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2 23
3 set -e 24 set -e
4 25 DEFAULT_WD=/tmp/flys-release
5 echo "INFO: define required variables" 26 DEVELOPER=aheinecke
27
6 ARTIFACTS_HG_REPO="http://wald.intevation.org/hg/dive4elements/artifacts" 28 ARTIFACTS_HG_REPO="http://wald.intevation.org/hg/dive4elements/artifacts"
7 HTTPCLIIENT_HG_REPO="http://wald.intevation.org/hg/dive4elements/http-client" 29 HTTPCLIIENT_HG_REPO="http://wald.intevation.org/hg/dive4elements/http-client"
8 FLYS_HG_REPO="http://wald.intevation.org/hg/dive4elements/flys" 30 FLYS_HG_REPO="http://wald.intevation.org/hg/dive4elements/flys"
9 31
10 ARTIFACTS_HG="hg.artifacts" 32 REPOS="artifacts http-client flys"
11 HTTPCLIENT_HG="hg.http-client" 33 # Do not use spaces in path
12 FLYS_HG="hg.flys" 34 FLYS_SOURCE_DIR=/local-vol1/aheinecke/flys-release
13 35
14 PREFIX="flys-" 36 SCRIPT_DIR=$(readlink -f `dirname $0`)
15 RELEASE=${RELEASE:-default} 37 usage(){
16 RELEASE_DATE=`date +'%Y-%m-%d'` 38 cat << EOF
17 DIRECTORY=$PREFIX$RELEASE-$RELEASE_DATE 39
18 40 usage: $0 [options] VERSION
19 ARTIFACT_PORT=${ARTIFACT_PORT:-9002} 41
20 TOMCAT_PORT=${TOMCAT_PORT:-8005} 42 Create a flys package
21 43
44 OPTIONS:
45 -?, --help Show this message
46 -w The working directory to use. (do not use spaces in path)
47 Default: $DEFAULT_WD
48 -t Tag the current default branch as "VERSION"
49 -o, --oracle Release is for oracle.
50 VERSION must be in the format MAYOR.MINOR.PATCH
51 EOF
52 exit 0
53 }
54 # --backend-db-url Url of database backend. Default: $BACKENDURL
55 # --backend-db-pass Backend db password. Default: $BACKENDPASS
56 # --backend-db-port Backend db port. Default: $BACKENDPORT
57 # --backend-db-user Backend db user. Default: $BACKENDUSER
58 # --backend-db-backend Backend db backend name. Default: $BACKENDBACK
59 # --seddb-url Sediment db url. Default: $SEDDBURL
60 # --seddb-port Sediment db port. Default: $SEDDBPORT
61 # --seddb-user Sediment db user. Default: $SEDDBUSER
62 # --seddb-pass Sediment db password. Default: $SEDDBPASS
63 # --seddb-back Sediment db backend. Default: $SEDDBBACK
64 TOMCAT_PORT=${TOMCAT_PORT:-8282}
22 MAPSERVER_URL=${MAPSERVER_URL:-czech-republic.atlas.intevation.de} 65 MAPSERVER_URL=${MAPSERVER_URL:-czech-republic.atlas.intevation.de}
23 WIKI_URL=${WIKI_URL:-https://flys-intern.intevation.de/Flys-3.0} 66 WIKI_URL=${WIKI_URL:-https://flys-intern.intevation.de/Flys-3.0}
24 67
25 echo "INFO: create server directories" 68 # Seddb Configuration
26 mkdir -p $DIRECTORY/server/bin/lib/own 69 SEDDBURL=${SEDDBURL:-czech-republic.atlas.intevation.de}
27 mkdir $DIRECTORY/server/shapefiles 70 SEDDBPORT=${SEDDBPORT:-1521}
28 mkdir $DIRECTORY/client 71 SEDDBBACK=${SEDDBBACK:-XE}
29 72 SEDDBUSER=${SEDDBUSER:-seddb}
30 echo "INFO: checkout sources" 73 SEDDBPASS=${SEDDBPASS:-seddbpass}
31 echo " ... checkout $ARTIFACTS_HG_REPO" 74
32 75 # Backend configuration
33 rm -rf $ARTIFACTS_HG 76 BACKENDURL=${BACKENDURL:-czech-republic.atlas.intevation.de}
34 hg clone $ARTIFACTS_HG_REPO $ARTIFACTS_HG 77 BACKENDPORT=${BACKENDPORT:-5432}
35 (cd $ARTIFACTS_HG && hg co $RELEASE) 78 BACKENDBACK=${BACKENDBACK:-flys_2912}
36 79 BACKENDUSER=${BACKENDUSER:-flys_dami}
37 echo " ... checkout $HTTPCLIIENT_HG_REPO" 80 BACKENDPASS=${BACKENDPASS:-flys_dami}
38 rm -rf $HTTPCLIENT_HG 81
39 hg clone $HTTPCLIIENT_HG_REPO $HTTPCLIENT_HG 82 OPTS=`getopt -o ?w:,t,o \
40 (cd $HTTPCLIENT_HG && hg co $RELEASE) 83 -l help,oracle \
41 84 -n $0 -- "$@"`
42 echo " ... checkout $FLYS_HG_REPO" 85
43 rm -rf $FLYS_HG 86 if [ $? != 0 ] ; then usage; fi
44 hg clone $FLYS_HG_REPO $FLYS_HG 87 eval set -- "$OPTS"
45 (cd $FLYS_HG && hg co $RELEASE) 88 while true ; do
46 89 case "$1" in
47 # adapt client configuration 90 "-?"|"--help")
48 echo "INFO: prepare configuration of web client" 91 usage;;
49 92 "--")
93 shift
94 break;;
95 "-w")
96 WORK_DIR=$2
97 shift 2;;
98 "-o"|"--oracle")
99 BUILD_ORACLE="TRUE"
100 shift;;
101 "-t")
102 DO_TAG="TRUE"
103 shift;;
104 *)
105 echo "Unknown Option $1"
106 usage;;
107 esac
108 done
109
110 if [ $# != 1 ]; then
111 usage
112 fi
113
114 VERSION=$1
115 ARTIFACT_PORT=${ARTIFACT_PORT:-`echo 1$VERSION | sed 's/\.//g'`}
116
117 if [ -z $WORK_DIR ]; then
118 WORK_DIR=$DEFAULT_WD
119 fi
120
121 mkdir -p $WORK_DIR
122
123 if [ ! -d $FLYS_SOURCE_DIR ]; then
124 mkdir -p $FLYS_SOURCE_DIR
125 echo "Cloning sources"
126 cd $FLYS_SOURCE_DIR
127 hg clone $ARTIFACTS_HG_REPO artifacts
128 hg clone $HTTPCLIIENT_HG_REPO http-client
129 hg clone $FLYS_HG_REPO flys
130 else
131 echo "Updating sources / Reverting changes"
132 cd $FLYS_SOURCE_DIR
133 for repo in $REPOS; do
134 cd $repo && hg pull && hg up && hg revert -a && cd $FLYS_SOURCE_DIR
135 done;
136 fi
137
138 if [ "$DO_TAG" = "TRUE" ]; then
139 echo "Tagging version $VERSION"
140 for repo in $REPOS; do
141 cd $repo
142 CHANGESET=$(hg log -l1 |head -1 | awk -F: '{print $3}')
143 echo ""
144 echo "Do you really want to tag $repo rev: $CHANGESET as Version $VERSION?"
145 echo "press enter to continue or CTRL+C to abort."
146 echo ""
147 hg log -l1
148 read
149 hg tag $VERSION -m "Added tag $VERSION for changeset $CHANGESET"
150 hg push ssh://$DEVELOPER@scm.wald.intevation.org/hg/dive4elements/$repo
151 cd $FLYS_SOURCE_DIR
152 done;
153 fi
154
155 # Update to current version
156 for repo in $REPOS; do
157 cd $repo
158 hg up $VERSION
159 cd $FLYS_SOURCE_DIR
160 done
161
162 rm -rf "$WORK_DIR/server" "$WORK_DIR/client"
163 cd $WORK_DIR
164 mkdir -p "$WORK_DIR/server/bin/lib/own"
165 mkdir "$WORK_DIR/server/shapefiles"
166 mkdir "$WORK_DIR/client"
167
168 echo "[INFO]: Preparing configuration of web client"
169 echo "[INFO]: Tomcat Port: $TOMCAT_PORT"
170 echo "[INFO]: Artifact Port: $ARTIFACT_PORT"
50 sed -i -e "s@http://localhost:8181@http://localhost:$ARTIFACT_PORT@g" \ 171 sed -i -e "s@http://localhost:8181@http://localhost:$ARTIFACT_PORT@g" \
51 -e "s@http://localhost:8888@http://localhost:$TOMCAT_PORT@g" \ 172 -e "s@http://localhost:8888@http://localhost:$TOMCAT_PORT@g" \
52 $FLYS_HG/flys-client/src/main/webapp/WEB-INF/web.xml 173 $FLYS_SOURCE_DIR/flys/flys-client/src/main/webapp/WEB-INF/web.xml
53 174
54 sed -i -e "s@/tmp/flys-client.log@/var/log/flys/client-${RELEASE}.log@g" \ 175 sed -i -e "s@/tmp/flys-client.log@/var/log/flys/client-${VERSION}.log@g" \
55 $FLYS_HG/flys-client/src/main/webapp/WEB-INF/log4j.properties 176 $FLYS_SOURCE_DIR/flys/flys-client/src/main/webapp/WEB-INF/log4j.properties
56 177
57 # Fix the Wiki URLs 178 find $FLYS_SOURCE_DIR/flys/flys-artifacts/src/main/resources/ -name messages_\*.properties \
58 find $FLYS_HG/flys-artifacts/src/main/resources/ -name messages_\*.properties \
59 -exec sed -i "s@https://flys-intern.intevation.de/Flys-3.0@${WIKI_URL}@g" {} \; 179 -exec sed -i "s@https://flys-intern.intevation.de/Flys-3.0@${WIKI_URL}@g" {} \;
60 180
61 echo "INFO: download OpenLayers-2.11 for client" 181 if [ ! -f $FLYS_SOURCE_DIR/OpenLayers-2.11.tar.gz ]; then
62 curl -O http://openlayers.org/download/OpenLayers-2.11.tar.gz 182 echo "INFO: download OpenLayers-2.11 for client"
63 tar xvfz OpenLayers-2.11.tar.gz 183 cd $FLYS_SOURCE_DIR
64 # TODO: Remove more superfluous OpenLayers stuff. 184 curl -O http://openlayers.org/download/OpenLayers-2.11.tar.gz
65 rm -rf OpenLayers-2.11/doc 185 tar xvfz OpenLayers-2.11.tar.gz
66 rm -rf OpenLayers-2.11/tests 186 # TODO: Remove more superfluous OpenLayers stuff.
67 rm -rf OpenLayers-2.11/examples 187 rm -rf OpenLayers-2.11/doc
68 mv OpenLayers-2.11 $FLYS_HG/flys-client/src/main/webapp/ 188 rm -rf OpenLayers-2.11/tests
69 189 rm -rf OpenLayers-2.11/examples
70 # compile and build our code stuff 190 cd $WORK_DIR
191 fi
192 cp -r $FLYS_SOURCE_DIR/OpenLayers-2.11 $FLYS_SOURCE_DIR/flys/flys-client/src/main/webapp/
193
71 echo "INFO: compile and build sources" 194 echo "INFO: compile and build sources"
72 mvn -f $ARTIFACTS_HG/pom.xml clean compile package install 195 mvn -f $FLYS_SOURCE_DIR/artifacts/pom.xml clean compile package install
73 mvn -f $FLYS_HG/flys-backend/pom.xml clean compile package install 196 mvn -f $FLYS_SOURCE_DIR/flys/flys-backend/pom.xml clean compile package install
74 mvn -f $FLYS_HG/flys-artifacts/pom.xml clean compile package dependency:copy-dependencies install 197 mvn -f $FLYS_SOURCE_DIR/flys/flys-artifacts/pom.xml clean compile package dependency:copy-dependencies install
75 mvn -f $HTTPCLIENT_HG/pom.xml clean compile package install 198 mvn -f $FLYS_SOURCE_DIR/http-client/pom.xml clean compile package install
76 mvn -f $FLYS_HG/flys-client/pom.xml clean compile package 199 mvn -f $FLYS_SOURCE_DIR/flys/flys-client/pom.xml clean compile package
77 200
78 ## fetch the java stuff 201
79 echo "INFO: copy dependencies and libs" 202 echo "INFO: copy dependencies and libs"
80 cp $ARTIFACTS_HG/artifact-database/target/artifact-database-1.0-SNAPSHOT.jar $DIRECTORY/server/bin/lib/own/ 203 cp $FLYS_SOURCE_DIR/artifacts/artifact-database/target/artifact-database-1.0-SNAPSHOT.jar $WORK_DIR/server/bin/lib/own/
81 cp $ARTIFACTS_HG/artifacts/target/artifacts-1.0-SNAPSHOT.jar $DIRECTORY/server/bin/lib/own/ 204 cp $FLYS_SOURCE_DIR/artifacts/artifacts/target/artifacts-1.0-SNAPSHOT.jar $WORK_DIR/server/bin/lib/own/
82 cp $ARTIFACTS_HG/artifacts-common/target/artifacts-common-1.0-SNAPSHOT.jar $DIRECTORY/server/bin/lib/own/ 205 cp $FLYS_SOURCE_DIR/artifacts/artifacts-common/target/artifacts-common-1.0-SNAPSHOT.jar $WORK_DIR/server/bin/lib/own/
83 cp $FLYS_HG/flys-backend/target/flys-backend-1.0-SNAPSHOT.jar $DIRECTORY/server/bin/lib/own/ 206 cp $FLYS_SOURCE_DIR/flys/flys-backend/target/flys-backend-1.0-SNAPSHOT.jar $WORK_DIR/server/bin/lib/own/
84 cp $FLYS_HG/flys-artifacts/target/flys-artifacts-1.0-SNAPSHOT.jar $DIRECTORY/server/bin/lib/own/ 207 cp $FLYS_SOURCE_DIR/flys/flys-artifacts/target/flys-artifacts-1.0-SNAPSHOT.jar $WORK_DIR/server/bin/lib/own/
85 cp $FLYS_HG/flys-client/target/FLYS-1.0-SNAPSHOT.war $DIRECTORY/client/flys-${RELEASE}.war 208 cp $FLYS_SOURCE_DIR/flys/flys-client/target/FLYS-1.0-SNAPSHOT.war $WORK_DIR/client/flys-${VERSION}.war
86 cp $FLYS_HG/flys-artifacts/target/dependency/* $DIRECTORY/server/bin/lib/ 209 cp $FLYS_SOURCE_DIR/flys/flys-artifacts/target/dependency/* $WORK_DIR/server/bin/lib/
87 210
88 echo "INFO: copy scripts and libraries to target destination" 211 echo "INFO: copy scripts and libraries to target destination"
89 cp bin/run.sh $DIRECTORY/server/bin/ 212 cp ${SCRIPT_DIR}/bin/run.sh $WORK_DIR/server/bin/
90 cp bin/wsplgen.exe $DIRECTORY/server/bin/ 213 cp ${SCRIPT_DIR}/bin/wsplgen.exe $WORK_DIR/server/bin/
91 cp libs/* $DIRECTORY/server/bin/lib/ 214 cp ${SCRIPT_DIR}/libs/* $WORK_DIR/server/bin/lib/
92 215
93 #echo "INFO: remove PostgreSQL and PostGIS libraries" 216
94 #rm $DIRECTORY/server/bin/lib/postg* 217 if [ "$BUILD_ORACLE" = "TRUE" ]; then
95 #rm $DIRECTORY/server/bin/lib/hibernate-spatial-postgis* 218 echo "INFO: remove PostgreSQL and PostGIS libraries"
96 219 rm $WORK_DIR/server/bin/lib/postg*
97 echo "INFO: remove Oralce libraries" 220 rm $WORK_DIR/server/bin/lib/hibernate-spatial-postgis*
98 rm -f $DIRECTORY/server/bin/lib/hibernate-spatial-oracle-1.1.jar 221 else
99 rm -f $DIRECTORY/server/bin/lib/ojdbc* 222 echo "INFO: remove Oralce libraries"
223 rm -f $WORK_DIR/server/bin/lib/hibernate-spatial-oracle-1.1.jar
224 rm -f $WORK_DIR/server/bin/lib/ojdbc*
225 fi
100 226
101 # fetch the configuration stuff 227 # fetch the configuration stuff
102 echo "INFO: copy default configuration to target destination" 228 echo "INFO: copy default configuration to target destination"
103 cp -R $FLYS_HG/flys-artifacts/doc/conf $DIRECTORY/server/ 229 cp -R $FLYS_SOURCE_DIR/flys/flys-artifacts/doc/conf $WORK_DIR/server/
104 230
105 #cp confs/* $DIRECTORY/server/conf/ 231 sed -i "s/8181/$ARTIFACT_PORT/g" \
106 mkdir -p $DIRECTORY/server/conf 232 $WORK_DIR/server/conf/rest-server.xml
107 233
108 sed "s/8999/$ARTIFACT_PORT/g" \ 234 sed -i -e "s@http://example.com/@http://${MAPSERVER_URL}/@g" \
109 confs/rest-server.xml \ 235 $WORK_DIR/server/conf/floodmap.xml
110 > $DIRECTORY/server/conf/rest-server.xml 236
111 237 sed -i -e "s@http://example.com/@http://${MAPSERVER_URL}/@g" \
112 sed -e "s@http://example.com/@http://${MAPSERVER_URL}/@g" \ 238 $WORK_DIR/server/conf/rivermap.xml
113 confs/floodmap.xml \ 239
114 > $DIRECTORY/server/conf/floodmap.xml 240 sed "s@/tmp/flys-server-default.log@/var/log/flys/server-${VERSION}.log@" \
115 241 $SCRIPT_DIR/confs/log4j.properties \
116 sed -e "s@http://example.com/@http://${MAPSERVER_URL}/@g" \ 242 > $WORK_DIR/server/conf/log4j.properties
117 confs/rivermap.xml \ 243
118 > $DIRECTORY/server/conf/rivermap.xml 244 cat > $WORK_DIR/server/conf/seddb-db.xml << EOF
119 245 <?xml version="1.0" encoding="UTF-8" ?>
120 sed "s@/tmp/flys-server-default.log@/var/log/flys/server-${RELEASE}.log@" \ 246 <seddb-database>
121 confs/log4j.properties \ 247 <!-- This is the default SedDB db configuration. -->
122 > $DIRECTORY/server/conf/log4j.properties 248 <user>$SEDDBUSER</user>
123 249 <password>$SEDDBPASS</password>
124 # TODO: Use templating here 250 <dialect>org.hibernate.dialect.Oracle9iDialect</dialect>
125 cp confs/seddb-db.xml $DIRECTORY/server/conf/seddb-db.xml 251 <driver>oracle.jdbc.driver.OracleDriver</driver>
126 cp confs/backend-db.xml $DIRECTORY/server/conf/backend-db.xml 252 <url>jdbc:oracle:thin:@//$SEDDBURL:$SEDDBPORT/$SEDDBBACK </url>
127 cp confs/artifact-db.xml $DIRECTORY/server/conf/artifact-db.xml 253 </seddb-database>
128 cp confs/datacage-db.xml $DIRECTORY/server/conf/datacage-db.xml 254 EOF
129 cp confs/mapserver/fontset.txt $DIRECTORY/server/conf/mapserver/fontset.txt 255
130 256 if [ "$BUILD_ORACLE" = "TRUE" ]; then
131 cp $ARTIFACTS_HG/artifact-database/doc/schema-h2.sql h2/artifacts-h2.sql 257 # Oracle backend configuration
132 cp $FLYS_HG/flys-artifacts/doc/conf/datacage.sql h2/datacage.sql 258 cat > $WORK_DIR/server/conf/backend-db.xml << EOF
259 <?xml version="1.0" encoding="UTF-8" ?>
260 <backend-database>
261 <user>flys27</user>
262 <password>flys27</password>
263 <dialect>org.hibernatespatial.oracle.OracleSpatial10gDialect</dialect>
264 <driver>oracle.jdbc.driver.OracleDriver</driver>
265 <url>jdbc:oracle:thin:@//czech-republic.atlas.intevation.de:1521/XE</url>
266 </backend-database>
267 EOF
268 else
269 #Postgresql backend configuration
270 cat > $WORK_DIR/server/conf/backend-db.xml << EOF
271 <?xml version="1.0" encoding="UTF-8" ?>
272 <backend-database>
273 <user>$BACKENDUSER</user>
274 <password>$BACKENDPASS</password>
275 <dialect>org.hibernate.dialect.PostgreSQLDialect</dialect>
276 <driver>org.postgresql.Driver</driver>
277 <url>jdbc:postgresql://$BACKENDURL:$BACKENDPORT/$BACKENDBACK</url>
278 </backend-database>
279 EOF
280 fi
281
282 mkdir $WORK_DIR/artifactsdb
283 mkdir $WORK_DIR/datacagedb
284
285 cp $FLYS_SOURCE_DIR/artifacts/artifact-database/doc/schema-h2.sql $WORK_DIR/artifactsdb/artifacts-h2.sql
286 cp $FLYS_SOURCE_DIR/flys/flys-artifacts/doc/conf/datacage.sql $WORK_DIR/datacagedb/datacage.sql
133 287
134 echo "INFO: create h2 database for artifacts and datacage" 288 echo "INFO: create h2 database for artifacts and datacage"
135 h2/createArtifacts.sh 289 $SCRIPT_DIR/h2/createArtifacts.sh $WORK_DIR/artifactsdb/artifacts-h2.sql
136 h2/createDatacage.sh 290 $SCRIPT_DIR/h2/createDatacage.sh $WORK_DIR/datacagedb/datacage.sql
137 291
138 mv artifactsdb $DIRECTORY/server/ 292 mv $WORK_DIR/artifactsdb $WORK_DIR/server/
139 mv datacagedb $DIRECTORY/server/ 293 mv $WORK_DIR/datacagedb $WORK_DIR/server/
140 294
141 echo "INFO: create tarball" 295 echo "INFO: create tarball"
142 tar cvfz $DIRECTORY.tar.gz $DIRECTORY 296 mkdir $WORK_DIR/flys-$VERSION
143 297 mv $WORK_DIR/server $WORK_DIR/client $WORK_DIR/flys-$VERSION
144 echo "INFO: remove temporary files and directories" 298 cd $WORK_DIR
145 rm -rf $ARTIFACTS_HG 299 tar cfz flys-$VERSION.tar.gz flys-$VERSION
146 rm -rf $HTTPCLIENT_HG 300 echo "INFO: cleanup"
147 rm -rf $FLYS_HG 301 #rm -r $WORK_DIR/flys-$VERSION
148 rm -rf $DIRECTORY 302
149 rm -rf OpenLayers.2.11.tar.gz 303 echo "DONE: $WORK_DIR/flys-$VERSION.tar.gz"

http://dive4elements.wald.intevation.org