Skip to content

How to create a .sar file from multiple packages

kris-fillip edited this page Jul 25, 2018 · 8 revisions

Insert this script into your Squeak workspace:

| folder packages preamble |
packages := #('Scamper' 'HTML' 'WebClient').
folder := 'Scamper'.

zip := ZipArchive new.
packages do: [:package | | mczStream workingCopy version |

	mczStream := RWBinaryOrTextStream on: (String new: 10000).
	workingCopy := MCWorkingCopy forPackage: (MCPackage new name: package).
	version := workingCopy newVersion fileOutOn: mczStream.
	(zip addString: mczStream contents as: package, '.mcz') desiredCompressionLevel: 0.
].
zip addTree: Smalltalk imagePath match: [:e | e fullName startsWith:
    Smalltalk imagePath , FileDirectory slash , folder].

preamble := String streamContents: [:stream |  
	packages do: [:package |
	stream nextPutAll: 'self fileInMonticelloZipVersionNamed: '''.
	stream nextPutAll: package.
	stream nextPutAll:  '.mcz''.'.
	stream cr.].
	stream nextPutAll: '(self membersMatching: ''' , folder , FileDirectory slash , '*.*'') do: [ :f | self
    extractMember: f].' ].
zip addString: preamble as: 'install/preamble'.

zip writeToFileNamed: 'scamper.sar'.

Modify packages as needed, and run the script. Just Accept every single popup and wait for the script to finish.

Congratulations! You will now find the .sar file in the Resources folder of your Squeak image.