STXInstaller.st
changeset 4 8b68fdf7c870
parent 3 7b048cdcc856
child 5 16cff74f42b0
--- a/STXInstaller.st	Tue Sep 03 13:50:53 1996 +0200
+++ b/STXInstaller.st	Tue Sep 03 15:16:32 1996 +0200
@@ -1,5 +1,6 @@
 Object subclass:#STXInstaller
-	instanceVariableNames:'stxLibDir stxBinDir actionPercentageHolder actionTextHolder'
+	instanceVariableNames:'stxLibDir stxBinDir actionPercentageHolder actionTextHolder
+		commandTraceView'
 	classVariableNames:'LastBinDir LastLibDir'
 	poolDictionaries:''
 	category:'eXept-tools'
@@ -75,7 +76,7 @@
     msg := #('ST/X Installation' '' 'copying:' '' 'to:' '') asStringCollection.
 
     fileSpec := #(
-                "/ name            destination   subDir        required
+                "/ name                        destination   subDir  required mode      
 
                 ( 'stc/stc'                         #bin     nil  false '755' )
                 ( 'rules/stmkmp'                    #bin     nil  false '755' )
@@ -145,34 +146,43 @@
     nDone := 0.
 
     filesToCopy do:[:entry |
-        |fileName destDir cmd p text|
-
-        actionPercentageHolder value:(nDone / numFiles * 100) rounded.
+        |fileName destDir cmd p text line|
 
         fileName := entry key.
         destDir := entry value.
 
-        msg at:4 put:'    ' , (fileName asText allBold).
-        msg at:6 put:'    ' , (destDir asText allBold).
-        actionTextHolder value:nil.
-        actionTextHolder value:msg.
+        ('../../' , fileName) asFilename exists ifTrue:[
+            actionPercentageHolder value:(nDone / numFiles * 100) rounded.
 
-        cmd := 'cp -r ../../' , fileName , ' ' , destDir.
+            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:[
-                text add:p nextLine
+            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.
             ].
-            p close.
+    "/        (OperatingSystem executeCommand:('cp -r ../../' , fileName , ' ' , destDir))
+    "/        ifFalse:[
+    "/            self warn:('error while copying ' , fileName , '\\Please check manually.') withCRs.
+    "/        ].        
         ].
-"/        (OperatingSystem executeCommand:('cp -r ../../' , fileName , ' ' , destDir))
-"/        ifFalse:[
-"/            self warn:('error while copying ' , fileName , '\\Please check manually.') withCRs.
-"/        ].        
 
         nDone := nDone + 1
     ].
@@ -207,12 +217,14 @@
 
         actionPercentageHolder value:(nDone / numDirs * 100) rounded.
 
-        msg at:4 put:'    ' , dirName.
+        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
         ].
@@ -400,25 +412,38 @@
 doInstall
     "install ST/X; return true if ok, false if not"
 
-    |progressView ok|
+    |progressView ok textView|
+
+    textView := HVScrollableView for:TextCollector.
+    textView preferredExtent:(100 @ 250).
+    commandTraceView := textView scrolledView.
 
     progressView := ProgressIndicator
-                        inBoxWithLabel:'ST/X Installation'
+                        inBoxWithLabel:'ST/X Installation' icon:(Depth8Image fromImage:NewLauncher aboutIcon)
                         text:#('ST/X Installation' '' '' '' '' '' '' '') asStringCollection
-                        abortable:true.
-    progressView topView extent:400@300.
+                        abortable:true
+                        view:textView
+                        closeWhenDone:false.
+    progressView topView extent:(500 min:Display width) @ 300.
 
     ok := false.
 
     progressView showProgressOf:
-            [:progressValue :currentAction |
+            [:progressValue :currentAction| |msg|
+
+              Processor activeProcess withPriority:7 do:[
+                  actionPercentageHolder := progressValue.
+                  actionTextHolder := currentAction.
 
-              actionPercentageHolder := progressValue.
-              actionTextHolder := currentAction.
-
-              (self createDirectories) ifTrue:[
-                  ok := self copyFiles
-              ]
+                  (self createDirectories) ifTrue:[
+                      ok := self copyFiles
+                  ].
+                  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
@@ -437,10 +462,7 @@
 postInstall
     "some messages at the end ..."
 
-    |shInfo cshInfo msg stxBinDir stxLibDir havePath|
-
-stxBinDir := '/home2/stx/bin'.
-stxLibDir := '/home2/stx/lib'.
+    |shInfo cshInfo msg havePath|
 
     msg := 'ST/X Installation complete.\\' withCRs.
     shInfo := ''.