#!/bin/sh # # $TOOLS/unreserve # # unreserve - Use RCS to un-lock code from a source dir tree that was # previously locked # # Syntax: unreserve [-s ] program_name # Purpose: # 1) Exec an rcs -q -u of the desired program # 2) Arg -s will unlock only a specific rev, else, latest rev # # Requirements: # 1) The rcs source tree must be compatible with that used by # the tools replace and unreserve (Ex: $RCSLIBR/RCS/*,v) # 2) The environment variable RCSLIBR must have been previously defined by # using the "lib" command. # 3) To create or access an RCS library, the user must be in the rcssys # group, and the library's parent directory must have R/W access for # the rcssys group. # 4) The "mode" script must exist and be found within the PATH. # # Environment Variables: # $RCSLIBR = Dir where we can find "program" dir # # Modified: # 02/20/97 Brian Lomasky - Modified for non-HP environments. # 01/25/96 Brian Lomasky - Initial creation. # #----------------------------------------------------------------------------- if [ "$DEBUG" != "" ]; then set -x; fi ErrorProc () #Sub Routine { case $ErrNo in 1) echo "\nUSAGE: unreserve [-s xxx] program-name" echo " -s xxx will unlock only revision xxx, else," \ "latest revision";; 2) echo "\nError - No program specified" echo "\nUSAGE: unreserve [-s xxx] program-name" echo " -s xxx will unlock only revision xxx, else," \ "latest revision";; 3) echo "\nError - There is no RCS library for ${b}$RCSLIBR${n}";; 4) echo "\nError - Can't unlock ${b}$Program${n}";; 5) echo "\nError - ${b}$Program${n} can not be found in RCS";; *) echo "\n\nUnknown error $ErrNo.......";; esac RtrnCode=1 exit_proc } #-------------------------------------------------------------------------- exit_proc () #Sub Routine { exit $RtrnCode } #-------------------------------------------------------------------------- # Main Program Flow b=`tput smso` # Bold video attribute n=`tput rmso` # Normal video attribute echo "\nUNRESERVE is used to unlock a program that was previously locked in" echo " an existing RCS library\n" if [ "$RCSLIBR" = "" ] then echo "\n\nError - You must first indicate the RCS library" \ "to be accessed.\n" echo " (This is done by typing: ${b}L=SOURCE${n}" echo " ${b}. lib${n}" echo " where \$SOURCE is the directory containing the" echo " file that you want to replace.)\n" echo " Example: L=SOURCE\n" echo " . lib" exit 1 fi ErrNo=0 RtrnCode=0 Program="" RcsRev="" JustLastestRev="" # if [ $# = 0 ]; then ErrNo=1 # No parameters supplied ErrorProc fi #-------------------------------------------------------------------------- # process command line arguments while [ "$1" != "" ]; do if [ "$1" = "-s" ]; then RcsRev=$2 # RCS revision level specified shift else Program=$1 # Must be program name fi shift done if [ "$Program" = "" ]; then ErrNo=2 # No program specified ErrorProc fi if [ ! -d $RCSLIBR/RCS ]; then ErrNo=3 # Not under RCS ctrl ErrorProc fi if [ ! -r $RCSLIBR/RCS/$Program,v ]; then ErrNo=5 # No such file ErrorProc fi # Calculate current file permissions for Program stored in RCS PROG=$RCSLIBR/RCS/$Program,v . mode #If desired RCS rev not provided, unlock latest RCS rev of any code if [ "$RcsRev" = "" ]; then JustLastestRev="1" RcsRev=`rlog $RCSLIBR/RCS/$Program,v | grep head: | \ awk '{print $2}' | sort -n -r | head -1` else # This is how RCS works, if desired rev not found...prior rev unlocked echo "\nAll code <= RCS revision $RcsRev will be unlocked..." fi #-------------------------------------------------------------------------- # Unlock each file matching the RCS rev level we want for file in `ls $RCSLIBR/RCS/$Program,v`; do if [ "$JustLastestRev" = "1" ]; then CkVer=`rlog $file | grep head: | awk '{print $2}'` if [ "$CkVer" = "$RcsRev" ] then rcs -q -u $file if [ $? -ne 0 ]; then ErrNo=4 ErrorProc fi chmod $mode $file fi else rcs -q -u$RcsRev $file if [ $? -ne 0 ]; then ErrNo=4 ErrorProc fi chmod $mode $file fi echo "\n${b}${Program}${n} has been unlocked..." done exit_proc