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
|
#!/bin/sh
#
# Launch squeakvm from the command line or a menu script, with a good
# plugin path, text encodings and pulseaudio kludge
#
# Last edited: 2012-09-17 09:06:59 by piumarta on linux64
PATH=/usr/bin:/bin
realpath () {
path="$1"
while test -L "${path}"; do
dir=`dirname "${path}"`
dir=`cd "${dir}" && pwd -P`
path=`basename "${path}"`
path=`ls -l "${dir}/${path}" | sed 's,.* -> ,,'`
if test `expr "${path}" : "/"` -eq 0; then
path="${dir}/${path}"
fi
done
if test -d "${path}"; then
(cd "${path}" && pwd -P)
else
dir=`dirname "${path}"`
base=`basename "${path}"`
(cd "${dir}" && echo "`pwd -P`/${base}")
fi
}
bindir=`realpath "${0}"`
bindir=`dirname "${bindir}"`
prefix=`dirname "${bindir}"`
libdir="${prefix}/lib/squeak"
plgdir="${libdir}/[version]"
useoss="[useoss]"
ck="ckformat"
squeakvm="squeakvm"
squeakvm64="squeakvm64"
plgd64="${plgdir}_64bit"
cogvm="cogvm"
cogvm64="cogvm64"
vm=""
plugins=""
wrapper=""
image=""
format=""
info=""
jit=""
# look for VM options affecting this script's behaviour
options () {
while test "$#" -gt "0"; do
case $1 in
-vm-sound*) useoss="false";;
-vm) shift; case "$1" in sound*) useoss="false"; esac;;
-image-info) info="true";;
--) break;;
*) if test -f "$1.image" -o -f "$1"; then image="$1"; fi;;
esac
shift
done
}
case "$1" in
-jit) jit=$1; shift; squeakvm=""; squeakvm64="";;
-nojit) jit=$1; shift; cogvm=""; cogvm64="";;
esac
options "$@"
# try to find the image file format
if test -x "${plgd64}/${ck}"; then ck="${plgd64}/${ck}"
elif test -x "${plgdir}/${ck}"; then ck="${plgdir}/${ck}"
elif test -x "${libdir}/${ck}"; then ck="${libdir}/${ck}"
elif test -x "${bindir}/${ck}"; then ck="${bindir}/${ck}"
elif test -x "`which ${ck}`"; then ck="`which ${ck}`"
fi
if test -z "${image}"; then image="${SQUEAK_IMAGE}"; fi
if test -z "${image}"; then image="squeak"; fi
if test -f "${image}.image"; then image="${image}.image"; fi
if test "${info}"; then
if test ! -x "${ck}"; then
echo "cannot find executable file: ${ck}" >&2
exit 1
fi
if test ! -f "${image}"; then
echo "cannot find image file: ${image}" >&2
exit 1
fi
exec "${ck}" "${image}"
fi
if test -x "${ck}" -a -f "${image}"; then
format=`"${ck}" "${image}"`
case "${format}" in
6502) vms="${squeakvm}";;
6504) vms="${cogvm} ${squeakvm}";;
6505) vms="${cogvm} ${squeakvm}";;
68000) vms="${squeakvm64}"; plgdir="${plgd64}";;
68002) vms="${squeakvm64}"; plgdir="${plgd64}";;
68003) vms="${squeakvm64}"; plgdir="${plgd64}";;
*) vms="${squeakvm}";;
esac
fi
# find the vm and set the plugin path
if test -z "${vms}"; then
echo "cannot find VM to run image '${image}' with option '${jit}'" >&2
exit 1
fi
for avm in ${vms}; do
echo CHECKING ${avm}
if test -x "${plgdir}/${avm}"; then # bin/squeak -> lib/squeak/x.y-z/squeakvm
vm="${plgdir}/${avm}"
plugins="${plgdir}"
break;
elif test -x "${bindir}/${avm}"; then # bld/squeak -> bld/squeakvm
vm="${bindir}/${avm}"
plugins="${bindir}/%n"
break;
elif test -x "`which ${avm}`"; then
vm="`which ${avm}`"
plugins=""
break;
fi
done
if test -z "${vm}"; then
echo "cannot find executable file: ${vms}" >&2
exit 1
fi
# command-line overrides environment, so communicate anything we decide here via the environment
if test -z "${SQUEAK_PATHENC}"; then SQUEAK_PATHENC="UTF-8"; export SQUEAK_PATHENC; fi
if test -z "${SQUEAK_ENCODING}"; then SQUEAK_ENCODING="UTF-8"; export SQUEAK_ENCODING; fi
if test -z "${SQUEAK_PLUGINS}"; then
if test -n "${plugins}"; then
SQUEAK_PLUGINS="${plugins}"
export SQUEAK_PLUGINS
fi
fi
# deal with pulseaudio if it is running
if test -z "${SQUEAK_VM}"; then
if ${useoss}; then
if pulseaudio --check 2>/dev/null; then
if padsp true 2>/dev/null; then
wrapper="padsp"
SQUEAK_VM="sound-OSS"
export SQUEAK_VM
fi
fi
fi
fi
# fix broken locales
if test -z "$LC_ALL"; then
LC_ALL="$LANG"
export LC_ALL
fi
# debug output
if test "0$SQUEAK_DEBUG" -gt "0"; then
set | fgrep SQUEAK_
set -x
fi
# run the vm
exec ${wrapper} "${vm}" "$@"
|