#! /bin/sh # $Id: cvs-mirror,v 1.7 2000/09/14 15:05:22 john Exp john $ ## configuration diff=diff # GNU patch is terminally fucked, but solaris version is even worse :-( patch=patch ## variables local_opts="" remote_opts="" update_remote=no opt_verbose=yes ## functions usage () { cat </dev/null )` if [ $update_remote = no ]; then # did any files change since last mirroring if echo "$out" | grep '^[ARUP]' >/dev/null; then update_remote=yes fi # sanity check if echo "$out" | grep '^[\?CM]' >/dev/null; then echo "warning: local repository has been modified!" exit 1 fi fi # do we need to update the remote repository? if [ $update_remote = yes ]; then print "\n* patching the copy of the remote tree\n" ( cd $local && $diff -urN -xCVS -L/dev/null $remote . ) \ | ( cd $remote && $patch -p0 ) \ || exit 1 print "\n* scanning remote tree for changes\n" upd_out=`( cd $remote && cvs $remote_opts -n upd . 2>/dev/null )` deleted=`echo "$upd_out" | grep '^U ' | sed -e 's/^U \(.*\)$/\1/'` for f in $deleted; do print "** removing $f\n" ( cd $remote/`dirname $f` \ && cvs $remote_opts rm -f `basename $f` ) || exit 1 done for f in `echo "$upd_out" | grep '^[\?]' | sed -e 's/^\? \(.*\)$/\1/'`; do print "** adding $f\n" ( cd $remote/`dirname $f` \ && cvs $remote_opts add -kb `basename $f` ) || exit 1 done print "\n* committing the new remote tree\n" ( cd $remote && cvs $remote_opts commit -m "" . ) || exit 1 fi