Setting Up and Using CVS
For those of you who are interested, I describe the steps it takes to set up a CVS server on a Red Hat-based system. The steps I provide here are almost certainly going to be the same when executed on non-Red Hat systems, and may differ in certain ways on other UNIX-based systems, including Mac OS X. The work involved in getting a CVS server up and running is not terribly difﬁcult, and can be done in a relatively short amount of time. You will need root access to the system upon which you are installing the server, and it will help to have a second system with a CVS client so that you can test the result.
That said, if doing system administration makes you nervous, or site policy disallows it, or you do not have root access, check with a local guru or your system administrator for help.
To start the process of getting a CVS server running, you need to download the source for CVS from the Internet, build it, and install it. I retrieved a nonstable version of CVS by downloading the ﬁle cvs-1.11.22. tar.gz from http://ftp.gnu.org/non-gnu/cvs/source/stable/1.1.22. You are probably best, however, grabbing the latest stable version you can ﬁnd.
After you have unpacked the ﬁle, cd into the top-level directory (in my case, cvs-1.11.22), and enter the following to build and install the source:
Next, while still logged in as root, you need to do some work so that the CVS server daemon executes each time the system is rebooted. The ﬁrst step is to check to see whether entries like the following are located in /etc/services:
cvspserver 2401/tcp # CVS client/server operations
If these lines donít exist, add them to /etc/services as shown. Next, you need to create a ﬁle named cvspserver in /etc/xinetd.d that contains the following:
Make sure the permissions of this ﬁle are -rw-r--r--, and that its group and owner are root. This is probably the default, but it doesnít hurt to check.
If you are not yet running the desktop graphical user interface (GUI), ﬁre it up, and from the Red Hat Start menu, select System Settings, Users and Groups to launch the Red Hat User Manager.
In the dialog that is displayed, click the Add Group button and add a group named cvsadmin. Next, click the Add User button, and add a user named cvsuser. You will be asked to provide a password; enter in something you can remember, and when you are done, exit the Red Hat User Manager.
Back in a terminal, and still as root, enter the following:
# cd /usr
The preceding commands create the root directory for the CVS server. The path /usr/cvsroot corresponds to the value used in the server_args ﬁeld of the service aggregate that was created earlier in /etc/xinetd.d. The following commands create a locks directory below cvsroot:
# cd cvsroot
Now that the directory exists for the repository, it is time to create the repository. You can do this by executing the cvs init command, as follows:
# cvs -d /usr/cvsroot init
The -d argument speciﬁes the location of the repository.
Now that the repository has been created, change to your home directory (for example, /home/syd), and execute the following command, which will check out the CVSROOT module from the repository that was just created:
# cvs -d /usr/cvsroot checkout CVSROOT
Next, cd into the CVSROOT directory that was created by the preceding command, and open up the ﬁle named conﬁg using your favorite editor. Make the contents of this ﬁle consistent with the following:
# Set this to "no" if pserver shouldn't check system
# Put CVS lock files in this directory rather than
# Set 'TopLevelAdmin' to 'yes' to create a CVS
# Set 'LogHistory' to 'all' or 'TOFEWGCMAR' to log all
# Set 'RereadLogAfterVerify' to 'always' (the default)
After you have made changes to the conﬁg ﬁle, check it into CVS as follows:
# cvs commit
In the same directory, run the following command to create a password for each user for whom you want to grant access to the repository. Every time you add a new developer to the project, you need to update the passwd ﬁle as I am about to describe, and check the changes into the repository:
# htpasswd passwd syd
Now, open the ﬁle passwd (which was just created). At the end of the password, append :cvsuser. The result should look something like this:
Next, you must add the password ﬁle to the repository, and commit the result:
# cvs -d /usr/cvsroot add passwd
This should result in two ﬁles in /usr/cvsroot/CVSROOT, one named passwd,v and the other named passwd. If there is not a ﬁle named passwd in /usr/cvsroot/CVSROOT (this could happen because of a bug in CVS), return to the checked-out version of CVSROOT (for example, the one in your home directory), edit the ﬁle named checkoutlist, and add a line to the end of the ﬁle that contains the text passwd. Then, doing a cvs commit on the checkoutlist ﬁle will cause the passwd ﬁle in /usr/cvsroot/CVSROOT to appear.
Now all that is left is to make the modules. Each directory you create under /usr/cvsroot is, logically, a project that is maintained in the repository. You can organize the hierarchy as you see ﬁt. Here, I create a project named client:
# cd /usr/cvsroot
Now that we have created the repository, added a project, and set up some users, we can start the CVS server daemon by kicking xinetd:
# /etc/init.d/xinetd restart
To ensure that the CVS server is running, run the following command:
# netstat -a | grep cvs
If you see output like the following, everything is in order, and you can use the repository:
tcp 0 0 *:cvspserver *:* LISTEN
To test out the new server and repository, ﬁnd another machine, open up a shell (or a GUI CVS client if you prefer), and then check out the project named client. In the following example, I am using a command-line CVS client, and the server is located on my local network at the IP address 192.168.1.102:
$ cvs -d :pserver:email@example.com:/usr/cvsroot login
There now should be a directory named client in the current directory. If you cd into the client directory, you should see the following contents:
$ cd client
At this point, you can add ﬁles and directories to the project with cvs add, and commit them to the repository using cvs commit.
blog comments powered by Disqus