STXInstaller.st
author Claus Gittinger <cg@exept.de>
Thu, 18 Jul 1996 15:24:24 +0200
changeset 0 ce9f4417b660
child 1 7ebb34d8f3df
permissions -rw-r--r--
intitial checkin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
Object subclass:#STXInstaller
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
	instanceVariableNames:'stxLibDir stxBinDir actionPercentageHolder actionTextHolder'
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
	classVariableNames:'LastBinDir LastLibDir'
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
	poolDictionaries:''
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
	category:'eXept-tools'
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
!
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
!STXInstaller  class methodsFor:'startup'!
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
open
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
    ^ self new open
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
    "Created: 17.7.1996 / 14:36:22 / cg"
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
! !
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
!STXInstaller methodsFor:'installing'!
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
copyFiles
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
    |msg fileSpec filesToCopy numFiles nDone|
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
    msg := #('ST/X Installation' '' 'copying:' '' 'to:' '') asStringCollection.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
    fileSpec := #(
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
                "/ name            destination   subDir   required
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
                ( 'stc/stc'               #bin     nil      false)
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
                ( 'rules/stmkmp'          #bin     nil      false)
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
                ( 'rules/stmkmf'          #bin     nil      false)
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
                ( 'librun/librun.a'       #lib     'lib'    false)
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
                ( 'libbasic/libbasic.o'   #lib     'lib'    false)
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
                ( 'libbasic2/libbasic2.o' #lib     'lib'    false)
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
                ( 'libbasic3/libbasic3.o' #lib     'lib'    false)
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
                ( 'libcomp/libcomp.o'     #lib     'lib'    false)
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
                ( 'libview/libview.o'     #lib     'lib'    false)
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
                ( 'libview2/libview2.o'   #lib     'lib'    false)
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
                ( 'libwidg/libwidg.o'     #lib     'lib'    false)
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
                ( 'libwidg2/libwidg2.o'   #lib     'lib'    false)
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
                ( 'libwidg3/libwidg3.o'   #lib     'lib'    false)
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
                ( 'libtool/libtool.o'     #lib     'lib'    false)
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
                ( 'projects/smalltalk/*.rc'    #lib   nil    false)
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
                ( 'projects/smalltalk/patches' #lib   nil    false)
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
                ( 'projects/smalltalk/bitmaps'        #lib nil    false)
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
                ( 'projects/smalltalk/configurations' #lib nil    false)
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
                ( 'projects/smalltalk/doc'            #lib nil    false)
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
                ( 'projects/smalltalk/include'        #lib nil    false)
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
                ( 'projects/smalltalk/resources'      #lib nil    false)
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
                ( 'projects/smalltalk/rules'          #lib nil    false)
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
              ).
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
    filesToCopy := OrderedCollection new.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
    fileSpec do:[:entry |
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
        |fileName dest subDir required destDir|
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
        fileName := entry at:1.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
        dest := entry at:2.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
        subDir := entry at:3.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
        required := entry at:4.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
        dest == #bin ifTrue:[
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
            destDir := stxBinDir
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
        ] ifFalse:[
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
            destDir := stxLibDir
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
        ].
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
        
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
        destDir := destDir asFilename.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
        subDir notNil ifTrue:[
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
            destDir := destDir construct:subDir
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
        ].
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
        filesToCopy add:(fileName -> destDir pathName)
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
    ].
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
    numFiles := filesToCopy size.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
    nDone := 0.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    filesToCopy do:[:entry |
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
        |fileName destDir|
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
        actionPercentageHolder value:(nDone / numFiles * 100) rounded.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
        fileName := entry key.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
        destDir := entry value.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
        msg at:4 put:'    ' , (fileName asText allBold).
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
        msg at:6 put:'    ' , (destDir asText allBold).
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
        actionTextHolder value:nil.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
        actionTextHolder value:msg.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
        OperatingSystem executeCommand:('cp -r ../../' , fileName , ' ' , destDir).
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
        nDone := nDone + 1
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
    ].
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
    ^ true
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    "Created: 17.7.1996 / 15:16:20 / cg"
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
    "Modified: 17.7.1996 / 15:21:09 / cg"
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
!
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
createDirectories
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
    |msg dirsToMake numDirs nDone|
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
    msg := #('ST/X Installation' '' 'creating directory:' '' '' '') asStringCollection.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
    dirsToMake := OrderedCollection new.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    dirsToMake add:stxBinDir.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    dirsToMake add:stxLibDir.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    dirsToMake add:(stxLibDir asFilename constructString:'lib').
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    dirsToMake add:(stxLibDir asFilename constructString:'doc').
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
    dirsToMake add:(stxLibDir asFilename constructString:'include').
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
    dirsToMake add:(stxLibDir asFilename constructString:'resources').
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
    dirsToMake add:(stxLibDir asFilename constructString:'binary').
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
    dirsToMake add:(stxLibDir asFilename constructString:'bitmaps').
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
    numDirs := dirsToMake size.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
    nDone := 0.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
    dirsToMake do:[:dirName |
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
        |d errMsg stop box|
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
        actionPercentageHolder value:(nDone / numDirs * 100) rounded.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
        msg at:4 put:'    ' , dirName.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
        actionTextHolder value:nil.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
        actionTextHolder value:msg.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
        d := dirName asFilename.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
        d exists ifFalse:[
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
            OperatingSystem recursiveCreateDirectory:d pathName
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
        ].
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
        d exists ifFalse:[
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
            errMsg := 'failed to create directory: ' , dirName.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
            stop := true
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
        ] ifTrue:[
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
            d isDirectory ifFalse:[
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
                errMsg := 'not a directory: ' , dirName.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
                stop := true
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
            ] ifTrue:[
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
                (d isReadable
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
                and:[d isWritable]) ifFalse:[
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
                    errMsg := 'no R/W access to directory: ' , dirName.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
                    stop := false
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
                ] ifTrue:[
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
                    errMsg := nil
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
                ]
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
            ]
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
        ].
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
        errMsg notNil ifTrue:[
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
            box := WarningBox new.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
            box title:errMsg.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
            box showAtPointerNotCovering:(WindowGroup activeGroup topViews first).
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
        ].
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
        Delay waitForSeconds:0.25.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
        nDone := nDone + 1.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
    ].
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
    ^ true
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
    "Created: 17.7.1996 / 15:24:19 / cg"
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
    "Modified: 17.7.1996 / 15:35:30 / cg"
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
! !
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
!STXInstaller methodsFor:'startup'!
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
askAndInstall
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
    "/ check, if we are in the projects/smalltalk directory
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
    (Filename currentDirectory pathName endsWith:'projects/smalltalk') ifFalse:[
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
        self warn:'must be in the projects/smalltalk directory'.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
        ^ self
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
    ].
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
    [self askForDestination] whileTrue:[
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
        self checkForExistingInstallationAndConfirm ifFalse:[
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
            ^ self
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
        ].
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
        self doInstall ifTrue:[
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
            ^ self
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
        ].
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
        (self confirm:'installation failed or aborted - retry ?')
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
        ifFalse:[
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
            ^ self
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
        ]
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
    ].
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
    "Modified: 17.7.1996 / 15:08:30 / cg"
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
!
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
askForDestination
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
    "open a dialog to enter destination directories"
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
    |d cm l green dark
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
     stxLibDirHolder stxBinDirHolder
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
    |
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
    LastLibDir isNil ifTrue:[
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
        LastLibDir := '/usr/local/lib/smalltalk'
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
    ].
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
    LastBinDir isNil ifTrue:[
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
        LastBinDir := '/usr/local/bin'
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
    ].
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
    stxLibDirHolder := LastLibDir asValue.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
    stxBinDirHolder := LastBinDir asValue.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
    Screen current hasColors ifTrue:[
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
        green := (Color red:0 green:80 blue:20) "darkened".
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
        dark := Color grey:10.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
    ] ifFalse:[
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
        green := Color white.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
        dark := Color black.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
    ].
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
    d := DialogBox new.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
    d label:'ST/X CD Installation'.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
    l := d addTextLabel:'Smalltalk/X CD installation.'.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
    l adjust:#left; backgroundColor:dark; foregroundColor:Color white.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
    d addVerticalSpace.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
    d addVerticalSpace.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
    d addHorizontalLine.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
    l := d addTextLabel:'Destination directories:'.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
    l adjust:#left; backgroundColor:dark; foregroundColor:Color white.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
    cm := ComboBoxView on:stxBinDirHolder.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
    cm list:(Array 
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
                with:'/tmp/stxbin'
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
                with:'/usr/local/bin'
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
                with:'/usr/bin'
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
                with:(Filename homeDirectory constructString:'bin')).
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
    d 
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
        addLabelledField:cm 
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
        label:'binaries' 
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
        adjust:#left 
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
        tabable:true 
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
        from:0.0 to:1.0 separateAtX:0.25
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
        nameAs:'binaryBox'.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
    (d componentAt:'binaryBox.label') backgroundColor:dark; foregroundColor:Color white.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
    cm := ComboBoxView on:stxLibDirHolder.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
    cm list:(Array 
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
                with:'/tmp/stxlib'
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
                with:'/usr/local/lib/smalltalk'
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
                with:'/usr/lib/smalltalk'
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
                with:((Filename homeDirectory 
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
                            construct:'lib')
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
                            constructString:'smalltalk')).
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
    d 
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
        addLabelledField:cm 
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
        label:'libraries' 
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
        adjust:#left 
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
        tabable:true 
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
        from:0.0 to:1.0 separateAtX:0.25
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
        nameAs:'libraryBox'.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
    (d componentAt:'libraryBox.label') backgroundColor:dark; foregroundColor:Color white.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
    d addAbortButton; addOkButtonLabelled:'install'.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
    d extent:400@300.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
    d allViewBackground:dark.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
    d openAtCenter.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
    d accepted ifTrue:[
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
        stxLibDir := LastLibDir := stxLibDirHolder value.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
        stxBinDir := LastBinDir := stxBinDirHolder value.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
        ^ true
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
    ].
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
    ^ false
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
    "Modified: 17.7.1996 / 15:08:30 / cg"
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
!
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
checkForExistingInstallationAndConfirm
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
    "look if there is another installation and confirm
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
     reinstalling; return true if ok, false if not"
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
    stxLibDir asFilename exists ifTrue:[
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
        ^ DialogBox
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
            confirm:('detected existing installation in ' 
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
                     , stxLibDir asText allBold
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
                     , '\\continue & overwrite ?') withCRs 
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
           yesLabel:'overwrite' noLabel:'cancel'
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
        
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
    ].
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
    ^ true
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
!
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
doInstall
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
    "install ST/X; return true if ok, false if not"
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
    |progressView ok|
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
    progressView := ProgressIndicator
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
                        inBoxWithLabel:'ST/X Installation'
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
                        text:#('ST/X Installation' '' '' '' '' '' '' '') asStringCollection
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
                        abortable:true.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
    progressView topView extent:400@300.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
    ok := false.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
    progressView showProgressOf:
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
            [:progressValue :currentAction |
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
              actionPercentageHolder := progressValue.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
              actionTextHolder := currentAction.
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
              (self createDirectories) ifTrue:[
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
                  ok := self copyFiles
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
              ]
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
            ].
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
    ^ ok
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
    "Created: 17.7.1996 / 15:11:27 / cg"
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
    "Modified: 17.7.1996 / 15:24:27 / cg"
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
!
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
open
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   332
    self askAndInstall
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   333
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
    "Created: 17.7.1996 / 14:37:14 / cg"
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
! !
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
!STXInstaller  class methodsFor:'documentation'!
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
version
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
    ^ '$Header$'
ce9f4417b660 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
! !