/gnu/usr.bin/rcs/rcsfreeze/rcsfreeze.sh

https://bitbucket.org/iorivur/freebsd-bhyve-with-suspend-resume · Shell · 99 lines · 48 code · 13 blank · 38 comment · 13 complexity · 7764285cbb6277ca49ee30a0db296d8d MD5 · raw file

  1. #! /bin/sh
  2. # rcsfreeze - assign a symbolic revision number to a configuration of RCS files
  3. # $FreeBSD: head/gnu/usr.bin/rcs/rcsfreeze/rcsfreeze.sh 73349 2001-03-02 16:52:14Z ru $
  4. # The idea is to run rcsfreeze each time a new version is checked
  5. # in. A unique symbolic revision number (C_[number], where number
  6. # is increased each time rcsfreeze is run) is then assigned to the most
  7. # recent revision of each RCS file of the main trunk.
  8. #
  9. # If the command is invoked with an argument, then this
  10. # argument is used as the symbolic name to freeze a configuration.
  11. # The unique identifier is still generated
  12. # and is listed in the log file but it will not appear as
  13. # part of the symbolic revision name in the actual RCS file.
  14. #
  15. # A log message is requested from the user which is saved for future
  16. # references.
  17. #
  18. # The shell script works only on all RCS files at one time.
  19. # It is important that all changed files are checked in (there are
  20. # no precautions against any error in this respect).
  21. # file names:
  22. # {RCS/}.rcsfreeze.ver version number
  23. # {RCS/}.rscfreeze.log log messages, most recent first
  24. PATH=/bin:/usr/bin:$PATH
  25. export PATH
  26. DATE=`LC_ALL=C date` || exit
  27. # Check whether we have an RCS subdirectory, so we can have the right
  28. # prefix for our paths.
  29. if test -d RCS
  30. then RCSDIR=RCS/ EXT=
  31. else RCSDIR= EXT=,v
  32. fi
  33. # Version number stuff, log message file
  34. VERSIONFILE=${RCSDIR}.rcsfreeze.ver
  35. LOGFILE=${RCSDIR}.rcsfreeze.log
  36. # Initialize, rcsfreeze never run before in the current directory
  37. test -r $VERSIONFILE || { echo 0 >$VERSIONFILE && >>$LOGFILE; } || exit
  38. # Get Version number, increase it, write back to file.
  39. VERSIONNUMBER=`cat $VERSIONFILE` &&
  40. VERSIONNUMBER=`expr $VERSIONNUMBER + 1` &&
  41. echo $VERSIONNUMBER >$VERSIONFILE || exit
  42. # Symbolic Revision Number
  43. SYMREV=C_$VERSIONNUMBER
  44. # Allow the user to give a meaningful symbolic name to the revision.
  45. SYMREVNAME=${1-$SYMREV}
  46. echo >&2 "rcsfreeze: symbolic revision number computed: \"${SYMREV}\"
  47. rcsfreeze: symbolic revision number used: \"${SYMREVNAME}\"
  48. rcsfreeze: the two differ only when rcsfreeze invoked with argument
  49. rcsfreeze: give log message, summarizing changes (end with EOF or single '.')" \
  50. || exit
  51. # Stamp the logfile. Because we order the logfile the most recent
  52. # first we will have to save everything right now in a temporary file.
  53. TMPLOG=/tmp/rcsfrz$$
  54. trap 'rm -f $TMPLOG; exit 1' 1 2 13 15
  55. # Now ask for a log message, continously add to the log file
  56. (
  57. echo "Version: $SYMREVNAME($SYMREV), Date: $DATE
  58. -----------" || exit
  59. while read MESS
  60. do
  61. case $MESS in
  62. .) break
  63. esac
  64. echo " $MESS" || exit
  65. done
  66. echo "-----------
  67. " &&
  68. cat $LOGFILE
  69. ) >$TMPLOG &&
  70. # combine old and new logfiles
  71. cp $TMPLOG $LOGFILE &&
  72. rm -f $TMPLOG &&
  73. # Now the real work begins by assigning a symbolic revision number
  74. # to each rcs file. Take the most recent version on the default branch.
  75. # If there are any .*,v files, throw them in too.
  76. # But ignore RCS/.* files that do not end in ,v.
  77. DOTFILES=
  78. for DOTFILE in ${RCSDIR}.*,v
  79. do
  80. if test -f "$DOTFILE"
  81. then
  82. DOTFILES="${RCSDIR}.*,v"
  83. break
  84. fi
  85. done
  86. exec rcs -q -n$SYMREVNAME: ${RCSDIR}*$EXT $DOTFILES