ESD Software Engineering

CVS: How to setup a repository to conform to ESD Software Requirements

The requirements for the ESD Software UNIX Development and Deployment Environment states:

(9) A script will be developed so that the proper CVS reference areas are updated after a commit is done. The updated files will be set read-only (user, group, and world) during the update. Since an update takes a noticeable amount of time, the script must limit the amount or number of updates. The script will send email to notify interested parties of the update.


Reference Area

I manage the reference area by using CVS administrative files to perform pre-commit checking and post-commit logging.  

The pre-commit administrative file and associated script unlocks the commited files in the reference area should cvs successfully complete the commit.  Here are the contents of the needed files:

$CVSROOT/CVSROOT/commitinfo

ALL $CVSROOT/CVSROOT/cvs-precommit

$CVSROOT/CVSROOT/cvs-precommit

#!/usr/local/bin/bash
# echo cvs pre-commit of $*
for file in $*
do
  if (echo $file | grep $CVSROOT > /dev/null)
  then
    len=`echo $CVSROOT | wc | cut -f21 -d' '`
    dir=`echo $file | cut -c$len-100 | cut -c2-100`
  else
    token=`echo $dir | cut -d/ -f 1`
    for entry in `grep ^$token $CVSROOT/CVSROOT/cvs-reference-database`
    do
      if [ $entry != $token ]
      then
        fullfile=`echo $entry/$dir/$file`
        echo Unlocking $fullfile
        chmod +w $fullfile
      fi
    done
  fi
done

$CVSROOT/CVSROOT/cvs-reference-database

# If you want a cvs reference area updated on cvs commit then add it here.
script    /afs/slac/package/epics/script

Notes:

  1. The above commitinfo cvs administrative file runs the cvs-presommit shell script on all cvs commits.
  2. The first column of the cvs-reference-database is what you see on the main page of cvsweb, the second column is the reference area for that cvs entry.  Subdirectories of script need not be listed.  script may appear more than once in this file.

If the cvs-precommit script returns a good status then cvs attempts the commit.  When the cvs commit is completed the reference areas are updated and locked as follows:

$CVSROOT/CVSROOT/loginfo

ALL $CVSROOT/CVSROOT/cvs-postcommit %{s}

$CVSROOT/CVSROOT/cvs-postcommit

# echo cvs post-commit of $*
$CVSROOT/CVSROOT/cvs-postcommit-background $* &

$CVSROOT/CVSROOT/cvs-postcommit-background

#!/usr/local/bin/bash
# echo cvs-postcommit-background $*
dir=0
for file in $*
do
  if [ $dir = 0 ]
  then
    dir=`echo $file`
    token=`echo $dir | cut -d/ -f 1`
  else
    for entry in `grep ^$token $CVSROOT/CVSROOT/cvs-reference-database`
    do
      if [ $entry != $token ] 
      then
        fullfile=`echo $entry/$dir/$file`
        cvs -q update -dA $fullfile > /dev/null 2>&1
        chmod -w $fullfile > /dev/null 2>&1
      fi
    done
  fi
done

Notes:

  1. The loginfo administrative file can't run its associated script in the background.
  2. The cvs update is only done on the particular files cvs committed.

Email Notification

If a user wishes to watch certain CVS'd software the user must actively subscribe to it using the CVS watch command.  For example, if I have the script directory checked out and I want to know whether someone else is actively working in the script directory I set my watch as follows:

flora04:~/work> cvs co script
cvs checkout: Updating script
U script/ENVS.csh
[snip]
flora04:~/work> cvs watch add [filespec]
flora04:~/work/script> cvs watchers
ENVS.csh zelazny edit unedit commit
cvsSetup.csh zelazny edit unedit commit
dspSetup.csh zelazny edit unedit commit
epicsSetup zelazny edit unedit commit
epicsSetupBbr zelazny edit unedit commit
epicsSetupDev zelazny edit unedit commit
epicsSetupProd zelazny edit unedit commit
javaSetup.csh zelazny edit unedit commit
matlabSetup.csh zelazny edit unedit commit
pathSetup.csh zelazny edit unedit commit
printerSetupBbr.csh zelazny edit unedit commit
pythonSetup.csh zelazny edit unedit commit
tclSetup.csh zelazny edit unedit commit
flora04:~/work/script> 

When someone else commits a change to the script directory I get an email message similar to the following:

From:   Allison, Stephanie
To:        Zelazny, Michael S.
Subject: CVS notification /afs/slac/package/epics/slaconly/cvs

script matlabSetup.csh
---
Triggered commit watch on /afs/slac/package/epics/slaconly/cvs/script
By saa

Note that I do not get email for my own cvs commits.

To remove myself from the watch list, I must actively remove my watch as follows:

flora04:~/work/script> cvs watch remove
flora04:~/work/script> cvs watchers
flora04:~/work/script> 

Note that I can add or remove myself to the watch list without having the CVS'd directory checked out by using the reference area.  Also note that releasing the directory does not remove the watch.  For example:

flora04:~/work/script> cvs watchers
epicsSetup zelazny edit unedit commit
flora04:~/work/script> cd ..
flora04:~/work> cvs release script
You have [0] altered files in this repository.
Are you sure you want to release directory `script': y
flora04:~/work> rm -fr script
flora04:~/work> cd /afs/slac/package/epics/script
flora04:/afs/slac/package/epics/script> cvs watchers
epicsSetup zelazny edit unedit commit
flora04:/afs/slac/package/epics/script> cvs watch remove
flora04:/afs/slac/package/epics/script> cvs watchers
flora04:/afs/slac/package/epics/script> 

How does CVS know to send mail?  There exists a CVS administrative file called $CVSROOT/CVSROOT/notify that can be used to notify subscribed users of the requested subscribed action.  By default, this file is empty.  But, I've changed it to add the following:

ALL Mail -s "CVS notification $CVSROOT" %s

How does CVS know who has subscribed to what?  I imagine there must be a file somewhere that holds this information, but I can't find it.  I'll find how CVS stores this information if I ever have to hack into it for some unknown reason.



ESD Software Engineering | SLAC Computing | SLAC Detailed Home
EPICS at SLAC | PEPII Controls | NLC Dev Controls
Owner:   Mike Zelazny
Last modified:   June 25th, 2002