diff contrib/make_flys_release/bin/make-importer-package.sh @ 8675:ae3df0f96e15

Mavenize importer packaging and allow packaging for specific versions and database systems.
author Tom Gottfried <tom@intevation.de>
date Thu, 09 Apr 2015 17:29:45 +0200
parents 32682fa2127d
children f7007b1aaa3f
line wrap: on
line diff
--- a/contrib/make_flys_release/bin/make-importer-package.sh	Thu Apr 09 17:08:51 2015 +0200
+++ b/contrib/make_flys_release/bin/make-importer-package.sh	Thu Apr 09 17:29:45 2015 +0200
@@ -1,56 +1,113 @@
 #!/bin/bash
+# Packaging-script for Dive4Elements River-Importer
+#
+# Copyright (C) 2011 - 2014 by Bundesanstalt für Gewässerkunde
+# Software engineering by Intevation GmbH
+#
+# This file is Free Software under the GNU AGPL (>=v3)
+# and comes with ABSOLUTELY NO WARRANTY! Check out the
+# documentation coming with Dive4Elements River for details.
+
 set -e
 
-# See README for more information
-
-# The working directory. Resulting tarball will be placed in the directory above.
-PKG_DIR=~/tmp/flys-importer
+# See ../README for more information
+# The working directory. Resulting tarball will be placed here.
+PKG_DIR=/tmp/flys-importer
 # Path to the flys checkout
-FLYS_DIR=~/flys/river/
-# Tarball that will be extracted into flys-importer/opt
-EXTRAS=$1
-
-rm -fr $PKG_DIR
-mkdir -p $PKG_DIR/hydr_morph
-mkdir -p $PKG_DIR/geodaesie
-mkdir -p $PKG_DIR/opt/lib64
-mkdir -p $PKG_DIR/schema
+SOURCE_DIR=$(readlink -f `dirname $0`)/../../..
 
-cd ${FLYS_DIR}/backend
-mvn -f pom-oracle.xml clean compile assembly:single
-cp target/backend-1.0-SNAPSHOT-jar-with-dependencies.jar \
-    $PKG_DIR/hydr_morph/importer.jar
-mvn -f pom.xml clean compile assembly:single
-cp target/river-backend-1.0-SNAPSHOT-jar-with-dependencies.jar \
-    $PKG_DIR/hydr_morph/importer_psql.jar
-cp ${FLYS_DIR}/backend/contrib/shpimporter/*.py $PKG_DIR/geodaesie
-cp ${FLYS_DIR}/backend/contrib/run_geo.sh \
-    ${FLYS_DIR}/backend/contrib/run_hydr_morph.sh \
-    ${FLYS_DIR}/backend/contrib/import_river.sh \
-    $PKG_DIR
-cp -r ${FLYS_DIR}/backend/doc/conf $PKG_DIR/
-if [ -f "$EXTRAS" ]; then
-    cd $PKG_DIR
-    tar -xzf "$EXTRAS"
+usage(){
+    cat << EOF
+
+usage: $0 [options] VERSION [EXTRAS]
+
+Create a D4E River Importer-package
+
+OPTIONS:
+   -?, --help          Show this message
+   -o, --oracle        Package is for Oracle.
+                       Suitable jar-file for JDBC driver has to be given with
+                       the environment variable ORACLE_JDBC
+   VERSION must specify a tag (usually MAYOR.MINOR.PATCH) or a branch name.
+   With EXTRAS, a tarball with dependencies can be given.
+EOF
+exit 0
+}
+
+OPTS=`getopt -o ?,o -l help,oracle -n $0 -- "$@"`
+
+if [ $? != 0 ] ; then usage; fi
+eval set -- "$OPTS"
+while true ; do
+  case "$1" in
+    "-?"|"--help")
+      usage;;
+    "--")
+      shift
+      break;;
+    "-o"|"--oracle")
+      BUILD_ORACLE="TRUE"
+      shift;;
+    *)
+      echo "Unknown Option $1"
+      usage;;
+  esac
+done
+
+if [ $# != 1 ]; then
+    usage
 fi
 
-cp ${FLYS_DIR}/backend/doc/schema/*.sql $PKG_DIR/schema
+VERSION=$1
+EXTRAS=$2
+
+# Update to VERSION
+echo "WARNING: any local changes in $SOURCE_DIR will be packaged."
+cd ${SOURCE_DIR}
+if [ -z "`hg tags | sed -n "/$VERSION/p"`" -a -z "`hg branches | sed -n "/$VERSION/p"`" ]
+then
+    echo "WARNING: $VERSION not found in $repo! Updating to default."
+    hg up default
+else
+    hg up "$VERSION"
+fi
 
 # create PDF of manual
 REV=`hg parent | sed -n '1s/[[:alnum:]]*: *\([0-9]*:.*\)/\1/;1p'`
-cd ${FLYS_DIR}/backend/doc/documentation/de/
+cd ${SOURCE_DIR}/backend/doc/documentation/de/
 sed -i "s/documentrevision..rev.*/documentrevision}{rev$REV}/" \
     importer-manual.tex
 # run pdflatex three times to get references and page numbering right
 pdflatex importer-manual.tex
 pdflatex importer-manual.tex
 pdflatex importer-manual.tex
-cp importer-manual.pdf $PKG_DIR
-
-sed -i 's/shpimporter\/shp/geodaesie\/shp/' $PKG_DIR/run_geo.sh
 
-cd $PKG_DIR/..
-DATE=$(date +%Y%m%d%H%M)
-tar -czf flys-importer_${DATE}.tar.gz flys-importer
-sha1sum flys-importer_${DATE}.tar.gz > flys-importer_${DATE}.tar.gz.sha1
-echo Package is at: `readlink -f flys-importer_${DATE}.tar.gz`
+# package importer
+if [ "$BUILD_ORACLE" = "TRUE" ]; then
+    if [ ! -f $ORACLE_JDBC ]; then
+        echo "Could not find oracle jdbc in $ORACLE_JDBC"
+        echo "Please make sure that the ORACLE_JDBC variable is set correctly"
+        exit 1
+    fi
+    mvn install:install-file -DgroupId=ojdbc -DartifactId=ojdbc \
+       -Dversion=0 -Dpackaging=jar -Dfile=$ORACLE_JDBC -DgeneratePom=true
+    mvn -f $SOURCE_DIR/backend/pom-oracle.xml clean package assembly:single
+else
+    mvn -f $SOURCE_DIR/backend/pom.xml clean package assembly:single
+fi
+
+echo "INFO: create tarball"
+rm -fr $PKG_DIR
+mkdir $PKG_DIR
+cd $PKG_DIR
+
+mv $SOURCE_DIR/backend/target/river-backend-1.0-SNAPSHOT*-flys-importer.tar \
+    flys-importer-$VERSION.tar
+if [ -f "$EXTRAS" ]; then
+    tar -xzf "$EXTRAS"
+    tar -rf flys-importer-$VERSION.tar opt
+fi
+
+gzip flys-importer-$VERSION.tar
+sha1sum flys-importer-$VERSION.tar.gz > flys-importer-$VERSION.tar.gz.sha1
+echo Package is at: `readlink -f flys-importer-$VERSION.tar.gz`

http://dive4elements.wald.intevation.org