#!/bin/sh # # cvschroot - change CVS/Root and CVS/Repository # # usage: cvschroot [-d work_directory] new_cvsroot [new_module] # # examples: # % setenv CVSROOT :pserver:anoncvs@sup.jp.netbsd.org:/cvs/cvsroot # # % cd /usr/pkgsrc/shells/tcsh # % cvschroot $CVSROOT # # or # # % cvschroot -d /usr/pkgsrc $CVSROOT pkgsrc # # $Id: cvschroot,v 1.1.1.1 2001/03/14 06:35:39 gotoh Exp $ # set workspace if [ "$1" = "-d" ]; then workdir=`echo $2 | sed -e 's@/$@@'` if [ ! -d "$workdir" ]; then echo "$0: $workdir: not found directory" >&2 exit 1 fi shift; shift else workdir=. fi # check options if [ $# -lt 1 ]; then echo "usage: cvschroot [-d work_directory] new_cvsroot [new_module]" >&2 exit 1 fi # set newcvsroot and newmodule newcvsroot=$1 [ -n "$2" ] && newmodule=`echo $2 | sed -e 's@/$@@'` find $workdir \( -name Root -o -name Repository \) -print | while read f; do case $f in */CVS/Root) echo changing $f echo $newcvsroot > $f ;; */CVS/Repository) [ -n "$newmodule" ] || continue subdir=`echo $f | sed "s@^$workdir\(.*\)/CVS/Repository@\1@"` echo changing $f echo ${newmodule}${subdir} > $f ;; esac done exit 0