*** /usr/bin/scratch 2016-05-02 18:38:55.000000000 +0000 --- scratch 2016-05-17 01:24:53.503234451 +0000 *************** *** 5,13 **** # 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="" WRAPPER="" #set to 1 to work around OLPC bug #8008 --- 5,14 ---- # 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/NuScratch15012016.image" IMOPTIONS="" + DISPLAYMODULE=-vm-display-X11 DOCUMENT="" WRAPPER="" #set to 1 to work around OLPC bug #8008 *************** *** 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." } --- 27,34 ---- { echo "Usage: scratch [--param value] [-vmopt value] [arg value]" echo " where --param is --vm, --image, or --document;" ! echo " -display-module is an option to specify a vm display module;" ! echo " -displayopt is an option passed to the display module;" echo " and args are passed to the Squeak image." } *************** *** 56,62 **** *) DOCUMENT="$PWD/$2" ;; esac ! shift ;; --image) case "$2" in --- 58,64 ---- *) DOCUMENT="$PWD/$2" ;; esac ! shift ;; --image) case "$2" in *************** *** 65,71 **** *) IMAGE="$PWD/$2" ;; esac ! shift ;; --vm) case "$2" in --- 67,77 ---- *) IMAGE="$PWD/$2" ;; esac ! shift ! ;; ! -vmopt) ! VMOPTIONS="$VMOPTIONS $2" ! shift ;; --vm) case "$2" in *************** *** 76,82 **** esac shift ;; ! -*) VMOPTIONS="$VMOPTIONS $1 $2" shift ;; *) IMOPTIONS="$IMOPTIONS $1 $2" --- 82,91 ---- esac shift ;; ! -display-module) DISPLAYMODULE="$2" ! shift ! ;; ! -displayopt) DISPLAYOPTIONS="$DISPLAYOPTIONS $2" shift ;; *) IMOPTIONS="$IMOPTIONS $1 $2" *************** *** 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 - --- 110,148 ---- 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='; then + DISPLAYOPTIONS="$DISPLAYOPTIONS -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 $DISPLAYMODULE $DISPLAYOPTIONS $IMAGE $DOCUMENT $IMOPTIONS ! env LD_LIBRARY_PATH="$PLUGINS:$SVMLLP:${LD_LIBRARY_PATH}" $WRAPPER "$VM" $VMOPTIONS $DISPLAYMODULE $DISPLAYOPTIONS "$IMAGE" "$DOCUMENT" $IMOPTIONS if [ $PIGPIOD_ACTIVE -ne 0 ]; then sudo systemctl stop pigpiod fi