Setting Own CVS Repository

General Information

In this guide I’d like to present a short info on setting own CVS repository. It has been written with an assumption that the repository will be accessed locally and through the SSH connection. Using ssh might require setting $CVS_RSH=ssh environment variable on client system.


  1. Updated ports collection (for mail notification).
  2. root or sudo rights.

Repository Initiation

The cvs utility is a part of base system on all BSDs, thus no special installation steps are needed to make it up and running.

One of the things you’ll have to do when initializing new repository is to decide on it’s location (for example /home/cvs) and structure, as later modifications may present some problems. You should also choose a system user that will actually own repository’s files. Most commonly one of the sysadmin’s accounts is used.

Next step is to create a system group, i.e. cvs, that will consist of all users that will have an access to the repository.

# pw add group cvs

Now, you can initialize the repository:

# cd /home
# mkdir cvs
# cvs -d /home/cvs init
# chown -R cvsadmin:cvs /home/cvs

Now, you can put your project into the repository:

$ cd $HOME/project1
$ cvs -d /home/cvs/ import project1 mysoft v1
N project1/project.c

No conflicts created by this import

The general syntax for importing sources into the repository is:

# cvs -d  import   

Now, let’s add your project to the repository:

$ cd ..
$ cvs -d /home/cvs/ co project1
cvs checkout: Updating project1
U project1/project.c
$ cd project1/
$ ls
CVS       project.c

You’re done…

Adding Useful Features

Ports Collection have some fine applications for sending e-mail notifications when any changes are done to the repository. In this guide I’ll present a CVSSpam application that generate nice HTML messages. For plain text messages take a look at ActivityMail.

Installing the CVSSpam

# cd /usr/ports/devel/cvsspam
# make install clean


Having done that you can create a temporary directory to checkout repository’s configuration files:

$ mkdir $HOME/temp
$ cd $HOME/temp
$ cvs -d /home/cvs/ co CVSROOT

Now, you can copy cvsspam files to CVSROOT directory. These should be: collect_diffs.rb, cvsspam.rb, record_lastdir.rb.

$ cp /usr/local/libexec/cvsspam/* ./

Next, add them to the checkoutlist so they also would be uploaded do the repository:

$ ls *.rb >> checkoutlist
$ cvs commit checkoutlist

… and add them to the repository:

$ cvs add *.rb
$ cvs commit

And now for the final touch add appropriate configuration to commitinfo and loginfo files:

$ echo "DEFAULT $CVSROOT/CVSROOT/record_lastdir.rb" >> commitinfo
$ echo "DEFAULT $CVSROOT/CVSROOT/activitymail -dSf %{sVv} -t" >> loginfo
$ cvs commit

Now, every time any change will be done to the repository an email will be sent to the address, which most commonly is the mailing list address used by the developers.

What about substituting normal $Id$ tag for a custom one, like all the BSD projects does in their source files? There’s actually nothing to it. Having checked out the CVSROOT add options file to the checkoutlist:

$ echo "options" >> checkoutlist
$ cvs commit

… and then create the file:

$ echo "tag=FreeBSD=CVSHeader" >> options
$ cvs add options
$ cvs commit

That’s it! Now you have your own CVS repository up and running. Next step is adding an anonymous cvs support, but that’s the subject for another guide.

Speak Your Mind