!=========================================================================
! Copyright (C) VMware, Inc. 1986-2011.  All Rights Reserved.
!
! Name - upgrade_img.topaz
!
! Purpose - common filein script shared by various upgrade image scripts .
!   The calling script responsible for login/logout and output push
!
! $Id: upgrade_img.topaz,v 1.7 2008-01-09 22:50:20 stever Exp $
!
!========================================================================

! fix TimeZone to match result of bom.c
input $upgradeDir/timezonerename.gs

! filein methods for kernel classes that are created in bom.c
input $upgradeDir/filein1.topaz

input $upgradeDir/bomconv.gs
input $upgradeDir/bomnew.gs

!Create an empty Globals association for GsCurrentSession.
expectvalue %String
run
  (Globals includesKey: #GsCurrentSession) ifFalse:[
    Globals at:#GsCurrentSession put: nil.
    ^ 'added'
  ].
  ^ 'did nothing'
%
expectvalue true
send System _commitPrintingDiagnostics

! create classes and filein methods for classes created in 
! GemStone Smalltalk
input $upgradeDir/filein2.topaz

! now load the error dictionaries
input $upgradeDir/errordict.gs
input $upgradeDir/errors.gs

! final fixup of various methods with foward refs and other stuff relating
! to segments and user profiles.
input $upgradeDir/bomlastconv.gs

commit

logout
input $upgradeDir/gcuser.gs
input $upgradeDir/nameless.gs
input $upgradeDir/sessionmethods.topaz

set gemstone $stoneName user SystemUser pass swordfish
login

input $upgradeDir/upgradeAllSymbols.topaz

!========================================================================
!   Set the imageVersion
!========================================================================

input $upgradeDir/version.topaz
  
!========================================================================
!   Cluster the image
!========================================================================

input $upgradeDir/clusterimage.gs

!========================================================================
!  set database internal compatibility level to current version.
!  this will enable GcGem if config file had it enabled
expectvalue SystemRepository
run
SystemRepository _setVersion 
%

!========================================================================
! save work to this point 
expectvalue true
send System _commitPrintingDiagnostics

!========================================================================
!   Bug 34886 - clean up the image
!========================================================================
input $upgradeDir/removeemptycateg.gs
expectvalue true
send System _commitPrintingDiagnostics

time

!========================================================================
expectvalue %SmallInteger
send UserGlobals at: #ErrCount put: ErrorCount
expectvalue true
send System _commitPrintingDiagnostics

iferror
expectvalue 0
send UserGlobals at: #ErrCount put: ErrorCount

expectvalue true
send System _commitPrintingDiagnostics

