teichmann@4484: #!/bin/bash tom@8493: # Release script for Dive4Elements River aheinecke@5251: # aheinecke@5251: # Authors: aheinecke@5251: # Andre Heinecke aheinecke@5251: # tom@8493: # Copyright (C) 2011 - 2014 by Bundesanstalt für Gewässerkunde tom@8493: # Software engineering by Intevation GmbH aheinecke@5251: # tom@8493: # This file is Free Software under the GNU AGPL (>=v3) tom@8493: # and comes with ABSOLUTELY NO WARRANTY! Check out the tom@8493: # documentation coming with Dive4Elements River for details. ingo@4065: aheinecke@5220: set -e andre@8080: LC_ALL=en_US.UTF-8 aheinecke@5251: DEFAULT_WD=/tmp/flys-release aheinecke@5251: DEVELOPER=aheinecke aheinecke@5220: tom@8499: ARTIFACTS_HG_REPO="https://wald.intevation.org/hg/dive4elements/framework" tom@8499: HTTPCLIIENT_HG_REPO="https://wald.intevation.org/hg/dive4elements/http-client" tom@8499: FLYS_HG_REPO="https://wald.intevation.org/hg/dive4elements/river" ingo@4065: aheinecke@5900: REPOS="river http-client framework" aheinecke@5251: # Do not use spaces in path aheinecke@5251: FLYS_SOURCE_DIR=/local-vol1/aheinecke/flys-release ingo@4065: aheinecke@5251: SCRIPT_DIR=$(readlink -f `dirname $0`) aheinecke@5251: usage(){ aheinecke@5251: cat << EOF ingo@4065: aheinecke@5251: usage: $0 [options] VERSION teichmann@4484: tom@8501: Create a D4E River package aheinecke@5251: aheinecke@5251: OPTIONS: tom@8494: -?, --help Show this message tom@8494: -w The working directory to use (do not use spaces in path) tom@8494: Default: $DEFAULT_WD tom@8494: -t Tag the current default branch as "VERSION" tom@8494: -o, --oracle Release is for oracle. tom@8523: Suitable jar-file for JDBC driver has to be given with tom@8523: the environment variable ORACLE_JDBC tom@8673: VERSION must specify a tag (usually MAYOR.MINOR.PATCH) or a branch name. aheinecke@5251: EOF aheinecke@5251: exit 0 aheinecke@5251: } aheinecke@5251: # --backend-db-url Url of database backend. Default: $BACKENDURL aheinecke@5251: # --backend-db-pass Backend db password. Default: $BACKENDPASS aheinecke@5251: # --backend-db-port Backend db port. Default: $BACKENDPORT aheinecke@5251: # --backend-db-user Backend db user. Default: $BACKENDUSER aheinecke@5251: # --backend-db-backend Backend db backend name. Default: $BACKENDBACK aheinecke@5251: # --seddb-url Sediment db url. Default: $SEDDBURL aheinecke@5251: # --seddb-port Sediment db port. Default: $SEDDBPORT aheinecke@5251: # --seddb-user Sediment db user. Default: $SEDDBUSER aheinecke@5251: # --seddb-pass Sediment db password. Default: $SEDDBPASS aheinecke@5251: # --seddb-back Sediment db backend. Default: $SEDDBBACK teichmann@4494: tom@8501: # customizable variables rrenkert@7813: ELBE_MODEL_UUID=${ELBE_MODEL_UUID:-1a4825f6-925f-11e3-8165-001f29e71d12} tom@7775: aheinecke@5251: OPTS=`getopt -o ?w:,t,o \ aheinecke@5251: -l help,oracle \ aheinecke@5251: -n $0 -- "$@"` ingo@4065: aheinecke@5251: if [ $? != 0 ] ; then usage; fi aheinecke@5251: eval set -- "$OPTS" aheinecke@5251: while true ; do aheinecke@5251: case "$1" in aheinecke@5251: "-?"|"--help") aheinecke@5251: usage;; aheinecke@5251: "--") aheinecke@5251: shift aheinecke@5251: break;; aheinecke@5251: "-w") aheinecke@5251: WORK_DIR=$2 aheinecke@5251: shift 2;; aheinecke@5251: "-o"|"--oracle") aheinecke@5251: BUILD_ORACLE="TRUE" aheinecke@5251: shift;; aheinecke@5251: "-t") aheinecke@5251: DO_TAG="TRUE" aheinecke@5251: shift;; aheinecke@5251: *) aheinecke@5251: echo "Unknown Option $1" aheinecke@5251: usage;; aheinecke@5251: esac aheinecke@5251: done teichmann@4484: aheinecke@5251: if [ $# != 1 ]; then aheinecke@5251: usage aheinecke@5251: fi aheinecke@5251: aheinecke@5251: VERSION=$1 aheinecke@5251: aheinecke@5251: if [ -z $WORK_DIR ]; then aheinecke@5251: WORK_DIR=$DEFAULT_WD aheinecke@5251: fi aheinecke@5251: aheinecke@5251: mkdir -p $WORK_DIR aheinecke@5251: aheinecke@5251: if [ ! -d $FLYS_SOURCE_DIR ]; then aheinecke@5251: mkdir -p $FLYS_SOURCE_DIR aheinecke@5251: echo "Cloning sources" aheinecke@5251: cd $FLYS_SOURCE_DIR aheinecke@5900: hg clone $ARTIFACTS_HG_REPO framework aheinecke@5251: hg clone $HTTPCLIIENT_HG_REPO http-client aheinecke@5900: hg clone $FLYS_HG_REPO river aheinecke@5251: else aheinecke@5251: echo "Updating sources / Reverting changes" aheinecke@5251: cd $FLYS_SOURCE_DIR aheinecke@5251: for repo in $REPOS; do tom@8523: cd $repo && hg purge && hg revert -a && hg pull -u && cd - aheinecke@5251: done; aheinecke@5251: fi aheinecke@5251: aheinecke@5251: if [ "$DO_TAG" = "TRUE" ]; then tom@8523: echo "INFO: Tagging version $VERSION" aheinecke@5251: for repo in $REPOS; do aheinecke@5251: cd $repo aheinecke@5251: CHANGESET=$(hg log -l1 |head -1 | awk -F: '{print $3}') aheinecke@5251: echo "" aheinecke@5251: echo "Do you really want to tag $repo rev: $CHANGESET as Version $VERSION?" aheinecke@5251: echo "press enter to continue or CTRL+C to abort." aheinecke@5251: echo "" aheinecke@5251: hg log -l1 aheinecke@5251: read aheinecke@5320: OLD_REV=$(cat .hgtags | tail -1 | awk '{print $2}') aheinecke@5251: hg tag $VERSION -m "Added tag $VERSION for changeset $CHANGESET" aheinecke@5251: hg push ssh://$DEVELOPER@scm.wald.intevation.org/hg/dive4elements/$repo aheinecke@5320: echo "Changelog for $repo" >> $WORK_DIR/changes_$OLD_REV-$VERSION.txt aheinecke@5320: echo "#############################################################################" \ aheinecke@5320: >> $WORK_DIR/changes_$OLD_REV-$VERSION.txt aheinecke@5320: hg log -r $VERSION:$OLD_REV --style changelog >> $WORK_DIR/changes_$OLD_REV-$VERSION.txt aheinecke@5251: cd $FLYS_SOURCE_DIR aheinecke@5251: done; aheinecke@5251: fi aheinecke@5251: aheinecke@5251: # Update to current version aheinecke@5251: for repo in $REPOS; do aheinecke@5251: cd $repo tom@7996: if [ -z "`hg tags | sed -n "/$VERSION/p"`" -a -z "`hg branches | sed -n "/$VERSION/p"`" ] tom@7996: then tom@8740: echo "ERROR: No tag or branch $VERSION found in repository of $repo!" tom@8740: exit 1 tom@7996: else tom@7996: hg up "$VERSION" tom@7996: fi aheinecke@5251: cd $FLYS_SOURCE_DIR aheinecke@5251: done aheinecke@5251: tom@8523: tom@8523: if [ ! -f $FLYS_SOURCE_DIR/OpenLayers-2.11.tar.gz ]; then tom@8523: echo "INFO: download OpenLayers-2.11 for client" tom@8523: cd $FLYS_SOURCE_DIR tom@8523: wget "https://github.com/openlayers/openlayers/releases/download/release-2.11/OpenLayers-2.11.tar.gz" tom@8523: tar xvfz OpenLayers-2.11.tar.gz tom@8523: # TODO: Remove more superfluous OpenLayers stuff. tom@8523: rm -rf OpenLayers-2.11/doc tom@8523: rm -rf OpenLayers-2.11/tests tom@8523: rm -rf OpenLayers-2.11/examples tom@8523: cd $WORK_DIR tom@8523: fi tom@8523: cp -r $FLYS_SOURCE_DIR/OpenLayers-2.11 \ tom@8523: $FLYS_SOURCE_DIR/river/gwt-client/src/main/webapp/ tom@8523: tom@8523: tom@8523: echo "INFO: Downloading smartGWT" tom@8523: mvn com.isomorphic:isc-maven-plugin:install -Dproduct=SMARTGWT -Dlicense=LGPL \ tom@8739: -DbuildNumber=4.1p -DbuildDate=2015-04-25 -Dworkdir=$WORK_DIR tom@8523: tom@8523: echo "INFO: compile sources" tom@8523: mvn -f $FLYS_SOURCE_DIR/framework/pom.xml clean compile install tom@8523: mvn -f $FLYS_SOURCE_DIR/river/backend/pom.xml clean compile install tom@8523: mvn -f $FLYS_SOURCE_DIR/river/artifacts/pom.xml clean compile tom@8523: mvn -f $FLYS_SOURCE_DIR/http-client/pom.xml clean compile install tom@8523: # gwt-client has to be compiled later to allow custom CLIENT_CONF tom@8523: tom@8523: echo "INFO: create h2 database for artifacts and datacage" tom@8523: cd $FLYS_SOURCE_DIR/river/artifacts tom@8523: rm -rf artifactsdb datacagedb tom@8523: $FLYS_SOURCE_DIR/framework/artifact-database/bin/createArtifacts.sh tom@8523: $FLYS_SOURCE_DIR/river/artifacts/bin/createDatacage.sh tom@8523: cd - tom@8523: tom@8523: echo "INFO: download WSPLGEN" aheinecke@5251: cd $WORK_DIR tom@8735: rm wsplgen-linux-*bit-static tom@8523: wget \ tom@8523: https://wald.intevation.org/frs/download.php/1496/wsplgen-linux-64bit-static.gz \ tom@8523: https://wald.intevation.org/frs/download.php/1498/wsplgen-linux-32bit-static.gz tom@8523: gunzip wsplgen-linux-64bit-static.gz wsplgen-linux-32bit-static.gz tom@8523: chmod +x wsplgen-linux-* tom@8523: cp wsplgen-linux-32bit-static $FLYS_SOURCE_DIR/river/artifacts/bin/wsplgen tom@8523: cd - tom@8523: tom@8523: if [ "$DO_TAG" = "TRUE" ]; then tom@8523: echo "INFO: Building packages for publication" tom@8523: cd $FLYS_SOURCE_DIR/river/artifacts tom@8523: mvn package assembly:single tom@8523: mv target/river-artifacts-1.0-SNAPSHOT-bin.tar.bz2 \ tom@8523: $WORK_DIR/d4e-river-$VERSION.tar.bz2 && cd .. tom@8523: cd gwt-client && mvn clean compile package tom@8523: mv target/gwt-client-1.0-SNAPSHOT.war \ tom@8523: $WORK_DIR/d4e-river-$VERSION.war && cd .. tom@8523: fi aheinecke@5251: tom@8501: tom@8501: echo "INFO: Preparing configuration of web client" aheinecke@5692: aheinecke@5692: #Needs to be done before the tomcat replacement below rrenkert@7813: sed -i -e "s@1a4825f6-925f-11e3-8165-001f29e71d12@${ELBE_MODEL_UUID}@g" \ rrenkert@7813: $FLYS_SOURCE_DIR/river/gwt-client/src/main/webapp/images/FLYS_Karte_interactive.html rrenkert@7813: tom@8501: if [ -d $WEBINF ]; then tom@8501: echo "INFO: copy custom client configuration to target destination" tom@8501: WEBINF_DIR=$FLYS_SOURCE_DIR/river/gwt-client/src/main/webapp/WEB-INF/ tom@8501: cp -R $WEBINF/* $WEBINF_DIR tom@8501: for file in `find $WEBINF_DIR/ -type f`; do tom@8501: sed -i -e "s@D4E_VERSION@${VERSION}@g" $file tom@8501: done tom@7801: fi tom@7801: andre@8506: if [ -f $CLIENT_CONF ]; then andre@8506: echo "INFO: copy custom java script client configuration to target destination" andre@8506: cp $CLIENT_CONF \ andre@8506: $FLYS_SOURCE_DIR/river/gwt-client/src/main/java/org/dive4elements/river/client/client/config.xml andre@8506: fi tom@8384: tom@8523: if [ -n $DGM_PATH ]; then tom@8523: sed -i -e "s@.*@${DGM_PATH}@g" \ tom@8523: $FLYS_SOURCE_DIR/river/artifacts/doc/conf/conf.xml aheinecke@5251: fi ingo@4065: tom@8523: if [ -n $WIKI_URL ]; then tom@8523: sed -i -e "s@http://example.com@${WIKI_URL}@g" \ tom@8523: $FLYS_SOURCE_DIR/river/artifacts/doc/conf/conf.xml tom@8523: fi tom@8523: tom@8523: if [ -d $SERVER_CONF ]; then tom@8523: echo "INFO: copy custom server configuration to target destination" tom@8523: cp -R $SERVER_CONF/* $FLYS_SOURCE_DIR/river/artifacts/doc/conf/ tom@8523: for file in `find $FLYS_SOURCE_DIR/river/artifacts/doc/conf -type f`; do tom@8523: sed -i -e "s@D4E_VERSION@${VERSION}@g" $file tom@8523: done tom@8523: fi tom@8523: rrenkert@7939: ingo@4065: echo "INFO: compile and build sources" tom@8523: cp $WORK_DIR/wsplgen-linux-64bit-static \ tom@8523: $FLYS_SOURCE_DIR/river/artifacts/bin/wsplgen ingo@4065: aheinecke@5251: if [ "$BUILD_ORACLE" = "TRUE" ]; then aheinecke@5320: if [ ! -f $ORACLE_JDBC ]; then aheinecke@5320: echo "Could not find oracle jdbc in $ORACLE_JDBC" aheinecke@5320: echo "Please make sure that the ORACLE_JDBC variable is set correctly" aheinecke@5320: exit 1 aheinecke@5320: fi tom@8523: mvn install:install-file -DgroupId=ojdbc -DartifactId=ojdbc \ tom@8523: -Dversion=0 -Dpackaging=jar -Dfile=$ORACLE_JDBC -DgeneratePom=true tom@8523: mvn -f $FLYS_SOURCE_DIR/river/backend/pom-oracle.xml clean compile install tom@8523: mvn -f $FLYS_SOURCE_DIR/river/artifacts/pom-oracle.xml \ tom@8523: package assembly:single aheinecke@5251: else tom@8523: mvn -f $FLYS_SOURCE_DIR/river/artifacts/pom.xml package assembly:single aheinecke@5251: fi tom@8523: mvn -f $FLYS_SOURCE_DIR/river/gwt-client/pom.xml clean compile package ingo@4065: tom@8495: tom@8523: echo "INFO: create tarball" aheinecke@7771: cd $WORK_DIR tom@8523: mv $FLYS_SOURCE_DIR/river/artifacts/target/river-artifacts-1.0-SNAPSHOT-bin.tar \ tom@8523: flys-$VERSION.tar tom@8523: mv $FLYS_SOURCE_DIR/river/gwt-client/target/gwt-client-1.0-SNAPSHOT.war \ tom@8523: flys-${VERSION}.war tom@8523: tar -rf flys-$VERSION.tar flys-${VERSION}.war ingo@4065: tom@8495: if [ -f $INSTALL ]; then tom@8464: echo "INFO: prepare custom installation script" tom@8523: cp $INSTALL . tom@8523: sed -i "s/D4E_VERSION/$VERSION/g" ./`basename $INSTALL` tom@8523: tar -rf flys-$VERSION.tar `basename $INSTALL` aheinecke@6612: fi aheinecke@6612: tom@8523: ## TODO: tag with maven and include basedir with correct name in assembly ## tom@8523: rm -rf flys-$VERSION && mkdir flys-$VERSION tom@8523: tar -xf flys-$VERSION.tar -C flys-$VERSION tom@8523: tar cfz flys-$VERSION.tar.gz flys-$VERSION tom@8523: ## tom@8523: tom@8523: if [ "$DO_TAG" = "TRUE" ]; then tom@8523: echo "Binary-packages for publication:" tom@8523: echo "_ $WORK_DIR/d4e-river-$VERSION.tar.bz2" tom@8523: echo "_ $WORK_DIR/d4e-river-$VERSION.war" tom@8464: fi aheinecke@5251: echo "DONE: $WORK_DIR/flys-$VERSION.tar.gz" aheinecke@5320: echo "Changelog: $WORK_DIR/changes_$OLD_REV-$VERSION.txt"