STXInstaller.st
changeset 73 2087134eea96
parent 31 0f95ba9204f6
child 117 45af2b7a5eca
equal deleted inserted replaced
72:a5a7054e2b7d 73:2087134eea96
   119     dirsToMake add:(stxLibDir asFilename constructString:'binary').
   119     dirsToMake add:(stxLibDir asFilename constructString:'binary').
   120     dirsToMake add:(stxLibDir asFilename constructString:'bitmaps').
   120     dirsToMake add:(stxLibDir asFilename constructString:'bitmaps').
   121     dirsToMake add:(stxLibDir asFilename constructString:'goodies').
   121     dirsToMake add:(stxLibDir asFilename constructString:'goodies').
   122 
   122 
   123     ^ dirsToMake
   123     ^ dirsToMake
       
   124 !
       
   125 
       
   126 listOfOptionalPackages
       
   127     ^ #(
       
   128         'libDB'
       
   129         'clients/CBrowser'
       
   130         'libtool2'
       
   131         'libcompat'
       
   132         'libui'
       
   133         'libxt'
       
   134 
       
   135 
       
   136         "/ mhmh - these should not be needed here ...
       
   137 
       
   138         'projects/smalltalk/bitmaps/javaImages'
       
   139         'doc/online/english/overview/icons'
       
   140       )
       
   141 
       
   142     "Created: 2.3.1997 / 12:39:59 / cg"
       
   143     "Modified: 2.3.1997 / 13:24:41 / cg"
   124 !
   144 !
   125 
   145 
   126 specOfFilesToCopy
   146 specOfFilesToCopy
   127     |fileSpec|
   147     |fileSpec|
   128 
   148 
   256             msg at:4 put:'    ' , (fileName asText allBold).
   276             msg at:4 put:'    ' , (fileName asText allBold).
   257             msg at:6 put:'    ' , (destDir asText allBold).
   277             msg at:6 put:'    ' , (destDir asText allBold).
   258             actionTextHolder value:nil.
   278             actionTextHolder value:nil.
   259             actionTextHolder value:msg.
   279             actionTextHolder value:msg.
   260 
   280 
   261             cmd := 'cp -r ../../' , fileName , ' ' , destDir.
   281             ((fileName includes:$*) not
   262             commandTraceView showCR:cmd , ' ...'.
   282             and:[('../../' , fileName) asFilename exists not]) ifTrue:[
   263 "/            cmd := 'sh -c "echo ; ' , cmd , ' 2>&1"' .
   283                 (self listOfOptionalPackages includes:fileName) ifFalse:[
   264             cmd := cmd , ' 2>&1' .
   284                     commandTraceView showCR:('cannot copy ' , fileName , ' - not included in distribution')
   265 
   285                 ]
   266             doneSemaphore := Semaphore new.
   286             ] ifFalse:[
   267 
   287                 cmd := 'cp -r ../../' , fileName , ' ' , destDir.
   268             [   
   288                 commandTraceView showCR:cmd , ' ...'.
   269 
   289                 cmd := cmd , ' 2>&1' .
   270                 p := PipeStream readingFrom:cmd.
   290 
   271                 p isNil ifTrue:[
   291                 doneSemaphore := Semaphore new.
   272                     self warn:('command error. Could not execute:\\' , cmd) withCRs.
   292 
   273                 ] ifFalse:[
   293                 [   
   274                     [p atEnd] whileFalse:[
   294 
   275                         (p readWaitWithTimeout:0.1) ifFalse:[
   295                     p := PipeStream readingFrom:cmd.
   276                             line := p nextLine.
   296                     p isNil ifTrue:[
   277                             (line notNil and:[line notEmpty]) ifTrue:[
   297                         self warn:('command error. Could not execute:\\' , cmd) withCRs.
   278                                 commandTraceView showCR:(('  ' , line) asText emphasizeAllWith:(#color->Color red)).
   298                     ] ifFalse:[
       
   299                         [p atEnd] whileFalse:[
       
   300                             (p readWaitWithTimeout:0.1) ifFalse:[
       
   301                                 line := p nextLine.
       
   302                                 (line notNil and:[line notEmpty]) ifTrue:[
       
   303                                     commandTraceView showCR:(('  ' , line) asText emphasizeAllWith:(#color->Color red)).
       
   304                                 ]
   279                             ]
   305                             ]
   280                         ]
   306                         ].
       
   307                         p close.
   281                     ].
   308                     ].
   282                     p close.
   309                     doneSemaphore signal.
   283                 ].
   310                 ] forkAt:4.
   284                 doneSemaphore signal.
   311 
   285             ] forkAt:4.
   312                 doneSemaphore wait.
   286 
   313             ]
   287             doneSemaphore wait.
       
   288 
       
   289         ].
   314         ].
   290 
   315 
   291         nDone := nDone + 1
   316         nDone := nDone + 1
   292     ].
   317     ].
   293 
   318 
   294     ^ true
   319     ^ true
   295 
   320 
   296     "Created: 17.7.1996 / 15:16:20 / cg"
   321     "Created: 17.7.1996 / 15:16:20 / cg"
   297     "Modified: 9.1.1997 / 03:15:23 / cg"
   322     "Modified: 2.3.1997 / 12:43:47 / cg"
   298 !
   323 !
   299 
   324 
   300 createDirectories
   325 createDirectories
   301     |msg dirsToMake numDirs nDone|
   326     |msg dirsToMake numDirs nDone|
   302 
   327 
   367     OperatingSystem executeCommand:('(cd ' , stxLibDir , '/doc/online ; make links)').
   392     OperatingSystem executeCommand:('(cd ' , stxLibDir , '/doc/online ; make links)').
   368     ^ true
   393     ^ true
   369 
   394 
   370     "Created: 17.7.1996 / 15:24:19 / cg"
   395     "Created: 17.7.1996 / 15:24:19 / cg"
   371     "Modified: 18.7.1996 / 22:18:38 / cg"
   396     "Modified: 18.7.1996 / 22:18:38 / cg"
       
   397 !
       
   398 
       
   399 outputInitialMessage
       
   400     #(
       
   401     'Notice:'
       
   402     ''
       
   403     'During the installation, you may get error messages'
       
   404     'complaining that some files where not found'
       
   405     'and could therefore not be copied.'
       
   406     ) do:[:line |
       
   407         commandTraceView showCR:((resources string:line) asText emphasizeAllWith:(#color->Color blue)).
       
   408         commandTraceView endEntry. 
       
   409     ].
       
   410 
       
   411     Delay waitForSeconds:2.
       
   412 
       
   413     #(
       
   414     ''
       
   415     'This is normal behavior; since the CD may contain'
       
   416     'broken symbolic links to non-existing packages'
       
   417     'which are either not contained on your ordered'
       
   418     'package (i.e. non-commercial) or not yet published by eXept.'
       
   419     ) do:[:line |
       
   420         commandTraceView showCR:((resources string:line) asText emphasizeAllWith:(#color->Color blue)).
       
   421         commandTraceView endEntry.
       
   422     ].
       
   423 
       
   424     Delay waitForSeconds:2.
       
   425 
       
   426     #(
       
   427     ''
       
   428     'Please excuse this inconvenience.'
       
   429     ''
       
   430     ) do:[:line |
       
   431         commandTraceView showCR:((resources string:line) asText emphasizeAllWith:(#color->Color blue)).
       
   432         commandTraceView endEntry.
       
   433     ].
       
   434 
       
   435     Delay waitForSeconds:2.
       
   436 
       
   437     "Created: 2.3.1997 / 12:49:52 / cg"
       
   438     "Modified: 2.3.1997 / 13:22:45 / cg"
   372 ! !
   439 ! !
   373 
   440 
   374 !STXInstaller methodsFor:'startup'!
   441 !STXInstaller methodsFor:'startup'!
   375 
   442 
   376 askAndInstall
   443 askAndInstall
   382         self warn:(resources string:'must be in the ''projects/smalltalk'' directory').
   449         self warn:(resources string:'must be in the ''projects/smalltalk'' directory').
   383         ^ self
   450         ^ self
   384     ].
   451     ].
   385 
   452 
   386     [self askForDestination] whileTrue:[
   453     [self askForDestination] whileTrue:[
   387         self checkForExistingInstallationAndConfirm ifFalse:[
   454         self checkForExistingInstallationAndConfirm ifTrue:[
   388             ^ self
   455             self preInstall.
   389         ].
   456             self doInstall ifTrue:[
   390         self preInstall.
   457                 self postInstall.
   391         self doInstall ifTrue:[
   458                 ^ self
   392             self postInstall.
   459             ].
   393             ^ self
   460             (self confirm:(resources string:'installation failed or aborted - retry ?'))
   394         ].
   461             ifFalse:[
   395         (self confirm:(resources string:'installation failed or aborted - retry ?'))
   462                 ^ self
   396         ifFalse:[
   463             ]
   397             ^ self
       
   398         ]
   464         ]
   399     ].
   465     ].
   400 
   466 
   401     "Modified: 18.7.1996 / 21:20:56 / cg"
   467     "Modified: 2.3.1997 / 13:46:23 / cg"
   402 !
   468 !
   403 
   469 
   404 askForDestination
   470 askForDestination
   405     "open a dialog to enter destination directories"
   471     "open a dialog to enter destination directories"
   406 
   472 
   407     |d cm l green dark img
   473     |d cm l green dark img
   408      stxLibDirHolder stxLibBinDirHolder stxBinDirHolder
   474      stxLibDirHolder stxLibBinDirHolder stxBinDirHolder
   409      installDocHolder installSourceHolder installSTCHolder installGoodiesHolder
   475      installDocHolder installSourceHolder installSTCHolder installGoodiesHolder
   410      binMegabytes libMegabytes
   476      binMegabytes libMegabytes docMegabytes stcMegabytes srcMegabytes
   411     |
   477     |
   412 
   478 
   413     binMegabytes := 10.
   479     binMegabytes := 10.
   414     libMegabytes := 10.
   480     libMegabytes := 30.
       
   481     docMegabytes := 11.
       
   482     stcMegabytes := 1.
       
   483     srcMegabytes := 15.
   415 
   484 
   416     LastLibDir isNil ifTrue:[
   485     LastLibDir isNil ifTrue:[
   417         LastLibDir := '/usr/local/lib/smalltalk'
   486         LastLibDir := '/usr/local/lib/smalltalk'
   418     ].
   487     ].
   419     LastLibBinDir isNil ifTrue:[
   488     LastLibBinDir isNil ifTrue:[
   513     d addVerticalSpace.
   582     d addVerticalSpace.
   514 
   583 
   515     (d addTextLabel:(resources string:'optional:'))
   584     (d addTextLabel:(resources string:'optional:'))
   516         adjust:#left; foregroundColor:Color white backgroundColor:dark.
   585         adjust:#left; foregroundColor:Color white backgroundColor:dark.
   517 
   586 
   518     (d addCheckBox:((resources string:'doc files') , ' (+8 Mb)') on:installDocHolder)
   587     (d addCheckBox:((resources string:'doc files (+%1 Mb)' with:docMegabytes)) on:installDocHolder)
   519         labelView foregroundColor:Color white backgroundColor:dark.
   588         labelView foregroundColor:Color white backgroundColor:dark.
   520     (d addCheckBox:((resources string:'stc & support files') , ' (+2 Mb)') on:installSTCHolder)
   589     (d addCheckBox:((resources string:'stc & support files (+%1 Mb)' with:stcMegabytes)) on:installSTCHolder)
   521         labelView foregroundColor:Color white backgroundColor:dark.
   590         labelView foregroundColor:Color white backgroundColor:dark.
   522 
   591 
   523     d addVerticalSpace.
   592     d addVerticalSpace.
   524     d addHorizontalLine.
   593     d addHorizontalLine.
   525     d addVerticalSpace.
   594     d addVerticalSpace.
   526 
   595 
   527     (d addTextLabel:(resources string:'optional (but highly recommended):'))
   596     (d addTextLabel:(resources string:'optional (but highly recommended):'))
   528         adjust:#left; foregroundColor:Color white backgroundColor:dark.
   597         adjust:#left; foregroundColor:Color white backgroundColor:dark.
   529 
   598 
   530     (d addCheckBox:((resources string:'smalltalk source files') , ' (+12 Mb)') on:installSourceHolder)
   599     (d addCheckBox:((resources string:'smalltalk source files (+%1 Mb)' with:srcMegabytes)) on:installSourceHolder)
   531         labelView foregroundColor:Color white backgroundColor:dark.
   600         labelView foregroundColor:Color white backgroundColor:dark.
   532     (d addCheckBox:((resources string:'goodies') , ' (+0.5 Mb)') on:installGoodiesHolder)
   601     (d addCheckBox:((resources string:'goodies (+0.5 Mb)')) on:installGoodiesHolder)
   533         labelView foregroundColor:Color white backgroundColor:dark.
   602         labelView foregroundColor:Color white backgroundColor:dark.
   534 
   603 
   535     d addVerticalSpace.
   604     d addVerticalSpace.
   536     d addHorizontalLine.
   605     d addHorizontalLine.
   537 
   606 
   538     d addHelpButtonFor:'STXInstaller/installHelp.html';
   607     d addHelpButtonFor:'STXInstaller/installHelp.html';
   539       addAbortButton; 
   608       addAbortButton; 
   540       addOkButtonLabelled:(resources string:'install').
   609       addOkButtonLabelled:(resources string:'install').
   541     d extent:400@300.
   610     d extent:500@400.
   542 
   611 
   543     d allViewBackground:dark.
   612     d allViewBackground:dark.
   544 
   613 
   545     d openAtCenter.
   614     d openAtCenter.
   546     d accepted ifTrue:[
   615     d accepted ifTrue:[
   555         ^ true
   624         ^ true
   556     ].
   625     ].
   557     d destroy.
   626     d destroy.
   558     ^ false
   627     ^ false
   559 
   628 
   560     "Modified: 18.7.1996 / 19:43:38 / cg"
   629     "Modified: 2.3.1997 / 13:40:44 / cg"
   561 !
   630 !
   562 
   631 
   563 checkForExistingInstallationAndConfirm
   632 checkForExistingInstallationAndConfirm
   564     "look if there is another installation and confirm
   633     "look if there is another installation and confirm
   565      reinstalling; return true if ok, false if not"
   634      reinstalling; return true if ok, false if not"
   573                                       with:stxLibDir asText allBold)
   642                                       with:stxLibDir asText allBold)
   574                         label:(resources string:'Attention')
   643                         label:(resources string:'Attention')
   575                         labels:(resources array:#('remove first' 'overwrite' 'cancel')) 
   644                         labels:(resources array:#('remove first' 'overwrite' 'cancel')) 
   576                         values:#(remove over nil) 
   645                         values:#(remove over nil) 
   577                         default:nil.     
   646                         default:nil.     
       
   647 
   578         whatToDo isNil ifTrue:[^false].
   648         whatToDo isNil ifTrue:[^false].
   579         whatToDo == #remove ifTrue:[
   649         whatToDo == #remove ifTrue:[
   580             ((stxLibDir findString:'stx') == 0
   650             ((stxLibDir findString:'stx') == 0
   581             and:[(stxLibDir findString:'smalltalk') == 0]) ifTrue:[
   651             and:[(stxLibDir findString:'smalltalk') == 0]) ifTrue:[
   582                 "/ confirm again
   652                 "/ confirm again
   583                 (self confirm:(resources 
   653                 (self confirm:(resources 
   584                                 string:'are you certain that the directory to remove
   654                                 string:'are you certain that the directory to remove
   585 is really an smalltalk directory ?
   655 (' , stxLibDir , ') is really a smalltalk directory ?
   586 
   656 
   587 Remove it now ?')) ifFalse:[ ^ true].
   657 Remove it now ?')) ifFalse:[ 
       
   658                     (self confirm:(resources 
       
   659                                      string:'overwrite ?')) ifTrue:[^ true].
       
   660                     ^ false
       
   661                 ]
   588             ].
   662             ].
   589 
   663 
   590             (OperatingSystem recursiveRemoveDirectory:stxLibDir)
   664             (OperatingSystem recursiveRemoveDirectory:stxLibDir)
   591             ifFalse:[
   665             ifFalse:[
   592                 self warn:(resources string:'mhmh - could not remove old installation.')
   666                 self warn:(resources string:'mhmh - could not remove old installation.')
   593             ].
   667             ].
   594         ].
   668         ].
   595         ^ true
   669         ^ true
   596 "/        ^ DialogBox
       
   597 "/            confirm:('detected existing installation in ' 
       
   598 "/                     , stxLibDir asText allBold
       
   599 "/                     , '\\continue & overwrite ?') withCRs 
       
   600 "/           yesLabel:'overwrite' noLabel:'cancel'
       
   601         
       
   602     ].
   670     ].
   603     ^ true
   671     ^ true
   604 
   672 
   605     "Modified: 18.7.1996 / 20:01:36 / cg"
   673     "Modified: 2.3.1997 / 13:45:13 / cg"
   606 !
   674 !
   607 
   675 
   608 doInstall
   676 doInstall
   609     "install ST/X; return true if ok, false if not"
   677     "install ST/X; return true if ok, false if not"
   610 
   678 
   611     |progressView ok textView|
   679     |progressView ok textView|
   612 
   680 
   613     textView := HVScrollableView for:TextCollector.
   681     textView := HVScrollableView for:TextCollector.
   614     textView preferredExtent:(100 @ 250).
   682     textView preferredExtent:(200 @ 300).
   615     commandTraceView := textView scrolledView.
   683     commandTraceView := textView scrolledView.
   616 
   684 
   617     progressView := ProgressIndicator
   685     progressView := ProgressIndicator
   618                         inBoxWithLabel:'ST/X Installation' icon:(Depth8Image fromImage:Launcher aboutIcon)
   686                         inBoxWithLabel:'ST/X Installation' icon:(Depth8Image fromImage:Launcher aboutIcon)
   619                         text:#('ST/X Installation' '' '' '' '' '' '' '') asStringCollection
   687                         text:#('ST/X Installation' '' '' '' '' '' '' '') asStringCollection
   620                         abortable:true
   688                         abortable:true
   621                         view:textView
   689                         view:textView
   622                         closeWhenDone:false.
   690                         closeWhenDone:false.
   623     progressView topView extent:(500 min:Display width) @ 300.
   691     progressView topView extent:(640 min:Display width) @ (500 min:Display height).
   624 
   692 
   625     ok := false.
   693     ok := false.
   626 
   694 
   627     progressView showProgressOf:
   695     progressView showProgressOf:
   628             [:progressValue :currentAction| |msg|
   696             [:progressValue :currentAction| |msg|
   629 
   697 
   630               Processor activeProcess withPriority:7 do:[
   698               Processor activeProcess withPriority:7 do:[
   631                   actionPercentageHolder := progressValue.
   699                   actionPercentageHolder := progressValue.
   632                   actionTextHolder := currentAction.
   700                   actionTextHolder := currentAction.
       
   701 
       
   702                   self outputInitialMessage.
   633 
   703 
   634                   (self createDirectories) ifTrue:[
   704                   (self createDirectories) ifTrue:[
   635                       ok := self copyFiles
   705                       ok := self copyFiles
   636                   ].
   706                   ].
   637                   self createSymbolicLinks.
   707                   self createSymbolicLinks.
   649             ].
   719             ].
   650 
   720 
   651     ^ ok
   721     ^ ok
   652 
   722 
   653     "Created: 17.7.1996 / 15:11:27 / cg"
   723     "Created: 17.7.1996 / 15:11:27 / cg"
   654     "Modified: 17.7.1996 / 15:24:27 / cg"
   724     "Modified: 2.3.1997 / 12:59:47 / cg"
   655 !
   725 !
   656 
   726 
   657 open
   727 open
   658     self askAndInstall.
   728     self askAndInstall.
   659 
   729 
   709         '' errorPrintCR.
   779         '' errorPrintCR.
   710         cshInfo withCRs errorPrintCR.
   780         cshInfo withCRs errorPrintCR.
   711         '' errorPrintCR.
   781         '' errorPrintCR.
   712         '*********************************************************' errorPrintCR.
   782         '*********************************************************' errorPrintCR.
   713     ].
   783     ].
   714     self information:msg.
   784 
       
   785     msg := msg , '\\Have fun using ST/X !!'.
       
   786 
       
   787     self information:msg withCRs.
   715 
   788 
   716     "
   789     "
   717      STXInstaller new postInstall
   790      STXInstaller new postInstall
   718     "
   791     "
   719 
   792 
   720     "Modified: 18.7.1996 / 22:10:42 / cg"
   793     "Modified: 2.3.1997 / 13:28:18 / cg"
   721 !
   794 !
   722 
   795 
   723 preInstall
   796 preInstall
   724     "clobber the doc directory, to avoid copying cyclic symbolic links"
   797     "clobber the doc directory, to avoid copying cyclic symbolic links"
   725 
   798