How can I specify version-dependent prerequisites?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How can I specify version-dependent prerequisites?

Joachim Geidel
Hi list,

I am trying to prepare JNIPort for VisualWorks 7.6. I found that I have
to specify version dependent prerequisites. E.g., I had to add
Character>>codePoint for compatibility with the Dolphin Smalltalk
version of JNIPort. This method did not exist in 7.5, but VW 7.6
implements it. There are some more things which make it necessary to
either load different packages in 7.5 and 7.6, or to load different
versions of the same package.

Store pretends to enable something like this with the "Prerequisite
Version Selection Action" (Source Code Management Guide, section
"Specify prerequisite version", p. 4-11). However, this feature does not
do what I need, and it also has a bug which I have reported in a
separate mail to the vw-dev list.

What I need is a way to specify one of the following:

- In VW 7.5, load the package 'JNIPort VW Extensions 75', in VW 7.6,
load the package 'JNIPort VW Extensions 76', with no versions specified.

- In VW 7.5, load the package 'JNIPort VW Extensions' with a version
matching '7.5*', in VW 7.6, load the same package with a version
matching '7.6*'.

It does not matter if this is done by defining prerequisites or by
defining bundle contents.

There is an additional constraint: As JNIPort is an open source project,
the solution must not depend on a custom PrerequisitePolicy, as my
"customers" must be able to use their own policy.

I could do it with a post-load action which checks "ObjectMemory
versionId" to determine the VisualWorks version and then loads another
package, but I am not sure if this would break the loading process,
especially with shadow loading.

Any ideas?

Thanks in advance,
Joachim Geidel





Reply | Threaded
Open this post in threaded view
|

Re: How can I specify version-dependent prerequisites?

Joachim Geidel
Hello everybody,

> I am trying to prepare JNIPort for VisualWorks 7.6. I found that I have
> to specify version dependent prerequisites. E.g., I had to add
> Character>>codePoint for compatibility with the Dolphin Smalltalk
> version of JNIPort. This method did not exist in 7.5, but VW 7.6
> implements it. There are some more things which make it necessary to
> either load different packages in 7.5 and 7.6, or to load different
> versions of the same package.

Just in case someone else has the same problem, here is how I solved it:

- I moved code which is specific for VisualWorks 7.5 or older versions
to a separate package. It is called "JNIPort VW75 Extensions" and is not
part of any of the JNIPort bundles.

- In the post-load block of "JNIPort VW Extensions" which is loaded in
all VW versions, the version of the VisualWorks image is checked. If
needed, the version-specific package is loaded.

The code of my post-load block is in the attachment. It gets a list of
all versions of the prerequisite package, which is sorted by timestamp
in descending order, i.e. latest versions first. It tries to find the
latest version with a blessing level at least as high as the blessing
level of the package which defines the post-load block. If no such
version exists, it tries to find one which has at least the "Development"
blessing. If found, the package version is loaded.

This technique can also be used in other cases, e.g. if you want
to load special code when another package (third-party code etc.) is
loaded/not loaded.

Best regards,
Joachim Geidel

[:package |
| systemVersion |
systemVersion := ObjectMemory versionId.
((systemVersion at: 5) < 75 "pre-7.5"
or: [(systemVersion at: 5) = 75 and: [(systemVersion at: 6) = 0] "7.5 - if the 6th element is 1, its a 7.6 pre-release image"])
        ifTrue:
                [| versions matchingVersion myBlessingLevel developmentBlessingLevel |
                versions := Store.Package allVersionsWithName: 'JNIPort VW75 Extensions'.
                myBlessingLevel := package parentRecord blessingLevelNumber.
                developmentBlessingLevel := Store.Policies blessingPolicy developmentBlessing.
                matchingVersion := versions
                                                detect: [:each | each blessingLevelNumber >= myBlessingLevel]
                                                ifNone: [versions detect: [:each | each blessingLevelNumber >= developmentBlessingLevel] ifNone: [nil]].
                matchingVersion ifNotNil: [matchingVersion loadSrc].
                ].
]