STXInstaller.st
changeset 1 7ebb34d8f3df
parent 0 ce9f4417b660
child 2 936a4407697b
equal deleted inserted replaced
0:ce9f4417b660 1:7ebb34d8f3df
    10 
    10 
    11 open
    11 open
    12     ^ self new open
    12     ^ self new open
    13 
    13 
    14     "Created: 17.7.1996 / 14:36:22 / cg"
    14     "Created: 17.7.1996 / 14:36:22 / cg"
       
    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"
    15 ! !
    52 ! !
    16 
    53 
    17 !STXInstaller methodsFor:'installing'!
    54 !STXInstaller methodsFor:'installing'!
    18 
    55 
    19 copyFiles
    56 copyFiles
    20     |msg fileSpec filesToCopy numFiles nDone|
    57     |msg fileSpec filesToCopy numFiles nDone|
    21 
    58 
    22     msg := #('ST/X Installation' '' 'copying:' '' 'to:' '') asStringCollection.
    59     msg := #('ST/X Installation' '' 'copying:' '' 'to:' '') asStringCollection.
    23 
    60 
    24     fileSpec := #(
    61     fileSpec := #(
    25                 "/ name            destination   subDir   required
    62                 "/ name            destination   subDir        required
    26 
    63 
    27                 ( 'stc/stc'               #bin     nil      false)
    64                 ( 'stc/stc'                         #bin     nil  false '755' )
    28                 ( 'rules/stmkmp'          #bin     nil      false)
    65                 ( 'rules/stmkmp'                    #bin     nil  false '755' )
    29                 ( 'rules/stmkmf'          #bin     nil      false)
    66                 ( 'rules/stmkmf'                    #bin     nil  false '755' )
    30 
    67                 ( 'projects/smalltalk/smalltalk'    #bin     nil  true  '755' )
    31                 ( 'librun/librun.a'       #lib     'lib'    false)
    68 
    32                 ( 'libbasic/libbasic.o'   #lib     'lib'    false)
    69                 ( 'librun/librun.a'                 #lib     'lib'    false '644' )
    33                 ( 'libbasic2/libbasic2.o' #lib     'lib'    false)
    70                 ( 'libbasic/libbasic.o'             #lib     'lib'    false '644' )
    34                 ( 'libbasic3/libbasic3.o' #lib     'lib'    false)
    71                 ( 'libbasic2/libbasic2.o'           #lib     'lib'    false '644' )
    35                 ( 'libcomp/libcomp.o'     #lib     'lib'    false)
    72                 ( 'libbasic3/libbasic3.o'           #lib     'lib'    false '644' )
    36                 ( 'libview/libview.o'     #lib     'lib'    false)
    73                 ( 'libcomp/libcomp.o'               #lib     'lib'    false '644' )
    37                 ( 'libview2/libview2.o'   #lib     'lib'    false)
    74                 ( 'libview/libview.o'               #lib     'lib'    false '644' )
    38                 ( 'libwidg/libwidg.o'     #lib     'lib'    false)
    75                 ( 'libview2/libview2.o'             #lib     'lib'    false '644' )
    39                 ( 'libwidg2/libwidg2.o'   #lib     'lib'    false)
    76                 ( 'libwidg/libwidg.o'               #lib     'lib'    false '644' )
    40                 ( 'libwidg3/libwidg3.o'   #lib     'lib'    false)
    77                 ( 'libwidg2/libwidg2.o'             #lib     'lib'    false '644' )
    41                 ( 'libtool/libtool.o'     #lib     'lib'    false)
    78                 ( 'libwidg3/libwidg3.o'             #lib     'lib'    false '644' )
    42 
    79                 ( 'libsnmp/libsnmp.o'               #lib     'lib'    false '644' )
    43                 ( 'projects/smalltalk/*.rc'    #lib   nil    false)
    80                 ( 'libtable/libtable.o'             #lib     'lib'    false '644' )
    44                 ( 'projects/smalltalk/patches' #lib   nil    false)
    81                 ( 'libtool/libtool.o'               #lib     'lib'    false '644' )
    45 
    82                 ( 'libxt/libxt.o'                   #lib     'lib'    false '644' )
    46                 ( 'projects/smalltalk/bitmaps'        #lib nil    false)
    83                 ( 'librt/librt.o'                   #lib     'lib'    false '644' )
    47                 ( 'projects/smalltalk/configurations' #lib nil    false)
    84                 ( 'support/VGL/vogl/src/libvogl.a'  #lib     'lib'        false '644' )
    48                 ( 'projects/smalltalk/doc'            #lib nil    false)
    85                 ( 'support/VGL/vogl/src/*.h'        #lib     'include'    false '644' )
    49                 ( 'projects/smalltalk/include'        #lib nil    false)
    86                 ( 'support/DLD/dld-3.2.5/libdld.a'  #lib     'lib'        false '644' )
    50                 ( 'projects/smalltalk/resources'      #lib nil    false)
    87 
    51                 ( 'projects/smalltalk/rules'          #lib nil    false)
    88                 ( 'projects/smalltalk/*.rc'         #lib   nil    false '644' )
       
    89                 ( 'projects/smalltalk/patches'      #lib   nil    true  '644' )
       
    90 
       
    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' )
    52               ).
   102               ).
    53 
   103 
    54     filesToCopy := OrderedCollection new.
   104     filesToCopy := OrderedCollection new.
    55 
   105 
    56     fileSpec do:[:entry |
   106     fileSpec do:[:entry |
    77 
   127 
    78     numFiles := filesToCopy size.
   128     numFiles := filesToCopy size.
    79     nDone := 0.
   129     nDone := 0.
    80 
   130 
    81     filesToCopy do:[:entry |
   131     filesToCopy do:[:entry |
    82         |fileName destDir|
   132         |fileName destDir cmd p text|
    83 
   133 
    84         actionPercentageHolder value:(nDone / numFiles * 100) rounded.
   134         actionPercentageHolder value:(nDone / numFiles * 100) rounded.
    85 
   135 
    86         fileName := entry key.
   136         fileName := entry key.
    87         destDir := entry value.
   137         destDir := entry value.
    89         msg at:4 put:'    ' , (fileName asText allBold).
   139         msg at:4 put:'    ' , (fileName asText allBold).
    90         msg at:6 put:'    ' , (destDir asText allBold).
   140         msg at:6 put:'    ' , (destDir asText allBold).
    91         actionTextHolder value:nil.
   141         actionTextHolder value:nil.
    92         actionTextHolder value:msg.
   142         actionTextHolder value:msg.
    93 
   143 
    94         OperatingSystem executeCommand:('cp -r ../../' , fileName , ' ' , destDir).
   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 "/        ].        
    95 
   160 
    96         nDone := nDone + 1
   161         nDone := nDone + 1
    97     ].
   162     ].
    98 
   163 
    99     ^ true
   164     ^ true
   100 
   165 
   101     "Created: 17.7.1996 / 15:16:20 / cg"
   166     "Created: 17.7.1996 / 15:16:20 / cg"
   102     "Modified: 17.7.1996 / 15:21:09 / cg"
   167     "Modified: 18.7.1996 / 22:20:24 / cg"
   103 !
   168 !
   104 
   169 
   105 createDirectories
   170 createDirectories
   106     |msg dirsToMake numDirs nDone|
   171     |msg dirsToMake numDirs nDone|
   107 
   172 
   114     dirsToMake add:(stxLibDir asFilename constructString:'doc').
   179     dirsToMake add:(stxLibDir asFilename constructString:'doc').
   115     dirsToMake add:(stxLibDir asFilename constructString:'include').
   180     dirsToMake add:(stxLibDir asFilename constructString:'include').
   116     dirsToMake add:(stxLibDir asFilename constructString:'resources').
   181     dirsToMake add:(stxLibDir asFilename constructString:'resources').
   117     dirsToMake add:(stxLibDir asFilename constructString:'binary').
   182     dirsToMake add:(stxLibDir asFilename constructString:'binary').
   118     dirsToMake add:(stxLibDir asFilename constructString:'bitmaps').
   183     dirsToMake add:(stxLibDir asFilename constructString:'bitmaps').
       
   184     dirsToMake add:(stxLibDir asFilename constructString:'goodies').
   119 
   185 
   120     numDirs := dirsToMake size.
   186     numDirs := dirsToMake size.
   121     nDone := 0.
   187     nDone := 0.
   122 
   188 
   123     dirsToMake do:[:dirName |
   189     dirsToMake do:[:dirName |
   155 
   221 
   156         errMsg notNil ifTrue:[
   222         errMsg notNil ifTrue:[
   157             box := WarningBox new.
   223             box := WarningBox new.
   158             box title:errMsg.
   224             box title:errMsg.
   159             box showAtPointerNotCovering:(WindowGroup activeGroup topViews first).
   225             box showAtPointerNotCovering:(WindowGroup activeGroup topViews first).
       
   226             stop ifTrue:[^ false].
   160         ].
   227         ].
   161 
   228 
   162         Delay waitForSeconds:0.25.
   229         Delay waitForSeconds:0.25.
   163         nDone := nDone + 1.
   230         nDone := nDone + 1.
   164     ].
   231     ].
   165     ^ true
   232     ^ true
   166 
   233 
   167     "Created: 17.7.1996 / 15:24:19 / cg"
   234     "Created: 17.7.1996 / 15:24:19 / cg"
   168     "Modified: 17.7.1996 / 15:35:30 / cg"
   235     "Modified: 18.7.1996 / 22:18:38 / cg"
   169 ! !
   236 ! !
   170 
   237 
   171 !STXInstaller methodsFor:'startup'!
   238 !STXInstaller methodsFor:'startup'!
   172 
   239 
   173 askAndInstall
   240 askAndInstall
   181     [self askForDestination] whileTrue:[
   248     [self askForDestination] whileTrue:[
   182         self checkForExistingInstallationAndConfirm ifFalse:[
   249         self checkForExistingInstallationAndConfirm ifFalse:[
   183             ^ self
   250             ^ self
   184         ].
   251         ].
   185         self doInstall ifTrue:[
   252         self doInstall ifTrue:[
       
   253             self postInstall.
   186             ^ self
   254             ^ self
   187         ].
   255         ].
   188         (self confirm:'installation failed or aborted - retry ?')
   256         (self confirm:'installation failed or aborted - retry ?')
   189         ifFalse:[
   257         ifFalse:[
   190             ^ self
   258             ^ self
   191         ]
   259         ]
   192     ].
   260     ].
   193 
   261 
   194     "Modified: 17.7.1996 / 15:08:30 / cg"
   262     "Modified: 18.7.1996 / 21:20:56 / cg"
   195 !
   263 !
   196 
   264 
   197 askForDestination
   265 askForDestination
   198     "open a dialog to enter destination directories"
   266     "open a dialog to enter destination directories"
   199 
   267 
   231 
   299 
   232     l := d addTextLabel:'Destination directories:'.
   300     l := d addTextLabel:'Destination directories:'.
   233     l adjust:#left; backgroundColor:dark; foregroundColor:Color white.
   301     l adjust:#left; backgroundColor:dark; foregroundColor:Color white.
   234 
   302 
   235     cm := ComboBoxView on:stxBinDirHolder.
   303     cm := ComboBoxView on:stxBinDirHolder.
   236     cm list:(Array 
   304     cm list:self defaultBinDirs.
   237                 with:'/tmp/stxbin'
       
   238                 with:'/usr/local/bin'
       
   239                 with:'/usr/bin'
       
   240                 with:(Filename homeDirectory constructString:'bin')).
       
   241     d 
   305     d 
   242         addLabelledField:cm 
   306         addLabelledField:cm 
   243         label:'binaries' 
   307         label:'binaries' 
   244         adjust:#left 
   308         adjust:#left 
   245         tabable:true 
   309         tabable:true 
   247         nameAs:'binaryBox'.
   311         nameAs:'binaryBox'.
   248 
   312 
   249     (d componentAt:'binaryBox.label') backgroundColor:dark; foregroundColor:Color white.
   313     (d componentAt:'binaryBox.label') backgroundColor:dark; foregroundColor:Color white.
   250 
   314 
   251     cm := ComboBoxView on:stxLibDirHolder.
   315     cm := ComboBoxView on:stxLibDirHolder.
   252     cm list:(Array 
   316     cm list:self defaultLibDirs.
   253                 with:'/tmp/stxlib'
       
   254                 with:'/usr/local/lib/smalltalk'
       
   255                 with:'/usr/lib/smalltalk'
       
   256                 with:((Filename homeDirectory 
       
   257                             construct:'lib')
       
   258                             constructString:'smalltalk')).
       
   259     d 
   317     d 
   260         addLabelledField:cm 
   318         addLabelledField:cm 
   261         label:'libraries' 
   319         label:'libraries' 
   262         adjust:#left 
   320         adjust:#left 
   263         tabable:true 
   321         tabable:true 
   273 
   331 
   274     d openAtCenter.
   332     d openAtCenter.
   275     d accepted ifTrue:[
   333     d accepted ifTrue:[
   276         stxLibDir := LastLibDir := stxLibDirHolder value.
   334         stxLibDir := LastLibDir := stxLibDirHolder value.
   277         stxBinDir := LastBinDir := stxBinDirHolder value.
   335         stxBinDir := LastBinDir := stxBinDirHolder value.
       
   336         d destroy.
   278         ^ true
   337         ^ true
   279     ].
   338     ].
       
   339     d destroy.
   280     ^ false
   340     ^ false
   281 
   341 
   282     "Modified: 17.7.1996 / 15:08:30 / cg"
   342     "Modified: 18.7.1996 / 19:43:38 / cg"
   283 !
   343 !
   284 
   344 
   285 checkForExistingInstallationAndConfirm
   345 checkForExistingInstallationAndConfirm
   286     "look if there is another installation and confirm
   346     "look if there is another installation and confirm
   287      reinstalling; return true if ok, false if not"
   347      reinstalling; return true if ok, false if not"
   288 
   348 
       
   349     |whatToDo|
       
   350 
   289     stxLibDir asFilename exists ifTrue:[
   351     stxLibDir asFilename exists ifTrue:[
   290         ^ DialogBox
   352         whatToDo := Dialog 
   291             confirm:('detected existing installation in ' 
   353                         choose:('detected existing installation in ' 
   292                      , stxLibDir asText allBold
   354                                  , stxLibDir asText allBold)
   293                      , '\\continue & overwrite ?') withCRs 
   355                         labels:#('remove first' 'overwrite' 'cancel') 
   294            yesLabel:'overwrite' noLabel:'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'
   295         
   371         
   296     ].
   372     ].
   297     ^ true
   373     ^ true
   298 
   374 
       
   375     "Modified: 18.7.1996 / 20:01:36 / cg"
   299 !
   376 !
   300 
   377 
   301 doInstall
   378 doInstall
   302     "install ST/X; return true if ok, false if not"
   379     "install ST/X; return true if ok, false if not"
   303 
   380 
   327     "Created: 17.7.1996 / 15:11:27 / cg"
   404     "Created: 17.7.1996 / 15:11:27 / cg"
   328     "Modified: 17.7.1996 / 15:24:27 / cg"
   405     "Modified: 17.7.1996 / 15:24:27 / cg"
   329 !
   406 !
   330 
   407 
   331 open
   408 open
   332     self askAndInstall
   409     self askAndInstall.
   333 
   410 
   334     "Created: 17.7.1996 / 14:37:14 / cg"
   411     "Created: 17.7.1996 / 14:37:14 / cg"
       
   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"
   335 ! !
   479 ! !
   336 
   480 
   337 !STXInstaller  class methodsFor:'documentation'!
   481 !STXInstaller  class methodsFor:'documentation'!
   338 
   482 
   339 version
   483 version