File: rebuild-8.0

package info (click to toggle)
mit-scheme 12.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 208,300 kB
  • sloc: lisp: 781,881; xml: 425,435; ansic: 86,059; sh: 10,135; makefile: 2,501; asm: 2,121; csh: 1,143
file content (381 lines) | stat: -rwxr-xr-x 9,853 bytes parent folder | download | duplicates (2)
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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
#!/bin/csh -f

# Arguments: runtimeversion compilerversion edwinversion 6001version

# The versions can be omitted, and if they are, the current version
# as determined by the appropriate RCS file (e.g. runtime/version.scm)
# is built.

# If a version is the string "none", the corresponding band is not built,
# nor is the corresponding subsystem recompiled.

# If either the compiler or edwin is re-built, the combined (c+e) band
# is re-built as well.

# If the 6.001 (student) band is re-built, the range- and type-checked
# runtime system (runtime-check) is recompiled first.  Since the
# runtime-check/ directory uses symbolic links to .bin files in the
# runtime/ directory, the 6.001 band will not reflect changes to the
# runtime system that have not yet been resyntaxed in the runtime/
# directory.

# This script silently ignores additional arguments.

# Stage 1: Choose architecture and directories

hp9000s300
if ("$status" == 0) then
  set root="/scheme/7.4/300"
  set student_constant=""
endif
hp9000s800
if ("$status" == 0) then
  set root="/scheme/8.0/700"
  set student_constant=" -constant 2000"
endif

set src="/scheme/8.0/src"
set scheme="scheme-8.0"
set compile_heap=3000

set noclobber
set lock="$root/tmp/lock"
(echo "### Rebuild in progress started by" `whoami` "on" `date` "on" `hostname` > $lock)
if ("$status" != 0) then
  cat "$lock"
  exit 1
endif


# Stage 2: Write re-compilation script

set script="$root/tmp/build.$$"
rm -f "$script"

onintr abort_and_exit

echo \(begin\  > $script

if ("$1" != "none") then
  if (("$1" == "") || ("$1" == "next")) then
    set runver=`rcsversion $src/runtime/version.scm`
  else
    set runver="$1"
  endif
  echo "### Making runtime system version $runver..."
  set runtime="$root/backup/runtime-$runver"
  echo \(load\ \"runtime.sf\"\)\ \(load\ \"runtime.cbf\"\) >> $script
else
  set runtime=""
endif

if ("$2" != "none") then
  if (("$2" == "") || ("$2" == "next")) then
    set compver=`rcsversion $src/compiler/base/make.scm`
  else
    set compver="$2"
  endif
  echo "### Making compiler version $compver..."
  set complr="$root/backup/complr-$compver"
  echo \(cd\ \"../sf\"\)\ \(load\ \"sf.sf\"\)\ \(load\ \"sf.cbf\"\) >> $script
  echo \(cd\ \"../cref\"\)\ \(load\ \"cref.sf\"\)\ \(load\ \"cref.cbf\"\) >> $script
  echo \(cd\ \"../compiler\"\)\ \(load\ \"compiler.sf\"\)\ \(load\ \"compiler.cbf\"\) >> $script
else
  set complr=""
endif

if ("$3" != "none") then
  if (("$3" == "") || ("$3" == "next")) then
    set edver=`rcsversion $src/edwin/make.scm`
  else
    set edver="$3"
  endif
  echo "### Making edwin version $edver..."
  set edwin="$root/backup/edwin-$edver"
  echo \(cd\ \"../edwin\"\)\ \(load\ \"edwin.sf\"\)\ \(load\ \"edwin.cbf\"\) >> $script
else
  set edwin=""
endif

if ("$4" != "none") then
  if (("$4" == "") || ("$4" == "next")) then
    set stver=`rcsversion $src/6001/make.scm`
  else
    set stver="$4"
  endif
  echo "### Making 6.001 student band version $stver..."
  set student="$root/backup/6001-$stver"
  echo \(cd\ \"../runtime-check\"\) >> $script
  echo \(load\ \"runtime.cbf\"\) >> $script
  if ("$edwin" == "") then
    echo ";;; Must syntax Edwin in order to syntax the 6.001 make.scm file." >> $script
    echo \(cd\ \"../edwin\"\) >> $script
    echo \(load\ \"edwin.sf\"\) >> $script
  endif
  echo \(cd\ \"../6001\"\) >> $script
  echo \(load\ \"6001.sf\"\) >> $script
  echo \(load\ \"6001.cbf\"\) >> $script
else
  set student=""
endif

echo \(write-line\ \'\(finished\ recompilation\)\) >>$script

# This exit is inside the BEGIN
echo \(\%exit 0\)\) >>$script
#   but this one is not
echo \(\%exit 1\) >> $script
# That way, the first one will be executed if no error occurs in the BEGIN,
#  returning zero, but the second will be executed if an error does occur,
#  returning one.  Similar hack used everywhere.

if (("$runtime" == "") \
    && ("$complr" == "") \
    && ("$edwin" == "") \
    && ("$student" == "")) then
  echo "### No systems to rebuild."
  rm -f "$script" "$lock"
  exit 0
endif

# Stage 3: Re-compile sources

echo "### cd $root/runtime"
cd $root/runtime

echo "### $scheme -compiler -heap $compile_heap -no-init-file"
$scheme -compiler -heap $compile_heap -no-init-file <$script

set result="$status"
rm -f $script

if ("$result" != 0) then
  echo "### Recompilation failed."
  rm -f "$lock"
  exit "$result"
endif


# Stage 4: Re-build bands in staging area

if ("$runtime" != "") then
  echo "### cd $root/runtime"
  cd $root/runtime
  rm -f ../tmp/runtime.com
  echo "### $scheme -large -fasl make.com -no-init-file"
  $scheme -large -fasl make.com -no-init-file <<*END*
(begin
  (write-line '(saving runtime band ...))
  (disk-save "../tmp/runtime.com")
  (write-line '(saved runtime band))
  (%exit 0))
(%exit 1)
*END*
  set result="$status"
  if ("$result" != 0) then
    echo "### Re-building the runtime system failed."
    rm -f ../tmp/runtime.com "$lock"
    exit "$result"
  endif
  set runband="$root/tmp/runtime.com"
  set runbandarg="-band $runband"
else
  set runband=""
  set runbandarg=""
endif


if ("$complr" != "") then
  echo "### cd $root/sf"
  cd $root/sf
  rm -f ../tmp/complr.com
  echo "### $scheme -heap 2000 $runbandarg -no-init-file"
  $scheme -heap 2000 $runbandarg -no-init-file <<*END*
(begin
  (load "make.com")
  (cd "../compiler")
  (load "make.com")
  (write-line '(saving compiler band ...))
  (disk-save "../tmp/complr.com")
  (write-line '(saved compiler band))
  (%exit 0))
(%exit 1)
*END*
  set result="$status"
  if ("$result" != 0) then
    echo "### Re-building the compiler failed."
    rm -f ../tmp/runtime.com ../tmp/complr.com "$lock"
    exit "$result"
  endif
  set compband="$root/tmp/complr.com"
  set cbandarg="-band $compband"
else
  set compband=""
  set cbandarg=""
endif


if ("$edwin" != "") then
  echo "### cd $root/edwin"
  cd $root/edwin
  rm -f ../tmp/edwin.com
  echo "### $scheme -heap 2000 $runbandarg -no-init-file"
  $scheme -heap 2000 $runbandarg -no-init-file <<*END*
(begin
  (load "make.com")
  (write-line '(saving edwin band ...))
  (disk-save "../tmp/edwin.com")
  (write-line '(saved edwin band))
  (%exit 0))
(%exit 1)
*END*
  set result="$status"
  if ("$result" != 0) then
    echo "### Re-building edwin failed."
    rm -f ../tmp/runtime.com ../tmp/complr.com ../tmp/edwin.com "$lock"
    exit "$result"
  endif
  set edwinband="$root/tmp/edwin.com"
else
  set edwinband=""
endif


if (("$edwin" != "") || ("$complr" != "")) then
  echo "### cd $root/edwin"
  cd $root/edwin
  rm -f ../tmp/c+e.com
  echo "### $scheme -constant 2000 -heap 2000 -compiler $cbandarg -no-init-file"
  $scheme -constant 2000 -heap 2000 -compiler $cbandarg -no-init-file <<*END*
(begin
  (load "make.com")
  (write-line '(saving c+e band ...))
  (disk-save "../tmp/c+e.com")
  (write-line '(saved c+e band))
  (%exit 0))
(%exit 1)
*END*
  set result="$status"
  if ("$result" != 0) then
    echo "### Re-building c+e failed."
    set fullband=""
  else
    set fullband="$root/tmp/c+e.com"
  endif
else
  set fullband=""
endif


if ("$student" != "") then
  echo "### cd $root/runtime-check"
  cd $root/runtime-check
  rm -f ../tmp/6001.com
  echo "### $scheme -large$student_constant -fasl make.com -no-init-file"
  $scheme -large$student_constant -fasl make.com -no-init-file <<*END*
(begin
  (cd "../edwin")
  (load "make.com")
  (cd "../6001")
  (load "make.com")
  (write-line '(saving 6001 band ...))
  (disk-save "../tmp/6001.com")
  (write-line '(saved 6001 band))
  (%exit 0))
(%exit 1)
*END*
  set result="$status"
  if ("$result" != 0) then
    echo "### Re-building 6.001 student band failed."
    rm -f ../tmp/runtime.com ../tmp/complr.com ../tmp/edwin.com ../tmp/6001.com "$lock"
    exit "$result"
  endif
  set studband="$root/tmp/6001.com"
else
  set studband=""
endif


# Stage 5: Install bands
# This part should be atomic

onintr -

if ("$runtime" != "") then
  set backup=`nextver $runtime.gz`
  if ("$backup" != "$runtime.gz") then
    echo "###" mv -f "$runtime.gz" "$backup"
    mv -f "$runtime.gz" "$backup"
  endif
  echo "### gzip $runtime"
  cpx $runband $runtime
  gzip $runtime
  chmod a-w $runtime.gz
  echo "###" mv -f "$runband" "$root/lib/runtime.com"
  mv -f "$runband" "$root/lib/runtime.com"
endif

if ("$complr" != "") then
  set backup=`nextver $complr.gz`
  if ("$backup" != "$complr.gz") then
    echo "###" mv -f "$complr.gz" "$backup"
    mv -f "$complr.gz" "$backup"
  endif
  echo "### gzip $complr"
  cpx $compband $complr
  gzip $complr
  chmod a-w $complr.gz
  echo "###" mv -f "$compband" "$root/lib/compiler.com"
  mv -f "$compband" "$root/lib/compiler.com"
endif

if ("$edwin" != "") then
# Don't save this -- CPH
#  set backup=`nextver $edwin.gz`
#  if ("$backup" != "$edwin.gz") then
#    echo "###" mv -f "$edwin.gz" "$backup"
#    mv -f "$edwin.gz" "$backup"
#  endif
#  echo "### gzip $edwin"
#  cpx $edwinband $edwin
#  gzip $edwin
#  chmod a-w $edwin.gz
  echo "###" mv -f "$edwinband" "$root/lib/edwin.com"
  mv -f "$edwinband" "$root/lib/edwin.com"
endif

if ("$fullband" != "") then
  echo "###" mv -f "$fullband" "$root/lib/c+e.com"
  mv -f "$fullband" "$root/lib/c+e.com"
endif

if ("$student" != "") then
# Don't save this -- CPH
#  set backup=`nextver $student.gz`
#  if ("$backup" != "$student.gz") then
#    echo "###" mv -f "$student.gz" "$backup"
#    mv -f "$student.gz" "$backup"
#  endif
#  echo "### gzip $student"
#  cpx $studband $student
#  gzip $student
#  chmod a-w $student.gz
  echo "###" mv -f "$studband" "$root/lib/6001.com"
  mv -f "$studband" "$root/lib/6001.com"
endif

rm -f "$lock"
echo "### Done."
exit 0

abort_and_exit:
  echo ""
  echo "### Aborting -- Cleaning up..."
  if ("`jobs`" != "") then
    kill %1
    wait
  endif
  cd "$root/tmp"
  rm -f "$script" runtime.com complr.com edwin.com c+e.com 6001.com "$lock"
  echo "### Cleaned up."
  exit 1