author | kleing |
Tue, 06 May 2003 12:29:49 +0200 | |
changeset 13965 | 46ad7fd03a38 |
parent 13002 | e844d0ee15d5 |
child 14981 | e73f8140af78 |
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" |
13965
46ad7fd03a38
use -Smax with poly 4.1.3 for maximum database space (see poly release notes)
kleing
parents:
13002
diff
changeset
|
76 |
[ "$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
|
77 |
DISCGARB_OPTIONS="$DISCGARB_OPTIONS -Smax" |
12810 | 78 |
[ "$ML_SYSTEM" = polyml-4.1.1 -o "$ML_SYSTEM" = polyml-4.1.2 ] && \ |
13002 | 79 |
DISCGARB_OPTIONS="$DISCGARB_OPTIONS -S 180" |
10105 | 80 |
else |
81 |
COPYDB=true |
|
2301 | 82 |
fi |
83 |
||
84 |
if [ -z "$OUTFILE" ]; then |
|
85 |
DB="$INFILE" |
|
2349 | 86 |
ML_OPTIONS="-r $ML_OPTIONS" |
87 |
elif [ "$INFILE" -ef "$OUTFILE" ]; then |
|
2301 | 88 |
DB="$INFILE" |
89 |
elif [ -n "$COPYDB" ]; then |
|
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2605
diff
changeset
|
90 |
[ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; } |
2548 | 91 |
cp "$INFILE" "$OUTFILE" || fail_out |
2349 | 92 |
chmod +w "$OUTFILE" || fail_out |
2301 | 93 |
DB="$OUTFILE" |
94 |
else |
|
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2605
diff
changeset
|
95 |
[ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; } |
9789 | 96 |
echo "PolyML.make_database \"$OUTFILE\"; PolyML.quit();" | "$POLY" -r "$INFILE" |
2301 | 97 |
[ -f "$OUTFILE" ] || fail_out |
98 |
DB="$OUTFILE" |
|
99 |
fi |
|
100 |
||
101 |
||
102 |
## run it! |
|
103 |
||
4505 | 104 |
if [ -z "$TERMINATE" ]; then |
12111 | 105 |
FEEDER_OPTS="" |
4505 | 106 |
else |
107 |
FEEDER_OPTS="-q" |
|
108 |
fi |
|
109 |
||
10206 | 110 |
DB_INFO=$(ls -l "$DB" 2>/dev/null) |
2349 | 111 |
|
9789 | 112 |
"$ISABELLE_HOME/lib/scripts/feeder" -p -h "$MLTEXT" $FEEDER_OPTS | \ |
113 |
{ read FPID; "$POLY" $ML_OPTIONS "$DB"; RC="$?"; kill -HUP "$FPID"; exit "$RC"; } |
|
114 |
RC="$?" |
|
2301 | 115 |
|
13965
46ad7fd03a38
use -Smax with poly 4.1.3 for maximum database space (see poly release notes)
kleing
parents:
13002
diff
changeset
|
116 |
|
10206 | 117 |
NEW_DB_INFO=$(ls -l "$DB" 2>/dev/null) |
118 |
[ -n "$OUTFILE" -a -n "$COMPRESS" -a "$DB_INFO" != "$NEW_DB_INFO" ] && \ |
|
119 |
"$DISCGARB" $DISCGARB_OPTIONS "$OUTFILE" |
|
4505 | 120 |
[ -n "$OUTFILE" -a -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE" |
2301 | 121 |
|
9789 | 122 |
exit "$RC" |