| | |
| | | #!/bin/sh |
| | | # |
| | | # Loosely based on Ian Piumarta's SqueakV4 wrapper script |
| | | # this script also uses the 'ckformat' binary to check the Squeak image |
| | | # and then launches a 32bit or 64bit vm (based on ckformat) |
| | | # |
| | | # The script then sets the LD_LIBRARY_PATH to the SQUEAK_PLUGINS directory. |
| | | # |
| | | # Launch squeakvm from the command line or a menu script, with a good |
| | | # plugin path, text encodings and pulseaudio kludge |
| | | # |
| | | # Last edited: 2013-11-13 19:51:35 by piumarta on emilia |
| | | |
| | | CK=/usr/bin/ckformat5c |
| | | DBX= |
| | | PATH=/usr/bin:/bin |
| | | PLUGIN_REV=5.0-202105050900-cog |
| | | LIB32=/usr/lib/squeak/$PLUGIN_REV |
| | | LIB64=/usr/lib/amd64/squeak/$PLUGIN_REV |
| | | |
| | | if [ "${SQUEAK_PLUGINS-unset}" = unset ]; then |
| | | SQUEAK_PLUGINS="$LIB32" |
| | | export SQUEAK_PLUGINS |
| | | 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}/$PLUGIN_REV" |
| | | useoss="false" |
| | | ck="ckformat" |
| | | squeakvm="squeak" |
| | | squeakvm64="squeak" |
| | | plgd64="${prefix}/lib/amd64/squeak/$PLUGIN_REV" |
| | | cogvm="" |
| | | 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 ! "$image" -a \( -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 |
| | | |
| | | while test "$#" -gt "0"; do |
| | | case $1 in |
| | | -dbx) |
| | | DBX='dbx -C' |
| | | ;; |
| | | -gdb) |
| | | DBX='gdb' |
| | | ;; |
| | | --) break;; # pass to VM |
| | | *) if test ! "$image" -a \( -f "$1.image" -o -f "$1" \); then image="$1"; fi;; |
| | | esac |
| | | shift |
| | | done |
| | | 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 |
| | | |
| | | # set the image |
| | | 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 -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 -x "${CK}" -a -f "${image}"; then |
| | | format=`"${CK}" "${image}"` |
| | | if test -x "${ck}" -a -f "${image}"; then |
| | | format=`"${ck}" "${image}"` |
| | | case "${format}" in |
| | | 6521) |
| | | export SQUEAK_PLUGINS="$LIB32";; |
| | | 68021) |
| | | export SQUEAK_PLUGINS="$LIB64";; |
| | | *) echo "Unknown Squeak image format ${format}";exit 0;; |
| | | 6521) vms="${squeakvm}";; |
| | | 68021) vms="${squeakvm64}"; plgdir="${plgd64}";; |
| | | *) vms="${squeakvm}";; |
| | | esac |
| | | else |
| | | echo "No image found, run default VM with args" |
| | | vms="${squeakvm}" # no image found, run default VM with args |
| | | fi |
| | | |
| | | LD_LIBRARY_PATH="${SQUEAK_PLUGINS}:${LD_LIBRARY_PATH}" exec $DBX "$SQUEAK_PLUGINS/squeak" $image |
| | | # 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}" "$@" |