#!/bin/sh # # This script creates a delivery tag # # Parameters # $1 : delivery name # $2 : version # # Environment variable that MUST be defined # by the calling script # # SVN_URL SVN_USER SVN_PASS # # Source functions # . `dirname $0`/functions # # Binaries # BIN_ECHO="/bin/echo" BIN_SVN="/usr/bin/svn" # # Parameters # SVN_DELIVERY="" SVN_VERSION="" # # Internal variables # EXIT=0 # # Main script # if [ $EXIT -eq 0 ] ; then check_svn_parameters if [ -z "$1" ] ; then $BIN_ECHO "-> SVN delivery parameter is missing" EXIT=1 else SVN_DELIVERY=$1 fi if [ -z "$2" ] ; then $BIN_ECHO "-> SVN version parameter is missing" EXIT=1 else SVN_VERSION=$2 fi fi if [ $EXIT -eq 0 ] ; then $BIN_SVN list --username $SVN_USER --password $SVN_PASS $SVN_URL/trunk/delivery/$SVN_DELIVERY >> /dev/null 2>&1 if [ $? -ne 0 ] ; then $BIN_ECHO "-> Directory '$SVN_URL/trunk/delivery/$SVN_DELIVERY' does not exist" EXIT=1 fi fi if [ $EXIT -eq 0 ] ; then $BIN_SVN list --username $SVN_USER --password $SVN_PASS $SVN_URL/tags/delivery/$SVN_DELIVERY >> /dev/null 2>&1 if [ $? -ne 0 ] ; then $BIN_SVN mkdir --username $SVN_USER --password $SVN_PASS -m "Create tag directory of delivery $SVN_DELIVERY" $SVN_URL/tags/delivery/$SVN_DELIVERY >> /dev/null 2>&1 if [ $? -ne 0 ] ; then $BIN_ECHO "-> Error while creating directory '$SVN_URL/tags/delivery/$SVN_DELIVERY'" EXIT=1 fi fi fi if [ $EXIT -eq 0 ] ; then $BIN_SVN list --username $SVN_USER --password $SVN_PASS $SVN_URL/tags/delivery/$SVN_DELIVERY/$SVN_VERSION >> /dev/null 2>&1 if [ $? -eq 0 ] ; then $BIN_ECHO "-> Directory '$SVN_URL/tags/delivery/$SVN_DELIVERY/$SVN_VERSION' already exists" EXIT=1 fi fi if [ $EXIT -eq 0 ] ; then $BIN_SVN copy --username $SVN_USER --password $SVN_PASS -m "Create tag $SVN_VERSION of delivery $SVN_DELIVERY" $SVN_URL/trunk/delivery/$SVN_DELIVERY $SVN_URL/tags/delivery/$SVN_DELIVERY/$SVN_VERSION >> /dev/null 2>&1 if [ $? -ne 0 ] ; then $BIN_ECHO "-> Error while creating tag '$SVN_URL/tags/delivery/$SVN_DELIVERY/$SVN_VERSION' from '$SVN_URL/trunk/delivery/$SVN_DELIVERY'" EXIT=1 fi fi exit $EXIT