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