Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Streamline Drupal CVS checkout

Parent Feed: 

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!


function getmod () {
MODULE="${1}";
VERSION="${2}";
cvs -z6 -d:pserver:anonymous:[email protected]:/cvs/drupal-contrib co -r DRUPAL-6--$VERSION -d ./$MODULE contributions/modules/$MODULE;
cd $MODULE;
getrevs $MODULE.module
}
function getrevs() {
cvs log "${1}" | egrep 'DRUPAL-.*:' | sort
}
function updatemod(){
cvs update -r DRUPAL-6--"${1}" -dP
}
function getdrupal(){
FOLDER=${PWD##*/};
cd ..;
cvs -z6 -d:pserver:anonymous:[email protected]:/cvs/drupal checkout -d $FOLDER -r DRUPAL-"${1}" drupal;
cd $FOLDER
}
function updatedrupal(){
cvs update -r DRUPAL-"${1}" -dP
}

Drupal CVS bash script

Author: 
Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web