[rancid] [PATCH 1/2] Better support for subversion repositories
Zenon Mousmoulas
zmousm at noc.grnet.gr
Mon Nov 28 13:36:45 UTC 2011
Improve subversion support:
- Support arbitrary subversion URLs as (pre-provisioned) repositories.
- Do not overwrite an existing local repository.
- Avoid "svn: Directory '<GROUP>' is out of date" message.
Included for completeness, copied from Debian patch
by Nicolas DEFFAYET <nicolas-ml at deffayet.com>:
http://patch-tracker.debian.org/patch/series/dl/rancid/2.3.6-1/09_svn.dpatch
Signed-off-by: Zenon Mousmoulas <zmousm at noc.grnet.gr>
---
diff -ru rancid-2.3.6/bin/control_rancid.in rancid-2.3.6-grnet/bin/control_rancid.in
--- rancid-2.3.6/bin/control_rancid.in 2011-02-16 01:16:59.000000000 +0200
+++ rancid-2.3.6-grnet/bin/control_rancid.in 2011-11-26 00:12:08.000000000 +0200
@@ -167,6 +167,12 @@
fi
fi
+# svn update to avoid 'Out of date' error
+if [ $RCSSYS = svn ]
+then
+ svn update
+fi
+
# do cvs update of router.db in case anyone has fiddled.
$RCSSYS update router.db > $TMP 2>&1
grep "^C" $TMP > /dev/null
diff -ru rancid-2.3.6/bin/rancid-cvs.in rancid-2.3.6-grnet/bin/rancid-cvs.in
--- rancid-2.3.6/bin/rancid-cvs.in 2011-02-16 01:16:59.000000000 +0200
+++ rancid-2.3.6-grnet/bin/rancid-cvs.in 2011-11-26 00:12:08.000000000 +0200
@@ -93,11 +93,20 @@
fi
# Top level CVS stuff
-if [ ! -d $CVSROOT ]; then
- if [ $RCSSYS = cvs ]; then
+if [ $RCSSYS = cvs ]; then
+ if [ ! -d $CVSROOT ]; then
cvs -d $CVSROOT init
+ fi
+else
+ if echo "$CVSROOT" | grep -q "://"; then
+ # do nothing because CVSROOT is some sort of a URL
+ # also assume the repository has already been provisioned
+ :
else
- svnadmin create $CVSROOT @SVN_FSTYPE@
+ if [ ! -d $CVSROOT ] && ! svn ls "file://$CVSROOT" >/dev/null 2>&1; then
+ svnadmin create $CVSROOT @SVN_FSTYPE@
+ fi
+ CVSROOT="file://$CVSROOT"
fi
fi
@@ -128,9 +137,11 @@
cd $BASEDIR
cvs checkout $GROUP
else
- svn import -m "$GROUP" . file:///$CVSROOT/$GROUP
+ svn import -m "$GROUP" . $CVSROOT/$GROUP
cd $BASEDIR
- svn checkout file:///$CVSROOT/$GROUP $GROUP
+ svn checkout $CVSROOT/$GROUP $GROUP
+ cd $DIR
+ svn update
fi
fi
cd $DIR
diff -ru rancid-2.3.6/etc/rancid.conf.sample.in rancid-2.3.6-grnet/etc/rancid.conf.sample.in
--- rancid-2.3.6/etc/rancid.conf.sample.in 2011-02-16 01:16:59.000000000 +0200
+++ rancid-2.3.6-grnet/etc/rancid.conf.sample.in 2011-11-26 00:12:08.000000000 +0200
@@ -21,6 +21,15 @@
BASEDIR=@localstatedir@; export BASEDIR
PATH=@bindir@:@ENV_PATH@; export PATH
# Location of the CVS/SVN repository. Be careful changing this.
+# If RCSSYS is svn, this can be:
+# - an (absolute) path (a subdirectory of BASEDIR by default).
+# - any URL that subversion understands, but beware that:
+# - no attempt will be made to create the repository when
+# running rancid-cvs.
+# - authentication credentials, if necessary, MUST be cached
+# (see SVN book, Ch. 3, Network Model, Caching credentials)
+# before non-interactive commands can run, e.g. by running
+# rancid-cvs after installation.
CVSROOT=$BASEDIR/CVS; export CVSROOT
# Location of log files produced by rancid-run(1).
LOGDIR=$BASEDIR/logs; export LOGDIR
More information about the Rancid-discuss
mailing list