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