rebuild geeqie
[oi-userland.git] / components / runtime / smalltalk / stack-spur / inisqueak5
blob39a9b0b66b04f232505030525a9420cc5ace2a4e
1 #!/bin/sh
2 # $Id: inisqueak5,v 1.1 2020/12/01 11:19:19 stes Exp $
3 #
4 # inisqueak -- setup a directory for use with Squeak
5 #
6 # Copyright (C) 1996-2004 by Ian Piumarta and other authors/contributors
7 # listed elsewhere in this file.
8 # All rights reserved.
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
31 # SOFTWARE.
33 # Author: Ian.Piumarta@INRIA.Fr
34 # Last edited: 2006-10-18 10:14:20 by piumarta on emilia.local
36 # Author: David Stes
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
44 MAJOR=5.3
45 MAJORV=50
46 VERSION=5.3-19486
47 BIT=64
49 REMOTESRC="http://files.squeak.org/sources_files/"
50 REMSUFFIX="-64bit"
52 prefix=/usr
53 exec_prefix=${prefix}
54 bindir=${exec_prefix}/bin
55 imgdir=${prefix}/lib/squeak
57 if test ! -w .; then
58 echo "You don't have write permission in this directory." >&2
59 exit 1
62 # Sun's /bin/sh does not understand "test -e", but [/usr]/bin/test does
63 test="`which test`"
65 list=false
66 startup=true
67 batch=false
68 interactive=true
69 remote=true
70 # in 5.3 19480 and 19481 the sources seem to be in the zip image
71 remotesrc=false
73 while true; do
74 case "$1" in
75 -l) list=true; shift;;
76 -n) startup=false; shift;;
77 -r) remote=true; shift;;
78 -32) BIT=32;REMSUFFIX='-32bit'; shift;;
79 -64) 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;;
83 -h|-help|--help)
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'
96 exit 0;;
97 *) break;;
98 esac
99 done
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
116 missing()
118 echo "The file ${1} is missing." >&2
119 echo "Please check your Squeak installation." >&2
120 exit 1
123 REMOTESOURCES=SqueakV${MAJORV}.sources.gz
125 if ${remotesrc}; then
126 echo "Downloading $REMOTESOURCES from $REMOTESRC"
127 wget -O $REMOTESOURCES $REMOTESRC/$REMOTESOURCES
128 case $? in
129 0) ;;
130 *) echo "Unable to download $REMOTESOURCES from $REMOTESRC"; exit 1;
131 esac
132 gunzip $REMOTESOURCES
133 case $? in
134 0) ;;
135 *) echo "Unable to unzip $REMOTESOURCES"; exit 1;
136 esac
139 if ${remote}; then
140 echo "Downloading $REMOTEIMAGEZIP from $REMOTEDIR"
141 if [ -f $REMOTEIMAGEZIP ]
142 then
143 rm $REMOTEIMAGEZIP Squeak${VERSION}${REMSUFFIX}.image Squeak${VERSION}${REMSUFFIX}.changes
144 case $? in
145 0) ;;
146 *) echo "Unable to clean up existing $REMOTEIMAGEZIP"; exit 1;
147 esac
149 wget -O $REMOTEIMAGEZIP $REMOTEDIR/$REMOTEIMAGEZIP
150 case $? in
151 0) ;;
152 *) echo "Unable to download $REMOTEIMAGEZIP from $REMOTEDIR"; exit 1;
153 esac
154 unzip $REMOTEIMAGEZIP
155 case $? in
156 0) ;;
157 *) echo "Unable to unzip $REMOTEIMAGEZIP"; exit 1;
158 esac
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} \)
165 then
166 if ${startup}; then
167 if test ! -x ${SQUEAK}; then
168 missing "${SQUEAK}"
170 if ${interactive}; then
171 echo "Running ${SQUEAK}";
173 exec ${SQUEAK}
174 else
175 if ${interactive}; then
176 echo "Squeak is already installed in this directory" >&2
178 exit 1
182 install()
184 cpy="${1}"
185 src="${2}"
186 red="${3}"
187 dst="${4}"
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}
194 else
195 missing "${src}"
197 else
198 echo "${dst} is already present -- leaving it alone"
199 # startup=false
203 # choose an image to install
205 if ${list}; then :; else
206 if ${test} \( ! -e ${imgdir}/${IMAGE} \) \
207 -o \( ! -e ${imgdir}/${CHANGES} \) ; then
208 if ${batch}; then
209 echo "Could not find default image to install -- giving up." >&2
210 exit 1;
212 list=true
213 echo "No default image, looking for alternatives..."
214 echo
218 if ${list}; then
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
224 exit 1
226 nimg=`echo ${images} | tr ' ' '\012' | wc -l`
227 nimg=`echo ${nimg}`
228 more=true
229 while ${more}; do
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}]? "
236 read reply
237 case ${reply} in
238 [1-9]) ;;
239 [1-9][0-9]) ;;
240 *) echo
241 echo "Let's try that again, with a NUMBER between 1 and ${nimg}."
242 echo
243 continue;;
244 esac
245 if test \( ${reply} -ge 1 \) -a \( ${reply} -le ${nimg} \); then
246 more=false
248 if ${more}; then
249 echo
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)."
253 echo
255 done
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"
267 if ${startup}; then
268 if test ! -x ${SQUEAK}; then
269 missing "${SQUEAK}"
271 if ${interactive}; then
272 echo "Running ${SQUEAK}";
274 exec ${SQUEAK}