2 # $Id: inisqueak5,v 1.1 2020/12/01 11:19:19 stes Exp $
4 # inisqueak -- setup a directory for use with Squeak
6 # Copyright (C) 1996-2004 by Ian Piumarta and other authors/contributors
7 # listed elsewhere in this file.
10 # Copyright (C) 2020 by David Stes
11 # All rights reserved.
13 # This file is part of Unix Squeak.
15 # Permission is hereby granted, free of charge, to any person obtaining a copy
16 # of this software and associated documentation files (the "Software"), to deal
17 # in the Software without restriction, including without limitation the rights
18 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19 # copies of the Software, and to permit persons to whom the Software is
20 # furnished to do so, subject to the following conditions:
22 # The above copyright notice and this permission notice shall be included in
23 # all copies or substantial portions of the Software.
25 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 # Author: Ian.Piumarta@INRIA.Fr
34 # Last edited: 2006-10-18 10:14:20 by piumarta on emilia.local
37 # -r option to use wget and download image from files.squeak.org
38 # -32 and -64 options to choose 32bit or 64bit image (64 default)
39 # -v6 option to download Squeak 6.0 image
40 # $Id: inisqueak5,v 1.1 2020/12/01 11:19:19 stes Exp $
43 # subtle difference between SqueakV46.sources not SqueakV4.6.sources
49 REMOTESRC
="http://files.squeak.org/sources_files/"
54 bindir
=${exec_prefix}/bin
55 imgdir
=${prefix}/lib
/squeak
58 echo "You don't have write permission in this directory." >&2
62 # Sun's /bin/sh does not understand "test -e", but [/usr]/bin/test does
70 # in 5.3 19480 and 19481 the sources seem to be in the zip image
75 -l) list
=true
; shift;;
76 -n) startup
=false
; shift;;
77 -r) remote
=true
; shift;;
78 -32) BIT
=32;REMSUFFIX
='-32bit'; shift;;
80 -v6) MAJOR
=6.0; MAJORV
=60; VERSION
=6.0-22104; shift ;;
81 -R) remote
=false
; shift;;
82 -b) batch=true
; interactive
=false
; shift;;
84 echo "`basename $0` [-option...] [rootdir]"
85 echo ' -b batch (avoid interaction, exit status reflects success)'
86 echo ' -h you already know about'
87 echo ' -r download Squeak from remote server (default)'
88 echo ' -v6 download Squeak 6.0 images'
89 echo ' -32 download 32 bit images'
90 echo ' -64 download 64 bit images (default)'
91 echo ' -R do not download Squeak from remote server'
92 echo ' -help same as -h'
93 echo ' -l always present a list of alternative images (overrides -b)'
94 echo ' -n do not run Squeak after installing the files'
95 echo ' --help same as -help'
101 if test "$1" != ""; then
102 bindir
=${1}/${bindir}
103 imgdir
=${1}/${imgdir}
106 SQUEAK
=${bindir}/squeak
107 SOURCES
=SqueakV
${MAJORV}.sources
108 IMAGE
=squeak.image.gz
109 CHANGES
=squeak.changes.gz
110 REMOTEIMAGE
=Squeak
${VERSION}${REMSUFFIX}
111 REMOTEDIR
="http://files.squeak.org/${MAJOR}/${REMOTEIMAGE}"
112 REMOTEIMAGEZIP
=${REMOTEIMAGE}.
zip
114 # local install function
118 echo "The file ${1} is missing." >&2
119 echo "Please check your Squeak installation." >&2
123 REMOTESOURCES
=SqueakV
${MAJORV}.sources.gz
125 if ${remotesrc}; then
126 echo "Downloading $REMOTESOURCES from $REMOTESRC"
127 wget
-O $REMOTESOURCES $REMOTESRC/$REMOTESOURCES
130 *) echo "Unable to download $REMOTESOURCES from $REMOTESRC"; exit 1;
132 gunzip
$REMOTESOURCES
135 *) echo "Unable to unzip $REMOTESOURCES"; exit 1;
140 echo "Downloading $REMOTEIMAGEZIP from $REMOTEDIR"
141 if [ -f $REMOTEIMAGEZIP ]
143 rm $REMOTEIMAGEZIP Squeak
${VERSION}${REMSUFFIX}.image Squeak${VERSION}${REMSUFFIX}.changes
146 *) echo "Unable to clean up existing $REMOTEIMAGEZIP"; exit 1;
149 wget
-O $REMOTEIMAGEZIP $REMOTEDIR/$REMOTEIMAGEZIP
152 *) echo "Unable to download $REMOTEIMAGEZIP from $REMOTEDIR"; exit 1;
154 unzip $REMOTEIMAGEZIP
157 *) echo "Unable to unzip $REMOTEIMAGEZIP"; exit 1;
159 echo "Copying to default image name .."
160 cp Squeak
${VERSION}${REMSUFFIX}.image squeak.image
161 cp Squeak
${VERSION}${REMSUFFIX}.changes squeak.changes
164 if ${test} \
( -f squeak.image \
) -a \
( -f squeak.changes \
) -a \
( -e ${SOURCES} \
)
167 if test ! -x ${SQUEAK}; then
170 if ${interactive}; then
171 echo "Running ${SQUEAK}";
175 if ${interactive}; then
176 echo "Squeak is already installed in this directory" >&2
188 if ${test} ! -e ${dst}; then
189 if ${test} -e ${src}; then
190 if ${interactive}; then
191 echo "+ ${cpy} ${src} ${red} ${dst}";
193 eval ${cpy} ${src} ${red} ${dst}
198 echo "${dst} is already present -- leaving it alone"
203 # choose an image to install
205 if ${list}; then :; else
206 if ${test} \( ! -e ${imgdir}/${IMAGE} \
) \
207 -o \
( ! -e ${imgdir}/${CHANGES} \
) ; then
209 echo "Could not find default image to install -- giving up." >&2
213 echo "No default image, looking for alternatives..."
219 images
=`ls -1 ${imgdir}/*.image.gz 2>/dev/null | \
220 sed "s.${imgdir}/..;s/.image.gz//"`
221 if test "$images" = ""; then
222 echo "I could not find an image to install." >&2
223 echo "Please check your Squeak installation." >&2
226 nimg
=`echo ${images} | tr ' ' '\012' | wc -l`
230 echo "I found the following images:"
231 echo ${images} |
tr ' ' '\012' |
cat -n
232 if echo ${images} | fgrep
"Squeak${VERSION}" >/dev
/null
; then
233 echo "(of which I might recommend Squeak${VERSION}, unless you know better)."
235 echo -n "Which one should I install [1-${nimg}]? "
241 echo "Let's try that again, with a NUMBER between 1 and ${nimg}."
245 if test \
( ${reply} -ge 1 \) -a \( ${reply} -le ${nimg} \
); then
250 echo "Ha ha, very clever. Now give me a number between 1 and ${nimg}"
251 echo "(or hit your interrupt key [^C or whatever] if you don't like"
252 echo "the look of any of them)."
256 IMAGE
=`echo ${images} | tr ' ' '\012' | tail +${reply} | head -1`
257 CHANGES
=${IMAGE}.changes.gz
258 IMAGE
=${IMAGE}.image.gz
261 if ${interactive}; then echo "Installing ${IMAGE} in `pwd`"; fi
263 install "ln -s" "${imgdir}/${SOURCES}" " " "${SOURCES}"
264 install "gunzip -dc" "${imgdir}/${IMAGE}" ">" "squeak.image"
265 install "gunzip -dc" "${imgdir}/${CHANGES}" ">" "squeak.changes"
268 if test ! -x ${SQUEAK}; then
271 if ${interactive}; then
272 echo "Running ${SQUEAK}";