CVS

My notes on CVS. CVS appears to be just the ticket for getting remote access to sources and also for messing around with source code management in general. This page is how I got my NTpak going with a CVS repository on a Solaris machine, in case it's useful to someone else. I don't claim to know what I'm doing.

Resources

Getting started

Some simple exercises to get things going. This worked for me on Solaris. For Windows, it should be basically the same if you install the Cyclic Software CVS binaries.

Add this to .cshrc and source it:

  setenv CVSROOT ~/Repository
When I tried it on Windows, the Windows version of CVS seems to assume that the Windows machine is running as a CVS client to a remote server. To have it run the server locally, set CVSROOT in the System control panel to eg:
  :local:c:\users\johnr\Repository

Create the CVS repository

  cvs init
Create a new directory tree:
  cd ~/java
  mkdir diva
  mkdir diva/canvas
  mkdir diva/kernel
Import the new directory into CVS:
  cd diva
  cvs import -m "Created directory" diva local start
Get a working version of the new directory structure:
  cd ..
  mv diva diva.orig
  cvs checkout diva
Tell CVS to set permissions so that files are read-only until a "cvs edit" is performed on them:
  cvs watch on diva
Create a new source file in diva/canvas. Here's a sample:
// A simple Java file
// $Header: /home/johnr/cvs/eecs.berkeley.edu/info/cvs.html,v 1.1.1.1 1998/07/20 21:42:55 johnr Exp $
class Foo {
    public static void main(String[] argv) {
        System.out.println("Foo!");
    }
}
Add the file to CVS:
  cd ~/java/diva/canvas
  cvs add Foo.java
  cvs commit Foo.java
  chmod 444 Foo.java
Check out the file for editing:
  cvs edit Foo.java
Check the file back in:
  cvs commit Foo.java

Remote access -- Solaris

I did this mainly to figure out how to do remote CVS access in principle before messing around with Windows.

  1. Generate your RSA encryption keys:
      ssh-keygen
    
    Enter a passphrase when prompted. This will generate the files ~/.ssh/identity and ~/.ssh/identity.pub, which are your private and public encryption keys respectively.

  2. Copy ~/.ssh/identity.pub on the local machine to ~/.ssh/authorized_keys on the remote machine. If you're just testing this and have a shared file-system, then of course this is the same directory.

  3. Start an xterm inside an ssh agent:
      ssh-agent xterm
    
    (This step and the following step are optional -- without them you may have to enter your RSA passphrase each time you do a CVS operation.)

  4. In the new xterm, add your identity file to the agent:
      ssh-add
    

  5. Tell CVS to use ssh as its remote shell (the default is rsh, which is bad-bad-naughty! these days.)
      setenv CVS_RSH ssh
    

  6. Run cvs. For example:
      cvs -d :ext:brahe.eecs.berkeley.edu:/users/johnr/Repository checkout diva
    
If you didn't run steps 3 and 4, you may be prompted for your RSA pass-phrase each time. To use RSA host-key authentication instead, simply use ssh to connect to the other machine using the machine's full name and then connect back to the first machine.

Remote access -- Windows

Windows access to the CVS repository on a UNIX machine is functioning, although it's not as convenient as it could be:

The following is from memory -- if you try it and it doesn't work, email me.
  1. Get cvs.exe from Gordon Chaffee's page and replace the Cyclic version. Get the modified ssh binary from the same page and unpack it somewhere.

  2. Set the following environment variables to equivalent values:
    HOME c:\users\johnr
    CVSROOT :ext:kahn.eecs.berkeley.edu:/users/johnr/Repository
    CVS_RSH c:\networking\ssh-console\ssh.exe
    (CVS_RSH must point to Chaffee's ssh binary.)

  3. Create the directory c:\ssh\etc. Create a file named ssh_config that contains:
    Host *
      RhostsRSAAuthentication yes
    

  4. Copy the files ~/.ssh/identity and ~/.ssh/identity.pub from the UNIX machine to the directory c:\users\johnr\.ssh.

  5. In MS-DOS, run cvs. For example:
      cvs checkout diva
    
    You will be prompted for your RSA passphrase.
In theory, the RSA pass-phrase prompt can be rendered unnecessary by using RSA host-key authentication. To do this, use ssh-keygen to generate keys for use as the PC's host keys, place them into c:\ssh\etc\ssh_host_key and c:\ssh\etc\ssh_host_key.pub, and add the public key to ~/.ssh/known_hosts on the UNIX machine.

I couldn't make it work. If you can, tell me how!