author | wenzelm |
Wed, 08 Aug 2001 15:16:38 +0200 | |
changeset 11485 | f7157bdc1e70 |
parent 10555 | 2323ec838401 |
child 12111 | d942348d8faf |
permissions | -rwxr-xr-x |
10555 | 1 |
#!/usr/bin/env bash |
2301 | 2 |
# |
2314 | 3 |
# $Id$ |
9789 | 4 |
# Author: Markus Wenzel, TU Muenchen |
5 |
# License: GPL (GNU GENERAL PUBLIC LICENSE) |
|
2314 | 6 |
# |
2301 | 7 |
# Poly/ML startup script. |
9977 | 8 |
|
10105 | 9 |
export -n INFILE OUTFILE COPYDB COMPRESS MLTEXT TERMINATE NOWRITE |
2301 | 10 |
|
11 |
||
12 |
## diagnostics |
|
13 |
||
2349 | 14 |
function fail_out() |
2301 | 15 |
{ |
2349 | 16 |
echo "Unable to create output heap file: \"$OUTFILE\"" >&2 |
2301 | 17 |
exit 2 |
18 |
} |
|
19 |
||
10206 | 20 |
function check_file() |
5063 | 21 |
{ |
22 |
if [ ! -f "$1" ]; then |
|
23 |
echo "Unable to locate $1" >&2 |
|
10206 | 24 |
echo "Please check your ML system settings!" >&2 |
5063 | 25 |
exit 2 |
26 |
fi |
|
27 |
} |
|
28 |
||
2301 | 29 |
|
2400 | 30 |
## Poly/ML programs |
2301 | 31 |
|
10206 | 32 |
ML_DBASE_PREFIX="" |
9789 | 33 |
POLY="$ML_HOME/poly" |
10206 | 34 |
check_file "$POLY" |
2301 | 35 |
|
9765 | 36 |
case "$ML_SYSTEM" in |
37 |
polyml-4.*) |
|
10206 | 38 |
if [ -z "$ML_DBASE" ]; then |
39 |
if [ -z "$COPYDB" ]; then |
|
40 |
ML_DBASE_PREFIX="$ML_HOME/" |
|
41 |
ML_DBASE="ML_dbase" |
|
42 |
else |
|
43 |
ML_DBASE="$ML_HOME/ML_dbase" |
|
44 |
fi |
|
45 |
POLYPATH="$ML_HOME" |
|
46 |
else |
|
47 |
POLYPATH=$(dirname "$ML_DBASE") |
|
48 |
fi |
|
49 |
export POLYPATH |
|
50 |
||
51 |
DISCGARB="$POLY" |
|
52 |
DISCGARB_OPTIONS="-d -c" |
|
53 |
||
9765 | 54 |
EXIT="fun exit 0 = (OS.Process.exit OS.Process.success): unit | exit _ = OS.Process.exit OS.Process.failure;" |
55 |
;; |
|
56 |
*) |
|
10206 | 57 |
if [ -z "$ML_DBASE" ]; then |
58 |
ML_DBASE="$ML_HOME/ML_dbase" |
|
59 |
fi |
|
60 |
||
61 |
DISCGARB="$ML_HOME/discgarb" |
|
62 |
DISCGARB_OPTIONS="-c" |
|
63 |
check_file "$DISCGARB" |
|
64 |
||
9765 | 65 |
EXIT="val exit = PolyML.exit;" |
66 |
;; |
|
67 |
esac |
|
68 |
||
69 |
||
2301 | 70 |
## prepare databases |
71 |
||
72 |
if [ -z "$INFILE" ]; then |
|
10206 | 73 |
check_file "$ML_DBASE_PREFIX$ML_DBASE" |
74 |
INFILE="$ML_DBASE" |
|
9765 | 75 |
MLTEXT="val use = PolyML.use; $EXIT $MLTEXT" |
11485
f7157bdc1e70
[ "$ML_SYSTEM" = polyml-4.1.1 ] && DISCGARB_OPTIONS="$DISCGARB_OPTIONS -S 120";
wenzelm
parents:
10555
diff
changeset
|
76 |
[ "$ML_SYSTEM" = polyml-4.1.1 ] && DISCGARB_OPTIONS="$DISCGARB_OPTIONS -S 120" |
10105 | 77 |
else |
78 |
COPYDB=true |
|
2301 | 79 |
fi |
80 |
||
81 |
if [ -z "$OUTFILE" ]; then |
|
82 |
DB="$INFILE" |
|
2349 | 83 |
ML_OPTIONS="-r $ML_OPTIONS" |
84 |
elif [ "$INFILE" -ef "$OUTFILE" ]; then |
|
2301 | 85 |
DB="$INFILE" |
86 |
elif [ -n "$COPYDB" ]; then |
|
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2605
diff
changeset
|
87 |
[ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; } |
2548 | 88 |
cp "$INFILE" "$OUTFILE" || fail_out |
2349 | 89 |
chmod +w "$OUTFILE" || fail_out |
2301 | 90 |
DB="$OUTFILE" |
91 |
else |
|
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2605
diff
changeset
|
92 |
[ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; } |
9789 | 93 |
echo "PolyML.make_database \"$OUTFILE\"; PolyML.quit();" | "$POLY" -r "$INFILE" |
2301 | 94 |
[ -f "$OUTFILE" ] || fail_out |
95 |
DB="$OUTFILE" |
|
96 |
fi |
|
97 |
||
98 |
||
99 |
## run it! |
|
100 |
||
4505 | 101 |
if [ -z "$TERMINATE" ]; then |
102 |
FEEDER_OPTS="-s" |
|
103 |
else |
|
104 |
FEEDER_OPTS="-q" |
|
105 |
fi |
|
106 |
||
10206 | 107 |
DB_INFO=$(ls -l "$DB" 2>/dev/null) |
2349 | 108 |
|
9789 | 109 |
"$ISABELLE_HOME/lib/scripts/feeder" -p -h "$MLTEXT" $FEEDER_OPTS | \ |
110 |
{ read FPID; "$POLY" $ML_OPTIONS "$DB"; RC="$?"; kill -HUP "$FPID"; exit "$RC"; } |
|
111 |
RC="$?" |
|
2301 | 112 |
|
10206 | 113 |
NEW_DB_INFO=$(ls -l "$DB" 2>/dev/null) |
114 |
[ -n "$OUTFILE" -a -n "$COMPRESS" -a "$DB_INFO" != "$NEW_DB_INFO" ] && \ |
|
115 |
"$DISCGARB" $DISCGARB_OPTIONS "$OUTFILE" |
|
4505 | 116 |
[ -n "$OUTFILE" -a -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE" |
2301 | 117 |
|
9789 | 118 |
exit "$RC" |