home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / dbmalloc.zip / minipatch < prev    next >
Text File  |  1993-01-04  |  4KB  |  201 lines

  1. #
  2. # minipatch - shell script for automatically building miniature patch file
  3. #
  4. #
  5. FREEZE=RCS/.rcsfreeze.log
  6. MINIDATA=.minipatch
  7.  
  8. if [ $# != 0 ]; then
  9.     echo "usage: minipatch"
  10.     exit 1
  11. fi
  12.  
  13. FILES="`make srclist`"
  14.  
  15. #
  16. # see if any files are still locked.  If so, we cannot proceed (they must be
  17. # unlocked before a patch file can be built
  18. #
  19. if rlog -l $FILES 2>rlog.err | grep "locked by:" >/dev/null; then
  20.     echo "all files must be checked in before a patch file can be built"
  21.     exit 1
  22. fi
  23.  
  24. if [ -s rlog.err ]; then
  25.     echo "all files must be checked in before a patch file can be built"
  26.     exit 1
  27. fi
  28.  
  29. #
  30. # get the mini-patch version and the true patchlevel
  31. #
  32. if [ -s ${MINIDATA} ]; then
  33.     read patchlevel oldlevel < ${MINIDATA}
  34. fi
  35. read title realpatch < patchlevel
  36.  
  37. #
  38. # if there is no mini-patch number, or the real patch number has changed
  39. #
  40.  
  41. if [ -z "$oldlevel" -o "x$patchlevel" != "x$realpatch" ]; then
  42.  
  43.     #
  44.     # need to clean out old mini-patch freezes
  45.     #
  46.     OLDREVS=`grep minipatch $FREEZE |
  47.              while read version patchname junk
  48.             do
  49.                 oldrev=\`expr "$patchname" : "\(.*\)("\`
  50.                 echo " -n$oldrev"
  51.             done
  52.         `
  53.  
  54.     if [ ! -z "$OLDREVS" ]; then
  55.  
  56.         #
  57.         # remove the minipatch freeze names
  58.         #
  59.         rcs $OLDREVS $FILES
  60.  
  61.         #
  62.         # change the minipatch lines in the freeze log so that we
  63.         # don't think they are still there.
  64.         #
  65.         sed -e "s/minipatch/oldmpatch/g" $FREEZE > /tmp/ttt
  66.         cp /tmp/ttt $FREEZE
  67.  
  68.         #
  69.         # remove the old minipatch files
  70.         #
  71.         rm -f mini.*.*
  72.     fi
  73.  
  74.     newlevel=1
  75.     version="patchlevel_$realpatch"
  76. else
  77.     version="minipatch_$oldlevel"
  78.     newlevel=`expr $oldlevel + 1 `
  79. fi
  80.  
  81.  
  82. #
  83. # create a new, empty patch file and empty directory for old versions of files
  84. #
  85. PATCH=mini.$realpatch.$newlevel
  86.  
  87. cat <<-endcat > $PATCH
  88.  
  89.     WARNING: this is a mini-patch that contains a subset of the patches
  90.     that will be included in the next full patch release for the library.
  91.     if you apply these changes, you will most likely have to manually
  92.     apply the next real patch release.
  93.  
  94. endcat
  95.  
  96. if [ -d old ]; then
  97.     rm -rf old
  98. fi
  99. mkdir old
  100.  
  101. #
  102. # process each source file
  103. #
  104. echo "Generating diffs"
  105. for i in $FILES
  106. do
  107.     #
  108.     # get the old version of the file
  109.     #
  110.     co -q -p -r$version $i > old/$i 2>/tmp/ttt
  111.  
  112.     #
  113.     # if the file hasn't changed, skip it
  114.     #
  115.     if cmp -s $i old/$i ; then
  116.         continue;
  117.     fi
  118.  
  119.     #
  120.     # name the file
  121.     #
  122.     echo "\nIndex: $i" >> $PATCH
  123.  
  124.     #
  125.     # if there is an old version, add the prerequisite
  126.     #
  127.     if [ -s old/$i ]; then
  128.         
  129.         #
  130.         # get old rcs id
  131.         #
  132.         PREREQ="`rlog -r$version $i |
  133.              grep '^revision' | cut -f2 -d' ' 2>/dev/null`"
  134.  
  135.         #
  136.         # if the id is in the file, add the prereq line
  137.         #
  138.         if fgrep "$PREREQ" old/$i > /dev/null 2>&1; then
  139.  
  140.             echo "Prereq: $PREREQ" >> $PATCH
  141.  
  142.         elif [ "$i" = "patchlevel" ]; then
  143.  
  144.             echo "Prereq: $oldlevel" >> $PATCH
  145.  
  146.         fi
  147.     fi
  148.  
  149.     # 
  150.     # diff the file to generate the patch stuff
  151.     #
  152.     diff -c old/$i $i >> $PATCH
  153.  
  154.  
  155. done
  156.  
  157. #
  158. # and now to check to verify that the patchfile correctly updates the
  159. # old code to the current version.  First apply the patch to the old
  160. # code and then see if there are any differences between the files.
  161. #
  162. echo "Verifying patch..."
  163. (
  164.     cd old
  165.     patch < ../$PATCH > /dev/null 2>&1
  166. )
  167.  
  168. FILES="`
  169. for i in $*
  170. do
  171.     if cmp -s $i old/$i; then
  172.         continue;
  173.     fi
  174.  
  175.     echo file $i did not patch correctly > /dev/tty
  176.     echo $i
  177. done `"
  178.  
  179. if [ ! -z "$FILES" ]; then
  180.  
  181.     echo "patch file did not build correctly($FILES)."
  182.     exit 1
  183.  
  184. fi
  185.  
  186. rm -rf old
  187.  
  188. echo "Verification complete"
  189.  
  190. #
  191. # and now freeze all the files at this patchlevel, and checkout the current
  192. # versions of the files
  193. #
  194.  
  195. echo "freezing source at MINI patch level $newlevel"
  196. echo "." | rcsfreeze minipatch_$newlevel  > /dev/null 2>&1 
  197.  
  198. echo "$realpatch $newlevel" > $MINIDATA
  199.  
  200. exit 0
  201.