TCM's Repository: an Annotated Example
First create oneself an account on cvs.
pc55:/scratch/mjr$ ssh cvs.tcm.phy Could not chdir to home directory /home/mjr: No such file or directory New Home Directory created. Please log in again. Connection to cvs.tcm.phy closed.
Then set up an initial SVN repository
pc55:/scratch/mjr$ ssh cvs.tcm.phy cvs-chroot:~$ svnadmin create check2xsf cvs-chroot:~$ ls check2xsf README.txt conf dav db format hooks locks cvs-chroot:~$ exit pc55:/scratch/mjr$ cd check2xsf_1.01/ pc55:/scratch/mjr/check2xsf_1.01$ svn import svn+ssh://cvs.tcm.phy.cam.ac.uk/home/mjr/check2xsf/ -m 'Initial import' Adding super.c Adding xyz_write.c Adding periodic_table.c Adding check_read.c Adding molecule_fix.c [...] Committed revision 1. pc55:/scratch/mjr/check2xsf_1.01$(It might have been better to add this as
pc55:/scratch/mjr/check2xsf_1.01$ svn import svn+ssh://cvs.tcm.phy.cam.ac.uk/home/mjr/check2xsf/trunk/ -m 'Initial import'as a lack of a trunk will make it hard to branch in the future.)
Now to do some real work on the project:
pc55:/scratch/mjr/work$ svn checkout svn+ssh://cvs.tcm.phy.cam.ac.uk/home/mjr/check2xsf/ A check2xsf/super.c A check2xsf/xyz_write.c [...] Checked out revision 1. pc55:/scratch/mjr/work$ cd check2xsf/ pc55:/scratch/mjr/work/check2xsf$ vi c2xsf.h check2xsf.c rotate.c pc55:/scratch/mjr/work/check2xsf$ svn status M check2xsf.c M c2xsf.h M rotate.c
The initial checkout will create a .svn directory which enables it to keep track of where the repository came from, and which files have been modified. Hence, from this point, the repository does not need to be named again. The svn status command is telling us that three files are modified with respect to the master copy. We can remind ourselves of our modifications too:
pc55:/scratch/mjr/work/check2xsf$ svn diff c2xsf.h Index: c2xsf.h =================================================================== --- c2xsf.h (revision 1) +++ c2xsf.h (working copy) @@ -1,4 +1,4 @@ -#define C2XSF_VER "1.01" +#define C2XSF_VER "1.01C" /* Global variables for system description */
Note that status and diff do not require access to the master copy. The initial checkout command actually makes two copies, one which you see, the other hidden under the .svn directory. Thus svn can determine changes from the original version checked out rapidly and without accessing the network. One can then finally commit one's changes to the master repository:
pc55:/scratch/mjr/work/check2xsf$ svn commit -m 'Importing V1.01C' Sending c2xsf.h Sending check2xsf.c Sending rotate.c Transmitting file data ... Committed revision 2.
If someone else has modified the master copy, then the working copy can be updated with `svn update'. Before trying this, one may wish to try
svn status -u
which, unlike the usual status command, will contact the master repository, and thus will report modifications made to the master.
If new files are created, svn will not automatically add them when a commit command is issued. It first needs to be told that they should be included using
svn add foo.c
Web Access
At this point, attempts to access http://src.tcm.phy.cam.ac.uk/viewvc/mjr/ will give an empty listing. To permit all to view the repositories, it is necessary to create suitable allow files:
cvs-chroot:~$ echo '*' > check2xsf/allow cvs-chroot:~$ echo '*' > rpm2dir/allow
For a less open approach, one can try the following:
cvs-chroot:~$ mkdir secret_example cvs-chroot:~$ chmod 700 secret_example cvs-chroot:~$ setfacl -m d:g:www:rx secret_example cvs-chroot:~$ setfacl -m g:www:rx secret_example cvs-chroot:~$ svnadmin create secret_example cvs-chroot:~$ echo spqr1 > secret_example/allow cvs-chroot:~$ mkdir public_html cvs-chroot:~$ cat > public_html/.htaccess << EOF > AuthType Basic > AuthName "Password Required" > AuthUserFile /home/mjr/pwd > Require valid-user > EOF cvs-chroot:~$ htpasswd spqr1 VivatBrutus >> pwd
Followed by a usual import
pc55:/scratch/mjr/secret$ svn import svn+ssh://cvs.tcm.phy.cam.ac.uk/home/mjr/secret_example/ -m 'Initial import' Adding secret.txt Committed revision 1.
Now no-one will even see this project in the directory listing for mjr
unless either they have first visited the Raven login page, and authenticated
as spqr1, or they use URLs of the form
https://src.tcm.phy.cam.ac.uk/~mjr/viewvc/
Note that Raven, or the per user htpasswd file, provide authentication. Authorisation is done a per-project basis by "allow" files in the directory containing that project.
When confused over web access, it is worth checking that things are as accesible as they should be:
cvs-chroot:~$ getfacl secret_example | grep www group:www:r-x default:group:www:r-x cvs-chroot:~$ getfacl secret_example/allow | grep www group:www:r-x #effective:r--is fine, whereas
cvs-chroot:~$ getfacl bad_example | grep www group:www:r-x #effective:--- default:group:www:r-xis not. This is probably the result of an incorrect mask, and therefore can be fixed with
cvs-chroot:~$ setfacl -m m::rx bad_example cvs-chroot:~$ getfacl bad_example | grep www group:www:r-x default:group:www:r-xMuch more information can be found in the man pages of acl, setfacl and getfacl. Beware that "cp" does not preserve acls. However, "cp -p" does.
As a debugging aid, the page https://src.tcm.phy.cam.ac.uk/~spqr1/whoami.html exists for approrpiate values of spqr1 for those users who are using their own password files, and http://src.tcm.phy.cam.ac.uk/whoami.html exists for those who are trying to use Raven.
The CVS Appendix
pc55:/scratch/mjr$ export CVS_RSH=ssh pc55:/scratch/mjr$ export CVSROOT=cvs.tcm.phy.cam.ac.uk:/home/mjr/rpm2dir pc55:/scratch/mjr$ cvs init pc55:/scratch/mjr/rpm2dir$ cvs import rpm2dir rpm2dir v1-00 [vi launches for log message creation] N rpm2dir/rpm2dir.c No conflicts created by this importBack to repository page.