Adverts

This is one of the harder areas of the Linux build. It is a little harder than other sections because it is not anywhere nearly as well documented as things like Samba although it is defiantly getting there.

Set Up

First grab yourself a copy of the CVS Server

apt-get -u install cvs

should do it.

I suggest you use the standard path (/usr/local/cvsroot) for the CVS repository unless you have a particular reason to place it somewhere else. If you want to use and only CVS repository on a new machine just copy it to the new /usr/local/cvsroot. If you don't currently have a repository to bring over you will have to create one with this command

cvs -d /usr/local/cvsroot init

which will create a default empty repository at the path specified.Once you have the repository in place you have to run the CVS server from some form of super server such as xinetd or inetd.

Setup of xinetd

To set up xinetd create a file called "cvs" in "/etc/xinetd.d/" with the following content

service cvspserver
{
     port = 2401
     socket_type = stream
     protocol = tcp
     user = root
     wait = no
     type = UNLISTED
     server = /usr/bin/cvs
     server_args = -f --allow-root /usr/local/cvsroot pserver
     disable = no
}

which is simply a service definition. As you can see you can also change the port (2401 is the default) and you can specify a different location for the cvsroot. It is worth noting however that access to a pserver over the internet is asking for trouble unless you restrict it to anonymous read access only. If you want write access then you should use CVS over SSH which is covered below.

Setting up inetd

In order to use the pserver you have to ensure that it is correctly started from inetd (look in "/etc/inetd.conf") you should have a line like

cvspserver      stream  tcp     nowait  root    /usr/sbin/tcpd  /usr/sbin/cvs-pserver

Environment Variables

It is probably also a good idea to include the environment variable CVSROOT. I find that this is best included in /etc/profile since there is no security problems associated with all the users knowing where the repository is only with them being able to access it. Add these few lines to the /etc/profile file after the "export PATH " line. You will need to log out and log back in to cause the root process to re-read the file. Alternatively you can "su - your_username" with every new console window.

#CVS
CVSROOT=/usr/local/cvsroot
export CVSROOT

Adding Users

CVS allows you to add users independently of the underlying OS installation which is both a good thing and a bad thing. Probably the easiest way from a management point of view is to use the Linux users for CVS as well although this does have a few minor security issues since this is just a home network we will grin and bear it.

When you add a user cvs doesn't know that there is already a user on the system with that name. In /usr/loca/cvsroot/CVSROOT/passwd update the users to indicate that they are actually known system users rather than just CVS users. This is done by adding the name of the system account you want the cvs account to run as at the end of the line. Each line is made up of three parts <cvs_acc_name>:<cvs_password>:<sys_acc_name>

Now set up a user group called cvs or some such and add your users to this group. Give this group permission to write to the /usr/local/cvsroot directory and all subdirectories. Change the Group Ownership to be what ever the group was that you created above. Once this is done the CVS users "own" the cvs repository and can from now on create lock files in it.

To keep things simple at this stage we are giving all users the ability to read and write the repository. As things change you will probably want to change this. Allowing everybody access is the default set up.

The Client Side

Depending on what you are intending to do with CVS depends a little on which tools you will want to use on the client side to interact with your repository. I do most Java work and use NetBeans as my development environment of choice. This has built in CVS functionality that works very well.

CVS Tips

If you have an old CVS Repository sitting around from an old install just drop that in place. There is no need to re-import everything

An import can be performed using ssh as the communication channel by first setting the appropriate environment variable. For instance: (Note: the last two lines should be on one line I had to break it at the -m)

CVS_RSH=ssh
export CVS_RSH
cvs -d :ext:username@servername.com:/usr/local/cvsroot import -m
"initial check in" util crazysquirrel initial

In order to use CVS over SSH in NetBeans 3.6 you must have the SSH_Agent set up.

Define the location of the repositories in "/etc/cvs-pserver.conf". Then restart inetd with

To then check something out so that it can so that it can be modified use

CVS_RSH=ssh
export CVS_RSH
cvs -d :ext:username@servername.com:/usr/local/cvsroot checkout modulename

Where you have to replace username, servername.com and modulename (and optionally the /usr/local/cvsroot) with the correct values. Obviously the first two lines can be skipped if you already have this value set as an environment value. This system is particularly useful if you want to check out the repository for use in NetBeans and you don't want an extra level of directories present. I am sure it is possible to achieve the same result using NetBeans CVS module but I can't seem to make it work consistently. This on the other hand always provides a clean simple directory structure. Don't forget that you have delete the directory you imported above or the checkout wont work (because it tries to create this directory). Strictly speaking this is only the case where you are trying to checkout over the directory you have imported but I find I do this quite often and you probably don't want an old version of the files kicking about anyway.

Adverts

Donate and Help

Please support this site and
Bandwidth doesn't grow on trees y' know :o)

Adverts

Get Adsense