forked from cisco/ChezScheme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkin
executable file
·344 lines (309 loc) · 8.05 KB
/
checkin
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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
#! /bin/csh -f
# checkin
# Copyright 1984-2017 Cisco Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
if ($#argv != 1) then
echo "Usage: checkin <workarea name>"
exit 1
endif
# set M to machine type and W to workarea name
set W = $1
if (!(-d $W)) then
echo "Workarea ./$W not found."
exit 1
endif
set M = $W/boot/*/.
if ($status || $#M != 1) then
echo "Cannot determine machine type."
exit 1
endif
set M = $M:h
set M = $M:t
onintr error
# This shell script checks sources and binaries in from a workarea to
# the release directory. Invoke with the name of a machine type and
# an optional workarea name. The workarea name defaults to the machine
# type.
set BACKUPDIR = $cwd:h/backup
if (!(-d $BACKUPDIR)) then
echo "creating backup directory $BACKUPDIR"
mkdir $BACKUPDIR || goto error
endif
echo -n "have you updated $W/LOG? [y]: "
set RESPONSE = $<
if ("$RESPONSE" != "y" && "$RESPONSE" != "") goto error
if (-e $W/scheme.1.in) then
cmp scheme.1.in $W/scheme.1.in >& /dev/null
if ($status != 0) then
echo -n "Did you update the date in $W/scheme.1.in? [y]: "
set RESPONSE = $<
if ("$RESPONSE" != "y" && "$RESPONSE" != "") goto error
endif
endif
set tmpsdirs = (. c mats s examples unicode makefiles csug release_notes wininstall bintar rpm pkg)
set sdirs = ()
foreach x ($tmpsdirs)
if (!(-e $x)) then
echo "ERROR: ./$x does not exist"
goto error
endif
if (!(-d $x)) then
echo "ERROR: ./$x is not a directory"
goto error
endif
test -d $W/$x && set sdirs = ($sdirs $x)
end
set tmpbdirs = (bin/$M boot/$M)
set bdirs = ()
foreach x ($tmpbdirs)
if ((-e $x) && !(-d $x)) then
echo "ERROR: ./$x is not a directory"
goto error
endif
test -d $W/$x && set bdirs = ($bdirs $x)
end
echo '*** running "make clean" in source directories ***'
foreach x ($sdirs)
switch ($x)
case .:
case unicode:
case unicode/UNIDATA:
case makefiles:
case csug:
case release_notes:
breaksw
case c:
case s:
case mats:
case benchmarks:
case examples:
case wininstall:
case bintar:
case rpm:
case pkg:
(cd $W/$x; make clean >& /dev/null)
breaksw
default:
echo "checkin error: unexpected sdir $x"
goto error
endsw
end
set ignorefiles = ()
set tmpsfiles = ()
foreach x ($sdirs)
set y = `(cd $W; find $x/* -type f -print -o -type d -prune)`
set tmpsfiles = ($tmpsfiles $y)
end
set sfiles = ()
foreach x ($tmpsfiles)
if ("$x" == "./Makefile" || "$x" == "./Mf-install" || "$x" == "./Mf-boot" || "$x" == "c/config.h" || "$x" == "c/Mf-config") then
set ignorefiles = ($ignorefiles $x)
else
cmp $W/$x $x >& /dev/null
if ($status == 0) then
set ignorefiles = ($ignorefiles $x)
else
set sfiles = ($sfiles $x)
endif
endif
end
if ($#sfiles == 0) echo "*** no source files found in ./$W ***"
set tmpbfiles = ()
foreach x ($bdirs)
set y = `(cd $W; find $x/* -type f -print -o -type d -prune)`
set tmpbfiles = ($tmpbfiles $y)
end
set bfiles = ()
foreach x ($tmpbfiles)
cmp $W/$x $x >& /dev/null
if ($status == 0) then
set ignorefiles = ($ignorefiles $x)
else
set bfiles = ($bfiles $x)
endif
end
if ($#bfiles == 0) echo "*** no binary files found in ./$W ***"
if ($#sfiles == 0 && $#bfiles == 0) goto delete
set tmpsfiles = ($sfiles)
set sfiles = ()
foreach x ($tmpsfiles)
if ($x:h == ".") then
set xpretty = $x:t
else
set xpretty = $x
endif
if (-e $x) then
set comment = ""
else
set comment = " new"
endif
echo -n "check in$comment source file $W/$xpretty? [y]: "
set RESPONSE = $<
if ("$RESPONSE" == "" || "$RESPONSE" == "y") set sfiles = ($sfiles $x)
end
set tmpbfiles = ($bfiles)
set bfiles = ()
foreach x ($tmpbfiles)
if (-e $x) then
set comment = ""
else
set comment = " new"
endif
echo -n "check in$comment binary file $W/$x? [y]: "
set RESPONSE = $<
if ("$RESPONSE" == "" || "$RESPONSE" == "y") set bfiles = ($bfiles $x)
end
set RESPONSE = ""
while ("$RESPONSE" != "y")
echo -n "proceed with check in? (y/n): "
set RESPONSE = $<
if ("$RESPONSE" == "n") exit 0
end
set oldsfiles = ()
foreach x ($sfiles)
if (-e $x) set oldsfiles = ($oldsfiles $x)
end
if ($#oldsfiles != 0) then
echo "backing up old versions of source files"
if (!(-f $BACKUPDIR/seqno)) then
set seqno = 0
else
set seqno = `cat $BACKUPDIR/seqno`
endif
set backuproot = $BACKUPDIR/$seqno
@ seqno = $seqno + 1
echo $seqno > $BACKUPDIR/seqno
echo "backup directory is $backuproot"
mkdir $backuproot || goto error
set n = 4
echo -n " "
foreach x ($oldsfiles)
set i = `echo "$x" | wc -c`
@ n = $n + $i + 1
if ($n > 78) then
echo ""
echo -n " "
@ n = $i + 4
endif
echo -n "$x "
set y = $backuproot/$x:h
if (!(-d $y)) then
mkdir -p $y || goto error
endif
rm -f $y/$x:t || goto error
mv $x $y || goto error
gzip $y/$x:t || goto error
end
echo ""
endif
set oldbfiles = ()
foreach x ($bfiles)
if (-e $x) set oldbfiles = ($oldbfiles $x)
end
if ($#oldbfiles != 0) then
echo "deleting old versions of binary files"
set n = 4
echo -n " "
foreach x ($oldbfiles)
set i = `echo "$x" | wc -c`
@ n = $n + $i + 1
if ($n > 78) then
echo ""
echo -n " "
@ n = $i + 4
endif
echo -n "$x "
rm -f $x || goto error
end
echo ""
endif
if ($#sfiles != 0) then
echo "moving new source files to release directory"
set n = 4
echo -n " "
foreach x ($sfiles)
set i = `echo "$x" | wc -c`
@ n = $n + $i + 1
if ($n > 78) then
echo ""
echo -n " "
@ n = $i + 4
endif
echo -n "$x "
mv $W/$x $x || goto error
end
echo ""
endif
if ($#bfiles != 0) then
echo "moving new binary files to release directory"
set n = 4
echo -n " "
foreach x ($bfiles)
set i = `echo "$x" | wc -c`
@ n = $n + $i + 1
if ($n > 78) then
echo ""
echo -n " "
@ n = $i + 4
endif
echo -n "$x "
if (!(-e $x:h)) mkdir -p $x:h || goto error
mv $W/$x $x || goto error
end
echo ""
endif
delete:
set tmpfiles = `(cd $W; find . -name zlib -prune -o -name lz4 -prune -o -type f -print)`
set files = ()
foreach x ($tmpfiles)
set files = ($x $files)
set tmpignorefiles = ($ignorefiles)
while ($#tmpignorefiles)
if ($x == ./$tmpignorefiles[1] || $x == $tmpignorefiles[1]) then
shift files
break
endif
shift tmpignorefiles
end
end
if ($#files == 0) then
set delete = "y"
else
set delete = "n"
echo "*** new or modified files remain in ./$W"
set n = 4
echo -n " "
foreach x ($files)
set i = `echo "$x" | wc -c`
@ n = $n + $i + 1
if ($n > 78) then
echo ""
echo -n " "
@ n = $i + 4
endif
echo -n "$x "
end
echo ""
endif
echo -n "delete ./$W? [$delete]: "
set RESPONSE = $<
if ("$RESPONSE" == "") set RESPONSE = $delete
if ("$RESPONSE" == "y") then
rm -rf $W || goto error
endif
exit 0
error:
echo ""
echo "quitting (error occurred)."
exit 1