0
|
1 |
Object subclass:#STXInstaller
|
|
2 |
instanceVariableNames:'stxLibDir stxBinDir actionPercentageHolder actionTextHolder'
|
|
3 |
classVariableNames:'LastBinDir LastLibDir'
|
|
4 |
poolDictionaries:''
|
|
5 |
category:'eXept-tools'
|
|
6 |
!
|
|
7 |
|
|
8 |
|
|
9 |
!STXInstaller class methodsFor:'startup'!
|
|
10 |
|
|
11 |
open
|
|
12 |
^ self new open
|
|
13 |
|
|
14 |
"Created: 17.7.1996 / 14:36:22 / cg"
|
1
|
15 |
"Modified: 18.7.1996 / 21:20:22 / cg"
|
|
16 |
! !
|
|
17 |
|
|
18 |
!STXInstaller methodsFor:'defaults'!
|
|
19 |
|
|
20 |
defaultBinDirs
|
|
21 |
|dirs|
|
|
22 |
|
|
23 |
dirs := OrderedCollection new.
|
|
24 |
dirs add:'/usr/local/bin'.
|
|
25 |
dirs add:'/usr/bin'.
|
|
26 |
dirs add:(Filename homeDirectory constructString:'bin').
|
|
27 |
dirs add:'/tmp/stxbin'.
|
|
28 |
dirs add:'/home/stx/bin'.
|
|
29 |
dirs add:'/home2/stx/bin'.
|
|
30 |
^ dirs
|
|
31 |
|
|
32 |
"Created: 18.7.1996 / 19:43:00 / cg"
|
|
33 |
"Modified: 18.7.1996 / 19:45:08 / cg"
|
|
34 |
!
|
|
35 |
|
|
36 |
defaultLibDirs
|
|
37 |
|dirs|
|
|
38 |
|
|
39 |
dirs := OrderedCollection new.
|
|
40 |
dirs add:'/usr/local/lib/smalltalk'.
|
|
41 |
dirs add:'/usr/lib/smalltalk'.
|
|
42 |
dirs add:((Filename homeDirectory
|
|
43 |
construct:'lib')
|
|
44 |
constructString:'smalltalk').
|
|
45 |
dirs add:'/tmp/stxlib'.
|
|
46 |
dirs add:'/home/stx/lib'.
|
|
47 |
dirs add:'/home2/stx/lib'.
|
|
48 |
^ dirs
|
|
49 |
|
|
50 |
"Created: 18.7.1996 / 19:43:21 / cg"
|
|
51 |
"Modified: 18.7.1996 / 19:46:04 / cg"
|
0
|
52 |
! !
|
|
53 |
|
|
54 |
!STXInstaller methodsFor:'installing'!
|
|
55 |
|
|
56 |
copyFiles
|
|
57 |
|msg fileSpec filesToCopy numFiles nDone|
|
|
58 |
|
|
59 |
msg := #('ST/X Installation' '' 'copying:' '' 'to:' '') asStringCollection.
|
|
60 |
|
|
61 |
fileSpec := #(
|
1
|
62 |
"/ name destination subDir required
|
0
|
63 |
|
1
|
64 |
( 'stc/stc' #bin nil false '755' )
|
|
65 |
( 'rules/stmkmp' #bin nil false '755' )
|
|
66 |
( 'rules/stmkmf' #bin nil false '755' )
|
|
67 |
( 'projects/smalltalk/smalltalk' #bin nil true '755' )
|
0
|
68 |
|
1
|
69 |
( 'librun/librun.a' #lib 'lib' false '644' )
|
|
70 |
( 'libbasic/libbasic.o' #lib 'lib' false '644' )
|
|
71 |
( 'libbasic2/libbasic2.o' #lib 'lib' false '644' )
|
|
72 |
( 'libbasic3/libbasic3.o' #lib 'lib' false '644' )
|
|
73 |
( 'libcomp/libcomp.o' #lib 'lib' false '644' )
|
|
74 |
( 'libview/libview.o' #lib 'lib' false '644' )
|
|
75 |
( 'libview2/libview2.o' #lib 'lib' false '644' )
|
|
76 |
( 'libwidg/libwidg.o' #lib 'lib' false '644' )
|
|
77 |
( 'libwidg2/libwidg2.o' #lib 'lib' false '644' )
|
|
78 |
( 'libwidg3/libwidg3.o' #lib 'lib' false '644' )
|
|
79 |
( 'libsnmp/libsnmp.o' #lib 'lib' false '644' )
|
|
80 |
( 'libtable/libtable.o' #lib 'lib' false '644' )
|
|
81 |
( 'libtool/libtool.o' #lib 'lib' false '644' )
|
|
82 |
( 'libxt/libxt.o' #lib 'lib' false '644' )
|
|
83 |
( 'librt/librt.o' #lib 'lib' false '644' )
|
|
84 |
( 'support/VGL/vogl/src/libvogl.a' #lib 'lib' false '644' )
|
|
85 |
( 'support/VGL/vogl/src/*.h' #lib 'include' false '644' )
|
|
86 |
( 'support/DLD/dld-3.2.5/libdld.a' #lib 'lib' false '644' )
|
0
|
87 |
|
1
|
88 |
( 'projects/smalltalk/*.rc' #lib nil false '644' )
|
|
89 |
( 'projects/smalltalk/patches' #lib nil true '644' )
|
0
|
90 |
|
1
|
91 |
( 'projects/smalltalk/bitmaps' #lib nil true '644' )
|
|
92 |
( 'doc' #lib nil false '644' )
|
|
93 |
( 'projects/smalltalk/include' #lib nil true '644' )
|
|
94 |
( 'projects/smalltalk/resources' #lib nil true '644' )
|
|
95 |
( 'projects/smalltalk/source' #lib nil true '644' )
|
|
96 |
( 'configurations' #lib nil false '644' )
|
|
97 |
( 'rules' #lib nil false '644' )
|
|
98 |
|
|
99 |
( 'goodies/*.st' #lib 'goodies' false '644' )
|
|
100 |
( 'goodies/*.chg' #lib 'goodies' false '644' )
|
|
101 |
( 'goodies/rdoit/rdoit' #bin nil false '755' )
|
0
|
102 |
).
|
|
103 |
|
|
104 |
filesToCopy := OrderedCollection new.
|
|
105 |
|
|
106 |
fileSpec do:[:entry |
|
|
107 |
|fileName dest subDir required destDir|
|
|
108 |
|
|
109 |
fileName := entry at:1.
|
|
110 |
dest := entry at:2.
|
|
111 |
subDir := entry at:3.
|
|
112 |
required := entry at:4.
|
|
113 |
|
|
114 |
dest == #bin ifTrue:[
|
|
115 |
destDir := stxBinDir
|
|
116 |
] ifFalse:[
|
|
117 |
destDir := stxLibDir
|
|
118 |
].
|
|
119 |
|
|
120 |
destDir := destDir asFilename.
|
|
121 |
subDir notNil ifTrue:[
|
|
122 |
destDir := destDir construct:subDir
|
|
123 |
].
|
|
124 |
|
|
125 |
filesToCopy add:(fileName -> destDir pathName)
|
|
126 |
].
|
|
127 |
|
|
128 |
numFiles := filesToCopy size.
|
|
129 |
nDone := 0.
|
|
130 |
|
|
131 |
filesToCopy do:[:entry |
|
1
|
132 |
|fileName destDir cmd p text|
|
0
|
133 |
|
|
134 |
actionPercentageHolder value:(nDone / numFiles * 100) rounded.
|
|
135 |
|
|
136 |
fileName := entry key.
|
|
137 |
destDir := entry value.
|
|
138 |
|
|
139 |
msg at:4 put:' ' , (fileName asText allBold).
|
|
140 |
msg at:6 put:' ' , (destDir asText allBold).
|
|
141 |
actionTextHolder value:nil.
|
|
142 |
actionTextHolder value:msg.
|
|
143 |
|
1
|
144 |
cmd := 'cp -r ../../' , fileName , ' ' , destDir.
|
|
145 |
|
|
146 |
p := PipeStream readingFrom:cmd.
|
|
147 |
p isNil ifTrue:[
|
|
148 |
self warn:('command error. Could not execute:\\' , cmd) withCRs.
|
|
149 |
] ifFalse:[
|
|
150 |
text := OrderedCollection new.
|
|
151 |
[p atEnd] whileFalse:[
|
|
152 |
text add:p nextLine
|
|
153 |
].
|
|
154 |
p close.
|
|
155 |
].
|
|
156 |
"/ (OperatingSystem executeCommand:('cp -r ../../' , fileName , ' ' , destDir))
|
|
157 |
"/ ifFalse:[
|
|
158 |
"/ self warn:('error while copying ' , fileName , '\\Please check manually.') withCRs.
|
|
159 |
"/ ].
|
0
|
160 |
|
|
161 |
nDone := nDone + 1
|
|
162 |
].
|
|
163 |
|
|
164 |
^ true
|
|
165 |
|
|
166 |
"Created: 17.7.1996 / 15:16:20 / cg"
|
1
|
167 |
"Modified: 18.7.1996 / 22:20:24 / cg"
|
0
|
168 |
!
|
|
169 |
|
|
170 |
createDirectories
|
|
171 |
|msg dirsToMake numDirs nDone|
|
|
172 |
|
|
173 |
msg := #('ST/X Installation' '' 'creating directory:' '' '' '') asStringCollection.
|
|
174 |
|
|
175 |
dirsToMake := OrderedCollection new.
|
|
176 |
dirsToMake add:stxBinDir.
|
|
177 |
dirsToMake add:stxLibDir.
|
|
178 |
dirsToMake add:(stxLibDir asFilename constructString:'lib').
|
|
179 |
dirsToMake add:(stxLibDir asFilename constructString:'doc').
|
|
180 |
dirsToMake add:(stxLibDir asFilename constructString:'include').
|
|
181 |
dirsToMake add:(stxLibDir asFilename constructString:'resources').
|
|
182 |
dirsToMake add:(stxLibDir asFilename constructString:'binary').
|
|
183 |
dirsToMake add:(stxLibDir asFilename constructString:'bitmaps').
|
1
|
184 |
dirsToMake add:(stxLibDir asFilename constructString:'goodies').
|
0
|
185 |
|
|
186 |
numDirs := dirsToMake size.
|
|
187 |
nDone := 0.
|
|
188 |
|
|
189 |
dirsToMake do:[:dirName |
|
|
190 |
|d errMsg stop box|
|
|
191 |
|
|
192 |
actionPercentageHolder value:(nDone / numDirs * 100) rounded.
|
|
193 |
|
|
194 |
msg at:4 put:' ' , dirName.
|
|
195 |
actionTextHolder value:nil.
|
|
196 |
actionTextHolder value:msg.
|
|
197 |
|
|
198 |
d := dirName asFilename.
|
|
199 |
|
|
200 |
d exists ifFalse:[
|
|
201 |
OperatingSystem recursiveCreateDirectory:d pathName
|
|
202 |
].
|
|
203 |
|
|
204 |
d exists ifFalse:[
|
|
205 |
errMsg := 'failed to create directory: ' , dirName.
|
|
206 |
stop := true
|
|
207 |
] ifTrue:[
|
|
208 |
d isDirectory ifFalse:[
|
|
209 |
errMsg := 'not a directory: ' , dirName.
|
|
210 |
stop := true
|
|
211 |
] ifTrue:[
|
|
212 |
(d isReadable
|
|
213 |
and:[d isWritable]) ifFalse:[
|
|
214 |
errMsg := 'no R/W access to directory: ' , dirName.
|
|
215 |
stop := false
|
|
216 |
] ifTrue:[
|
|
217 |
errMsg := nil
|
|
218 |
]
|
|
219 |
]
|
|
220 |
].
|
|
221 |
|
|
222 |
errMsg notNil ifTrue:[
|
|
223 |
box := WarningBox new.
|
|
224 |
box title:errMsg.
|
|
225 |
box showAtPointerNotCovering:(WindowGroup activeGroup topViews first).
|
1
|
226 |
stop ifTrue:[^ false].
|
0
|
227 |
].
|
|
228 |
|
|
229 |
Delay waitForSeconds:0.25.
|
|
230 |
nDone := nDone + 1.
|
|
231 |
].
|
|
232 |
^ true
|
|
233 |
|
|
234 |
"Created: 17.7.1996 / 15:24:19 / cg"
|
1
|
235 |
"Modified: 18.7.1996 / 22:18:38 / cg"
|
0
|
236 |
! !
|
|
237 |
|
|
238 |
!STXInstaller methodsFor:'startup'!
|
|
239 |
|
|
240 |
askAndInstall
|
|
241 |
"/ check, if we are in the projects/smalltalk directory
|
|
242 |
|
|
243 |
(Filename currentDirectory pathName endsWith:'projects/smalltalk') ifFalse:[
|
|
244 |
self warn:'must be in the projects/smalltalk directory'.
|
|
245 |
^ self
|
|
246 |
].
|
|
247 |
|
|
248 |
[self askForDestination] whileTrue:[
|
|
249 |
self checkForExistingInstallationAndConfirm ifFalse:[
|
|
250 |
^ self
|
|
251 |
].
|
|
252 |
self doInstall ifTrue:[
|
1
|
253 |
self postInstall.
|
0
|
254 |
^ self
|
|
255 |
].
|
|
256 |
(self confirm:'installation failed or aborted - retry ?')
|
|
257 |
ifFalse:[
|
|
258 |
^ self
|
|
259 |
]
|
|
260 |
].
|
|
261 |
|
1
|
262 |
"Modified: 18.7.1996 / 21:20:56 / cg"
|
0
|
263 |
!
|
|
264 |
|
|
265 |
askForDestination
|
|
266 |
"open a dialog to enter destination directories"
|
|
267 |
|
|
268 |
|d cm l green dark
|
|
269 |
stxLibDirHolder stxBinDirHolder
|
|
270 |
|
|
|
271 |
|
|
272 |
LastLibDir isNil ifTrue:[
|
|
273 |
LastLibDir := '/usr/local/lib/smalltalk'
|
|
274 |
].
|
|
275 |
LastBinDir isNil ifTrue:[
|
|
276 |
LastBinDir := '/usr/local/bin'
|
|
277 |
].
|
|
278 |
|
|
279 |
stxLibDirHolder := LastLibDir asValue.
|
|
280 |
stxBinDirHolder := LastBinDir asValue.
|
|
281 |
|
|
282 |
Screen current hasColors ifTrue:[
|
|
283 |
green := (Color red:0 green:80 blue:20) "darkened".
|
|
284 |
dark := Color grey:10.
|
|
285 |
] ifFalse:[
|
|
286 |
green := Color white.
|
|
287 |
dark := Color black.
|
|
288 |
].
|
|
289 |
|
|
290 |
d := DialogBox new.
|
|
291 |
|
|
292 |
d label:'ST/X CD Installation'.
|
|
293 |
l := d addTextLabel:'Smalltalk/X CD installation.'.
|
|
294 |
l adjust:#left; backgroundColor:dark; foregroundColor:Color white.
|
|
295 |
d addVerticalSpace.
|
|
296 |
d addVerticalSpace.
|
|
297 |
|
|
298 |
d addHorizontalLine.
|
|
299 |
|
|
300 |
l := d addTextLabel:'Destination directories:'.
|
|
301 |
l adjust:#left; backgroundColor:dark; foregroundColor:Color white.
|
|
302 |
|
|
303 |
cm := ComboBoxView on:stxBinDirHolder.
|
1
|
304 |
cm list:self defaultBinDirs.
|
0
|
305 |
d
|
|
306 |
addLabelledField:cm
|
|
307 |
label:'binaries'
|
|
308 |
adjust:#left
|
|
309 |
tabable:true
|
|
310 |
from:0.0 to:1.0 separateAtX:0.25
|
|
311 |
nameAs:'binaryBox'.
|
|
312 |
|
|
313 |
(d componentAt:'binaryBox.label') backgroundColor:dark; foregroundColor:Color white.
|
|
314 |
|
|
315 |
cm := ComboBoxView on:stxLibDirHolder.
|
1
|
316 |
cm list:self defaultLibDirs.
|
0
|
317 |
d
|
|
318 |
addLabelledField:cm
|
|
319 |
label:'libraries'
|
|
320 |
adjust:#left
|
|
321 |
tabable:true
|
|
322 |
from:0.0 to:1.0 separateAtX:0.25
|
|
323 |
nameAs:'libraryBox'.
|
|
324 |
|
|
325 |
(d componentAt:'libraryBox.label') backgroundColor:dark; foregroundColor:Color white.
|
|
326 |
|
|
327 |
d addAbortButton; addOkButtonLabelled:'install'.
|
|
328 |
d extent:400@300.
|
|
329 |
|
|
330 |
d allViewBackground:dark.
|
|
331 |
|
|
332 |
d openAtCenter.
|
|
333 |
d accepted ifTrue:[
|
|
334 |
stxLibDir := LastLibDir := stxLibDirHolder value.
|
|
335 |
stxBinDir := LastBinDir := stxBinDirHolder value.
|
1
|
336 |
d destroy.
|
0
|
337 |
^ true
|
|
338 |
].
|
1
|
339 |
d destroy.
|
0
|
340 |
^ false
|
|
341 |
|
1
|
342 |
"Modified: 18.7.1996 / 19:43:38 / cg"
|
0
|
343 |
!
|
|
344 |
|
|
345 |
checkForExistingInstallationAndConfirm
|
|
346 |
"look if there is another installation and confirm
|
|
347 |
reinstalling; return true if ok, false if not"
|
|
348 |
|
1
|
349 |
|whatToDo|
|
|
350 |
|
0
|
351 |
stxLibDir asFilename exists ifTrue:[
|
1
|
352 |
whatToDo := Dialog
|
|
353 |
choose:('detected existing installation in '
|
|
354 |
, stxLibDir asText allBold)
|
|
355 |
labels:#('remove first' 'overwrite' 'cancel')
|
|
356 |
values:#(remove over nil)
|
|
357 |
default:nil.
|
|
358 |
whatToDo isNil ifTrue:[^false].
|
|
359 |
whatToDo == #remove ifTrue:[
|
|
360 |
(OperatingSystem recursiveRemoveDirectory:stxLibDir)
|
|
361 |
ifFalse:[
|
|
362 |
self warn:'mhmh - could not remove old installation.'
|
|
363 |
].
|
|
364 |
].
|
|
365 |
^ true
|
|
366 |
"/ ^ DialogBox
|
|
367 |
"/ confirm:('detected existing installation in '
|
|
368 |
"/ , stxLibDir asText allBold
|
|
369 |
"/ , '\\continue & overwrite ?') withCRs
|
|
370 |
"/ yesLabel:'overwrite' noLabel:'cancel'
|
0
|
371 |
|
|
372 |
].
|
|
373 |
^ true
|
|
374 |
|
1
|
375 |
"Modified: 18.7.1996 / 20:01:36 / cg"
|
0
|
376 |
!
|
|
377 |
|
|
378 |
doInstall
|
|
379 |
"install ST/X; return true if ok, false if not"
|
|
380 |
|
|
381 |
|progressView ok|
|
|
382 |
|
|
383 |
progressView := ProgressIndicator
|
|
384 |
inBoxWithLabel:'ST/X Installation'
|
|
385 |
text:#('ST/X Installation' '' '' '' '' '' '' '') asStringCollection
|
|
386 |
abortable:true.
|
|
387 |
progressView topView extent:400@300.
|
|
388 |
|
|
389 |
ok := false.
|
|
390 |
|
|
391 |
progressView showProgressOf:
|
|
392 |
[:progressValue :currentAction |
|
|
393 |
|
|
394 |
actionPercentageHolder := progressValue.
|
|
395 |
actionTextHolder := currentAction.
|
|
396 |
|
|
397 |
(self createDirectories) ifTrue:[
|
|
398 |
ok := self copyFiles
|
|
399 |
]
|
|
400 |
].
|
|
401 |
|
|
402 |
^ ok
|
|
403 |
|
|
404 |
"Created: 17.7.1996 / 15:11:27 / cg"
|
|
405 |
"Modified: 17.7.1996 / 15:24:27 / cg"
|
|
406 |
!
|
|
407 |
|
|
408 |
open
|
1
|
409 |
self askAndInstall.
|
0
|
410 |
|
|
411 |
"Created: 17.7.1996 / 14:37:14 / cg"
|
1
|
412 |
"Modified: 18.7.1996 / 18:26:20 / cg"
|
|
413 |
!
|
|
414 |
|
|
415 |
postInstall
|
|
416 |
"some messages at the end ..."
|
|
417 |
|
|
418 |
|shInfo cshInfo msg stxBinDir stxLibDir havePath|
|
|
419 |
|
|
420 |
stxBinDir := '/home2/stx/bin'.
|
|
421 |
stxLibDir := '/home2/stx/lib'.
|
|
422 |
|
|
423 |
msg := 'ST/X Installation complete.\\' withCRs.
|
|
424 |
shInfo := ''.
|
|
425 |
cshInfo := ''.
|
|
426 |
|
|
427 |
havePath := true.
|
|
428 |
(((OperatingSystem getEnvironment:'PATH')
|
|
429 |
asCollectionOfSubstringsSeparatedBy:$:)
|
|
430 |
includes:stxBinDir) ifFalse:[
|
|
431 |
|
|
432 |
havePath := false.
|
|
433 |
shInfo := 'PATH=$PATH:' , stxBinDir , ' ; export PATH\'.
|
|
434 |
cshInfo := 'set path=($path ' , stxBinDir , ')\'.
|
|
435 |
msg := msg , stxBinDir asText allBold , ' is not in your PATH.
|
|
436 |
You should change your ".login" and/or ".profile" files to include it.
|
|
437 |
|
|
438 |
'
|
|
439 |
].
|
|
440 |
|
|
441 |
(stxLibDir ~= '/usr/local/lib/smalltalk'
|
|
442 |
and:[stxLibDir ~= '/usr/lib/smalltalk']) ifTrue:[
|
|
443 |
msg := msg ,
|
|
444 |
'The library directory is not a standard ST/X library directory
|
|
445 |
("/usr/local/lib/smalltalk" or "/usr/lib/smalltalk").
|
|
446 |
You have to define the ' , 'STX_LIBDIR' asText allBold ,' environment variable
|
|
447 |
as ' , stxLibDir asText allBold , ' before ST/X can be started.
|
|
448 |
'.
|
|
449 |
|
|
450 |
havePath ifFalse:[
|
|
451 |
msg := msg , 'The above mentioned files are also a good place to do this.
|
|
452 |
'.
|
|
453 |
] ifTrue:[
|
|
454 |
msg := msg , 'The ".login" and/or ".profile" files are a good place to do this.
|
|
455 |
'.
|
|
456 |
].
|
|
457 |
|
|
458 |
shInfo := shInfo , 'STX_LIBDIR=' , stxLibDir , ' ; export STX_LIBDIR\'.
|
|
459 |
cshInfo := cshInfo , 'setenv STX_LIBDIR ' , stxLibDir , '\'.
|
|
460 |
].
|
|
461 |
|
|
462 |
shInfo notEmpty ifTrue:[
|
|
463 |
'Please add the following to your ".profile" file:' errorPrintCR.
|
|
464 |
'' errorPrintCR.
|
|
465 |
shInfo withCRs errorPrintCR.
|
|
466 |
'' errorPrintCR.
|
|
467 |
'or (if you use csh/tcsh), add to your ".login" file:' errorPrintCR.
|
|
468 |
'' errorPrintCR.
|
|
469 |
cshInfo withCRs errorPrintCR.
|
|
470 |
'' errorPrintCR.
|
|
471 |
].
|
|
472 |
self information:msg.
|
|
473 |
|
|
474 |
"
|
|
475 |
STXInstaller new postInstall
|
|
476 |
"
|
|
477 |
|
|
478 |
"Modified: 18.7.1996 / 22:10:42 / cg"
|
0
|
479 |
! !
|
|
480 |
|
|
481 |
!STXInstaller class methodsFor:'documentation'!
|
|
482 |
|
|
483 |
version
|
|
484 |
^ '$Header$'
|
|
485 |
! !
|