. .


Updating Packages in a Bundle

April 7, 2011 11:48:12.888

The development process where I work treats bundles as configurations - manifests for all the proper (for that trunk/branch of development) that will go into a release. Given that, individual developers generally don't publish a bundle. A build is created, and part of that process spits out an associated development image. From there, the developer works (and publishes) the package(s) he or she is responsible for.

So... one of the things I got tired of was "let's see what packages have been updated inside the bundle" - so I added a method like this to the browser:

	"add menu item to RB"

	<menuItem: 'Update Packages in Bundle...'
		icon: nil
		nameKey: #mesPackagesUpdate
		enablement: #isBundleSelected
		indication: nil
		menu: #(#pundleMenu)
		position: 200.1>

	| pundle stream version match |
	(self pundles size > 1 or: [Store.DbRegistry isConnected not])
		ifTrue: [^Dialog warn: 'Select one bundle and/or establish a Store Connection'].
	pundle := self pundles first.
	stream := pundle versionString readStream.
	stream skip: 1.
	version := stream upTo: $,.
	match := version size 

I have a class that handles the actual updating, BundleDef. The relevant code there looks like this:

	self getMatchingRecord.
	self allContainedPackagesAndBundles.
	self updateAllPackages.

That gets any newer published package in the same branch (based on the version string passed in), and then iteratively updates each package (including those in contained bundles). The work is in the last two methods above:

	"get the full collection of contained packages and bundles"

	self allContainedPackagesAndBundlesFor: pundle.
	containedBundles add: pundle.

allContainedPackagesAndBundlesFor: aBundle
	"answer a collection of all the packages I have, regardless of bundles in the middle"

	| items  |
	items := aBundle containedItems.
	items do: [:each |
		each isBundle
			ifTrue: [self allContainedPackagesAndBundlesFor: each.
					containedBundles add: each]
			ifFalse: [containedPackages add: each]].

And finally, the check and update:

	"iterate over the packages and update them"

	containedPackages do: [:each |
		| all newerMatch |
		all := Store.Package allVersionsWithName: each name newerThan: each.
		newerMatch := all detect: [:each1 | versionFragment match: each1 version] ifNone: [nil].
			ifNotNil: [Transcript show: 'Updating: ', each name; cr.
						newerMatch loadSrc]].

I just verified that this works in the upcoming 7.8 release of VW; it probably does use the (soon to be deprecated) Store objects though. I'll have to investigate that soon

Technorati Tags: , ,

posted by James Robertson

 Share Tweet This