multimedia/yt-dlp: update to 2025.1.12
[oi-userland.git] / components / runtime / smalltalk / stack-spur / squeak.ips
blob9855aa233152c287f659ff204885fa1443a6dd98
1 #!/bin/sh
2 #
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
8 PATH=/usr/bin:/bin
9 PLUGIN_REV=5.0-202412141720
11 realpath () {
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}"
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}")
31 bindir=`realpath "${0}"`
32 bindir=`dirname "${bindir}"`
33 prefix=`dirname "${bindir}"`
34 libdir="${prefix}/lib/squeak"
35 plgdir="${libdir}/$PLUGIN_REV-32bit"
36 useoss="false"
37 ck="ckformat"
38 squeakvm="squeak"
39 squeakvm64="squeak"
40 plgd64="${prefix}/lib/amd64/squeak/$PLUGIN_REV-64bit"
41 cogvm=""
42 cogvm64=""
43 vm=""
44 plugins=""
45 wrapper=""
46 image=""
47 format=""
48 info=""
49 jit=""
51 # look for VM options affecting this script's behaviour
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
66 case "$1" in
67 -jit) jit=$1; shift; squeakvm=""; squeakvm64="";;
68 -nojit) jit=$1; shift; cogvm=""; cogvm64="";;
69 esac
71 options "$@"
73 # try to find the image file format
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}`"
82 if test -z "${image}"; then image="${SQUEAK_IMAGE}"; fi
83 if test -z "${image}"; then image="squeak"; fi
84 if test -f "${image}.image"; then image="${image}.image"; fi
86 if test "${info}"; then
87 if test ! -x "${ck}"; then
88 echo "cannot find executable file: ${ck}" >&2
89 exit 1
91 if test ! -f "${image}"; then
92 echo "cannot find image file: ${image}" >&2
93 exit 1
95 exec "${ck}" "${image}"
98 if test -x "${ck}" -a -f "${image}"; then
99 format=`"${ck}" "${image}"`
100 case "${format}" in
101 6521|7033) vms="${squeakvm}";;
102 68021|68533) vms="${squeakvm64}"; plgdir="${plgd64}";;
103 *) vms="${squeakvm}";;
104 esac
105 else
106 vms="${squeakvm}" # no image found, run default VM with args
109 # find the vm and set the plugin path
111 if test -z "${vms}"; then
112 echo "cannot find VM to run image '${image}' with option '${jit}'" >&2
113 exit 1
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;
131 done
133 if test -z "${vm}"; then
134 echo "cannot find executable file: ${vms}" >&2
135 exit 1
138 # command-line overrides environment, so communicate anything we decide here via the environment
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
143 if test -z "${SQUEAK_PLUGINS}"; then
144 if test -n "${plugins}"; then
145 SQUEAK_PLUGINS="${plugins}"
146 export SQUEAK_PLUGINS
150 # deal with pulseaudio if it is running
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
164 # fix broken locales
166 if test -z "$LC_ALL"; then
167 LC_ALL="$LANG"
168 export LC_ALL
171 # debug output
173 if test "0$SQUEAK_DEBUG" -gt "0"; then
174 set | fgrep SQUEAK_
175 set -x
178 # run the vm
180 exec ${wrapper} "${vm}" "$@"