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 16:03, 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. The java message format is proposed to be used as it provides bi-directional conversion.

It is tempting to specify it as a prefix using a template where 'n' stands for 'numeric', and 'a' for 'alphanumeric, uppercase could mean required. OSGi version could then be expressed as 'N.n.n.a', but this quickly gets complex as there is the need to reorder the segments, specify delimiters, etc. Syntax like 1N.2n.3n.4a could be used to denote the ordering from major (1), to qualifier(4) - which would allow for something like 5a:1N.2n.3n-4a. If only one delimiter per segment is allowed it could easily added as in the 5a:1N.2n.3n-4a example. There are many issues with such an approach - it is probably not powerful enough to meet all requirements, and even if it is more user friendly and compact than having to specify a full regular expression, it is still looks quite horrible.

An alternative in these cases is to fix the reordering issue when publishing the artifacts as IUs. Previous example pattern could then be expressed as 'N.n.n-a-a' if it is known that the next to last segment will not have a '-' as a valid part of that segment.

But, there are lots of ways to get into trouble here: can segments be empty? how should a trailing segment separator be handled (is it significant?), and much more.

Anything short of a full regular expression will simply not deal with the most complex (and perhaps also least well thought through) numbering schemes. Using a regular expression as a prefix is certainly powerful, but not recommended. Such a pattern would be better expressed in a a proper named type.

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