Object subclass:#STXInstaller
instanceVariableNames:'stxLibDir stxBinDir installDocFiles installSourceFiles
installSTCFiles installGoodyFiles actionPercentageHolder
actionTextHolder commandTraceView resources'
classVariableNames:'LastBinDir LastLibDir'
poolDictionaries:''
category:'eXept-tools'
!
!STXInstaller class methodsFor:'startup'!
open
^ self new open
"Created: 17.7.1996 / 14:36:22 / cg"
"Modified: 18.7.1996 / 21:20:22 / cg"
! !
!STXInstaller methodsFor:'defaults'!
defaultBinDirs
|dirs|
dirs := OrderedCollection new.
dirs add:'/usr/local/bin'.
dirs add:'/usr/bin'.
dirs add:(Filename homeDirectory constructString:'bin').
dirs add:'/tmp/stxbin'.
('/home' asFilename exists and:['/home' asFilename isDirectory]) ifTrue:[
dirs add:'/home/stx/bin'.
].
('/home2' asFilename exists and:['/home2' asFilename isDirectory]) ifTrue:[
dirs add:'/home2/stx/bin'.
].
"/ dirs := dirs select:[:path |
"/ |f|
"/
"/ f := path asFilename.
"/ f exists and:[f isDirectory]].
^ dirs sort
"Created: 18.7.1996 / 19:43:00 / cg"
"Modified: 18.7.1996 / 19:45:08 / cg"
!
defaultLibDirs
|dirs|
dirs := OrderedCollection new.
dirs add:'/usr/local/lib/smalltalk'.
dirs add:'/usr/lib/smalltalk'.
dirs add:((Filename homeDirectory
construct:'lib')
constructString:'smalltalk').
dirs add:'/tmp/stxlib'.
dirs add:'/home/stx/lib'.
dirs add:'/home2/stx/lib'.
"/ dirs := dirs select:[:path |
"/ |f|
"/
"/ f := path asFilename.
"/ f exists and:[f isDirectory]].
^ dirs sort
"Created: 18.7.1996 / 19:43:21 / cg"
"Modified: 18.7.1996 / 19:46:04 / cg"
! !
!STXInstaller methodsFor:'installing'!
copyFiles
|msg fileSpec filesToCopy numFiles nDone|
msg := #('ST/X Installation' '' 'copying:' '' 'to:' '') asStringCollection.
fileSpec := #(
"/ name destination subDir required mode
( 'projects/smalltalk/smalltalk' #bin nil true '755' )
( 'projects/smalltalk/include' #lib nil true '644' )
( 'projects/smalltalk/*.rc' #lib nil true '644' )
( 'projects/smalltalk/patches' #lib nil true '644' )
( 'projects/smalltalk/bitmaps' #lib nil true '644' )
( 'projects/smalltalk/resources' #lib nil true '644' )
( 'projects/smalltalk/lib' #lib nil true '644' )
).
installDocFiles ifTrue:[
fileSpec := fileSpec , #(
( 'doc' #lib nil false '644' )
).
].
installSourceFiles ifTrue:[
fileSpec := fileSpec , #(
( 'projects/smalltalk/source' #lib nil false '644' )
).
].
installSTCFiles ifTrue:[
fileSpec := fileSpec , #(
( 'stc/stc' #bin nil false '755' )
( 'rules/stmkmp' #bin nil false '755' )
( 'rules/stmkmf' #bin nil false '755' )
( 'include' #lib nil false '644' )
( 'configurations' #lib nil false '644' )
( 'rules' #lib nil false '644' )
( 'support/VGL/vogl/src/libvogl.*' #lib 'lib' false '644' )
( 'support/VGL/vogl/src/*.h' #lib 'include' false '644' )
( 'support/DLD/dld-3.2.5/libdld.*' #lib 'lib' false '644' )
( 'goodies/persistency/db-1.6/PORT/libdb.*' #lib 'lib' false '644' )
( 'librun/librun.*' #lib 'lib' false '644' )
( 'libbasic/libbasic.*' #lib 'lib' false '644' )
( 'libbasic2/libbasic2.*' #lib 'lib' false '644' )
( 'libbasic3/libbasic3.*' #lib 'lib' false '644' )
( 'libcomp/libcomp.*' #lib 'lib' false '644' )
( 'libview/libview.*' #lib 'lib' false '644' )
( 'libview2/libview2.*' #lib 'lib' false '644' )
( 'libwidg/libwidg.*' #lib 'lib' false '644' )
( 'libwidg2/libwidg2.*' #lib 'lib' false '644' )
( 'libwidg3/libwidg3.*' #lib 'lib' false '644' )
( 'libsnmp/libsnmp.*' #lib 'lib' false '644' )
( 'contrib/libPVM/libPVM.*' #lib 'lib' false '644' )
( 'goodies/persistency/libdbase.*' #lib 'lib' false '644' )
( 'libtable/libtable.*' #lib 'lib' false '644' )
( 'libtool/libtool.*' #lib 'lib' false '644' )
( 'libxt/libxt.*' #lib 'lib' false '644' )
( 'librt/librt.*' #lib 'lib' false '644' )
).
].
installGoodyFiles ifTrue:[
fileSpec := fileSpec , #(
( 'goodies/*.st' #lib 'goodies' false '644' )
( 'goodies/*.chg' #lib 'goodies' false '644' )
( 'goodies/rdoit/rdoit' #bin nil false '755' )
).
].
filesToCopy := OrderedCollection new.
fileSpec do:[:entry |
|fileNames dest subDir required destDir|
fileNames := entry at:1.
dest := entry at:2.
subDir := entry at:3.
required := entry at:4.
dest == #bin ifTrue:[
destDir := stxBinDir
] ifFalse:[
destDir := stxLibDir
].
destDir := destDir asFilename.
subDir notNil ifTrue:[
destDir := destDir construct:subDir
].
filesToCopy add:(fileNames -> destDir pathName)
].
numFiles := filesToCopy size.
nDone := 0.
filesToCopy do:[:entry |
|fileName destDir cmd p text line|
fileName := entry key.
destDir := entry value.
((fileName includes:$*)
or:[('../../' , fileName) asFilename exists])ifTrue:[
actionPercentageHolder value:(nDone / numFiles * 100) rounded.
msg at:4 put:' ' , (fileName asText allBold).
msg at:6 put:' ' , (destDir asText allBold).
actionTextHolder value:nil.
actionTextHolder value:msg.
cmd := 'cp -r ../../' , fileName , ' ' , destDir.
commandTraceView showCR:cmd , ' ...'.
cmd := 'sh -c "echo ; ' , cmd , ' 2>&1"' .
p := PipeStream readingFrom:cmd.
p isNil ifTrue:[
self warn:('command error. Could not execute:\\' , cmd) withCRs.
] ifFalse:[
"/ text := OrderedCollection new.
[p atEnd] whileFalse:[
p readWaitWithTimeout:0.1.
line := p nextLine.
(line notNil and:[line notEmpty]) ifTrue:[
commandTraceView showCR:((' ' , line) asText emphasizeAllWith:(#color->Color red)).
"/ text add:line
]
].
p close.
].
"/ (OperatingSystem executeCommand:('cp -r ../../' , fileName , ' ' , destDir))
"/ ifFalse:[
"/ self warn:('error while copying ' , fileName , '\\Please check manually.') withCRs.
"/ ].
].
nDone := nDone + 1
].
^ true
"Created: 17.7.1996 / 15:16:20 / cg"
"Modified: 18.7.1996 / 22:20:24 / cg"
!
createDirectories
|msg dirsToMake numDirs nDone|
msg := #('ST/X Installation' '' 'creating directory:' '' '' '') asStringCollection.
dirsToMake := OrderedCollection new.
dirsToMake add:stxBinDir.
dirsToMake add:stxLibDir.
dirsToMake add:(stxLibDir asFilename constructString:'lib').
dirsToMake add:(stxLibDir asFilename constructString:'doc').
dirsToMake add:(stxLibDir asFilename constructString:'include').
dirsToMake add:(stxLibDir asFilename constructString:'resources').
dirsToMake add:(stxLibDir asFilename constructString:'binary').
dirsToMake add:(stxLibDir asFilename constructString:'bitmaps').
dirsToMake add:(stxLibDir asFilename constructString:'goodies').
numDirs := dirsToMake size.
nDone := 0.
dirsToMake do:[:dirName |
|d errMsg stop box|
actionPercentageHolder value:(nDone / numDirs * 100) rounded.
msg at:4 put:' ' , (dirName asText allBold).
actionTextHolder value:nil.
actionTextHolder value:msg.
d := dirName asFilename.
commandTraceView showCR:'creating ' , d pathName , ' ...'.
d exists ifFalse:[
OperatingSystem recursiveCreateDirectory:d pathName
].
d exists ifFalse:[
errMsg := 'failed to create directory: ' , dirName.
stop := true
] ifTrue:[
d isDirectory ifFalse:[
errMsg := 'not a directory: ' , dirName.
stop := true
] ifTrue:[
(d isReadable
and:[d isWritable]) ifFalse:[
errMsg := 'no R/W access to directory: ' , dirName.
stop := false
] ifTrue:[
errMsg := nil
]
]
].
errMsg notNil ifTrue:[
box := WarningBox new.
box title:errMsg.
box showAtPointerNotCovering:(WindowGroup activeGroup topViews first).
stop ifTrue:[^ false].
].
Delay waitForSeconds:0.25.
nDone := nDone + 1.
].
^ true
"Created: 17.7.1996 / 15:24:19 / cg"
"Modified: 18.7.1996 / 22:18:38 / cg"
! !
!STXInstaller methodsFor:'startup'!
askAndInstall
"/ check, if we are in the projects/smalltalk directory
(Filename currentDirectory pathName endsWith:'projects/smalltalk') ifFalse:[
self warn:'must be in the projects/smalltalk directory'.
^ self
].
[self askForDestination] whileTrue:[
self checkForExistingInstallationAndConfirm ifFalse:[
^ self
].
self doInstall ifTrue:[
self postInstall.
^ self
].
(self confirm:'installation failed or aborted - retry ?')
ifFalse:[
^ self
]
].
"Modified: 18.7.1996 / 21:20:56 / cg"
!
askForDestination
"open a dialog to enter destination directories"
|d cm l green dark img
stxLibDirHolder stxBinDirHolder
installDocHolder installSourceHolder installSTCHolder installGoodiesHolder
|
LastLibDir isNil ifTrue:[
LastLibDir := '/usr/local/lib/smalltalk'
].
LastBinDir isNil ifTrue:[
LastBinDir := '/usr/local/bin'
].
stxLibDirHolder := LastLibDir asValue.
stxBinDirHolder := LastBinDir asValue.
installDocHolder := true asValue.
installSourceHolder := true asValue.
installSTCHolder := true asValue.
installGoodiesHolder := true asValue.
Screen current hasColors ifTrue:[
green := (Color red:0 green:80 blue:20) "darkened".
dark := Color grey:10.
] ifFalse:[
green := Color white.
dark := Color black.
].
d := DialogBox new.
d label:'ST/X CD Installation'.
img := Image fromFile:'SmalltalkX.xbm'.
l := d addTextLabel:img.
l adjust:#left; foregroundColor:green backgroundColor:dark.
l := d addTextLabel:'Smalltalk/X CD installation.'.
l adjust:#left; backgroundColor:dark; foregroundColor:Color white.
d addVerticalSpace.
d addVerticalSpace.
d addHorizontalLine.
l := d addTextLabel:'Destination directories:'.
l adjust:#left; backgroundColor:dark; foregroundColor:Color white.
cm := ComboBoxView on:stxBinDirHolder.
cm list:self defaultBinDirs.
d
addLabelledField:cm
label:'binaries'
adjust:#left
tabable:true
from:0.0 to:1.0 separateAtX:0.25
nameAs:'binaryBox'.
(d componentAt:'binaryBox.label') backgroundColor:dark; foregroundColor:Color white.
cm := ComboBoxView on:stxLibDirHolder.
cm list:self defaultLibDirs.
d
addLabelledField:cm
label:'libraries'
adjust:#left
tabable:true
from:0.0 to:1.0 separateAtX:0.25
nameAs:'libraryBox'.
(d componentAt:'libraryBox.label') backgroundColor:dark; foregroundColor:Color white.
d addVerticalSpace.
d addHorizontalLine.
d addVerticalSpace.
(d addTextLabel:('required:'))
adjust:#left; foregroundColor:Color white backgroundColor:dark.
d leftIndent:35.
(d addTextLabel:('binaries (approx. 10 Mb)'))
adjust:#left; foregroundColor:Color white backgroundColor:dark.
(d addTextLabel:('libraries (approx. 10 Mb)'))
adjust:#left; foregroundColor:Color white backgroundColor:dark.
d leftIndent:0.
d addVerticalSpace.
d addHorizontalLine.
d addVerticalSpace.
(d addTextLabel:('optional:'))
adjust:#left; foregroundColor:Color white backgroundColor:dark.
(d addCheckBox:('doc files (+8 Mb)') on:installDocHolder)
labelView foregroundColor:Color white backgroundColor:dark.
(d addCheckBox:('stc & support files (+2 Mb)') on:installSTCHolder)
labelView foregroundColor:Color white backgroundColor:dark.
d addVerticalSpace.
d addHorizontalLine.
d addVerticalSpace.
(d addTextLabel:('optional (but highly recommended):'))
adjust:#left; foregroundColor:Color white backgroundColor:dark.
(d addCheckBox:('smalltalk source files (+12 Mb)') on:installSourceHolder)
labelView foregroundColor:Color white backgroundColor:dark.
(d addCheckBox:('goodies (+0.5 Mb)') on:installGoodiesHolder)
labelView foregroundColor:Color white backgroundColor:dark.
d addVerticalSpace.
d addHorizontalLine.
d addAbortButton; addOkButtonLabelled:'install'.
d extent:400@300.
d allViewBackground:dark.
d openAtCenter.
d accepted ifTrue:[
stxLibDir := LastLibDir := stxLibDirHolder value.
stxBinDir := LastBinDir := stxBinDirHolder value.
installDocFiles := installDocHolder value.
installSourceFiles := installSourceHolder value.
installSTCFiles := installSTCHolder value.
installGoodyFiles := installGoodiesHolder value.
d destroy.
^ true
].
d destroy.
^ false
"Modified: 18.7.1996 / 19:43:38 / cg"
!
checkForExistingInstallationAndConfirm
"look if there is another installation and confirm
reinstalling; return true if ok, false if not"
|whatToDo|
stxLibDir asFilename exists ifTrue:[
whatToDo := Dialog
choose:('detected existing installation in '
, stxLibDir asText allBold)
label:'Attention'
labels:#('remove first' 'overwrite' 'cancel')
values:#(remove over nil)
default:nil.
whatToDo isNil ifTrue:[^false].
whatToDo == #remove ifTrue:[
(OperatingSystem recursiveRemoveDirectory:stxLibDir)
ifFalse:[
self warn:'mhmh - could not remove old installation.'
].
].
^ true
"/ ^ DialogBox
"/ confirm:('detected existing installation in '
"/ , stxLibDir asText allBold
"/ , '\\continue & overwrite ?') withCRs
"/ yesLabel:'overwrite' noLabel:'cancel'
].
^ true
"Modified: 18.7.1996 / 20:01:36 / cg"
!
doInstall
"install ST/X; return true if ok, false if not"
|progressView ok textView|
textView := HVScrollableView for:TextCollector.
textView preferredExtent:(100 @ 250).
commandTraceView := textView scrolledView.
progressView := ProgressIndicator
inBoxWithLabel:'ST/X Installation' icon:(Depth8Image fromImage:NewLauncher aboutIcon)
text:#('ST/X Installation' '' '' '' '' '' '' '') asStringCollection
abortable:true
view:textView
closeWhenDone:false.
progressView topView extent:(500 min:Display width) @ 300.
ok := false.
progressView showProgressOf:
[:progressValue :currentAction| |msg|
Processor activeProcess withPriority:7 do:[
actionPercentageHolder := progressValue.
actionTextHolder := currentAction.
(self createDirectories) ifTrue:[
ok := self copyFiles
].
progressValue value:100.
progressView topView abortButton label:'continue'.
progressView topView abortButton action:[progressView topView hide].
msg := #('ST/X Installation finished.' '' 'press continue ...' '' '' '') asStringCollection.
actionTextHolder value:nil.
actionTextHolder value:msg.
]
].
^ ok
"Created: 17.7.1996 / 15:11:27 / cg"
"Modified: 17.7.1996 / 15:24:27 / cg"
!
open
self askAndInstall.
"
STXInstaller open
"
!
postInstall
"some messages at the end ..."
|shInfo cshInfo msg havePath|
msg := 'ST/X Installation complete.\\' withCRs.
shInfo := ''.
cshInfo := ''.
havePath := true.
(((OperatingSystem getEnvironment:'PATH')
asCollectionOfSubstringsSeparatedBy:$:)
includes:stxBinDir) ifFalse:[
havePath := false.
shInfo := 'PATH=$PATH:' , stxBinDir , ' ; export PATH\'.
cshInfo := 'set path=($path ' , stxBinDir , ')\'.
msg := msg , stxBinDir asText allBold , ' is not in your PATH.
You should change your ".login" and/or ".profile" files to include it.
'
].
(stxLibDir ~= '/usr/local/lib/smalltalk'
and:[stxLibDir ~= '/usr/lib/smalltalk']) ifTrue:[
msg := msg ,
'The library directory is not a standard ST/X library directory
("/usr/local/lib/smalltalk" or "/usr/lib/smalltalk").
You have to define the ' , 'STX_LIBDIR' asText allBold ,' environment variable
as ' , stxLibDir asText allBold , ' before ST/X can be started.
'.
havePath ifFalse:[
msg := msg , 'The above mentioned files are also a good place to do this.
'.
] ifTrue:[
msg := msg , 'The ".login" and/or ".profile" files are a good place to do this.
'.
].
shInfo := shInfo , 'STX_LIBDIR=' , stxLibDir , ' ; export STX_LIBDIR\'.
cshInfo := cshInfo , 'setenv STX_LIBDIR ' , stxLibDir , '\'.
].
shInfo notEmpty ifTrue:[
'Please add the following to your ".profile" file:' errorPrintCR.
'' errorPrintCR.
shInfo withCRs errorPrintCR.
'' errorPrintCR.
'or (if you use csh/tcsh), add to your ".login" file:' errorPrintCR.
'' errorPrintCR.
cshInfo withCRs errorPrintCR.
'' errorPrintCR.
].
self information:msg.
"
STXInstaller new postInstall
"
"Modified: 18.7.1996 / 22:10:42 / cg"
! !
!STXInstaller class methodsFor:'documentation'!
version
^ '$Header$'
! !