$Id: cvs-instructions.txt,v 1.2 2006/08/03 21:34:05 ogould Exp $


Instructions for use of CVS in the Computer Science Department.

1.   Requesting a CVS repository
2.   Setting up your environment for your CVS repository
2.1  jbod vs. cvs
2.2  different ssh key
3.   Initializing the CVS Repository:
4.   Sharing modules in your CVS repository with other people:
5.   Removing all files in a module


1. Requesting a CVS repository
------------------------------

If you would like to set up a CVS repository to which other people will have
access from outside of Stevens as well as from within the Stevens network, you
will need to create a new ssh-key using ssh-keygen(1).  Send the *public* key
to ogould@cs.stevens.edu and keep the private key in your ${HOME}/.ssh
directory or another convenient location.

In this document, we will assume that you created the file using the following
command:

$ ssh-keygen -t dsa -f ${HOME}/.ssh/id_dsa

Thus, you would submit the file ${HOME}/.ssh/id_dsa.pub.  Please do not copy
and paste the contents of that file into the email, but instead submit the
file as an attachment.

NOTE: if you already have a key called ~/.ssh/id_dsa, then you need to specify
a different output file in the command above and read 2.2.



2. Setting up your environment for your CVS repository:
-------------------------------------------------------

CVS will connect to our server through ssh.  You will need to set the
following environment variables. You can do so by either executing the
following line by hand or by adding it to your shells startup script
(${HOME}/.bashrc or ${HOME}/.bash_profile, for example):

$ export CVS_RSH=ssh

Furthermore, you will want to set the CVSROOT environment variable:

$ export CVSROOT=<username>@cvs.cs.stevens-tech.edu:/cvsroot-<username>

where "<username>" is to be replaced with your username, of course.
If you do not wish to set this variable for your environment, you can use the
'-d' flag to cvs to indicate this root.

Note that this step only needs to be done once, for the initial checkout of
the repository.  After that, cvs(1) will find the proper CVSROOT from the file
<dir>/CVS/Root unless you specify a different root either in the environment
or on the command-line.

If you saved your ssh-key as ~/.ssh/id_dsa, then you are done and you can skip
to section 3 of this document.


2.1 jbod vs. cvs
----------------

Before we used the hostname 'cvs.cs.stevens-tech.edu', we were using
'jbod.cs.stevens-tech.edu' with a different port.  This worked fine after the
initial setup, but to simplify instructions, we've switched.

The old instructions are available at
http://www.cs.stevens-tech.edu/~jschauma/old.cvs-instructions.txt


2.2 different ssh-key
---------------------

If you have saved your key to a different file than ~/.ssh/id_dsa, then you
need to tell ssh where to look for the key when it connects to
cvs.cs.stevens-tech.edu.  While this can be done in the same way as indicated
above in the old instructions, it might be easier to just use the
~/.ssh/config file.

Assuming you have saved the private key to the file ~/.ssh/cvskey, just add
the following lines to your ~/.ssh/config (creating that file if it does not
already exist):

Host cvs.cs.stevens-tech.edu
	IdentityFile ~/.ssh/cvskey



3. Initializing the CVS Repository:
-----------------------------------

The CVS repository can only be initialized after the ssh-key has been put in
place and the cvs account has been set up for you.  You will receive a note
indicating when the repository is ready for your use, soon after you submitted
the ssh-key.

Let's assume that you wish to create a new module from the files and
directories located under ${HOME}/foo/bar.  You import the files as follows:

$ cd ${HOME}/foo/bar
$ cvs import bar <username> init

IMPORTANT: If the directory in question already is under CVS control of
another repository, you will need to first create a copy of the hierarchy and
remove the CVS information:

$ cd ${HOME}/foo/blah
$ ls -d CVS
CVS
$ mkdir /var/tmp/blah
$ pax -rwp e . /var/tmp/blah
$ cd /var/tmp/blah
$ find -d . -name CVS -exec rm -fr {} \;
$ cvs import bar <username> init

Note that in either case after the initial import you will need to check out
this module into another location in order to retrieve the CVS files.

$ cd ${HOME}/foo
$ mv bar bar.orig
$ cvs co bar



4. Sharing modules in your CVS repository with other people:
------------------------------------------------------------

If you wish to share all or some of the modules in your CVS repository with
other users (regardless of whether they are local students, TAs, RAs or
colleagues from remote sites), you will need them to follow steps 1. and 2.
above, with the modification that they will have to set

$ export CVSROOT=<theirusername>@cvs.cs.stevens-tech.edu:/cvsroot-<yourusername>

Furthermore, you will have to send an email to ogould@cs.stevens.edu
indicating to which top-level modules this person is allowed access to.  Note
that it is possible for you to only give read-access to a module (ie they are
allowed to check it out, but may not check in modifications) as well as
write-access (ie they have full access and may make modifications).

Please import a top-level module for each project you wish to share with other
people.

Please note that each user should have their individual username and their own
ssh-key.  Sharing ssh-keys among several users is strongly advised against.



5. Removing all files in a module
---------------------------------

One of CVS' shortcomings is the fact that it's rather cumbersome to remove or
rename files and directory hierarchies.  Here is an example of how to remove
all files in a specific module:

According to the cvs manual page as well as
http://www.gnu.org/software/cvs/manual/html_chapter/cvs_12.html (the first URL
after entering 'cvs remove module' into google), 'cvs rm' accepts the '-R'
flag to indicate recursion.  With this information, the following approach
will remove all files from the current module:
 
cd <module>
find . -type f -print | grep -v CVS | xargs rm
cvs rm -R [^C]*
cvs commit
 
We need to use 'grep -v CVS' in the second command, as each directory
contains a CVS subdirectory, the files in which need to preserved, as
otherwise you can't 'cvs rm' anything in those directories.  (The same
command can be written as a single 'find' command with the appropriate 
flags:  find . -type f \! -path '*CVS*' -exec rm {} \;)
 
Similarly, in the third command we need to leave out the CVS directory.
(Actually, we leave out all files starting with a 'C' - you may need to adjust
this if you have files or directories starting with a 'C'.)
 
After running 'cvs commit' all files are removed from cvs control and
you can import new files.