BigMarv's How I Did That
Creating a CVS Repository from Scratch
I recently decided to use CVS to manage a few projects I've been working on with CVS. Why CVS? It's free, and widely used. I've used other source code revision systems, but I never administered any of those (with the exception of briefly setting up and using SourceSafe, an experience I really don't want to repeat.)
The one thing I couldn't figure out as I began using CVS was how to properly create a CVS Repository. I tried following what few docs I could find on how to do this, and I got things about half- working before I had to go ask how others on The Well how they accomplished this task. Here's what finally worked for me:
- As root, create a group for your CVS users. I went with a crazy naming scheme and called this group cvsusers. To do this, I used the command groupadd cvsusers.
-
As root, make your developers members of cvsusers. Before you
can, you'll need to get a list of the groups the user is already in.
To get a list of a users's groups, type groups dude (where
dude is the login of the user you need to add to cvsusers.)
Then, use the command usermod to add the additional group.
Here's a summary:- groups dude
- usermod -G oldgrp1,oldgrp2,oldgrp3,cvsusers dude
(Note that you can't have any spaces in the comma separated list of groups you specify for usermod.) - Create the root directory where your respository will live. The usual place that is often mentioned in various documents is /usr/local/CVSROOT. I went with that as my respository's location, which meant I had to create the directory while logged in as root. The command I used was mkdir /usr/local/CVSROOT.
- Change the group of the repository directory to cvsusers. To do this, type chgrp -R cvsusers /usr/local/CVSROOT.
-
Now that you've got your CVS directory created and initialized, you'll
find that you can't actually use it because your users can't write to
/usr/local/whatever. So you need to set the permissions of that
directory to allow user access.
What's the appropriate access, though? I'm told that you want to give user's full group access, and read access for others. But you also need to do the whole set-group-id thing so that all of the files created in the repository's directories are created with the same group permissions as that directory rather than the permissions of the user executing commands on that directory. (This chmod page that talks about the "group id bit" a little more.)
So, use the command chmod 2775 /usr/local/CVSROOT to set the repository's directory to have group write permissions, and to ensure that all files and directories created in that directory are created and owned by the group cvsusers. -
Once the directory is created and persmissions are properly set,
you need to initialize it so that it can be used by CVS. To do
this, cd into the directory you just created and execute
the command cvs init. This will generated the files cvs
needs. Because we've set the group id bit for our repository, we
can execute this command while logged in as any member of the
cvsusers group.
You can also use the -d parameter to specify the directory, but it assumes CVSROOT as the subdirectory so be aware of that. (For example, you could have typed cvs -d /usr/local/CVSROOT init instead of cding into the repository and typing cvs init.)
That should get you started. You'll want to add your new repository to your list of regularly backed-up directories, of course. The effectiveness of your source repository is reduced considerably if it isn't safely backed up.
Back to Index