#!/bin/sh # # cvs_rtag # # A script the do the *expected* thing with arguments to cvs rtag. # # Arguments: # # tag the tag string to be applied to the module # # module(s) The name(s) of the package, file, or directory # to be tagged. # #set -x #set -v if [ `echo $@ | wc -w` -lt 2 ] then echo "Oops - tag and module(s) required" exit 1 fi old_path=`pwd` cvs_root=${CVSROOT} tag=${1} shift 1 modules="$@" echo "OK - Setting up cdfsoft2 ${SRT_BASE_RELEASE}" UPS_SHELL=sh; export UPS_SHELL . `${UPS_DIR}/bin/ups setup ups` setup cdfsoft2 ${SRT_BASE_RELEASE} if [ -z "${CDFSOFT2_DIR}" ] then echo "OOPS - Unable to setup cdfsoft2 ${SRT_BASE_RELEASE}" exit fi [ -z ${cvs_root} ] && cvs_root=${CVSROOT} echo OK - Setting up cvs work space [ -d /tmp/cvs_rtag_$$ ] && rm -r /tmp/cvs_rtag_$$ mkdir /tmp/cvs_rtag_$$ if [ -d /tmp/cvs_rtag_$$ ] then cvs_tmp=/tmp/cvs_rtag_$$ else echo Oops - Unable to allocate cvs work space exit fi # # Determine if we are in a checked out module # echo OK - Checking directory space. if [ ! -f CVS/Root ] then not_cvs="yes" else cvs_root=`cat CVS/Root` cvs_base=/`echo ${cvs_root} | cut -f2- -d "/"` cvs_path="" if [ -f CVS/Repository ] then cvs_path=`cat CVS/Repository` cvs_rel_path=`echo ${cvs_path} | sed "s%${cvs_base}/%%"` cvs_pkg=`echo ${cvs_rel_path} | cut -f1 -d'/'` else not_cvs="yes" fi fi for module in ${modules} do echo '' # # Find the package name if necessary # echo OK - checking ${module} commit="no" if [ `echo ${module} | cut -c1` = "/" ] then echo "OOPS - Unable to deal with absolute paths" continue fi if [ `echo ${module} | cut -c1-2` = ".." ] then echo "OOPS - Unable to deal with back referenced paths" continue fi if [ "${module}" = "." ] then if [ -z ${cvs_pkg} ] then echo "OOPS - Not in checked out directory" exit else commit="yes" path=${cvs_rel_path} true_mod=${cvs_rel_path} package=${cvs_pkg} fi elif [ "${module}" = \* ] then if [ -z ${cvs_pkg} ] then echo "OOPS - Not in checked out directory" exit else commit="yes" path=${cvs_rel_path} package=${cvs_pkg} true_mod=${cvs_rel_path} fi elif [ -f ${module} -a ${cvs_pkg} ] then commit="yes" package=${cvs_pkg} true_mod=${cvs_rel_path}/${module} elif [ -d $module -a ${cvs_pkg} ] then commit="yes" package=${cvs_pkg} true_mod=${cvs_rel_path}/${module} else echo "OK - $module is not a file in" echo " $old_path assuming a package" path=${module} true_mod=${module} package=`echo ${module} | cut -f1 -d'/'` fi if [ -z "${package}" ] then echo "Oops - Unable to determine package for ${module}" continue fi echo OK - Determining repository for ${package} package found_cvs_root="" for cvs_rep in CDF-REP ZOOM-REP SRT-REP do rep_str=`$CDFSOFT2_DIR/Release/Scripts/Find_cvs_root ${cvs_rep}` CVSROOT=`echo ${rep_str} | cut -f2 -d,`; export CVSROOT [ -f ${cvs_tmp}/lscvs ] && rm ${cvs_tmp}/lscvs lscvs ${package} > ${cvs_tmp}/lscvs if [ `grep -i " does not exist" $cvs_tmp/lscvs | wc -l` -eq 0 ] then found_cvs_root=${cvs_rep} break fi done if [ -z "${found_cvs_root}" ] then echo OOPS - Package ${package} is not known in normal CVS repositories # rm -r ${cvs_tmp} continue fi [ -f ${cvs_tmp}/lscvs ] && rm ${cvs_tmp}/lscvs lscvs ${true_mod} > ${cvs_tmp}/lscvs if [ `grep -i " does not exist" $cvs_tmp/lscvs | wc -l` -ne 0 ] then echo ${true_mod} is not known in ${CVSROOT} continue fi # if [ ! -d ${cvs_tmp}/${found_cvs_root}/CVSROOT ] # then # [ ! -d ${cvs_tmp}/${found_cvs_root} ] && \ # mkdir ${cvs_tmp}/${found_cvs_root} # cd ${cvs_tmp}/${found_cvs_root} # cvs -Q checkout CVSROOT # if [ ! -f ${cvs_tmp}/${found_cvs_root}/CVSROOT/check_access ] # then # echo "OOPS - Error has occured accessing ${found_cvs_root}" # exit 2 # fi # cd ${old_path} # fi # mod_line=`grep " \\"${package}\\"" ${cvs_tmp}/${found_cvs_root}/CVSROOT/check_access | \ # cut -f2 -d,` # xline=${modline}`grep " \\"\\*\\"" ${cvs_tmp}/${found_cvs_root}/CVSROOT/check_access | \ # tail -1 | cut -f2 -d,` # xline=`echo $xline | tr \" " "` # if [ "${mod_line}" = '' ] # then # echo "Oops - ${package} is not known" # rm -r ${cvs_tmp} # exit # # elif [ -z `echo ${xline} | grep " ${USER} "` ] # then # echo Oops - ${USER} not permitted to modify ${package} # rm -r ${cvs_tmp} # exit 2 # fi commit_status=0 if [ "${commit}" = "yes" ] then echo OK - Checking update status of ${true_mod} echo cvs -d ${CVSROOT} commit \ -m "Updated by $USER using $0" ${module} cvs -d ${CVSROOT} commit \ -m "Updated by $USER using $0" ${module} commit_status=$? fi if [ $commit_status -eq 0 ] then echo OK - cvs rtagging ${true_mod} echo cvs -d ${CVSROOT} rtag ${tag} ${true_mod} cvs -d ${CVSROOT} rtag ${tag} ${true_mod} fi done rm -r ${cvs_tmp}