Managing multiple drupal installations can be a pain. You have to track changes to drupal-core and all the individual modules that you use, as well as managing your own custom modules and your own custom changes to drupal-core. And if if you’re doing this with several different drupal installations it can get inconvenient quickly.
A lot of this hassle can be reduced by installing drupal from cvs rather than installing one of the releases, and by keeping your installation under version control (in this article I use git [1] but you could use any VCS such as mercurial, svn etc).
Here I describe how I manage my drupal installations using the drupal cvs repository and git.
Note Drupal 6 has recently been released. If you want to use drupal 6 replace each occurrence of DRUPAL-5 with DRUPAL-6 in the cvs commands below. Note: It will take a while for all the drupal modules to get drupal 6 releases.
Drupal Core
Check out drupal-core
cvs -z9 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal checkout -r DRUPAL-5 drupalcreate sites/localhost
Store your development configuration here so it doesn’t conflict with the settings file in the CVS.
Drupal Modules
Create sites/modules and sites/themes and use these directories to store your drupal modules and themes.
Check out individual drupal modules that you use regularly. For example to check our the marksmarty module issue the following command from sites/modules.
cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal checkout -d ./marksmarty -r DRUPAL-5 contributions/modules/marksmartyFor other modules replace the two occurrences of marksmarty in the command above with the cvs name of the module you want. Note: not all module maintainers maintain a proper tag/branch structure for their code. For these you should download the module tar.gz file for drupal5 instead of doing the cvs checkout.
Updating drupal-core and modules
Run cvs update whenever you need to update stuff. For example if one of the modules you use issues an update, change into the directory for that module and run cvs update. If there is a security patch for drupal-core run cvs update from the root directory.
Put it all in git
Check this entire repository into a new git repository. Use cvs update to grab changes to drupal-core and modules and use git to track your own customizations and modules.
This git repository is our gold-standard drupal install. It can now be used to track drupal-core and whatever modules you use in all your projects. You can use this as a base for keeping all your drupal5 projects up to date.
Now at this stage you can use this repository for your application too. And if you maintain all your drupal applications from a single drupal codebase then this is probably the way to go. But if you have several drupal applications or you make modifications to drupal you may want to just use this repository to track drupal and a separate one for your application. We can do this by cloning this repository.
Clone this repository for new projects
Now we can clone this repository when we want to start a new project. It gives up a clean, up-to-date drupal install. And whenever we get updates to drupal-core or modules we can pull these changes from our original repository into each of the individual application repositories.
git clone drupal-5-cvs drupal-my-new-projectWe use this repository for our project. This will have our own custom modules. It may also be the case that we make changes to some of the drupal-core code or some of the core modules.
git pull This command will now pull in any new changes from our drupal-5-cvs repository and merge them into this, our application repository.
Summary
So once this is setup our workflow for updates is:
- If there is an update for drupal-core we run
cvs updateto get those changes from the drupal cvs repository. We then check these changes into our git repository. - If there is an update for one of the drupal modules we run
cvs updatefor that module directory and then check these changes into our git repository. - We use git pull command to merge these changes into our application git repository. If we have made changes ourselves to some of the drupal files we deal with the conflicts as they occur.
Note: There is also a git mirror of the drupal [2] cvs repository available.