I'm not sure which Forum this kind of thing should go in so General Discussion it is. Here are two scripts to create and maintain a Subversion repository of the Drupal core code, along with specific modules and themes, from the main Drupal CVS repository. cvsdrupal can be used independantly to just maintain a local CVS working copy and along with svndrupal they will together create and maintain a full Subversion repository plus a checked out working copy meant to be the local live site for testing. If you prefer to work with and maintain your local Drupal code with Subversion then these scripts could be very useful to you. I'm not aware of any code anywhere that can just about automatically keep a Subversion "mirror" of a CVS working copy, otherwise I'd be using it. I hope I haven't reinvented a wheel but I guess someone will let me know if I have. Feedback and suggestions most welcome. I hope this is useful for someone beside just me.
cvsdrupal
#!/bin/sh
#
# cvsdrupal v0.0.3 20060628 markc@renta.net
#
# A Bash script to initialize and maintain a CVS checkout
# of the drupal.org codebase. Just run it once a day or once
# a week to keep your checkout uptodate.
#
# License: http://www.gnu.org/licenses/gpl.txt
# Change these settings to suit your environment:
#
# CVS_WC root path where the "drupal" folder goes
#
# CVS_SRC full exportable path to CVS repository
#
# REL is whatever version you want to check out,
# leave as is for the very latest version
#
# UGID the local user:group perms to use, leave
# empty to ignore
#
# PATCH path to local patchset to apply
#
# v0.0.3 20060628
# Added PATCH var and test for applying local patches
#
# v0.0.2 20060628
# First publication at drupal.org
#
# v0.0.1 20060627
# Initial draft and testing of code
CVS_WC=/home/p/drupal_cvs
CVS_SRC=:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal
REL=HEAD
UGID=1:1
PATCH=~/drupal.patches
# Add the extra modules you want here
MODULES="
project
subversion
svn
"
# Add any themes you want to this section
THEMES="
meta
"
# Below here should remain untouched
export CVSROOT=$CVS_SRC
[ -d $CVS_WC ] || mkdir -p $CVS_WC
if [ -d $CVS_WC/CVS ]; then
cd $CVS_WC
cvs -z6 up . -PAd -r $REL
else
cd $(dirname $CVS_WC)
cvs -z6 co -r $REL $(basename $CVS_WC)
[ ! -z $LOCAL_PATCH ] && cat $LOCAL_PATCH | patch
fi
export CVSROOT=${CVS_SRC}-contrib
for M in $MODULES; do
if [ -d $CVS_WC/modules/$M/CVS ]; then
cd $CVS_WC/modules/$M
cvs -z6 up . -PAd -r $REL
else
cd $CVS_WC/modules
cvs -z6 co -r $REL -d $M contributions/modules/$M
fi
done
for T in $THEMES; do
if [ -d $CVS_WC/themes/$T/CVS ]; then
cd $CVS_WC/themes/$T
cvs -z6 up . -PAd
else
cd $CVS_WC/themes
cvs -z6 co -r $REL -d $T contributions/themes/$T
fi
done
[ ! -z $UGID ] && chown $UGID -R $CVS_WC
svndrupal (requires above cvsdrupal script)
#!/bin/sh
#
# svndrupal v0.0.1 20060628 markc@renta.net
#
# A Bash script to create and maintain a subversion repository from
# a CVS working directory. It is tailored for drupal.org but could
# easily be modified for any CVS to subversion conversion. It also
# depends on "cvsdrupal" to create, checkout and update the CVS
# working dir from drupal.org.
#
# License: http://www.gnu.org/licenses/gpl.txt
# Change these settings to suit your environment:
#
# CVS_WC full path to the CVS checked out working copy, not used
# for anything other than as storage to convert to svn
#
# SVN_WC full path to the destination svn working copy, this is
# where the live web code resides for testing and changes
#
# SVN_DST the full path to the svn repo (not the working directory
# but the actual local Subversion repository)
#
# CI_MSG the default message for auto check ins, if empty then
# the usual editor will pop up to allow for a manual entry
#
# v0.0.1 20060628
# Initial draft and testing of code, and public release
CVS_WC=/home/p/drupal_cvs
SVN_WC=/home/p/drupal
SVN_DST=/home/s/lan/shuttle/phorge/drupal
CI_MSG=
[ ! -d $CVS_WC/CVS ] && cvsdrupal
if [ ! -d $SVN_DST/db ]; then
svnadmin create $SVN_DST
mkdir -p $SVN_WC
rsync -av --exclude=CVS/ $CVS_WC/ $SVN_WC
cd $SVN_WC
svn import . file://$SVN_DST -m "Initial import"
rm -rf * .??*
svn co file://$SVN_DST .
fi
if [ ! -d $SVN_WC ]; then
mkdir -p $SVN_WC
cd $SVN_WC
svn co file://$SVN_DST .
fi
cvsdrupal
rsync -av --size-only --exclude=CVS/ $CVS_WC/ $SVN_WC
cd $SVN_WC
svn status | grep ^\? | awk '{print "svn add "$2}' | sh
svn ci . $CI_MSG
Comments
Two quesions: 1) Is this
Two questions:
1) Is this script still usable today with Drupal 6?
2) Can I do a manual cvs update and only use the second script to update my svn repo?
I wouldn't use it for D6. I
I wouldn't use it for D6. I see that this script is saving contribuited modules and themes within a drupalroot/modules/contributions directory and a drupalroot/themes/contributions directory. To keep your contribuited modules and themes out of the core files you should importe them into drupalroot/sites/default/modules and drupalroot/sites/default/themes.
For the second question, the first script is needed to run the second, as it states, so you wouldn't.