Hi, I'm Tim Millwood. I am a Web Developer from Abergavenny, UK, and work for Mark Boulton Design, specializing in Drupal. This is my blog!
Streamline Drupal CVS checkout
Today I had the task of checking out Drupal core and a load of modules for a new site, but all those CVS commands made me think there must be an easier way. So I started looking into scripting the process. This is when I came across Patrick Corbett's blog post "Drupal CVS Checkout Shortcuts".
(This is all done on Mac OS X Leopard) I started by opening up terminal and running the command "vi ~/.profile" this opened up the vi text editor and created the file .profile in my home directory. I copied the code from Patrick's blog post, saved, closed and reopened terminal and ran "getmod cck" to test it worked. To my amazement it worked.
Now came the time to change the script to make it do what I wanted. I wanted to be able to specify a module version, and checkout Drupal core. So I set out to find the right commands and write up the functions. Below you will see my code. I added a version variable to getmod() and I added getdrupal() and updatedrupal() functions to take care of core checkouts.
One issue I came across was that I wanted Drupal core to checkout into the current directory rather than the default "drupal" directory, but the problem was I didn't know what the current directory would be. Thanks to @bobthecow for the idea of using the pwd command. I was able to set the current directory to a $FOLDER variable, cd back one directory then checkout Drupal core into the previous directory using the value stored in $FOLDER.
To summerise. Copy the code below into a file called ".profile" in your home directory. Then restart terminal. Use the following commands.
getdrupal
updatedrupal
getmod
updatemod
Simple!
<br />
function getmod () {<br />
MODULE="${1}";<br />
VERSION="${2}";<br />
cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib co -r DRUPAL-6--$VERSION -d ./$MODULE contributions/modules/$MODULE;<br />
cd $MODULE;<br />
getrevs $MODULE.module<br />
}<br />
function getrevs() {<br />
cvs log "${1}" | egrep 'DRUPAL-.*:' | sort<br />
}<br />
function updatemod(){<br />
cvs update -r DRUPAL-6--"${1}" -dP<br />
}<br />
function getdrupal(){<br />
FOLDER=${PWD##*/};<br />
cd ..;<br />
cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal checkout -d $FOLDER -r DRUPAL-"${1}" drupal;<br />
cd $FOLDER<br />
}<br />
function updatedrupal(){<br />
cvs update -r DRUPAL-"${1}" -dP<br />
}<br />










