#!/bin/sh
# 
# inisqueak -- setup a directory for use with Squeak
# 
#   Copyright (C) 1996 1997 1998 1999 2000 2001 Ian Piumarta and individual
#      authors/contributors listed elsewhere in this file.
#   All rights reserved.
#   
#   This file is part of Unix Squeak.
# 
#   This file is distributed in the hope that it will be useful, but WITHOUT
#   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
#   FITNESS FOR A PARTICULAR PURPOSE.
#   
#   You may use and/or distribute this file ONLY as part of Squeak, under
#   the terms of the Squeak License as described in `LICENSE' in the base of
#   this distribution, subject to the following restrictions:
# 
#   1. The origin of this software must not be misrepresented; you must not
#      claim that you wrote the original software.  If you use this software
#      in a product, an acknowledgment to the original author(s) (and any
#      other contributors mentioned herein) in the product documentation
#      would be appreciated but is not required.
# 
#   2. This notice may not be removed or altered in any source distribution.
# 
#   Using or modifying this file for use in any context other than Squeak
#   changes these copyright conditions.  Read the file `COPYING' in the base
#   of the distribution before proceeding with any such use.
# 
#   You are STRONGLY DISCOURAGED from distributing a modified version of
#   this file under its original name without permission.  If you must
#   change it, rename it first.
# 
# Author: Ian.Piumarta@INRIA.Fr
# 
# Last edited: Sun Sep 10 10:23:42 2000 by piumarta (Ian Piumarta) on emilia

MAJOR=3
VERSION=3.0

prefix=/usr
exec_prefix=${prefix}
bindir=${exec_prefix}/bin
libdir=${exec_prefix}/lib
datadir=${prefix}/share

echo "Installing per-user files for Squeak${VERSION} in `pwd`"

SQDATADIR=${datadir}/squeak
VSQDATADIR=${SQDATADIR}/${VERSION}

SQUEAK=${bindir}/squeak

IMAGE=Squeak${VERSION}.image
CHANGES=Squeak${VERSION}.changes
SOURCES=SqueakV${MAJOR}.sources

# Sun's /bin/sh does not understand "test -e", but [/usr]/bin/test does
test="`which test`"

startup="yes"

if test ! -w .; then
  echo "You don't have write permission in this directory." >&2
  exit 1
fi

missing()
{
  echo "The file ${1} is missing." >&2
  echo "Please check your Squeak installation." >&2
  exit 1
}

if test ! -x ${SQUEAK}; then
  missing "${SQUEAK}"
fi

install()
{
  file="${1}"
  dir="${2}"
  if ${test} ! -e ${1}; then
    if ${test} -e ${2}/${1}; then
      echo "+ ${3} ${2}/${1} ."
              ${3} ${2}/${1} .
    else
      missing "${2}/${1}"
    fi
  else
    echo "${1} is already present -- leaving it alone"
    startup="no"
  fi
}

install "${SOURCES}" "${SQDATADIR}"  "ln -s"
install "${IMAGE}"   "${VSQDATADIR}" "cp -p"
install "${CHANGES}" "${VSQDATADIR}" "cp -p"

echo "Running ${SQUEAK}"

exec ${SQUEAK}
