Downloading Source Trees 101

Discover how to check out the latest development tree of your favorite projects using CVS or Subversion.

If you’ve been using open source for a good length of time, you’ve probably needed a feature or bug fix that’s only available in the development tree of a open source project. For example, if you want to use PostgreSQL with RTG, you have to download and build the developers’ latest code. (Those exact instructions can be found in the March 2005 “Tech Support” column, located online at http://www.linux-mag.com/2005-03/tech_01.html/.)

Unlike stable releases, which are usually conveniently available for download as either source tarballs or binary packages, development code is often only available from a project’s source code repository. Typically, a repository is either a CVS (http://www.nongnu.org/cvs/) or Subversion (SVN, http://subversion.tigris.org/) repository.

Here, let’s see how to use CVS and SVN to access the development tree of a few notable projects.

To try CVS, let’s download the latest version of RTG and the most recent version of Mozilla Firefox. Both examples use an anonymous CVS account, which means that you can check out any code you want to, but cannot commit any changes.

First, let’s check out the latest version of RTG. To do that, type:

$ cvs –d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/rtg login
$ cvs –z3 –d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/rtg co –P rtg

When prompted for a password, just hit Enter. The –z3 parameter causes files to be compressed while in transit. (While –z3 is usually optimal, –z9 offers a logarithmic improvement in compression at an exponential cost in CPU time.)

As you can see, RTG is hosted on SourceForge, where CVS access is consistent across all 100,000+ registered Sourceforge projects. Here is a generic formula for checking out code from any SourceForge project:

$ projectname=rtg; modulename=rtg
$ cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/$projectname login
$ cvs –z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/$projectname \
co –P $modulename

projectname is set to the name of the project and $modulename is name of the CVS module that you’d like to checkout. If you do not know the module name, you can use the web-based CVS repository viewer for the project to determine the proper module name.

The Mozilla CVS checkout process is a little more complicated and is prone to change. Because of this, the Mozilla Foundation has created a convenient and automated way to check out code: just check out a single script and let it perform all of the heavy lifting. Here’s how:

$ export CVSROOT=:pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot
$ cvs login
(Logging in to anonymous@cvs-mirror.mozilla.org)
CVS password: anonymous
$ cvs checkout mozilla/client.mk
U mozilla/client.mk
$ cd mozilla
$ make –f client.mk checkout MOZ_CO_PROJECT=browser

(The commands above assume you are using the bash shell. If you’re using another shell, such as tcsh, change the export lines to the appropriate form for setenv.) The make line automates the checkout of the browser CVS module that contains the Firefox code. You should only need to run cvs login once, as the password is remembered after that.

Next, let’s see how to check out code for any project from the Apache Software Foundation (ASF) using SVN. To get a list of modules that are available in the ASF subversion repository, type:

$ svn list http://svn.apache.org/repos/asf/

To check out the Spam Assassin code, type:

$ svn co http://svn.apache.org/repos/asf/spamassassin/trunk spamassassin

With Subversion, after you download a project’s code once, you can quickly update your code snapshot to the latest version by executing svn up, which downloads only the changes made since your original checkout or since your last svn up. For example, svn up spamassassin would update your Spam Assassin code to match the latest and greatest code in the project’s repository.

You should now have a basic idea of how to acquire the latest code from your favorite projects. Remember that development branches can sometimes be unstable, so make sure to test your builds throughly. Happy compiling.

Jeremy Garcia is the founder and administrator of LinuxQuestions.org, a free, friendly, and active Linux community. Please send questions and feedback to class="emailaddress">jeremy@linuxquestions.org.

Comments are closed.