#!/bin/sh
#
# $Id$
#
# The author disclaims all copyrights and releases this script into the
# public domain.
#
# Creates new CVS repository (usually for testing purposes).
TESTING=
if [ -z $TMPDIR ]; then
TMPDIR=/tmp
fi
if [ ! -d $TMPDIR ]; then
echo "error: TMPDIR not a directory: TMPDIR=$TMPDIR" >&2
exit 1
fi
# use argument as CVSROOT, or create fake dir (testing)
if [ -z $1 ]; then
CVSROOT=`mktemp -d $TMPDIR/cvs-test-repo.XXXXXX` || exit $?
echo "notice: using random repository: directory=$CVSROOT" >&2
TESTING=1
else
CVSROOT=$1
fi
if [ -d $CVSROOT/CVSROOT ]; then
echo "error: CVSROOT exists: directory=$CVSROOT" >&2
exit 1
fi
# local CVS repositories only (no pserver, :ext: supported)
mkdir -p $CVSROOT || exit $?
cvs -Q -d $CVSROOT init || exit $?
# TODO copy over standard CVSROOT changes? (e-mail notify, etc.)
# if using a test cvsroot, also checkout for use
SANDBOX=`mktemp -d $TMPDIR/cvs-test-sandbox.XXXXXX` || exit $?
(
cd $SANDBOX && cvs -Q -d $CVSROOT co .
# so we can 'chdir' on output in wrapper if need to
echo $SANDBOX
)