Using CVS/SSH on Windows via Cygwin, on Mac OS X using CVL, or on Linux using command-line CVS

by Marion Bates <mbates at whoopis.com>

For all operating systems, you will need:

For Windows:
(if not using Windows, skip to Step 3)

  1. Get Cygwin. http://www.cygwin.com/setup.exe (download and run)
  2. Leave most of the default package options alone, but make sure to install the binaries of the following packages. Some may already be installed by default, but others (like CVS and SSH, which are kinda key ;) are not. You definitely need to have these packages selected:
    • bash
    • cvs
    • openssh
    These are not necessarily required, but recommended:
    • make
    • less
    • findutils
    • links
    • gcc
    • file
    • inetutils
    • openssl
    • openssl-devel
    • perl
    • sh-utils
    • vim
    • which
  3. Unzip the nc11nt.zip file; find the nc.exe binary. Put it somewhere on your C drive such that it is in your path; if you install nc.exe in either C:\WINDOWS\ or C:\WINDOWS\COMMAND\, then it will be in your path (and Cygwin should be able to find it). To test, run "nc" from within Cygwin (quit and re-launch Cygwin to make it re-read the path, if necessary). If you see "Cmd line:" then it's working, ctrl-c to exit. From within Cygwin, it may run and quickly die with the error message "invalid port : NO DATA" -- this is ok. It will work the way we need it to when it's run from within ssh-keyinstall.
  4. Unpack the ssh-keyinstall package. Run ssh-keyinstall like so:
    ./ssh-keyinstall -s cvs-server.yourdomain.com -u your-cvs-username
    
    and type the passwords/passphrases as required. When it's all finished, assuming no errors, you should be able to log in to the cvs server and type only your pass _phrase_ (not password) to complete the login. If you are asked for the cvs server's password, something didn't work.
  5. Make a shell script to set the environment, or use your .bashrc file or whatever. (Example shell script shown below.) Make it executable (chmod 755 do-cvs-setup). Be sure to run this script by typing dot-space-scriptname, like so:
    . do-cvs-setup
    
    as opposed to the more common:
    ./do-cvs-setup
    
    so that the variables defined within the script will be accessible to the shell after the script ends.

    Example shell script:

    #!/bin/bash
    # do-cvs-setup -- Shell script to set up the environment for CVS.
    # April 9, 2002  by mbates 
    
    # First export CVSROOT and CVS_RSH locally so your local machine knows about 
    # the remote server AND knows to use SSH for the communication between your 
    # CVS client and the server.
    
    export CVSROOT=":ext:your-cvs-username@cvs-server.yourdomain.com:/repository"
    export CVS_RSH="ssh"
    
    # Now alias ssh-add to automatically add your key when it runs. Here, it is 
    # assumed that you created a DSA-type key -- if you used RSA or whatever 
    # instead, then specify the appropriate filename here.
    
    alias ssh-add='ssh-add $HOME/.ssh/id_dsa'
    
    # Now crank up the agent and add key (note the backticks, not single quotes)
    
    eval `ssh-agent -s`
    ssh-add
    
    # Now it will ask for your passphrase.
    
    CAVEAT: Beware of bad linefeeds if you copy this shell script between Windows and Linux! If it generates lots of errors when you run it, try converting the linefeeds, or re-type the script into a new document.

    GUI for Mac users (optional):

    The Developer Tools package that ships with Mac OS X includes Apple's Project Builder development environment, as well as command-line CVS available via the Terminal application. In addition, Sente Software makes a free, open-source program called Concurrent Versions Librarian (see References section for URL), which is a GUI for CVS (akin to gCVS on Linux), and which also interfaces nicely with Project Builder. (Project Builder includes a CVS GUI of its own, called SCM, but I use CVL instead due to personal preference.)

    Download and install CVL (Concurrent Versions Librarian) from http://www.sente.ch/software/cvl/. Add the following line to the bottom of the do-cvs-setup shell script shown above (assumes that you installed CVL into the Applications folder):

    open /Applications/CVL.app
    
    CVL then gets to use ssh-agent to connect to the remote server (anything launched from this particular Terminal window will be able to use ssh-agent for an SSH login prompt). The rest of the process is normal CVS with a nice GUI and if you double-click a project file from the file list, it will open in Project Builder, which provides the usual niceties of a good development environment (syntax highlighting etc.).

    Alternate Mac OS X GUI: You can also open Project Builder from this environment, and then use its version control system, but the quirks of SCM are not documented here.

    open /Developer/Applications/Project Builder.app
    
  6. Initial CVS import (command-line version):

    Assuming your project is in a directory called "YourProject," run the following commands:

    cd YourProject
    cvs import -m "initial import" YourProject your-cvs-username v0_1
    
    The last two fields are vendor and release tags, respectively.
  7. Command-line CVS crash course (shamelessly copied from Amund Tveit's "A Minimalistic Guide to CVS with SSH," available from http://www.jfipa.org/publications/CVSGuide/): To do the FIRST checkout, MOVE or REMOVE your local copy of YourProject and type:
    cvs checkout YourProject
    
    For subsequent checkouts, DON'T remove your local copy first.

    To check in modifications on existing files:

    cvs commit
    
    It is recommended to run cvs update before committing changes.

    To add a new file to the repository:

    cvs add newFile
    cvs commit
    
    To add a new BINARY file to the repository:
    cvs add -kb newBinaryFile
    cvs commit
    
    To remove an existing file from the repository:
    rm existingFile
    cvs remove existingFile
    cvs commit
    
    To receive changes from the latest commits from your co-developers:
    cvs update
    
    If another developer has made major changes like new directories, do:
    cvs update -d
    
    To stamp files with a release tag for each release:
    cvs tag -R "v001"
    cvs commit
    
    To check this release out:
    cvs checkout -r "v001" YourProject
    


    References

    Software links