Archive

Posts Tagged ‘CVS’

Setting Up a CVS Repository

August 4, 2008 1 comment

I use Concurrent Versions System (CVS) for almost every important source code file. It acts as a backup copy for valuable information and is also very useful when multiple developers are working on the same project.

A concurrent versions system is used to manage source code changes over time and across multiple developers. These days CVS is one of the most widely used source code management systems for software development.

Although there are many applications that perform well as a CVS repository manager, “CVS” and “Subversion” are preferred by most people.

The next steps will get you started with the creation of a CVS repository with the plus that all the information is going to travel through a secure tunnel: SSH

The requirements are fairly easy: A computer with SSH capabilities and cvs installed. For this example lets suppose the IP of our server is 10.50.51.52.

As always, yum and apt-get will help you get the needed files (if you don’t already have them).

On Debian based systems:
$ apt-get install cvs

On Fedora based systems:
$ yum install cvs

You can check the installation with the next command

$ cvs - v

It is strongly recommended to use CVS version 2.11 or higher. Previous versions contain bugs on some Intel architectures.

First of all you need to create a default cvs group and user.

$ useradd -g cvs cvsadmin
$ passwd cvsadmin
$ su - cvsadmin

Now create the folder where you are going to put the source files. It is best to chose one with plenty of space for the backups.

# mkdir /opt/cvsroot

It is time to define the CVS repository pointing to the newly created folder.

# cvs server -d /opt/cvsroot

This command will create a folder named “CVS” inside /cvsroot and put some files containing internal data of the cvs repository (all directories under CVS control will have this subdirectory). It is a useful practice to take a look at the content of the CVS files, but there is 99% chance you will never have to modify them.

Your CVS repository is up and ready but nobody is still using it. Your fellows John, Jane and Peter are desperate asking you to backup their source code versions.

So lets add some users. Remember to assign them to group cvs, otherwise they will have a “Permission denied” error.

$ useradd -g cvs john
$ useradd -g cvs jane
$ useradd -g cvs peter

$ passwd john
$ passwd jane
$ passwd peter

After this you will need to call John, Jane and Peter and tell them to run the following code on their machines:

For John:
# export CVSROOT = :ext:john@10.50.51.52:/opt/cvsroot

For Jane:
# export CVSROOT = :ext:jane@10.50.51.52:/opt/cvsroot

For Peter:
# export CVSROOT = :ext:peter@10.50.51.52:/opt/cvsroot

Note the IP address pointing to the CVS server. Every CVS user has the ability to add new data to the repository.

This is it, you have set up a CVS server!. But, how to use it?

Here is a brief example. Suppose John wants to upload the stable version of the project /home/SourceCode/:

# cd /home/SourceCode/
# cvs import -m "This is the stable version" SourceCode start version1.0

The template is the following:

# cvs -m [PERSONAL COMMENT] [NAME OF THE MODULE] [MODULE COMMENT] [BRANCH]

But then Jane and Peter want to get a copy of what Jonh uploaded to the CVS.

# cd /home/
# cvs checkout SourceCode

Checking out a project in CVS will create a CVS working copy. There is a shortcut for the command cvs checkout. Just type cvs co.

Then Jane finds a bug and edits the source code of the file index.html. To upload her changes she just have to issue the next command:

# cvs commit /home/index.html

And someday Jane calls you saying she screwed up her local copy of the index.html file and now the code is a mess. Do not worry, to recover the last stable version from CVS, then just update your files with the following command:

# cvs update /home/index.hml

This has been a fun little example. You can delete all the /opt/cvsroot/ stuff if you like now. Try putting something real into CVS, just to get yourself using it regularly.

CVS has fully compatible versions on Unix, Linux, Windows and MacOS. There are also simpler interfaces, web-based. When you’re ready, here are some other links:

CVS Official Web
CVS Official Manual

Categories: CVS Tags: