STXInstaller.st
changeset 4 8b68fdf7c870
parent 3 7b048cdcc856
child 5 16cff74f42b0
equal deleted inserted replaced
3:7b048cdcc856 4:8b68fdf7c870
     1 Object subclass:#STXInstaller
     1 Object subclass:#STXInstaller
     2 	instanceVariableNames:'stxLibDir stxBinDir actionPercentageHolder actionTextHolder'
     2 	instanceVariableNames:'stxLibDir stxBinDir actionPercentageHolder actionTextHolder
       
     3 		commandTraceView'
     3 	classVariableNames:'LastBinDir LastLibDir'
     4 	classVariableNames:'LastBinDir LastLibDir'
     4 	poolDictionaries:''
     5 	poolDictionaries:''
     5 	category:'eXept-tools'
     6 	category:'eXept-tools'
     6 !
     7 !
     7 
     8 
    73     |msg fileSpec filesToCopy numFiles nDone|
    74     |msg fileSpec filesToCopy numFiles nDone|
    74 
    75 
    75     msg := #('ST/X Installation' '' 'copying:' '' 'to:' '') asStringCollection.
    76     msg := #('ST/X Installation' '' 'copying:' '' 'to:' '') asStringCollection.
    76 
    77 
    77     fileSpec := #(
    78     fileSpec := #(
    78                 "/ name            destination   subDir        required
    79                 "/ name                        destination   subDir  required mode      
    79 
    80 
    80                 ( 'stc/stc'                         #bin     nil  false '755' )
    81                 ( 'stc/stc'                         #bin     nil  false '755' )
    81                 ( 'rules/stmkmp'                    #bin     nil  false '755' )
    82                 ( 'rules/stmkmp'                    #bin     nil  false '755' )
    82                 ( 'rules/stmkmf'                    #bin     nil  false '755' )
    83                 ( 'rules/stmkmf'                    #bin     nil  false '755' )
    83                 ( 'projects/smalltalk/smalltalk'    #bin     nil  true  '755' )
    84                 ( 'projects/smalltalk/smalltalk'    #bin     nil  true  '755' )
   143 
   144 
   144     numFiles := filesToCopy size.
   145     numFiles := filesToCopy size.
   145     nDone := 0.
   146     nDone := 0.
   146 
   147 
   147     filesToCopy do:[:entry |
   148     filesToCopy do:[:entry |
   148         |fileName destDir cmd p text|
   149         |fileName destDir cmd p text line|
   149 
       
   150         actionPercentageHolder value:(nDone / numFiles * 100) rounded.
       
   151 
   150 
   152         fileName := entry key.
   151         fileName := entry key.
   153         destDir := entry value.
   152         destDir := entry value.
   154 
   153 
   155         msg at:4 put:'    ' , (fileName asText allBold).
   154         ('../../' , fileName) asFilename exists ifTrue:[
   156         msg at:6 put:'    ' , (destDir asText allBold).
   155             actionPercentageHolder value:(nDone / numFiles * 100) rounded.
   157         actionTextHolder value:nil.
   156 
   158         actionTextHolder value:msg.
   157             msg at:4 put:'    ' , (fileName asText allBold).
   159 
   158             msg at:6 put:'    ' , (destDir asText allBold).
   160         cmd := 'cp -r ../../' , fileName , ' ' , destDir.
   159             actionTextHolder value:nil.
   161 
   160             actionTextHolder value:msg.
   162         p := PipeStream readingFrom:cmd.
   161 
   163         p isNil ifTrue:[
   162             cmd := 'cp -r ../../' , fileName , ' ' , destDir.
   164             self warn:('command error. Could not execute:\\' , cmd) withCRs.
   163             commandTraceView showCR:cmd , ' ...'.
   165         ] ifFalse:[
   164             cmd := 'sh -c "echo ; ' , cmd , ' 2>&1"' .
   166             text := OrderedCollection new.
   165 
   167             [p atEnd] whileFalse:[
   166             p := PipeStream readingFrom:cmd.
   168                 text add:p nextLine
   167             p isNil ifTrue:[
       
   168                 self warn:('command error. Could not execute:\\' , cmd) withCRs.
       
   169             ] ifFalse:[
       
   170     "/            text := OrderedCollection new.
       
   171                 [p atEnd] whileFalse:[
       
   172                     p readWaitWithTimeout:0.1.
       
   173                     line := p nextLine.
       
   174                     (line notNil and:[line notEmpty]) ifTrue:[
       
   175                         commandTraceView showCR:(('  ' , line) asText emphasizeAllWith:(#color->Color red)).
       
   176     "/                text add:line
       
   177                     ]
       
   178                 ].
       
   179                 p close.
   169             ].
   180             ].
   170             p close.
   181     "/        (OperatingSystem executeCommand:('cp -r ../../' , fileName , ' ' , destDir))
   171         ].
   182     "/        ifFalse:[
   172 "/        (OperatingSystem executeCommand:('cp -r ../../' , fileName , ' ' , destDir))
   183     "/            self warn:('error while copying ' , fileName , '\\Please check manually.') withCRs.
   173 "/        ifFalse:[
   184     "/        ].        
   174 "/            self warn:('error while copying ' , fileName , '\\Please check manually.') withCRs.
   185         ].
   175 "/        ].        
       
   176 
   186 
   177         nDone := nDone + 1
   187         nDone := nDone + 1
   178     ].
   188     ].
   179 
   189 
   180     ^ true
   190     ^ true
   205     dirsToMake do:[:dirName |
   215     dirsToMake do:[:dirName |
   206         |d errMsg stop box|
   216         |d errMsg stop box|
   207 
   217 
   208         actionPercentageHolder value:(nDone / numDirs * 100) rounded.
   218         actionPercentageHolder value:(nDone / numDirs * 100) rounded.
   209 
   219 
   210         msg at:4 put:'    ' , dirName.
   220         msg at:4 put:'    ' , (dirName asText allBold).
   211         actionTextHolder value:nil.
   221         actionTextHolder value:nil.
   212         actionTextHolder value:msg.
   222         actionTextHolder value:msg.
   213 
   223 
   214         d := dirName asFilename.
   224         d := dirName asFilename.
       
   225 
       
   226         commandTraceView showCR:'creating ' , d pathName , ' ...'.
   215 
   227 
   216         d exists ifFalse:[
   228         d exists ifFalse:[
   217             OperatingSystem recursiveCreateDirectory:d pathName
   229             OperatingSystem recursiveCreateDirectory:d pathName
   218         ].
   230         ].
   219 
   231 
   398 !
   410 !
   399 
   411 
   400 doInstall
   412 doInstall
   401     "install ST/X; return true if ok, false if not"
   413     "install ST/X; return true if ok, false if not"
   402 
   414 
   403     |progressView ok|
   415     |progressView ok textView|
       
   416 
       
   417     textView := HVScrollableView for:TextCollector.
       
   418     textView preferredExtent:(100 @ 250).
       
   419     commandTraceView := textView scrolledView.
   404 
   420 
   405     progressView := ProgressIndicator
   421     progressView := ProgressIndicator
   406                         inBoxWithLabel:'ST/X Installation'
   422                         inBoxWithLabel:'ST/X Installation' icon:(Depth8Image fromImage:NewLauncher aboutIcon)
   407                         text:#('ST/X Installation' '' '' '' '' '' '' '') asStringCollection
   423                         text:#('ST/X Installation' '' '' '' '' '' '' '') asStringCollection
   408                         abortable:true.
   424                         abortable:true
   409     progressView topView extent:400@300.
   425                         view:textView
       
   426                         closeWhenDone:false.
       
   427     progressView topView extent:(500 min:Display width) @ 300.
   410 
   428 
   411     ok := false.
   429     ok := false.
   412 
   430 
   413     progressView showProgressOf:
   431     progressView showProgressOf:
   414             [:progressValue :currentAction |
   432             [:progressValue :currentAction| |msg|
   415 
   433 
   416               actionPercentageHolder := progressValue.
   434               Processor activeProcess withPriority:7 do:[
   417               actionTextHolder := currentAction.
   435                   actionPercentageHolder := progressValue.
   418 
   436                   actionTextHolder := currentAction.
   419               (self createDirectories) ifTrue:[
   437 
   420                   ok := self copyFiles
   438                   (self createDirectories) ifTrue:[
   421               ]
   439                       ok := self copyFiles
       
   440                   ].
       
   441                   progressView topView abortButton label:'continue'.
       
   442                   progressView topView abortButton action:[progressView topView hide].
       
   443                   msg := #('ST/X Installation finished.' '' 'press continue ...' '' '' '') asStringCollection.
       
   444                   actionTextHolder value:nil.
       
   445                   actionTextHolder value:msg.
       
   446               ] 
   422             ].
   447             ].
   423 
   448 
   424     ^ ok
   449     ^ ok
   425 
   450 
   426     "Created: 17.7.1996 / 15:11:27 / cg"
   451     "Created: 17.7.1996 / 15:11:27 / cg"
   435 !
   460 !
   436 
   461 
   437 postInstall
   462 postInstall
   438     "some messages at the end ..."
   463     "some messages at the end ..."
   439 
   464 
   440     |shInfo cshInfo msg stxBinDir stxLibDir havePath|
   465     |shInfo cshInfo msg havePath|
   441 
       
   442 stxBinDir := '/home2/stx/bin'.
       
   443 stxLibDir := '/home2/stx/lib'.
       
   444 
   466 
   445     msg := 'ST/X Installation complete.\\' withCRs.
   467     msg := 'ST/X Installation complete.\\' withCRs.
   446     shInfo := ''.
   468     shInfo := ''.
   447     cshInfo := ''.
   469     cshInfo := ''.
   448 
   470