First my primary source, the ubuntu howto. Most of what I describe is described there. The first steps are to install cvs and a superserver, xinetd, which manages the cvs process, I don’t know too many of the technical details of the superserver, but I was able to successfully start a repository.
sudo apt-get install cvs xinetd
Then one needs to create a cvs repository directory, this is where cvs puts all the files it needs and is unrelated to the project directories one will probably be importing later. /var/lib/cvs is a common choice, and what I used.
sudo mkdir cvs
Now we reach a part that I believe is glossed over in the howto. Namely getting permissions right on the cvs directory. Users need to be able to write to the cvs directory, which would not be possible at this point because it’s owned by root and the root group. So I went to the user admin and added a group named cvsgroup, but you could choose any name you wanted, just make sure that the system accounts corresponding to the cvs users belong to the cvsgroup. Then go back and change the group ownership of /var/lib/cvs to cvsgroup. And then give the cvsgroup write permissions in the cvs dir.
sudo chgrp cvsgroup cvs
sudo chmod 775 cvs
Now the cvgroup owns the directory /var/lib/cvs, and any user belonging to that group can write to the cvs directory. Next we need to initialize the cvs repository (I had to logout and log back in at this point, I assume so that the computer understood that I was in the cvsgroup, which didn’t exist when I logged in).
cvs -d /var/lib/cvs init
Now we have a cvs repository. We make some changes to the configuration file of xinetd.
sudo gedit /etc/xinetd.d/cvspserver
and you can just copy paste this (though if you’re not using /var/lib/cvs make sure to change it):
port = 2401
socket_type = stream
protocol = tcp
user = root
wait = no
type = UNLISTED
server = /usr/bin/cvs
server_args = -f –allow-root /var/lib/cvs pserver
disable = no
Then we need to restart xinetd:
sudo /etc/init.d/xinetd restart
And finally, we import our project. For the purposes of testing I had hello world in a directory named ~/lib/testproj so I changed to that directory then I import.
cvs -d /var/lib/cvs import -m “this is the initial state of the testproject” . testproj start
And in that command the cvs gets you the cvs program, the -d option allows you to specific where the cvs repo lives, import is the command that cvs is running, -m allows you to write a note (generally used as a change log), the . tells it to import the current directory, testproj is naming the project (I think it’s nice if that name matches the directory name of the project), and finally start is something like a timestamp. A bit of a complicated command. The -d option can also allow remote connections, as
And finally you’re going to want to attach passwords to cvs users, to do this we go to our cvs base directory (/var/lib/cvs in this case), change to the CVSROOT directory and edit passwd (which does not exist by default). Syntax follows this format
(interestingly I made a mistake and used cvsgroup as the system username for my cvs user, and although it did not exist as a user, only as a group, it worked ok), also to get a passwordhash, you can use this perl script lifted from here. Invoke as ./scriptname username then you will be prompted for the password, you can copy and paste the output to your passwd file. At this point you should be all set to go with import, commit and update commands as you may have used on repositories someone else has set up. For convience sake it’s nice to set CVSROOT as an environmental variable in your .bashrc or whereever else you may.
$user = shift @ARGV || die “cvspasswd user\n”;
print “Enter password for $user: “;
system “stty -echo”;
chomp ($plain = <>);
system “stty echo”;
@chars = (‘A’..’Z’, ‘a’..’z’, ‘0’..’9′);
$salt = $chars[rand(@chars)] . $chars[rand(@chars)];
$passwd = crypt($plain, $salt);