! install Pier.
!
!  expects Magritte to already be loaded.
!
!  expects .mcz files to be found in $GEMSTONE/seaside/monticello/repository
!  or ./seaside/monticello/repository
!
ifError where
errorCount
output push pierInstall.out only
display resultcheck
errorCount

! install into UserGlobals
run
| policy |
policy := GsPackagePolicy current.
policy homeSymbolDict:  UserGlobals.
policy externalSymbolList: Array new.
true
%

errorCount
commit

run
| basePath dir repository spec |
basePath := GsPackageLibrary getMonticelloRepositoryDirectory .
dir := FileDirectory on: basePath.
repository := MCDirectoryRepository new directory: dir.
MCRepositoryGroup default addRepository: repository.
spec := #[	
    'Pier-Model-dkh.212.mcz',
       'http://source.lukas-renggli.ch/pier',
       'http://seaside.gemstone.com/ss/pier',
    'Pier-Tests-dkh.92.mcz',
       'http://source.lukas-renggli.ch/pier',
       'http://seaside.gemstone.com/ss/pier',
    'Pier-Seaside-dkh.254.mcz',
       'http://source.lukas-renggli.ch/pier',
       'http://seaside.gemstone.com/ss/pier',
    'Pier-Security-lr.103.mcz',
       'http://source.lukas-renggli.ch/pier',
       '',
    'Pier-Blog-lr.70.mcz',
       'http://source.lukas-renggli.ch/pier',
       '',
    'Pier-EditorEnh-lr.11.mcz',
       'http://source.lukas-renggli.ch/pieraddons',
       '',

].
1 to: spec size by: 3 do: [:i | | fileName httpRepository primaryRepository version rg |
    fileName := spec at: i.
    primaryRepository := MCHttpRepository
      location: (spec at: i + 1)
      user: ''
      password: ''.
    (spec at: i + 2) isEmpty not
      ifTrue: [
        httpRepository := MCHttpRepository
          location: (spec at: i + 2)
          user: ''
          password: ''].
    version := repository loadVersionFromFileNamed: fileName.
    [ version load ]
      on: OBConfirmationRequest         
      do: [:ex |
        "cancel request"
        GsFile gciLogServer: 'Cancel request: ', ex prompt printString.
        ex cancel].
    rg := version workingCopy repositoryGroup.
    rg addRepository: repository.
    rg addRepository: primaryRepository.
    (spec at: i + 2) isEmpty not
      ifTrue: [ rg addRepository: httpRepository ].
].
true
%

! initialize a default instance of Pier
run
PRPierFrame registerAsApplication: 'pier' kernel: (PRKernel named: 'Pier').
true
%


errorCount
commit

output pop
errorCount
