*** /usr/bin/scratch 2016-05-02 18:38:55.000000000 +0000 --- scratch 2016-05-25 22:50:37.614585930 +0000 *************** *** 5,11 **** # Adapted by: Miriam Ruiz, Alex Bradbury, tim@Rowledge.org # tim - trying to simplify a bit but good grief, shell script is incomprehensible ! VM="/usr/bin/squeak" IMAGE="/usr/share/scratch/NuScratch02052016.image" IMOPTIONS="" DOCUMENT="" --- 5,11 ---- # Adapted by: Miriam Ruiz, Alex Bradbury, tim@Rowledge.org # tim - trying to simplify a bit but good grief, shell script is incomprehensible ! VM=`echo /usr/lib/squeak/5.0-*/squeak|sort -r | head -1` IMAGE="/usr/share/scratch/NuScratch02052016.image" IMOPTIONS="" DOCUMENT="" *************** *** 26,32 **** { echo "Usage: scratch [--param value] [-vmopt value] [arg value]" echo " where --param is --vm, --image, or --document;" - echo " -vmopt is an option passed to the Squeak VM;" echo " and args are passed to the Squeak image." } --- 26,31 ---- *************** *** 56,62 **** *) DOCUMENT="$PWD/$2" ;; esac ! shift ;; --image) case "$2" in --- 55,61 ---- *) DOCUMENT="$PWD/$2" ;; esac ! shift ;; --image) case "$2" in *************** *** 65,71 **** *) IMAGE="$PWD/$2" ;; esac ! shift ;; --vm) case "$2" in --- 64,74 ---- *) IMAGE="$PWD/$2" ;; esac ! shift ! ;; ! -vmopt) ! VMOPTIONS="$VMOPTIONS $2" ! shift ;; --vm) case "$2" in *************** *** 76,84 **** esac shift ;; - -*) VMOPTIONS="$VMOPTIONS $1 $2" - shift - ;; *) IMOPTIONS="$IMOPTIONS $1 $2" shift ;; --- 79,84 ---- *************** *** 101,112 **** PIGPIOD_ACTIVE=$? sudo systemctl start pigpiod # VM, Image, and Document are non-optional # Document has to be present even if empty for IMOPTIONS to work ! echo Executing: $WRAPPER "$VM" "$IMAGE" "$DOCUMENT" $IMOPTIONS ! $WRAPPER "$VM" "$IMAGE" "$DOCUMENT" $IMOPTIONS if [ $PIGPIOD_ACTIVE -ne 0 ]; then sudo systemctl stop pigpiod fi - --- 101,139 ---- PIGPIOD_ACTIVE=$? sudo systemctl start pigpiod + + BIN=`/usr/bin/dirname $VM` + # At least on linux LD_LIBRARY_PATH's components must be absolute path names + case "$BIN" in + /*) PLUGINS="$BIN";; + *) PLUGINS="`pwd`/$BIN" + esac + + # On some linuxes there multiple versions of the C library. If the image uses + # libc (e.g. through the FFI) then it must use the same version that the VM uses + # and so it should take precedence over /lib libc. This is done by setting + # LD_LIBRARY_PATH appropriately, based on ldd's idea of the libc use by the VM. + LIBC_SO="`/usr/bin/ldd "$BIN/squeak" | /bin/fgrep /libc. | sed 's/^.*=> \([^ ]*\).*/\1/'`" + case "$LIBC_SO" in + /lib/arm-linux-gnueabihf/libc*) \ + SVMLLP="/lib/arm-linux-gnueabihf:/lib:/usr/lib/arm-linux-gnueabihf:/usr/lib";; + "") case `/bin/uname -m || /usr/bin/uname -m` in + *) echo "/usr/bin/ldd didn't produce any output. Can't infer base LD_LIBRARY_PATH. Aborting." 1>&2 + esac + exit 1;; + *) echo "Can't infer base LD_LIBRARY_PATH. Aborting. Try adding a line for $LIBC_SO to $0. Please report your edit to squeak vm-dev." 1>&2 + exit 1 + esac + + if echo $XMODIFIERS | grep '@im=' > /dev/null; then + VMOPTIONS="$VMOPTIONS -compositioninput" + fi + # VM, Image, and Document are non-optional # Document has to be present even if empty for IMOPTIONS to work ! echo Executing: env LD_LIBRARY_PATH="$PLUGINS:$SVMLLP:${LD_LIBRARY_PATH}" $WRAPPER $VM $VMOPTIONS $IMAGE $DOCUMENT $IMOPTIONS ! env LD_LIBRARY_PATH="$PLUGINS:$SVMLLP:${LD_LIBRARY_PATH}" $WRAPPER "$VM" $VMOPTIONS "$IMAGE" "$DOCUMENT" $IMOPTIONS if [ $PIGPIOD_ACTIVE -ne 0 ]; then sudo systemctl stop pigpiod fi