| repDir server changeHolder oldChanges newChanges stream installedMC installedVN | Cursor wait showWhile:[ csBlock _ [:csName :block | changeHolder _ (ChangeSet respondsTo: #newChanges:) ifTrue: [ChangeSet] ifFalse: [Smalltalk]. oldChanges _ (ChangeSet respondsTo: #current) ifTrue: [ChangeSet current] ifFalse: [Smalltalk changes]. newChanges _ ChangeSet new name: csName. changeHolder newChanges: newChanges. [block value] ensure: [changeHolder newChanges: oldChanges]]. "Begin by toasting the old SMLoader" (Smalltalk hasClassNamed: #SMLoader) ifTrue: [ (Smalltalk at: #SMLoader) allInstances do: [:e | e myDependents: #(). e delete]. csBlock value: 'SM1-loader-removal' value: [ SystemOrganization removeSystemCategory: 'SM-Loader']]. "Remember installed packages if we have them and toast old SM" (Smalltalk hasClassNamed: #SMSqueakMap) ifTrue: [ installed _ (Smalltalk at: #SMSqueakMap) default installedPackagesDictionary. csBlock value: 'SM1-removal' value: [ "Have no idea why this does not work:" "SystemOrganization removeSystemCategory: 'SM-domain'" "Instead I use the older method:" (SystemOrganization superclassOrder: 'SM-domain') reverseDo: [:class | class removeFromSystem]. SystemOrganization removeEmptyCategories ]]. installedVN _ false. "Install first versions of VersionNumber for SM2 if it is missing, we can't rely on using old SM because it is removed" (Smalltalk hasClassNamed: #VersionNumber) ifFalse: [ ChangeSorter newChangesFromStream: ((('http://map1.squeakfoundation.org/sm/package/35e02e3a-48e2-4843-94ee-e86d651aeafe/autoversion/1/downloadurl') asUrl retrieveContents content) asUrl retrieveContents content unzipped readStream) named: (ChangeSet uniqueNameLike: 'VersionNumber'). installedVN _ true]. "Load the new SM base, version 4, using available Monticello or MCInstaller, and installing version 1 of MCInstaller otherwise" stream _ HTTPClient httpGet: ('http://map1.squeakfoundation.org/sm/package/c4c13ea3-e376-42c7-8d9e-dc23b09f9f29/autoversion/4/downloadurl' asUrl retrieveContents content). installedMC _ false. (Smalltalk hasClassNamed: #MCMczReader) ifTrue: [(MCMczReader versionFromStream: stream) load "Using Monticello"] ifFalse: [ "No Monticello installed, will use MCInstaller and install it first if needed" (Smalltalk hasClassNamed: #MczInstaller) ifFalse: [ ChangeSorter newChangesFromStream: ((('http://map1.squeakfoundation.org/sm/package/af9d090d-2896-4a4e-82d0-c61cf2fdf40e/autoversion/1/downloadurl') asUrl retrieveContents content) asUrl retrieveContents content unzipped readStream) named: (ChangeSet uniqueNameLike: 'MCInstaller'). installedMC _ true]. MczInstaller installStream: stream]. "This clears the default map, but keeps info on installed packages if there where any" map _ (Smalltalk at: #SMSqueakMap) default. installed ifNotNil: [map installedPackagesDictionary: installed]. "Remove old SM Package Loader, if present" map clearInstalledPackageWithId: '047a3b12-7e52-4c5d-be8b-d06635fc4f1c'. "Remove old SqueakMap Base, if present" map clearInstalledPackageWithId: 'fffa45d3-2459-4b7d-b594-9cfae17c864d'. "Remove old SqueakMap loadscript, if present" map clearInstalledPackageWithId: '4f0b9db6-8add-43aa-8d6b-53e6a0ea8442'. "Add that we now have version 4 of SqueakMap2 base, VersionNumber and MCInstaller installed" map noteInstalledPackageWithId: 'c4c13ea3-e376-42c7-8d9e-dc23b09f9f29' autoVersion: '4'. installedVN ifTrue: [map noteInstalledPackageWithId: '35e02e3a-48e2-4843-94ee-e86d651aeafe' autoVersion: '1']. installedMC ifTrue: [map noteInstalledPackageWithId: 'af9d090d-2896-4a4e-82d0-c61cf2fdf40e' autoVersion: '1']. "Make sure map is updated" map loadUpdates. "Install version 2 (bugfixed) of new SMLoader using SM2, hmmm, MCInstaller makes silly changesetnames..." map installPackageWithId: '941c0108-4039-4071-9863-a8d7d2b3d4a3' autoVersion: '2'. "Ok, open a new loader" (Smalltalk at: #SMLoader) open]. "And kill this Process - This is because we don't want to return to the obsolete old SMLoader" Project spawnNewProcessAndTerminateOld: true