19Sjkh#! /bin/sh 29Sjkh 39Sjkh# rcsfreeze - assign a symbolic revision number to a configuration of RCS files 49Sjkh 550472Speter# $FreeBSD$ 69Sjkh 79Sjkh# The idea is to run rcsfreeze each time a new version is checked 89Sjkh# in. A unique symbolic revision number (C_[number], where number 99Sjkh# is increased each time rcsfreeze is run) is then assigned to the most 109Sjkh# recent revision of each RCS file of the main trunk. 119Sjkh# 129Sjkh# If the command is invoked with an argument, then this 139Sjkh# argument is used as the symbolic name to freeze a configuration. 149Sjkh# The unique identifier is still generated 159Sjkh# and is listed in the log file but it will not appear as 169Sjkh# part of the symbolic revision name in the actual RCS file. 179Sjkh# 189Sjkh# A log message is requested from the user which is saved for future 199Sjkh# references. 209Sjkh# 219Sjkh# The shell script works only on all RCS files at one time. 229Sjkh# It is important that all changed files are checked in (there are 239Sjkh# no precautions against any error in this respect). 249Sjkh# file names: 259Sjkh# {RCS/}.rcsfreeze.ver version number 269Sjkh# {RCS/}.rscfreeze.log log messages, most recent first 279Sjkh 2814605SwoschPATH=/bin:/usr/bin:$PATH 299Sjkhexport PATH 309Sjkh 3173349SruDATE=`LC_ALL=C date` || exit 329Sjkh# Check whether we have an RCS subdirectory, so we can have the right 339Sjkh# prefix for our paths. 3411891Speterif test -d RCS 3511891Speterthen RCSDIR=RCS/ EXT= 3611891Speterelse RCSDIR= EXT=,v 379Sjkhfi 389Sjkh 399Sjkh# Version number stuff, log message file 409SjkhVERSIONFILE=${RCSDIR}.rcsfreeze.ver 419SjkhLOGFILE=${RCSDIR}.rcsfreeze.log 429Sjkh# Initialize, rcsfreeze never run before in the current directory 4311891Spetertest -r $VERSIONFILE || { echo 0 >$VERSIONFILE && >>$LOGFILE; } || exit 449Sjkh 459Sjkh# Get Version number, increase it, write back to file. 469SjkhVERSIONNUMBER=`cat $VERSIONFILE` && 479SjkhVERSIONNUMBER=`expr $VERSIONNUMBER + 1` && 489Sjkhecho $VERSIONNUMBER >$VERSIONFILE || exit 499Sjkh 509Sjkh# Symbolic Revision Number 519SjkhSYMREV=C_$VERSIONNUMBER 529Sjkh# Allow the user to give a meaningful symbolic name to the revision. 539SjkhSYMREVNAME=${1-$SYMREV} 549Sjkhecho >&2 "rcsfreeze: symbolic revision number computed: \"${SYMREV}\" 559Sjkhrcsfreeze: symbolic revision number used: \"${SYMREVNAME}\" 569Sjkhrcsfreeze: the two differ only when rcsfreeze invoked with argument 579Sjkhrcsfreeze: give log message, summarizing changes (end with EOF or single '.')" \ 589Sjkh || exit 599Sjkh 609Sjkh# Stamp the logfile. Because we order the logfile the most recent 619Sjkh# first we will have to save everything right now in a temporary file. 629SjkhTMPLOG=/tmp/rcsfrz$$ 639Sjkhtrap 'rm -f $TMPLOG; exit 1' 1 2 13 15 649Sjkh# Now ask for a log message, continously add to the log file 659Sjkh( 669Sjkh echo "Version: $SYMREVNAME($SYMREV), Date: $DATE 679Sjkh-----------" || exit 689Sjkh while read MESS 699Sjkh do 709Sjkh case $MESS in 719Sjkh .) break 729Sjkh esac 739Sjkh echo " $MESS" || exit 749Sjkh done 759Sjkh echo "----------- 769Sjkh" && 779Sjkh cat $LOGFILE 789Sjkh) >$TMPLOG && 799Sjkh 809Sjkh# combine old and new logfiles 819Sjkhcp $TMPLOG $LOGFILE && 8211891Speterrm -f $TMPLOG && 839Sjkh 849Sjkh# Now the real work begins by assigning a symbolic revision number 8511891Speter# to each rcs file. Take the most recent version on the default branch. 869Sjkh 8711891Speter# If there are any .*,v files, throw them in too. 8811891Speter# But ignore RCS/.* files that do not end in ,v. 8911891SpeterDOTFILES= 9011891Speterfor DOTFILE in ${RCSDIR}.*,v 919Sjkhdo 9211891Speter if test -f "$DOTFILE" 9311891Speter then 9411891Speter DOTFILES="${RCSDIR}.*,v" 9511891Speter break 9611891Speter fi 979Sjkhdone 989Sjkh 9911891Speterexec rcs -q -n$SYMREVNAME: ${RCSDIR}*$EXT $DOTFILES 100