! install Monticello
!  expects .mcz files to be found in $SEASIDE/monticello/repository or
!  $GEMSTONE/seaside/monticello/repository
!
limit oops 100
limit bytes 1000
ifError where
ifError stack
!
! -- Uncomment the following two lines and rerun, if more error detail needed
! display oops
! ifError stack
errorCount
output push monticelloInstall.out only
display resultcheck
errorCount

!
! Define which SymbolDictionary into which the Bootstrap classes are to be installed.
!
run
UserGlobals at: #BootStrapSymbolDictionaryName put: #UserGlobals.
true
%
errorCount

! Enable SessionMethods, so that base class extensions are isolated. 
! Install Bootstrap and Monticello into UserGlobals
run
| policy package |
package := GsPackageLibrary createPackageNamed: #SessionMethods.
GsPackageLibrary installPackage: package.
policy := GsPackagePolicy current.
policy homeSymbolDict:  UserGlobals.
policy externalSymbolList: Array new.
true
%
errorCount

commit

! install Bootstrap
input $upgradeDir/Bootstrap.gs
errorCount

run
UserGlobals removeKey: #BootStrapSymbolDictionaryName.
true
%
errorCount

commit

run
| undef |
undef := SymbolDictionary new.
undef name: #UndefinedSymbols.
UserGlobals at: #UndefinedSymbols put: undef.
UserGlobals at: #UndefinedSymbolList put: (SymbolList with: undef).
true
%

errorCount
commit

! shouldn't have to do this. It will do for now, though.
run
GsPackagePolicy current refreshSessionMethodDictionary.
true
%

! install Monticello from packages using MczInstaller
run
| basePath |
basePath :=  GsPackageLibrary getMonticelloRepositoryDirectory .

#[	
    'Gemstone-bugfixes-dkh.7.mcz', 
    'GsRandom-dkh.6.mcz', 
    'Sport-dkh.3.mcz', 
    'Squeak-dkh.114.mcz',
    'PackageInfo-Base.g-dkh.24.mcz', 
    'Monticello.g-dkh.301.mcz',

] do: [:filename | 
    MczInstaller installFileNamed: basePath, filename in: UserGlobals.
].
true
%
errorCount

!----- Use an MCDictionaryRepository as the Monticello cache repository
run
| repository |
repository := MCDictionaryRepository new.
MCCacheRepository setDefault: repository.
true
%
errorCount

! Adopt the Bootstrap .mcz file as an ancestor for the Bootstrap package
run
| basePath package dir repository httpRepository primaryRepository |
basePath := GsPackageLibrary  getMonticelloRepositoryDirectory.
dir := FileDirectory on: basePath.
repository := MCDirectoryRepository new directory: dir.
httpRepository := MCHttpRepository
    location: 'http://seaside.gemstone.com/ss/monticello'
    user: ''
    password: ''.
#[	
    'Base-Bootstrap-dkh.2.mcz', 
    'Bootstrap-dkh.86.mcz',
    'GemStone-Exceptions-dkh.6.mcz',
    'MonticelloConfigurations.g-dkh.47.mcz',
    'Utf8Encoding-dkh.7.mcz',

] do: [:fileName | | version rg |
    GsFile gciLogServer: 'Loading ', fileName.
    version := repository loadVersionFromFileNamed: fileName.
    version load.
    rg := version workingCopy repositoryGroup.
    rg addRepository: repository.
    rg addRepository: httpRepository.
].
#[
    'Gemstone-bugfixes',
    'GsRandom', 
    'Sport', 
    'Squeak',
    'PackageInfo-Base', 
    'Monticello',

] do: [:pkgName | |rg |
  rg := (MCPackage named: pkgName) workingCopy repositoryGroup.
  rg addRepository: repository.
  rg addRepository: httpRepository.
].
"Define primaryRepository for MonticelloConfigurations"
primaryRepository := MCHttpRepository
    location: 'http://source.impara.de/mc'
    user: ''
    password: ''.
#[
    'MonticelloConfigurations'
] do: [:pkgName | | rg |
  rg := (MCPackage named: pkgName) workingCopy repositoryGroup.
  rg addRepository: repository.
  rg addRepository: httpRepository.
  rg addRepository: primaryRepository.
].
"Make sure that GLASS repository is included"
httpRepository := MCHttpRepository
    location: 'http://seaside.gemstone.com/ss/GLASS'
    user: ''
    password: ''.
MCRepositoryGroup default addRepository: httpRepository.
true
%
errorCount

! workaround for Bug38105
run
HTTPSocketError immediateInvariant.
true
%
errorCount

commit

output pop
errorCount
