[imp] Patch to horde-rsync.sh

Alexander Skwar ASkwar@DigitalProjects.com
Mon, 17 Sep 2001 18:30:43 +0200


---------------------- multipart/mixed attachment
So sprach =BBJon Parise=AB am 2001-09-17 um 11:18:56 -0400 :
> Sure, that shold work fine.  None of the details in the config
> file should be relevant to a local rsync'ed checkout, anyway.

Okay, there you are.  I've not only modified the rsync behaviour to
exclude CVSROOT/config*, but I also rewrote the handling of the command
line options.

Now, it's possible to call horde-rsync.sh with no parameters whatsoever
in which case default parameters will be used.  These defaults are to be
set in the script.  It's also possible to call horde-rsync.sh with 1 or
2 or 3 parameters.  These parameters will override the defaults in the
script.

This diff is against v2.9 of horde-rsync.sh

Alexander Skwar
--=20
How to quote:	http://learn.to/quote (german) http://quote.6x.to (english)
Homepage:	http://www.digitalprojects.com   |   http://www.iso-top.de
   iso-top.de - Die g=FCnstige Art an Linux Distributionen zu kommen
		Uptime: 4 days 10 hours 51 minutes

---------------------- multipart/mixed attachment
--- horde-rsync.sh?r=2.9&p=1	Mon Sep 17 18:25:00 2001
+++ my-horde-rsync.sh	Mon Sep 17 18:26:23 2001
@@ -1,84 +1,133 @@
 #!/bin/sh
 #
-#  $Horde: horde/scripts/horde-rsync.sh,v 2.8 2000/06/17 11:31:55 jon Exp $
+#  $Horde$
 #
 #  This script performs a checkout from the horde CVS tree at horde.org
 #
 #  [ Edit the following values to suit your local environment ]
 
-# The path to the basedirectory for your horde checkout                        
-export BASEDIR="${HOME}/horde"
+# The path to the basedirectory for your horde checkout
+BASEDIR="${HOME}/horde"
 
 # The path to your CVSROOT:
 export CVSROOT="${BASEDIR}/rsync"
 
 # The path in which to put the retrieved Horde files:
-export HORDE_DIR="${BASEDIR}/cvs"
+HORDE_DIR="${BASEDIR}/cvs"
 
 # The absolute path to your rsync binary:
-export RSYNC="/usr/local/bin/rsync"
+export RSYNC="/usr/bin/rsync"
 
 # The absolute path to your cvs binary:
 export CVSCOMMAND="/usr/bin/cvs"
 
-# The modules which you'd like to retrieve:
-export MODULE_LIST="imp kronolith turba jonah babel nag troll whups"
+# The default modules which you'd like to retrieve:
+DEFAULT_MODULE_LIST="imp kronolith turba jonah babel nag troll whups"
 
+# The default label from which to checkout
+DEFAULT_LABEL=HEAD
+
+# The default type of action that should be done
+DEFAULT_ACTION=update
 
 #  -[ NOTHING ELSE SHOULD NEED TO BE EDITED BELOW THIS LINE ]-
 
-MYNAME=`basename $0`
+# Arguments that you wish to pass on to cvs
+#CVS_ARGS="-q"
+
+# Arguments that you wish to pass on to rsync
+RSYNC_ARGS="-avz --delete"
+
+# The rsync server/repository from which to "checkout"
+RSYNC_DIR="rsync.horde.org::horde-cvs/"
 
 # Make sure that the CVSROOT and HORDE_DIR directories exist
 mkdir -p "$CVSROOT" "$HORDE_DIR"
 
-# Build the comma-separated modules list
-COMMA_MODULES=`echo "$MODULE_LIST" | tr ' ' ','`
+# Some useful vars
+MYNAME=`basename $0`
+CWD=`pwd`
 
 # Test the commandline arguments
-if [ $# -lt 3 ] ; then
-    echo "Usage: $MYNAME --with-modules=[module[, module]*] --type=[checkout|update] --label=[\"\"|[label]]" 1>&2
-    exit 2
-fi
-
-if (echo "$2" | grep -c "checkout" -) then
-    export CVS_ARGS="-q checkout"
-    export CVS_ACTION="Checking out"
-else
-    export CVS_ARGS="-q update"
-    export CVS_ACTION="Updating"
-fi
-
-if (echo "$3" | grep -c "STABLE" -) then
-    export LABEL="STABLE"
-else
-    export LABEL="HEAD"
-fi
-
-export CWD=`pwd`
-export RSYNC_ARGS="-az --delete"
-export RSYNC_DIR="rsync.horde.org::horde-cvs/"
+while [ $# -gt 0 ]; do
+	case "${1}" in
+		--with-modules=*)
+			# Set the comma module list
+			COMMA_MODULES=$(echo $1 | sed 's|.*=||')
+			# Transform this to the module list
+			MODULE_LIST="$(echo $COMMA_MODULES | tr ',' ' ')"
+			shift
+			;;
+		--type=*)
+			# Set the type of action
+			ACTION=$(echo $1 | sed 's|.*=||')
+			shift
+			;;
+		--label=*)
+			# Set the label from which to checkout
+			LABEL=$(echo $1 | sed 's|.*=||')
+			shift
+			;;
+		--h*|-h*)
+			echo "Usage: $MYNAME {--with-modules=[module[,module]*]|--type=[checkout|update]|--label=[\"\"|[label]]" 1>&2
+			exit 2
+			;;
+	esac
+done
+
+# Check if all the needed vars have been set
+MODULE_LIST="${MODULE_LIST:-$DEFAULT_MODULE_LIST}"
+COMMA_MODULES=${COMMA_MODULES:-$(echo $DEFAULT_MODULE_LIST | tr ' ' ',')}
+ACTION=${ACTION:-$DEFAULT_ACTION}
+LABEL=${LABEL:-$DEFAULT_LABEL}
+
+# Append the action to the cvs arguments
+CVS_ARGS="${CVS_ARGS} -d $CVSROOT ${ACTION}"
+
+# Buildup the list of to-be excluded files
+RSYNC_EXCLUDES="CVSROOT/config*"
+
+RSYNC_EXCLUDE=""
+for exclude in $RSYNC_EXCLUDES ; do
+	RSYNC_EXCLUDE="${RSYNC_EXCLUDE} --exclude=${exclude}"
+done
 
 # Sync up our repository with the main repository
+
+echo
+echo "*********************************************"
 echo "rsync'ing with $RSYNC_DIR..."
+echo "*********************************************"
+echo
 
-$RSYNC $RSYNC_ARGS $RSYNC_DIR $CVSROOT
+$RSYNC $RSYNC_EXCLUDE $RSYNC_ARGS $RSYNC_DIR $CVSROOT
 
 # Checkout the main Horde module
 cd `dirname $HORDE_DIR`
 
-echo "$CVS_ACTION main Horde module..."
+echo
+echo "================================================="
+echo "Doing $ACTION from $LABEL in main Horde module..."
+echo "================================================="
+echo
 
 $CVSCOMMAND $CVS_ARGS -r $LABEL horde
 cd $HORDE_DIR
 
 # Check out each of the other modules specified
 for MODULE in $MODULE_LIST; do
-    if (echo "$1" | grep -c "$MODULE" - ) then
-        echo "$CVS_ACTION $MODULE..."
-        $CVSCOMMAND $CVS_ARGS -r $LABEL $MODULE
-    fi
+
+	echo 
+	echo "**********************************************"
+	echo "Doing $ACTION from $LABEL in $MODULE module..."
+	echo "**********************************************"
+	echo
+
+	echo $CVSCOMMAND $CVS_ARGS -r $LABEL $MODULE
+	$CVSCOMMAND $CVS_ARGS -r $LABEL $MODULE
+
 done
 
 # Put the user back where they came from
 cd $CWD
+

---------------------- multipart/mixed attachment--