Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Equinox/p2/Omni Version

< Equinox‎ | p2
Revision as of 18:25, 2 December 2008 by Henrik.lindberg.puppet.com (Talk | contribs) (Exploring a possible pattern based type)

Under Construction

Introduction

This page describes a proposal for adding support for non OSGi version and version ranges in Equinox p2. This page was created as a result of the discussion on the p2 call on Dec 1, 2008.

Background

There are other versioning schemes in wide use that are not compatible with OSGi version and version ranges. The problem is both syntactic and semantic.

Example of semantic issue

Many open source projects do their versioning in a fashion similar to OSGi but with one very significant difference. For two versions that are otherwise equal, a lack of qualifier signifies a higher version then when a qualifier is present. I.e.

1.0.0.alpha 
1.0.0.beta
1.0.0.rc1
1.0.0

The 1.0.0 is the final release. The qualifier happens to be in alphabetical order here but that's not always true.

Example of syntax issue

Here are some examples of versions used in Red Had Fedora distributions.

KDE Admin version 7:4.0.3-3.fc9
Compat libstdc version 33-3.2.3-63
Automake 1.4p6-15.fc7

These are not syntactically compatible with OSGi versions as they use colon, and dash as leading separators.

Current implementation in p2

The current implementation in p2 uses the classes Version and VersionRange to describe the two concepts and these are implementations handling only OSGi version type.

Proposed Solution

Equinox p2 should support a set of "built in" version types. After a lengthy discussion about various "chicken and egg" type of problems relating to dynamic version type specifications and when and how the need for a particular version type is detected, and when it needs to be installed the meeting came to the conclusion that support for a "handful of built in types" would be sufficient as a starting point.

  • The interfaces IVersion and IVersionRange should be used throughout the code instead of directly using the corresponding Version and VersionRange classes.
  • An IVersion is obtained by calling a factory method such as VersionFactory.create(String versionString)
  • An IVersionRange is obtained by a similar factory method
  • The version string and version range has a URI scheme like prefix to indicate the version type
  • The factory API can naturally contain some options where scheme and version strings are either separate or canonical
  • When a version or version range is present without the version type prefix, the default is to use OSGi version type (this preserves backwards compatibility).

Proposed Version Types

type name description
alpha A alhpa numeric sequence of arbitrary depth separated by '.' e.g. 'mango.banana.0003.smoothie'. This type primarily exists to enable encoding of complex types. Segments may not contain reserved version range delimiters. A complex type is one that requires:
  • more than one alhpa compared segment
  • more than three numerical segments in combination with alpha segement(s)
  • alpha segment(s) in combination with less than three numerical segments
  • non '.' segment separators

As it is difficult to know how many zeros to pad with when a "numeric" comparison is required, a variation could be to have a special reserved character for a '"pseudo numeric" segment. As an example let's pick '-' which would mean that the previous example could be written 'mango.banana.-3.smoothie'. Comparison is still alphanumeric but it is always zero padded to the same length before comparison. (i.e. '2' becomes '002' when compared against '123' and '00002' when compared against 'mango'). Special cases needs to be worked out (i.e. does '-mango' become '-000mango' when compared against '12345678', and how can a segment be started with the special character? ('..' could be used as that would otherwise be an illegal combination, or we need an escape mechanism when '-' is needed in the starting position)).

numeric A numeric sequence of arbitrary depth separated by '.' e.g. 1.1.1.1.1.1
osgi The default OSGi version type.
string A free form string version that may contain any character except the reserved version range delimiters. Can imagine calling this "text" which perhaps makes it easier to differentiate from "alpha".
timestamp Time stamps compared in ascending order.
triplet A variation on OSGi, with the same syntax, but where the a lack of qualifier > any qualifier.

The version range delimiters are: '(', ')', '[', ']' and , ',' (comma).

Exploring a possible pattern based type

A "pattern based" type would be of value where it is possible to specify number of segments, their significance, use of numeric or string comparison, and what delimiters to use. There are some options for describing such patterns:

  • Regular expression transformation to a supported version type
  • Java Message Format transformation to a supported version type

The regular expression is the most powerful transformation, but is somewhat complicated to write and to understand by a human. The message format has the benefits of being bidirectional and being easier to read by a human, but it can however not be used to describe optional parts.

The best is probably to use regular expression transformation to canonical form, while retaining the original version string for presentation purposes (as opposed to formatting the canonical form back to the original - this as the original may have surplus information that is not made use of in the canonical form).

An IU publisher would create the IU with a "pattern" version type, the regular expression pattern is stored in a IU property, and the original version string is kept in a "original.version" (or similar property). The canonical form for the "pattern" version type can be the same as for the "alpha" type. The p2 engine does not make use of the pattern, all version comparisons are performed using the canonical form.

When presenting the version in a UI, the original version string value can be used.

Specifying a dependency on a specific version can be done by looking up the IU and then picking the version type pattern from that IU. A problem is when a user needs to specify a dependency on a range as the pattern is not known unless picked up first from the IU that specifies it. Once the pattern is known, the boundaries could be entered in the original form, and then parsed by the pattern.

When comparing two pattern based versions the pattern does not have to be taken into account. One could argue that patterns would need to be the same, but there are many ways to write a regular expression that parses the version format into the canonical form.

A more relaxed way of handling this would be to not encode the version at the required capability end. The comparison would instead be based on the format in the candidate IU. It would then not be possible to validate the correctness of the version format at the required capability end, but seems like a small price to pay for getting rid of having keep track of the transformation rule. All responsibility is placed on the publisher.

Exploring Internationalization

The two types string and alpha (as proposed) would use vanilla string comparison. This does not work so well if versions are expressed in a local language were lexical ordering is different. This could be supported by combining "string" and "alpha" with the name of a ISO 639 Language code (see java.util.Locale) and where the default would be english. The language could be encoded with a separating '-' e.g. 'string-pt' for collation in portuguese.

This opens up another can of worms (decomposition strength, comparison of locale and non locale specified types, etc.), and it is probably best to implement just basic string comparison in the first release.

Version Range

Version range uses the osgi syntax, but prefixed with version type name.

Examples:

  • [1.0.0,2.0.0] equal to osgi:[1.0.0,2.0.0]
  • string:[titanic,andrea doria]
  • alpha:[0007.0004.0000.0003.0003.fc9,0008] - an ecoding of example KDE Admin version 7:4.0.3-3.fc9 to 8:
  • triplet:[1.0.0.RC1,1.0.0]

Factory API

TBD

IVersion and IVersionRange API

TBD

Back to the top