source: trunk/third/ispell/Makepatch @ 10334

Revision 10334, 7.1 KB checked in by ghudson, 27 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r10333, which included commits to RCS files with non-trunk default branches.
  • Property svn:executable set to *
Line 
1: Use /bin/sh
2#
3# $Id: Makepatch,v 1.1.1.1 1997-09-03 21:08:09 ghudson Exp $
4#
5# Copyright 1992, 1993, Geoff Kuenning, Granada Hills, CA
6# All rights reserved.
7#
8# Redistribution and use in source and binary forms, with or without
9# modification, are permitted provided that the following conditions
10# are met:
11#
12# 1. Redistributions of source code must retain the above copyright
13#    notice, this list of conditions and the following disclaimer.
14# 2. Redistributions in binary form must reproduce the above copyright
15#    notice, this list of conditions and the following disclaimer in the
16#    documentation and/or other materials provided with the distribution.
17# 3. All modifications to the source code must be clearly marked as
18#    such.  Binary redistributions based on modified source code
19#    must be clearly marked as modified versions in the documentation
20#    and/or other materials provided with the distribution.
21# 4. All advertising materials mentioning features or use of this software
22#    must display the following acknowledgment:
23#      This product includes software developed by Geoff Kuenning and
24#      other unpaid contributors.
25# 5. The name of Geoff Kuenning may not be used to endorse or promote
26#    products derived from this software without specific prior
27#    written permission.
28#
29# THIS SOFTWARE IS PROVIDED BY GEOFF KUENNING AND CONTRIBUTORS ``AS IS'' AND
30# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32# ARE DISCLAIMED.  IN NO EVENT SHALL GEOFF KUENNING OR CONTRIBUTORS BE LIABLE
33# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39# SUCH DAMAGE.
40#
41#       Make an ispell patch kit.  This is not a clever script,
42#       just a handy one.
43#
44#       Usage:
45#
46USAGE="Usage:  Makepatch [-n] [-d destdir] [-o file] ... [new-files]"
47#
48#       destdir is the directory in which the kits and patches are kept.
49#
50#       new-files are any new files to be added to the distribution.
51#
52#       The -n switch suppresses RCS updates, so that the patch can be
53#       tested.
54#
55#       The -o switch can be used to limit patching to certain files.
56#       This is useful to control the size of patches.  Version.h is
57#       always patched.  This switch can appear more than once.
58#
59# $Log: not supported by cvs2svn $
60# Revision 1.16  1994/11/01  05:54:33  geoff
61# When doing a partial run, update the fields code in the right RCS
62# directory.
63#
64# Revision 1.15  1994/11/01  05:27:14  geoff
65# Change the special code for handling the fields routines to reflect my
66# latest source-tree reorganization.
67#
68# Revision 1.14  1994/05/18  02:56:48  geoff
69# Correctly detect dictionary files for context selection
70#
71# Revision 1.13  1994/05/17  06:37:27  geoff
72# Add the -o switch, to help handle overly-large patches.  Remember to
73# return a success status at the end (rcsdiff can return a nonzero
74# status).
75#
76# Revision 1.12  1994/02/08  06:03:56  geoff
77# Don't expect a comma after version number (it makes patch barf)
78#
79# Revision 1.11  1994/01/25  07:11:15  geoff
80# Get rid of all old RCS log lines in preparation for the 3.1 release.
81#
82#
83destdir=kits
84baserelease=3.1
85
86trialrun=
87files=
88partialrun=false
89nl='
90'
91while [ $# -gt 0 ]
92do
93    case "$1" in
94        -d)
95            destdir="$2"
96            shift; shift
97            ;;
98        -n)
99            trialrun=echo
100            shift
101            ;;
102        -o)
103            files="$files $2"
104            partialrun=true
105            shift; shift
106            ;;
107        -*)
108            echo "$USAGE" 1>&2
109            exit 1
110            ;;
111        *)
112            break
113            ;;
114    esac
115done
116
117allfiles=`Makekit -e`
118if $partialrun
119then
120    :
121else
122    files="$allfiles"
123fi
124
125[ -d "$destdir" ]  ||  mkdir "$destdir"
126
127if [ -r "$destdir/Patch${baserelease}.01" ]
128then
129    lastpatch=`ls $destdir/Patch${baserelease}.?? | tail -1 \
130      | sed "s;$destdir/Patch${baserelease}.;;"`
131else
132    lastpatch=00
133fi
134
135patchno=`expr $lastpatch + 1`
136case "$patchno" in
137    [1-9])
138        patchno=0$patchno
139        ;;
140esac
141
142patchfile="$destdir/Patch${baserelease}.$patchno"
143case "$trialrun" in
144    echo)
145        patchfile="${patchfile}-test"
146        ;;
147esac
148lastpatchid=`echo Patch${baserelease}.$lastpatch | sed 's/\./_/g'`
149patchid=`echo Patch${baserelease}.$patchno | sed 's/\./_/g'`
150
151echo 'Index: version.h' > "$patchfile"
152prereq=`co -r$lastpatchid -p RCS/version.h \
153  | egrep 'International Ispell Version' \
154  | sed -e 's/^.*International Ispell Version //' -e 's/ .*$//'`
155echo "Prereq: $prereq" >> "$patchfile"
156echo "" >> "$patchfile"
157patchlevel=`egrep "International Ispell Version $baserelease" version.h \
158  | sed -e "s/^.*Version $baserelease\.//" -e 's/ .*$//'`
159case "$patchlevel" in
160    $patchno)
161        ;;
162    $lastpatch)
163        $trialrun co -l version.h
164        # Note this requires System V date command!
165        date=`date +%D`
166        co -p -q version.h \
167          | sed "/International/s;$baserelease.$lastpatch ../../..;$baserelease.$patchno $date;" \
168          | case "$trialrun" in
169                '')
170                    cat > version.h
171                    ;;
172                echo)
173                    echo 'Edit version.h to produce:'
174                    egrep 'International Ispell Version'
175                    ;;
176            esac
177        ;;
178    *)
179        echo "Sorry, I can't figure out what level you're patching!" 1>&2
180        exit 1
181        ;;
182esac
183lastrev=`rlog -h version.h | sed -n 's/head:[    ]*//p'`
184if $partialrun
185then
186    $trialrun rcs -N$patchid:$lastpatchid \
187      `echo $allfiles | tr ' ' "$nl" \
188        | sed '/^fields.[ch3]$/s;^;'"$HOME/src/local/fields/;"`
189fi
190case "$trialrun" in
191    '')
192        rcs -N$patchid:$lastrev version.h
193        rcsdiff -r$lastpatchid -r$patchid version.h >> "$patchfile"
194        ;;
195    echo)
196        echo rcs -N$patchid:$lastrev version.h
197        rcsdiff -r$lastpatchid version.h >> "$patchfile"
198        ;;
199esac
200
201for basefile in $files
202do
203    case "$basefile" in
204        fields.[ch3])
205            rcsfile=$HOME/src/local/fields/RCS/$basefile,v
206            ;;
207        *)
208            rcsfile=`rlog -R $basefile`
209            ;;
210    esac
211    lastrev=`rlog -h $rcsfile | sed -n 's/head:[         ]*//p'`
212    case "$basefile" in
213        version.h)
214            ;;
215        *)
216            $trialrun rcs -N$patchid:$lastrev $rcsfile
217            case "$trialrun" in
218                '')
219                    changes=`rcsdiff -r$lastpatchid -r$patchid $rcsfile \
220                        $basefile 2>/dev/null \
221                      | sed 1q`
222                    ;;
223                echo)
224                    changes=`rcsdiff -r$lastpatchid $rcsfile $basefile \
225                        2>/dev/null \
226                      | sed 1d`
227                    ;;
228            esac
229            case "$changes" in
230                '')
231                    ;;
232                *)
233                    case "$basefile" in
234                        languages/english/*.[0-9])
235                            context=
236                            ;;
237                        *)
238                            context=-u
239                            ;;
240                    esac
241                    echo "" >> "$patchfile"
242                    echo "Index: $basefile" >> "$patchfile"
243                    echo "" >> "$patchfile"
244                    case "$trialrun" in
245                        '')
246                            rcsdiff $context -r$lastpatchid -r$patchid \
247                                $rcsfile $basefile \
248                              >> "$patchfile"
249                            ;;
250                        echo)
251                            rcsdiff $context -r$lastpatchid $rcsfile \
252                                $basefile \
253                              >> "$patchfile"
254                            ;;
255                    esac
256                    ;;
257            esac
258    esac
259done
260
261#
262# Do new files
263#
264for basefile
265do
266    echo "" >> "$patchfile"
267    echo "Index: $basefile" >> "$patchfile"
268    echo "" >> "$patchfile"
269    diff -c /dev/null $basefile | sed "s;/dev/null;$basefile;" >> "$patchfile"
270done
271exit 0
Note: See TracBrowser for help on using the repository browser.