#!/bin/bash function show_title() { echo "RK_HOME: $RK_HOME" echo "O---------------------------------------------O" echo echo " $rk_name "; echo " $rk_fullname "; echo echo "O---------------------------------------------O" } function show_help { echo "$rk_name - $rk_fullname" echo "Automatically creates Greenstone releases" echo echo "usage: $rk_name [-help|-cmd] [ANT_ARGS]" echo " -help" echo " show this help screen" echo echo " -cmd" echo " show the ant command being used by $rk_name" echo echo " ANT_ARGS" echo " Additional arguments to be passed to ant" } #determine requested release kit rk_name="$(basename $0)" export RK_HOME="$(cd "$(dirname "$0")/.." && pwd)" if [ "$rk_name" == "rk2" ]; then rk_fullname="Release Kit for Greenstone2" elif [ "$rk_name" == "rk3" ]; then rk_fullname="Release Kit for Greenstone3" else echo "Unrecognised release-kit name '$rk_name'" >&2 exit fi #cd up a level or two if needed if [ -e "$rk_name-build.properties" ]; then pushd . elif [ -e "../$rk_name-build.properties" ]; then pushd .. elif [ -e "../../$rk_name-build.properties" ]; then pushd ../.. else echo "couldn't find file $rk_name-build.properties" echo "it should exist in the top level of the release" exit fi #make sure ant has enough memory export ANT_OPTS=-Xmx800M #create the command toexec="ant -lib `pwd`/installer/classes -f $RK_HOME/kits/$rk_name/ant-scripts/build.xml -Dbasedir=`pwd` -D$rk_name.home=$RK_HOME" #pass on the arguments while [ "$1" != "" ]; do if [ "$1" == "-help" ]; then show_help exit elif [ "$1" == "-cmd" ]; then show_cmd=true else toexec="$toexec $1" fi shift done #show the command to be executed if [ "$show_cmd" == "true" ]; then echo $toexec #execute else show_title | tee ${rk_name}.out $toexec 2>&1 | tee -a ${rk_name}.out fi #go back to original dir popd