Using CVS to Upgrade a Drupal Site

If you have many Drupal sites under development, it may become quite difficult dealing with the frequent security upgrades that are released. Learning to use CVS commands can simplify this process considerably. CVS or Concurrent Versions System is a predecessor to Subversion.

As Collins-Sussman wrote in Version Control with Subversion:

“In the world of open source software, the Concurrent Version System (CVS) has long been the tool of choice for version control. And rightly so. CVS itself is free software, and its non-restrictive modus operandi and support for networked operation – which allow dozens of geographically dispersed programmers to share their work – fits the collaborative nature of the open-source world very well. CVS and its semi-chaotic development model have become cornerstones of open-source.”

CVS Commands:

The following line will install drupal 5-10 into dir drupal-5 from your current location.
(if you execute it from /www then it will install to /www/drupal-5/ )

/opt/csw/bin/cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal co -d drupal-5 -r DRUPAL-5-10 drupal

The following line will install drupal 6-4 into dir drupal-6 from your current location:

/opt/csw/bin/cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal co -d drupal-6 -r DRUPAL-6-4 drupal

To install a module, i.e. Views:

/opt/csw/bin/cvs co -d sites/all/modules/views -r DRUPAL-5–1-6 contributions/modules/views

To install a module, i.e. CCK:

/opt/csw/bin/cvs co -d sites/all/modules/cck -r DRUPAL-5–1-7 contributions/modules/cck

For an explanation of the above examples:

/opt/csw/bin/cvs – this is the path to CVS
co -d
sites/all/modules/views
-r
DRUPAL-5–1-7

This is important. It states the version of the module that you wish to check out. if you were for example to replace DRUPAL-5–1-7 with DRUPAL-5–1-6 it would check out version 5–1-6 not 5–1-7.

contributions/modules/cck

This is the cvs path to the version ( DRUPAL-5–1-7 ) that you wish to checkout.
See: http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/cck/
It is simply the path from the end of the url, reflected online from CVS path.

run from dir /www/drupal-5/sites/all/modules/cck
/opt/csw/bin/cvs update -r DRUPAL-5–1-7 –dP

Setting up the Drupal Installation:

To install CCK for drupal 6 run this command from the drupal-6 root dir, i.e. /www/drupal-6 (run from there as the path is already included in the syntax, sites/modules/all)

CVS checks out (downloads) the requested module to wherever the syntax tells it to: sites/all/modules/cck

/opt/csw/bin/cvs co -d sites/all/modules/cck -r DRUPAL-6–2-0-RC4 contributions/modules/cck

Another example, once more executed from /www/drupal6/

/opt/csw/bin/cvs co -d sites/all/modules/views -r DRUPAL-6–2-0-RC1 contributions/modules/views

This has of course checked out the views module from the CVS repository, version 6–2-0-RC1 and put it into /contributions/modules/views for us.

How to Install a Theme:

Go to the drupal-6 root dir /www/drupal-6

To install the Refresco theme:

Navigate through the CVS repository to find the most recent stable release. http://cvs.drupal.org/viewvc.py/drupal/contributions/themes/refresco/ from there you can find the latest stable is 6–1-1

Note: that the source and destination paths have changed from modules to themes in the following syntax.

/opt/csw/bin/cvs co -d sites/all/themes/refresco -r DRUPAL-6–1-1 contributions/themes/refresco

Thanks to Andy at Touch & Click for providing this information – hopefully it will be of use in saving some time for those who have to upgrade Drupal on a regular basis.

For more information, see:
http://drupal.org/handbook/cvs
http://drupal.org/node/320

Share and Enjoy:
  • Twitter
  • del.icio.us
  • StumbleUpon
  • Digg
  • Sphinn
  • Facebook
  • Google Bookmarks

Related Posts:

13 Responses to “Using CVS to Upgrade a Drupal Site”

  1. I’m just going to say it. I wish they’d let me use Subversion. Almost everything else I do uses Subversion (PhpMyAdmin, WordPress, ZendFramework, and all my personal stuff).

  2. proxous says:

    I recommend using drush for drupal instead of CVS, that way you have recommended updates instead of the latest.

  3. Sidharth says:

    I’d recommend using drush too. Its unnecessarily complicated. Perhaps Jeff could explain why using CVS in this way is advantageous.

    One way that would be useful to me is that I have patched different files on my local implementation. Say I’m running 5.7.1 (modified locally) and want to upgrade to 5.10.1…how will CVS help me in maintaining those patches that I have put locally?

    What I also did not understand is why you need to specify a drupal revision number e.g. 5.7.1 etc. for a *module*. When new versions of a module released and if Drupal’s current version is 5.10.1 will the 5.7.1 tree get the updated module?

  4. proxous and Sidharth: I’m not a CVS expert by any stretch, but isn’t the -r DRUPAL-x-x-x there so you can specify a tagged version rather than getting bleeding edge stuff?

    As for CVS helping to maintain local patches, I assume that CVS works much like Subversion in this. If you have local changes, it will try to patch the local file if it can (integrate the new without losing your updates), and if it can’t, it will ask you to manually merge the files.

    However, drush is very interesting to me. Are either of you familiar enough with it to be interested in writing a drush article to be posted here?

  5. Sidharth says:

    Thanks for your initial article…it caused me to think about cvs. I did some research and I think that the way you are downloading modules from cvs is not really correct.

    Because you can allow drush to use CVS also. The command that drush uses to install a particular module looks like this (you need to activate the cvs download method which then becomes the default instead of wget method):

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

    Note:
    1. The root is /cvs/drupal-contrib and not /cvs/drupal
    2. The revision number is the tagged revision number of the *module* (Note: DRUPAL-5--1-5 means 5.x-1.5)

    Note that if you are using cvs as a way to download modules, this will cause update status for modules to stop working for these modules. This is because the version string gets messed up. To solve this problem, please install cvs_deploy module. Read README.txt in the module directory for more information.

    In summary:
    1. You can use drush to download from cvs. It just allows you to issue simpler commands.
    2. If you are using direct cvs commands or the drush in the cvs mode, be sure to install the drupal cvs_deploy module so that update status can still work.

    Other useful commands, e.g. to simulate a command you should use the -n option (see cvs documentation).

    To see the tags / branches for a particular file:

    cvs status -v filename_xyz

    If you think that this is a better way, can you please update the documentation to reflect the new method?

  6. Sidharth says:

    Continuing above,

    say you want to update the google_analytics module from version 5.x-1.5 to 5.x-1.6 then you would issue the command in the google_analytics folder:

    cvs update -dP -r DRUPAL-5--1.6

    -d allows any required directories in the new version (if any) to be created
    -P allows any unused directories in the old version to be deleted

    To simulate the command without updating:

    cvs -n update -dP

    NOTE: There is a small typo in my previous comment. It should be
    -r DRUPAL-5--1.5 and NOT -r DRUPAL-5-1.5(with one ‘-’ only)

    Also it may be instructive to see the output of:

    cvs status -v README.txt

    where README.txt is the readme file in the google_analytics directory…

    ===================================================================
    File: README.txt Status: Up-to-date

    Working revision: 1.2.4.4
    Repository revision: 1.2.4.4 /cvs/drupal-contrib/contributions/modules/google_analytics/README.txt,v
    Commit Identifier: 73e24838784c4567
    Sticky Tag: DRUPAL-5--1-6 (revision: 1.2.4.4)
    Sticky Date: (none)
    Sticky Options: (none)

    Existing Tags:
    DRUPAL-6--1-2 (revision: 1.3.2.3)
    DRUPAL-5--1-6 (revision: 1.2.4.4)
    DRUPAL-5--1-5 (revision: 1.2.4.4)
    DRUPAL-6--1-1 (revision: 1.3.2.3)
    DRUPAL-6--1-0 (revision: 1.3.2.2)
    DRUPAL-5--1-4 (revision: 1.2.4.3)
    DRUPAL-6--1 (branch: 1.3.2)
    DRUPAL-5--1-3 (revision: 1.2.4.3)
    DRUPAL-5--1-2 (revision: 1.2.4.1)
    DRUPAL-5--1-1 (revision: 1.2.4.1)
    DRUPAL-5--1-0 (revision: 1.2)
    DRUPAL-5 (branch: 1.2.4)
    DRUPAL-4-7 (branch: 1.2.2)
    DRUPAL-4-6 (branch: 1.1.2)

    ==========

    Also these tags can be seen from the release notes link which is adjacent to the module download section on drupal.org

  7. Sidharth says:

    Sorry for clogging this with comments. But wordpress is messing things up… Two ‘–’ s are being joined to one long ‘-’. In this case having ‘-’ is critical because that is what the tag is named…

    So it is DRUPAL-5--1.5 with two ‘-’ between 5 and 1.5

  8. Sidharth – thanks for this, really excellent. I also would like to see an updated documentation that includes all the different methods and tools in one place.

  9. Sidharth: I added some code tags around parts of your comments. It seems to have helped the double – problem. Thanks for all the info.

  10. Web Design says:

    Thanks for the how-to, much helpful and appreciated.

  11. Followed it to a T and all is well, thank you.

  12. Wish List says:

    I decided to use drush instead of cvs, seems easier for me.

Leave a Reply

Pings/Trackbacks

  1. [...] Using CVS to Upgrade a Drupal Site (tags: drupal update cvs) [...]