Install Drupal and contributed modules and themes via cvs

The quickest and most efficient way to maintain a Drupal installation is in my opinion to install and update it via cvs. It looks complicated to start with but my experience is that when you get used to it you don’t want to do it any other way.

I will assume you already have cvs installed or otherwise know how to do it on your server. You also need to have shell access and be familiar with the command line. If this is not true you better stop reading :-).

Original article 2006-10-31, new revision 2007-11-16.

I will describe how a cvs install is done manually. Later I will show a couple of shell script to automate the procedure.

There are two Drupal modules that you should install first.

CVS deploy - Get the right version information for modules installed via cvs. The version information is used by the update status module and on the modules page at admin/build/modules. When you install modules via cvs the info files has no version info (they should’t have any at least).

Update status - Checks with drupal.org to see if there are new officially released versions of Drupal and any modules that you are running. Is part of core in Drupal 6.

With these two modules you will have all the module name and version information you need on one page, Available updates at admin/logs/updates. You load the “Available updates” page, put a Terminal window next to it and then get to work updating your Drupal installation.

For cvs I recommend you start by setting some good default options in the file ~/.cvsrc. See man cvs for more information about the option. This is what I use:

cvs -z3
update -dP
checkout -P
diff -up

Now we are ready to start installing. Assume we want to install Drupal on a shared host in a directory named “web”. First go to the parent directory of “web” and then use the following command to install Drupal 5.3 in the “web” directory.

cvs -d :pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal checkout -d web -r DRUPAL-5-3 drupal

You will now have the Drupal 5.3 code installed on your server.

Next up is to install some contributed modules and themes. There are a couple of different places you may choose to install these.

  • The main modules and theme directories together with the core files.
  • A sub directory, e.g. named “contrib” in the above directories.
  • Create your own modules and theme directories in sites/default or sites/example.com.

I favor the last option. This will keep core and contributed code separate and it will also keep all site specific code together. Many times I also put the files directory in the same place.

Change to the directory where you want to install the contributed modules. The following command will install version 5.x-1.1 of the Thickbox module in in a directory named “thickbox”.

cvs -d :pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -d thickbox -r DRUPAL-5--1-1 contributions/modules/thickbox

Change to the directory where you want to install the contributed themes. The following command will install version 5.x of the Slash theme in a directory named “slash”.

cvs -d :pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -d slash -r DRUPAL-5 contributions/themes/slash

Now it’s time keep all the code updated. You will need to do it once for the core Drupal install and once for each and every contributed module and them you have installed. The updates is done by going to the directory of the Drupal/module/theme install, e.g. web/thickbox/slash in the examples above, and give the following command. Replace “5—x-x” with the version you want.

cvs update -dP -r DRUPAL-5--x-x

It’s a good habit to make a dry run first by adding the option “-n”. This will not change any file, only report what would have happend.

cvs -n update -dP -r DRUPAL-5--x-x

If you followed my advice to set up a .cvsrc file with the default I suggested you can just do a cvs update -r DRUPAL-5--x-x instead.

If you have many contributed modules and themes it will be a small hassel to go through all the directories and issue the cvs update command. Compared to the alternatives it’s still a very quick and painless process.

To make it even better we can make some shell script to run the commands for us. Below you find one script to checkout (install) and one to update Drupal core, modules and themes via cvs. You can name them anything you like, I use “cvsdr” and “cvsup”. Short names, less typing.

cvsdr

#!/bin/sh
# $Id: cvsdr,v 1.1 2006/10/31 18:52:37 frjo Exp $
#
# Script to checkout Drupal core, modules and themes via cvs.

if [ "$1" = "" ]; then
  echo "Usage: name tag c|m|t (core/modules/themes) defaults to HEAD/module";
  exit 1;
fi

cmd="/usr/bin/cvs -d :pserver:anonymous:anonymous@cvs.drupal.org";

name=$1;
tag=`echo $2 | sed 's/DRUPAL-//'`;
type=$3;

if [ "${tag}" = "" ]; then
  tag="HEAD";
else
  tag=DRUPAL-${tag};
fi

if [ "${type}" = "t" ]; then
  type="themes";
elif [ "${type}" = "c" ]; then
  type="core";
else
  type="modules";
fi

if [ "${type}" = "core" ]; then
  echo "Doing this: /cvs/drupal checkout -d ${name} -r ${tag} drupal";
  ${cmd}:/cvs/drupal checkout -d ${name} -r ${tag} drupal;
else
  echo "Doing this: /cvs/drupal-contrib checkout -d ${name} -r ${tag} contributions/${type}/${name}";
  ${cmd}:/cvs/drupal-contrib checkout -d ${name} -r ${tag} contributions/${type}/${name};
fi

# end

cvsup

#!/bin/sh
# $Id: cvsup,v 1.1 2006/10/31 18:52:37 frjo Exp $
#
# Script to update Drupal core, modules and themes via cvs.

if [ "$1" = "" ]; then
  echo "Usage: tag : defaults to HEAD";
  exit 1;
fi

if [ "$2" != "" ]; then
  dry=" -n"
fi

cmd="/usr/bin/cvs${dry} update -dP";


tag=`echo $1 | sed 's/DRUPAL-//'`;

if [ "${tag}" = "" ]; then
  tag="HEAD";
else
  tag=DRUPAL-${tag};
fi

echo "Doing this: cvs${dry} update -dP -r ${tag}";
${cmd} -r ${tag};

# end

More reading:

Comments

Shell Access

And what it you don't have shell access?

If you have no shell access

If you have no shell access you can't use cvs in this way. You are stuck with manual uploads via FTP or something. My suggestion is to find a new web host that offer shell access.

Very handy little scripts

Jättebra små script, dom tackar man för! Grattis till en bra ranking hos Google, jag kom hit direkt genom att söka på "drupal install cvs". Hoppas resan är/blir trevlig, vi hörs senare!

Post new comment

The content of this field is kept private and will not be shown publicly.
  • No HTML tags allowed
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
1 + 12 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.