This micro-howto will canvas, in a short fashion, the necessary commands and configuration details involved in creating a CVS repository and using Unix permissions to enable access for one or more users (i.e., CVS-only accounts or other Unix accounts). It assumes that you are familiar with the process of logging into your Unix shell.
New CVS accounts are created from the CVS section of the Control Panel,
or using the
cvs add command from the Shell Interface:
csoftadm> cvs add mycvsuser1 csoftadm> cvs add mycvsuser2
Optionally, you can use the
cvs pubkey commands (or from the
Control Panel, click on the CVS account in the list) to manage a set
of SSH public keys for each CVS account. Public keys are used when
password-less authentication is needed.
csoftadm> cvs pubkey add mycvsuser1 csoftadm> cvs pubkey list mycvsuser1
CVS requires the use of standard Unix permissions to manage access
control over repositories (we recommend converting to
SVN where complex access-control schemes
We will create a new Unix group which will define a set of users with read/write access over the new repository. It is important to add your main username to the group as well.
csoftadm> group add mycvsgroup csoftadm> group user-add mycvsgroup myself csoftadm> group user-add mycvsgroup mycvsuser1 csoftadm> group user-add mycvsgroup mycvsuser2
After having created the new group, make sure to logout of your
existing shell session and login again, otherwise the following
chgrp command will fail.
Now use the
cvs init command on the server to create the new
CVS repository, and set the appropriate permissions on the
newly created directory.
$ export CVSROOT="/home/myself/MyCVS" $ cvs -d $CVSROOT init $ chgrp -R mycvsgroup $CVSROOT $ chmod 770 $CVSROOT
Now that the repository has been created, you can connect using
remote CVS client software. Assuming you are connecting from a Unix
workstation with the traditional
$ export CVSROOT="email@example.com:/home/myname/cvs" $ export CVS_RSH=ssh $ mkdir test $ cd test $ cvs import -m "Test" test mycvsuser1 start
In the previous example, substitute mycvsuser1 for the name of the CVS account you want to connect as. Also substitute myhost for the name of your assigned csoft.net server (if you have at minimum a Budget account, you can use your own domain name instead of myhost.csoft.net). Note that the CVSROOT is recorded with your working copy, so you only need to specify it once.
Here are a few examples of common operations that can be performed with the traditional command-line CVS client.
To create a directory, html on the server and add a file, new.html to the repository, execute -
$ cd ~/ $ mkdir html $ cp new.html html $ cd html $ cvs import -m "My website" html mycvsuser start
The above commands will create a directory html in and generate a cvs version of the file new.html to /home/myname/cvs. The exact value of the vendor-tag (here "mycvsuser") and release-tag (here "start") parameters are not all that important for most purposes.
Alternatively, the above importation could have been achieved by the import command.
To confim the existence of the directory and file in the repository, download them, after wiping out your local copy of the html directory -
$ cd ~/ $ rm -rf html $ cvs checkout html
Removing a file from the repository is performed by the remove command. The elimination of the file from the repository does not become permanent, until the commit command is invoked. Removing directory contents recursively is achieved with the -R flag. For example, to remove new.html -
$ cd ~/html $ cvs remove -f new.html $ cvs commit new.html
Transfering a binary type file to the server requires some consideration to prevent RCS tag substitution. The most practical method is to append the -kb switch to the add command. Suppose you wish to convey the image.jpg image on the local computer to the html directory on the repository, use this set of commands -
$ cd ~/html $ cvs add -kb image.jpg $ cvs commit image.jpg
Differences between revisions of text files can be reviewed using the diff command -
$ cvs diff foo.txt $ cvs diff -r1.2 -r1.3 foo.txt
Revision history of files can be reviewed using the log command -
$ cvs log foo.txt
Default flags for cvs commands can be specified in the ~/.cvsrc file. For example -
# Use compression level 3 cvs -z3 # Create directories and prune empty directories. update -dP # Prune empty directories. checkout -P # Produce unified diffs, include newly added/removed files. diff -uN
If the error "can't getwd" appears when attempting to commit or even checkout data, check that the CVS account you are using has search (+x) and read (+r) permissions on all parent directories leading up to the repository.
At least, to have an outside shot at operating cvs semi-competently, peruse the FAQ.