Setting up a CVS repository on FreeBSD in 5 minutes

Quickly throwing up a CVS repository seemed like a daunting task until I actually tried it. In retrospect it's absolutely trivial to set things up to the point of having a hierachy of directories which you can check stuff into and out of. If you want to stuff around with doing modules properly, decent access control, web interfaces to CVS, etc, that's beyond what I'm going to describe here.

The repository is running on my machine endor.internal, a P100 with 48Mb of RAM running FreeBSD 4.5.

1. Create the CVS user and group

Create a CVS user.

endor# adduser 
Enter username [a-z0-9_-]: cvs
Enter full name []: CVS User
Enter shell bash csh date no sh tcsh [sh]:

This means that anyone with the CVS user's password can access the repository without using their own username/password.

Enter home directory (full path) [/home/cvs]:
Uid [1003]:
Enter login class: default []:
Login group cvs [cvs]:

Everyone that you want to have access to the repository will belong to this group. If you already have such a group (for instance, you may have a coders group), you can use that group instead.

Login group is ``cvs''. Invite cvs into other groups: guest no
[no]: 
Enter password []:
Enter password again []:

Name:     cvs
Password: ****
Fullname: CVS User
Uid:      1003
Gid:      1003 (cvs)
Class:
Groups:   cvs
HOME:     /home/cvs
Shell:    /bin/sh
OK? (y/n) [y]: 
Added user ``cvs''
Add another user? (y/n) [y]: n
endor#

Add any users that you wish to have access to the CVS repository to the CVS group.

cvs:*:1003:cvs,andrew

2. Create your CVS repository

/exports/cvsroot seems to be the typical place to throw a CVS repository. As I didn't have a /exports, I created it under /usr and symlinked to it from /.

endor# mkdir /usr/exports
endor# cd /
endor# ln -s /usr/cvsroot

Create the CVS directory, owned by the user and group you just created, and writable by both.

endor# mkdir /exports/cvsroot
endor# chown cvs:cvs /exports/cvsroot
endor# chmod 775 /exports/cvsroot

As the CVS user, initialise the repository.

endor# su cvs
$ cvs -d /exports/cvsroot init

That's it! You can now use CVS as a local user, or as a remote user over SSH/RSH to import modules, add, update, commit, etc. As a local user, set the CVSROOT to /exports/cvsroot. As a remote user, set the CVSROOT to :ext:username@host:/exports/cvsroot.

If using SSH, under Unix you'll want to set CVS_RSH to ssh. From WinCvs on Windows using PuTTY, go into Admin->Preferences->Ports and type in the path to a copy of plink.exe as the "alternate rsh." Note that you'll need to set up private key authentication for this to work, as otherwise WinCvs will choke when plink asks for the password.

3. Setting up pserver

Pserver is an alternative to RSH/SSH access for users accessing the repository remotely.

Make sure the pserver port is in /etc/services. It already is in FBSD-4.5.

cvspserver      2401/tcp   #CVS network server

Add the pserver line in /etc/inetd.conf. It's already mostly there in FreeBSD 4.5 - uncomment it and point it to /exports/cvsroot. Note that tabs are commonly used between columns, spaces between the arguments to cvs.

cvspserver   stream   tcp   nowait   root   /usr/bin/cvs   cvs --allow-root=/exports/cvsroot pserver

Check to see if inetd is running, and if it is, send it a HUP signal so it re-reads /etc/inetd.conf.

endor# ps ax | grep inetd
20194  ??  Is     0:00.00 /usr/sbin/inetd
endor# kill -1 20194

If it isn't running, start it ...

endor# /usr/sbin/inetd

... and add the following line to /etc/rc.conf so it will be automatically started when the system comes up.

inetd_enable="YES"

You can now access the repository remotely using the pserver. Set CVSROOT to :pserver:username@host:/exports/cvsroot. When using the pserver you'll need to do a cvs login before anything else.

4. About this document

This document was written by Andrew Francis, and should be available from http://www.sullust.net/docs/quickcvs.html.

It was distilled from some lecture slides on CVS by Peter Parnes, available here.

I punched it up in HTML using Vim. I really should learn DocBook.


Copyright © Andrew Francis 2002. Fully XHTML 1.0 Compliant!
$Id: quickcvs.html,v 1.3 2002/04/13 17:21:08 andrew Exp $