STXInstaller.st
changeset 1 7ebb34d8f3df
parent 0 ce9f4417b660
child 2 936a4407697b
--- a/STXInstaller.st	Thu Jul 18 15:24:24 1996 +0200
+++ b/STXInstaller.st	Thu Jul 18 22:29:56 1996 +0200
@@ -12,6 +12,43 @@
     ^ 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'.
+    dirs add:'/home/stx/bin'.
+    dirs add:'/home2/stx/bin'.
+    ^ dirs
+
+    "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
+
+    "Created: 18.7.1996 / 19:43:21 / cg"
+    "Modified: 18.7.1996 / 19:46:04 / cg"
 ! !
 
 !STXInstaller methodsFor:'installing'!
@@ -22,33 +59,46 @@
     msg := #('ST/X Installation' '' 'copying:' '' 'to:' '') asStringCollection.
 
     fileSpec := #(
-                "/ name            destination   subDir   required
+                "/ name            destination   subDir        required
 
-                ( 'stc/stc'               #bin     nil      false)
-                ( 'rules/stmkmp'          #bin     nil      false)
-                ( 'rules/stmkmf'          #bin     nil      false)
+                ( 'stc/stc'                         #bin     nil  false '755' )
+                ( 'rules/stmkmp'                    #bin     nil  false '755' )
+                ( 'rules/stmkmf'                    #bin     nil  false '755' )
+                ( 'projects/smalltalk/smalltalk'    #bin     nil  true  '755' )
 
-                ( 'librun/librun.a'       #lib     'lib'    false)
-                ( 'libbasic/libbasic.o'   #lib     'lib'    false)
-                ( 'libbasic2/libbasic2.o' #lib     'lib'    false)
-                ( 'libbasic3/libbasic3.o' #lib     'lib'    false)
-                ( 'libcomp/libcomp.o'     #lib     'lib'    false)
-                ( 'libview/libview.o'     #lib     'lib'    false)
-                ( 'libview2/libview2.o'   #lib     'lib'    false)
-                ( 'libwidg/libwidg.o'     #lib     'lib'    false)
-                ( 'libwidg2/libwidg2.o'   #lib     'lib'    false)
-                ( 'libwidg3/libwidg3.o'   #lib     'lib'    false)
-                ( 'libtool/libtool.o'     #lib     'lib'    false)
+                ( 'librun/librun.a'                 #lib     'lib'    false '644' )
+                ( 'libbasic/libbasic.o'             #lib     'lib'    false '644' )
+                ( 'libbasic2/libbasic2.o'           #lib     'lib'    false '644' )
+                ( 'libbasic3/libbasic3.o'           #lib     'lib'    false '644' )
+                ( 'libcomp/libcomp.o'               #lib     'lib'    false '644' )
+                ( 'libview/libview.o'               #lib     'lib'    false '644' )
+                ( 'libview2/libview2.o'             #lib     'lib'    false '644' )
+                ( 'libwidg/libwidg.o'               #lib     'lib'    false '644' )
+                ( 'libwidg2/libwidg2.o'             #lib     'lib'    false '644' )
+                ( 'libwidg3/libwidg3.o'             #lib     'lib'    false '644' )
+                ( 'libsnmp/libsnmp.o'               #lib     'lib'    false '644' )
+                ( 'libtable/libtable.o'             #lib     'lib'    false '644' )
+                ( 'libtool/libtool.o'               #lib     'lib'    false '644' )
+                ( 'libxt/libxt.o'                   #lib     'lib'    false '644' )
+                ( 'librt/librt.o'                   #lib     'lib'    false '644' )
+                ( 'support/VGL/vogl/src/libvogl.a'  #lib     'lib'        false '644' )
+                ( 'support/VGL/vogl/src/*.h'        #lib     'include'    false '644' )
+                ( 'support/DLD/dld-3.2.5/libdld.a'  #lib     'lib'        false '644' )
 
-                ( 'projects/smalltalk/*.rc'    #lib   nil    false)
-                ( 'projects/smalltalk/patches' #lib   nil    false)
+                ( 'projects/smalltalk/*.rc'         #lib   nil    false '644' )
+                ( 'projects/smalltalk/patches'      #lib   nil    true  '644' )
 
-                ( 'projects/smalltalk/bitmaps'        #lib nil    false)
-                ( 'projects/smalltalk/configurations' #lib nil    false)
-                ( 'projects/smalltalk/doc'            #lib nil    false)
-                ( 'projects/smalltalk/include'        #lib nil    false)
-                ( 'projects/smalltalk/resources'      #lib nil    false)
-                ( 'projects/smalltalk/rules'          #lib nil    false)
+                ( 'projects/smalltalk/bitmaps'      #lib nil    true  '644' )
+                ( 'doc'                             #lib nil    false '644' )
+                ( 'projects/smalltalk/include'      #lib nil    true  '644' )
+                ( 'projects/smalltalk/resources'    #lib nil    true  '644' )
+                ( 'projects/smalltalk/source'       #lib nil    true  '644' )
+                ( 'configurations'                  #lib nil    false '644' )
+                ( 'rules'                           #lib nil    false '644' )
+
+                ( 'goodies/*.st'                    #lib 'goodies'    false '644' )
+                ( 'goodies/*.chg'                   #lib 'goodies'    false '644' )
+                ( 'goodies/rdoit/rdoit'             #bin nil          false '755' )
               ).
 
     filesToCopy := OrderedCollection new.
@@ -79,7 +129,7 @@
     nDone := 0.
 
     filesToCopy do:[:entry |
-        |fileName destDir|
+        |fileName destDir cmd p text|
 
         actionPercentageHolder value:(nDone / numFiles * 100) rounded.
 
@@ -91,7 +141,22 @@
         actionTextHolder value:nil.
         actionTextHolder value:msg.
 
-        OperatingSystem executeCommand:('cp -r ../../' , fileName , ' ' , destDir).
+        cmd := 'cp -r ../../' , fileName , ' ' , destDir.
+
+        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 close.
+        ].
+"/        (OperatingSystem executeCommand:('cp -r ../../' , fileName , ' ' , destDir))
+"/        ifFalse:[
+"/            self warn:('error while copying ' , fileName , '\\Please check manually.') withCRs.
+"/        ].        
 
         nDone := nDone + 1
     ].
@@ -99,7 +164,7 @@
     ^ true
 
     "Created: 17.7.1996 / 15:16:20 / cg"
-    "Modified: 17.7.1996 / 15:21:09 / cg"
+    "Modified: 18.7.1996 / 22:20:24 / cg"
 !
 
 createDirectories
@@ -116,6 +181,7 @@
     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.
@@ -157,6 +223,7 @@
             box := WarningBox new.
             box title:errMsg.
             box showAtPointerNotCovering:(WindowGroup activeGroup topViews first).
+            stop ifTrue:[^ false].
         ].
 
         Delay waitForSeconds:0.25.
@@ -165,7 +232,7 @@
     ^ true
 
     "Created: 17.7.1996 / 15:24:19 / cg"
-    "Modified: 17.7.1996 / 15:35:30 / cg"
+    "Modified: 18.7.1996 / 22:18:38 / cg"
 ! !
 
 !STXInstaller methodsFor:'startup'!
@@ -183,6 +250,7 @@
             ^ self
         ].
         self doInstall ifTrue:[
+            self postInstall.
             ^ self
         ].
         (self confirm:'installation failed or aborted - retry ?')
@@ -191,7 +259,7 @@
         ]
     ].
 
-    "Modified: 17.7.1996 / 15:08:30 / cg"
+    "Modified: 18.7.1996 / 21:20:56 / cg"
 !
 
 askForDestination
@@ -233,11 +301,7 @@
     l adjust:#left; backgroundColor:dark; foregroundColor:Color white.
 
     cm := ComboBoxView on:stxBinDirHolder.
-    cm list:(Array 
-                with:'/tmp/stxbin'
-                with:'/usr/local/bin'
-                with:'/usr/bin'
-                with:(Filename homeDirectory constructString:'bin')).
+    cm list:self defaultBinDirs.
     d 
         addLabelledField:cm 
         label:'binaries' 
@@ -249,13 +313,7 @@
     (d componentAt:'binaryBox.label') backgroundColor:dark; foregroundColor:Color white.
 
     cm := ComboBoxView on:stxLibDirHolder.
-    cm list:(Array 
-                with:'/tmp/stxlib'
-                with:'/usr/local/lib/smalltalk'
-                with:'/usr/lib/smalltalk'
-                with:((Filename homeDirectory 
-                            construct:'lib')
-                            constructString:'smalltalk')).
+    cm list:self defaultLibDirs.
     d 
         addLabelledField:cm 
         label:'libraries' 
@@ -275,27 +333,46 @@
     d accepted ifTrue:[
         stxLibDir := LastLibDir := stxLibDirHolder value.
         stxBinDir := LastBinDir := stxBinDirHolder value.
+        d destroy.
         ^ true
     ].
+    d destroy.
     ^ false
 
-    "Modified: 17.7.1996 / 15:08:30 / cg"
+    "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:[
-        ^ DialogBox
-            confirm:('detected existing installation in ' 
-                     , stxLibDir asText allBold
-                     , '\\continue & overwrite ?') withCRs 
-           yesLabel:'overwrite' noLabel:'cancel'
+        whatToDo := Dialog 
+                        choose:('detected existing installation in ' 
+                                 , stxLibDir asText allBold)
+                        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
@@ -329,9 +406,76 @@
 !
 
 open
-    self askAndInstall
+    self askAndInstall.
 
     "Created: 17.7.1996 / 14:37:14 / cg"
+    "Modified: 18.7.1996 / 18:26:20 / cg"
+!
+
+postInstall
+    "some messages at the end ..."
+
+    |shInfo cshInfo msg stxBinDir stxLibDir havePath|
+
+stxBinDir := '/home2/stx/bin'.
+stxLibDir := '/home2/stx/lib'.
+
+    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'!