commit | author | age
|
d4bb1e
|
1 |
#!/bin/sh |
8a2cb9
|
2 |
# |
DS |
3 |
# Launch squeakvm from the command line or a menu script, with a good |
|
4 |
# plugin path, text encodings and pulseaudio kludge |
|
5 |
# |
|
6 |
# Last edited: 2013-11-13 19:51:35 by piumarta on emilia |
d4bb1e
|
7 |
|
8a2cb9
|
8 |
PATH=/usr/bin:/bin |
679795
|
9 |
PLUGIN_REV=5.0-202403301849 |
d4bb1e
|
10 |
|
8a2cb9
|
11 |
realpath () { |
DS |
12 |
path="$1" |
|
13 |
while test -L "${path}"; do |
|
14 |
dir=`dirname "${path}"` |
|
15 |
dir=`cd "${dir}" && pwd -P` |
|
16 |
path=`basename "${path}"` |
|
17 |
path=`ls -l "${dir}/${path}" | sed 's,.* -> ,,'` |
|
18 |
if test `expr "${path}" : "/"` -eq 0; then |
|
19 |
path="${dir}/${path}" |
|
20 |
fi |
|
21 |
done |
|
22 |
if test -d "${path}"; then |
|
23 |
(cd "${path}" && pwd -P) |
|
24 |
else |
|
25 |
dir=`dirname "${path}"` |
|
26 |
base=`basename "${path}"` |
|
27 |
(cd "${dir}" && echo "`pwd -P`/${base}") |
|
28 |
fi |
|
29 |
} |
|
30 |
|
|
31 |
bindir=`realpath "${0}"` |
|
32 |
bindir=`dirname "${bindir}"` |
|
33 |
prefix=`dirname "${bindir}"` |
|
34 |
libdir="${prefix}/lib/squeak" |
40a469
|
35 |
plgdir="${libdir}/$PLUGIN_REV-32bit" |
8a2cb9
|
36 |
useoss="false" |
DS |
37 |
ck="ckformat" |
|
38 |
squeakvm="squeak" |
|
39 |
squeakvm64="squeak" |
40a469
|
40 |
plgd64="${prefix}/lib/amd64/squeak/$PLUGIN_REV-64bit" |
8a2cb9
|
41 |
cogvm="" |
DS |
42 |
cogvm64="" |
|
43 |
vm="" |
|
44 |
plugins="" |
|
45 |
wrapper="" |
|
46 |
image="" |
|
47 |
format="" |
|
48 |
info="" |
|
49 |
jit="" |
|
50 |
|
|
51 |
# look for VM options affecting this script's behaviour |
|
52 |
|
|
53 |
options () { |
|
54 |
while test "$#" -gt "0"; do |
|
55 |
case $1 in |
|
56 |
-vm-sound*) useoss="false";; |
|
57 |
-vm) shift; case "$1" in sound*) useoss="false"; esac;; |
|
58 |
-image-info) info="true";; |
|
59 |
--) break;; |
|
60 |
*) if test ! "$image" -a \( -f "$1.image" -o -f "$1" \); then image="$1"; fi;; |
|
61 |
esac |
|
62 |
shift |
|
63 |
done |
|
64 |
} |
|
65 |
|
|
66 |
case "$1" in |
|
67 |
-jit) jit=$1; shift; squeakvm=""; squeakvm64="";; |
|
68 |
-nojit) jit=$1; shift; cogvm=""; cogvm64="";; |
|
69 |
esac |
|
70 |
|
|
71 |
options "$@" |
|
72 |
|
|
73 |
# try to find the image file format |
|
74 |
|
|
75 |
if test -x "${plgd64}/${ck}"; then ck="${plgd64}/${ck}" |
|
76 |
elif test -x "${plgdir}/${ck}"; then ck="${plgdir}/${ck}" |
|
77 |
elif test -x "${libdir}/${ck}"; then ck="${libdir}/${ck}" |
|
78 |
elif test -x "${bindir}/${ck}"; then ck="${bindir}/${ck}" |
|
79 |
elif test -x "`which ${ck}`"; then ck="`which ${ck}`" |
d4bb1e
|
80 |
fi |
DS |
81 |
|
8a2cb9
|
82 |
if test -z "${image}"; then image="${SQUEAK_IMAGE}"; fi |
DS |
83 |
if test -z "${image}"; then image="squeak"; fi |
|
84 |
if test -f "${image}.image"; then image="${image}.image"; fi |
d4bb1e
|
85 |
|
8a2cb9
|
86 |
if test "${info}"; then |
DS |
87 |
if test ! -x "${ck}"; then |
|
88 |
echo "cannot find executable file: ${ck}" >&2 |
|
89 |
exit 1 |
|
90 |
fi |
|
91 |
if test ! -f "${image}"; then |
|
92 |
echo "cannot find image file: ${image}" >&2 |
|
93 |
exit 1 |
|
94 |
fi |
|
95 |
exec "${ck}" "${image}" |
|
96 |
fi |
d4bb1e
|
97 |
|
8a2cb9
|
98 |
if test -x "${ck}" -a -f "${image}"; then |
DS |
99 |
format=`"${ck}" "${image}"` |
d4bb1e
|
100 |
case "${format}" in |
0b0bff
|
101 |
6521|7033) vms="${squeakvm}";; |
DS |
102 |
68021|68533) vms="${squeakvm64}"; plgdir="${plgd64}";; |
|
103 |
*) vms="${squeakvm}";; |
d4bb1e
|
104 |
esac |
DS |
105 |
else |
8a2cb9
|
106 |
vms="${squeakvm}" # no image found, run default VM with args |
d4bb1e
|
107 |
fi |
DS |
108 |
|
8a2cb9
|
109 |
# find the vm and set the plugin path |
d4bb1e
|
110 |
|
8a2cb9
|
111 |
if test -z "${vms}"; then |
DS |
112 |
echo "cannot find VM to run image '${image}' with option '${jit}'" >&2 |
|
113 |
exit 1 |
|
114 |
fi |
|
115 |
|
|
116 |
for avm in ${vms}; do |
|
117 |
#echo CHECKING ${avm} |
|
118 |
if test -x "${plgdir}/${avm}"; then # bin/squeak -> lib/squeak/x.y-z/squeakvm |
|
119 |
vm="${plgdir}/${avm}" |
|
120 |
plugins="${plgdir}" |
|
121 |
break; |
|
122 |
elif test -x "${bindir}/${avm}"; then # bld/squeak -> bld/squeakvm |
|
123 |
vm="${bindir}/${avm}" |
|
124 |
plugins="${bindir}/%n" |
|
125 |
break; |
|
126 |
elif test -x "`which ${avm}`"; then |
|
127 |
vm="`which ${avm}`" |
|
128 |
plugins="" |
|
129 |
break; |
|
130 |
fi |
|
131 |
done |
|
132 |
|
|
133 |
if test -z "${vm}"; then |
|
134 |
echo "cannot find executable file: ${vms}" >&2 |
|
135 |
exit 1 |
|
136 |
fi |
|
137 |
|
|
138 |
# command-line overrides environment, so communicate anything we decide here via the environment |
|
139 |
|
|
140 |
if test -z "${SQUEAK_PATHENC}"; then SQUEAK_PATHENC="UTF-8"; export SQUEAK_PATHENC; fi |
|
141 |
if test -z "${SQUEAK_ENCODING}"; then SQUEAK_ENCODING="UTF-8"; export SQUEAK_ENCODING; fi |
|
142 |
|
|
143 |
if test -z "${SQUEAK_PLUGINS}"; then |
|
144 |
if test -n "${plugins}"; then |
|
145 |
SQUEAK_PLUGINS="${plugins}" |
|
146 |
export SQUEAK_PLUGINS |
|
147 |
fi |
|
148 |
fi |
|
149 |
|
|
150 |
# deal with pulseaudio if it is running |
|
151 |
|
|
152 |
if test -z "${SQUEAK_VM}"; then |
|
153 |
if ${useoss}; then |
|
154 |
if pulseaudio --check 2>/dev/null; then |
|
155 |
if padsp true 2>/dev/null; then |
|
156 |
wrapper="padsp" |
|
157 |
SQUEAK_VM="sound-OSS" |
|
158 |
export SQUEAK_VM |
|
159 |
fi |
|
160 |
fi |
|
161 |
fi |
|
162 |
fi |
|
163 |
|
|
164 |
# fix broken locales |
|
165 |
|
|
166 |
if test -z "$LC_ALL"; then |
|
167 |
LC_ALL="$LANG" |
|
168 |
export LC_ALL |
|
169 |
fi |
|
170 |
|
|
171 |
# debug output |
|
172 |
|
|
173 |
if test "0$SQUEAK_DEBUG" -gt "0"; then |
|
174 |
set | fgrep SQUEAK_ |
|
175 |
set -x |
|
176 |
fi |
|
177 |
|
|
178 |
# run the vm |
|
179 |
|
|
180 |
exec ${wrapper} "${vm}" "$@" |