[squeak-dev] Letting the VM run multiple image formats

K K Subbu kksubbu.ml at gmail.com
Sun Feb 9 04:59:15 UTC 2020


On 08/02/20 1:59 AM, David T. Lewis wrote:
> To say it another way, if I have Cog installed on my Linux box, and
> then I install 32-bit Spur, it overwrites the /usr/local/bin/squeak
> file.  And if I then isntall 64-bit Spur, it overwrites the one for
> 32-bit Spur. They also conflict with the original /usr/local/bin/squeak.

+1 for fixing this.

Currently, I am using a hack to support different squeak VMs on a single 
(non-root) session. I install all products in /opt/share/squeak but 
create a symlink based on the image format number. My directory looks 
like something like this (edited for brevity) :

/opt/share/squeak$ ls -n 6*
lrwxrwxrwx ... 6502 -> sqtrunklinux
lrwxrwxrwx ... 6504 -> sqcoglinuxht
lrwxrwxrwx ... 6505 -> sqcoglinuxht
lrwxrwxrwx ... 6521 -> sqcogspurlinuxht
lrwxrwxrwx ... 68019 -> sqcogspur64linuxht
lrwxrwxrwx ... 68021 -> sqcogspur64linuxht

I use the attached run script (installed in /opt/share/bin/run and 
included in $PATH) to launch any given image. The script extracts the 
image format from the given image and then picks up the right VM through 
these symlinks.

I propose two changes to the official VM download :

* Squeak VM is a personal app, so it need not use the conventional 
/usr/local path. The Official VM unix build can set its prefix to a 
non-root directory, so that Linux/Unix downloads don't need root 
permission to install. Package maintainers do their own builds, so they 
can override the prefix path to suit their distros.

* Include the image format in the binary path so that we don't overwrite 
binaries that handle other format numbers. e.g. $HOME/.squeak/68019/.... 
We could insert an conf/ini/plist file inside this directory for the 
name (e.g. cog, spur, sista etc.), word size (32, 64) or optional features.

Regards .. Subbu
-------------- next part --------------
#!/bin/sh
# usage: run <myimage>
#
# Select a VM and run an image based on the image format number
#

# Assume scripts are in the same directory, e.g. /usr/local/bin or $HOME/squeak/bin
BIN=`dirname "$0"`

# The ckformat utility is distributed with interpreter VM builds.
# Find it in the lib directory for the interpreter VM.
CKFORMAT=ckformat

# Paths to the run scripts
INTERP="/usr/bin/squeak" # fallback
IMAGENAME=${SQUEAK_IMAGE:-squeak.image}
for arg in $*; do
  case ${arg} in
  -* )  ;;  #ignore
  *.image) IMAGENAME=${arg}; break ;;
  *.*) ;; 	# possible arguments to image
  * )		# image name without extension?
    a=${arg}.image
    if test -f ${a}; then
      IFMT=`${CKFORMAT} ${a} 2>/dev/null`
      if test $? -eq 0; then
        IMAGENAME=${a}
        break
      fi
    fi
    ;;
  esac
done

if test -z "$IFMT" -a -f ${IMAGENAME}; then
  IFMT=`${CKFORMAT} ${IMAGENAME} 2>/dev/null`
  if test $? -ne 0; then
    echo image format ${IFMT} not recognized for ${IMAGENAME}
    exit 1
  fi
else
  echo `basename $0` $@: image file not found
  exit 1
fi

VM=$(cd ${BIN}/..; pwd)/squeak/$IFMT/bin/squeak
# Use standard VM as default if preferred VM not present
if test ! -x "${VM}"; then
  echo ${VM} not found, trying ${INTERP}
  VM="${INTERP}"
fi

echo Running ${IMAGENAME} with image format $IFMT using $VM
exec ${VM} $@


More information about the Squeak-dev mailing list