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

Difference between revisions of "Equinox/p2/Omni Version"

< Equinox‎ | p2
Line 1: Line 1:
{{CommentBox|Changes made December 30,2008
+
{{CommentBox|'''Changes made December 30,2008'''
 
* Modified rules for 's' to mean only alpha characters, and added S for 'any character'
 
* Modified rules for 's' to mean only alpha characters, and added S for 'any character'
 
* Removed requirement that 'next element start' acts as delimiter for previous element. Care must be taken when using a, s, S, elements so they do not include intended delimiter in the parsed string.
 
* Removed requirement that 'next element start' acts as delimiter for previous element. Care must be taken when using a, s, S, elements so they do not include intended delimiter in the parsed string.
Line 6: Line 6:
 
* The 'a' rule with character count now treats 'change of type' as a delimiter
 
* The 'a' rule with character count now treats 'change of type' as a delimiter
  
Changes made to simplify rules and ensure performant parsing.
+
Changes above made to simplify rules and ensure performant parsing.
  
Changes made December 29, 2008:
+
'''Changes made December 29, 2008:'''
 
* The 'a' format does not support quoted strings
 
* The 'a' format does not support quoted strings
 
* Added format rule 'N' to allow negative integers
 
* Added format rule 'N' to allow negative integers
 
* Added raw element '-M' with the meaning -MAX_INT
 
* Added raw element '-M' with the meaning -MAX_INT
  
Reworked proposal after discussion Dec 15, 2008 - Ready for review.
+
'''Reworked proposal after discussion Dec 15, 2008 - Ready for review.'''
 
Summary of changes:
 
Summary of changes:
 
* Previous proposal alllowed multiple implementations of Version and VersionRange. The new proposal  is to only support a single implementation.
 
* Previous proposal alllowed multiple implementations of Version and VersionRange. The new proposal  is to only support a single implementation.

Revision as of 19:58, 30 December 2008

Changes made December 30,2008
  • Modified rules for 's' to mean only alpha characters, and added S for 'any character'
  • Removed requirement that 'next element start' acts as delimiter for previous element. Care must be taken when using a, s, S, elements so they do not include intended delimiter in the parsed string.
  • 'q' now has stricter meaning - it only accepts quoted strings
  • It is now allowed to have nested arrays
  • The 'a' rule with character count now treats 'change of type' as a delimiter

Changes above made to simplify rules and ensure performant parsing.

Changes made December 29, 2008:

  • The 'a' format does not support quoted strings
  • Added format rule 'N' to allow negative integers
  • Added raw element '-M' with the meaning -MAX_INT

Reworked proposal after discussion Dec 15, 2008 - Ready for review. Summary of changes:

  • Previous proposal alllowed multiple implementations of Version and VersionRange. The new proposal is to only support a single implementation.
  • The 'any' format has been removed
  • The 'raw' format has been change to the new name 'format', and 'raw' is now used to describe a canonical version
  • The pattern language have been made more powerful - since new version types can not be plugged in
  • A proposal how to handle sharing of named patterns has been added - some more work is required though
  • An FAQ has been added at the end, answering some of the questions asked by reviewers

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. See bug 233699 for discussion.

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 issues

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.

Mozilla Toolkit versioning has many rules and where each segment has 4 (optional slots; numeric, string, numeric, and string where each slot has a default value of being 0 or "max string" if missing).

1.2a3b.  // yes, a trailing . is allowed and means .0
1.a2

Mozilla also allows bumping the version (using an older Mozilla scheme)

1.0+ 

This means 1.1pre in mozilla.

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

And here are some mozilla toolkit versions:

1.*.1
1.0+
1.-1  // yes, negative integer version numbers are allowed, the - is not a delimiter
1.2a3b.a

These are not syntactically compatible with OSGi versions.

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

One implementation of Version and VersionRange

Equinox p2 should have one implementation of Version and one of VersionRange (called OmniVersion, and OmniVersionRange in this proposal just to give these implementation different names) capable of capturing the semantics of various version formats. The advantages over previous proposal are that there is no need to dynamically plugin new implementations, and new formats can be more easily be introduced.

Even if the finished solution only requires a single implementation (the OmniVersion discussed below), there are other factors to consider. The current p2 SimplePlanner uses the OSGi planner, and it can only understand OSGi versions. There is work being done on SAT4J to enable it being used instead of the OSGi planner (work to handle "explanations" could also be used to handle "attachments" (now being done with OSGi planner).

See bug 233699 for more information. A patch is now proposed that has the p2 Version and VersionRange classes broken out, and where these are translated to OSGI version and version range where needed.

With this patch it is possible to replace the p2 Version and VersionRange with the Omni implementation and replace SimplePlanner's use of OSGi planner with a similar planner that handles OmniVersion. This can be done by someone that needs support for different versions formats before the SAT4j solution is available.

One Canonical Format

The OmniVersion and OmniVersion range should be "universal" - all instances of Version should be comparable against each other with a fully defined (non ambiguous) ordering. The API could (as today) be based on a single string fully describing a version or version range, or use a structured approach to describe the canonical, original, and transformation rule in separate strings. In both cases, having string representation in the API is probably the best.

This proposal is based on the assumption that a single string is used.

The canonical string format is called "raw" and it is explained in more detail below. To ensure backwards compatibility, as well as providing ease of use in an osgi environment, version strings that are not prefixed with the keyword "raw" have the same format and semantics as the current osgi version format.

Ad an example the following two version strings are both valid input, and express exactly the same version:

1.0.0.r1234
raw:1.0.0.'r1234'

Implementation of Omni Version and VersionRange

An implementation is being developed in parallell with this specification.

OmniVersion

The OmniVersion implementation uses an Object Array to store version-segements in order of descending significance. A segment is an instance of Integer, String, Comparable[], MaxInteger, MaxString, or Pad. A Pad instance has a reference to one version segment used as padding. Pad can only be placed last in a version segment array.

Comparison

Comparison is done by iterating over segments from 0 to n.

  • If a segment is a pad segment, the referenced version segment is used in the comparison.
  • If segments are of different type the rule MaxInteger > Integer > Comparable[] > MaxString > String is used - the comparison is done and the version with the greater segment type is reported as greater.
  • If segments are of equal type - they are compared - if one is greater the comparison is done and the version with the greater segment is reported as greater.
  • If the shorter of two versions has a pad segment, the extra segments in the longer version are compared against this pad segment.
  • If all segments are equal up to end of the shortest segment array, the longer version is reported as greater.
  • As a consequence of not including delimiters in the canonical format; two versions are equal if they only differ on delimiters.

Raw and Original Version String

The original version should be kept when the raw version format is used, but it is not an absolute requirement as simple raw based forms such as raw:1.2.3.4.5 could certainly be used by humans. Someone (who for some reason does not want to use osgi or some other version scheme), could elect to use the raw format as their native format.

A version string with raw and original is written on the form:

  'raw' ':' raw-format-string '/' original-format-string

The p2 Engine completely ignores the original part - only the raw part is used, and the original format is only used for human consumption.

Example using a mozilla version string (as it has the most complex format encountered to date).

  raw:<1.m.0.m>.<20.'a'.3.'b'>p<0.m.0.m>/format((<n=0;?s=m;?n=0;?s=m;?>(.<n=0;?s=m;?n=0;?s=m;?>)*)=pad(<0.m.0.m>):1.20a3b.a

An original version string can be included with unknown format:

  raw:<1.m.0.m>.<20.'a'.3.'b'>p<0.m.0.m>/:1.20a3b.a

See below for full explanation of the raw format.

OmniVersionRange

The OmniVersionRange holds two OmniVersion instances (lower and upper bound). A version range string uses the delimiters '[]', '()' and ','. If these characters are used in the lower or upper bound version strings, these occurrences must be escaped with '\' and occurrences of '\' must also be escaped.

The version range is either an osgi version range (if raw prefix is not used), or a raw range. The format of the raw range is:

  'raw' ':' ( '[' | '(' ) raw-format-string ',' raw-format-string ( ']' | ')' ) 

The raw-range can be followed by the original range:

  raw-range '/' ( '[' | '(' ) original-format-string ',' original-format-string ( ']' | ')' )

The p2 Engine completely ignores the original part - only the raw part is used, and the original format is only used for human consumption.

See below for full explanation of the raw format.

Other range formats

Note that some version schemes have range concepts where the notion of inclusive or exclusive does not exist, and instead use symbolic markers such as "next larger", "next smaller", or use wildcards to define ranges. In these cases, the publisher of an IU must use discrete versions and the inclusive/exclusive notation to define the same range.

Some range specifications allows the specification of union, or exclusion of certain versions. This is not yet supported by p2. If introduced it could be expressed as a series of ranges where a ^ before a range negates it. Example [0,1][3,10]^[3.1,3.7) equivalent to [0,10]^(1,3)^[3.1,3.7)

Format Specification

There are two basic formats default osgi string format, and raw canonical string format. There are also two corresponding range formats osgi-version-range, and raw-version-range.

The raw format is a string representation of the internally used format - it consists of the keyword "raw", followed by a list of entries separated by period. An entry can be numerical, quoted alphanumerical, or a sub canonical list on the same format. A canonical version (and sub canoncial version arrays) can be padded to infinity with a special padding element. Special entries express the notion of 'max integer' and 'max string'.

The osgi string format is the well known format in current use.

   digit: [0-9];
   letter: [a-zA-Z];
   numeric : digit+;
   alpha : letter+;
   alpha-numeric : [0-9a-zA-Z]+;
   delimiter: [^0-9a-zA-Z];
   character: .;
   characters .+;
   quoted-string: ("[^"]*")|('[^']*');  // i.e a sequence of charactes quoted with " or ', where ' can be used in a " quoted string and vice versa
   range-safe-string:  TBD; // a sequence of any characters but with ',' ']', ')' and '\' escaped with '\';
   sq: ['];
   dq: ["];

   version :
      | osgi-version
      | raw-version
      ;
   osgi-version :
      | numeric
      | numeric '.' numeric
      | numeric '.' numeric '.' numeric
      | numeric '.' numeric '.' numeric '.' .+
      ;
   raw-version : 
      | 'raw' ':' raw-segments optional-original-version
      ;
   optional-original-version :
      |
      | '/' original-version
      ;
   version-range : 
      | osgi-version-range
      | raw-version-range
      ;
   rs : ('[' | '(') ;
   re : (']' | ')') ;

   osgi-version-range : 
      | rs osgi-version ',' osgi-version re
      ;
   raw-version-range : 
      | 'raw' ':' rs raw-segments ',' raw-segments re optional-original-range
      ;
   optional-original-range :
      | 
      | '/' original-range
      ;

   raw-segments : 
      | raw-elements optional-pad-element
      ;
   raw-elements :
      | raw-elements '.' raw-element
      | raw-element
      ;
   raw-element :
      | numeric
      | quoted-strings  // strings are concatenated
      | '<' raw-elements optional-pad-element '>'   // subvector of elements
      | 'm'   // symbolic 'maxs' == max string 
      | 'M'   // symbolic 'absolute max' i.e. max > MAX_INT > maxs
      | '-M // symbolic 'absolute min' i.e. -M <  empty string < array <  int
      ;
   optional-pad-element :
      |
      | pad-element 
      ;
   quoted-strings :
      | quoted-strings quoted-string
      | quoted-string
      ;
   pad-element :
      | 'p' raw-element
      ;

   original-version :
      | optional-format-definition ':' .*
      ;
   original-range :
      | optional-format-definition ':' rs range-safe-string ',' range-safe-string re
      ;
   optional-format-definition :
      | 
      | format-definition
      ;
   format-definition :
      | 'format' '(' pattern ')'
      ;

   // Definition of parsing patterns
   //
   pattern :
      | pattern pattern-element
      | pattern-element 
      ;
   pattern-element :
      | pelem optional-processing-rules optional-pattern-range
      | '[' pattern ']' processing-rules
      ;
   optional-processing-rules :
      | optional- processing-rules '=' processing-rule ';'
      | '=' processing-rule ';'
      | 
      ;
   optional-pattern-range :
      | repeat-range
      | 
      ;

   pelem 
      | 'r' | 'd' | 'p' | 'a' | 's' | 'S' |  'n' | 'N' | 'q'
      | '(' pattern ')'
      | '<' pattern '>'
      | delimiter
      ;
   repeat-range : 
      | '?' | '*' | '+'
      | '{' exact '}'
      | '{' at-least ',' '}'
      | '{' at-least ',' at-most '}'
      ;

   exact : at-least : at-most : numeric ;

   processing-rule :
      | raw-element
      | 'pad' '(' raw-element ')'
      | 'ignore' 
      | '[' char-list ']'
      | '[' '^' char-list ']'
      | '{' exact '}'   // for character count
      | '{' at-least ',' '}'
      | '{' at-least ',' at-most '}'
      ;
   char-list: TBD ; // Sequence of any character but with '^', ']' and '\' escaped with '\' 
   delimiter : 
      | [!#$%&/=^,.;:-_ ] // Any non-alpha-num that has no special meaning
      | quoted-string
      | '\' .  // any escaped character
      ;
   


Examples:

  • OSGi 1.0.0.r1234 is expressed as raw:1.0.0.'r1234'
  • apache/triplet style 1.2.3 is expressed as raw:1.2.3.m
  • mozilla style 1a.2a3c. can be expressed as raw:<1.'a'.0.m>.<2.'a'.3.'c'>p<0.m.0.m> (mozilla is a complex format - see external links at the end of page).

Format Pattern Explanation

Here are explanations for the ruels in format(pattern).

rule description
r raw - matches one raw-element as specified by the raw format. If the matching 'r' element is the last element in the input string it may also be a pad-element.
'characters' matches a single character or sequence of characters - the matched result is not included in the resulting canonical vector (i.e. it is not a segment). A '\\' is needed to include a single '\'. The sequence of chars acts as one delimiter.
non-alphanum character matches any non alpha-numerical character (including space) - the matched result is not included in the canonical vector (i.e. it is not a segment). A non alphanumerical character acts as a delimiter. Special characters must be escaped when wanted as delimiters.
a auto - a sequence of digits creates a numeric segment, a sequence of alphabetical characters creates a string segment. Segments are delimited by any character not having the same character class as the first character in the sequence, or by the following delimiter. A numerical sequence ignores leading zeros.
d delimiter; matches any non alpha-numeric character.
s a string group matching only alpha characters (i.e. "letters"). Use processing rules =[]; or =[^] to define the set of allowed characters. It is possible to allow inclusion of delimiter chars, but not inclusion of digits.
S a string group matching any group of characters. Use processing rules =[]; or =[^] to define the set of allowed characters. Care must be taken to specify exclusion of a delimiter if elements are to follow the 'S'.
n a numeric (integer) group with value >= 0. Leading zeros are ignored.
N a possibly negative value numeric (integer) group. Leading zeros are ignored.
p parses an explicit pad-element in the input string as defined by the raw format. To define an implicit pad as part of the pattern use the processing instruction =pad(). A pad element can only be last in the overall version string, or last in a sub array.
q smart quoted string - matches a quoted alphanumeric string where the quote is determined by the first character of the string segment. The quote must be a non alphanumeric character, and the string must be delimited by the same character except brackets and parenthesises (i.e. (), {}, [], <>) which are handled as pairs, thus 'q' matches "<andrea-doria>" and produces a single string segment with the text 'andrea-doria'. A non-quoted sequence of characters are not matched by 'q'.
() indicates a group
< > indicates a group, where the resulting elements of the group is placed in an array, and the array is one resulting element in the enclosing result
? zero to one occurrence of the preceding rule
* zero to many occurrences of the preceding rule
+ one to many occurrences of the preceding rule
{n} exactly n occurrences of the preceding rule
{n,} at least n occurrences of the preceding rule
{n,m} at least n occurrences of the preceding rule, but not more than m times
[ ] short hand notation for an optional group. Is equivalent to ()?
=processing; an additional processing rule is applied to the preceding rule. The processing part can be:
  • raw-element - use this raw-element (as defined by the raw format) as the default value if input is missing
  • ignore - if input is present do not turn it into a segment (i.e. ignore what was matched)
  • [<list of chars>] - when applied to a 'd' defines the set of delimiters. The characters ], ^, and \ must be escaped with \ to be used in the list of chars. and Example d=[+-/]; One or several ranges of characters such as "a-z" can also be used. Example d=[a-zA-Z0-9_-];
  • [^<list of chars>] - when applied to a 'd' defines the set of delimiters to be all non alpha numeric except the listed characters. The characters ], ^, and \ must be escaped with \ to be used in the list of chars. One or several ranges of characters such as "a-z" can also be used. Example d=[^$]
  • pad(raw-element) - defines "padding to infinity with specified raw-element" when applied to an array, or a group enclosing the entire format. Example format((n.s)=pad(M);) The pad processing rule is only applied to a parsed array, not to a default value for an array. If padding is wanted in the default array value, it can be expressed explicitly in the default value.
  • {n} {n,} {n,m} character ranges - with the same meaning as the rules with the same syntax, but limits the range in characters matched in the preceding 's', 'S', 'n', 'N', 'q', or 'a' rules. For 'q' the quotes does not count.
\ escape removes the special meaning of a character and must be used if a special character is wanted as a delimiter. A '\\' is needed to include a '\'. Escaping a non special character is superflous but allowed.

Additional rules:

  • if a rule produces a null segment, it is not placed in the result vector e.g. format(ndddn):10-/-12 => raw:10.12
  • Processing (i.e. default values) applied to a group has higher precedence than individual processing inside the group if the entire group was not successfully matched.
  • Parsing is greedy - format(n(.n)*(.s)*) will interpret 1.2.3.hello as raw:1.2.3.'hello' (as opposed to being reluctant which would produce raw:1.'2'.'3'.'hello')
  • When combining N with ={...}; and the input has a negative number, the "-" is included in the character count - "format(N{3}N{2}):-1234" results in "raw:-123.4"
  • When combining n or N with ={...} and input has leading zeros - these are included in the character count.

Note about white space in the raw format:

  • white space is accepted inside quoted strings - i.e. "1.'a string'" is allowed, but not "1. 2"
  • white space is accepted between version range delimiters and version strings - i.e. [ 1.0, 2.0 ] is allowed.

Note about timestamps An earlier proposal had a 't' rule, but this rule has been deprecated because of the complexity. Instead, the creator of an IU should simply use 's' or 'n' and ensure comparability by using a fixed number of characters when choosing 's' format.

Examples of Version Formats

Here are examples of various version formats expressed as using the format pattern notation. The examples also show the notation of using the names of the patterns as aliases for predefined patterns. (See the section 'defining named formats')

type name pattern comment
osgi n[.n=0;[.n=0;[.S=[a-zA-Z0-9_-];]] Example: the following are equivalent:
  • format(n[.n=0;[.n=0;[.S=[a-zA-Z0-9_-];]]]):1.0.0.r1234
  • raw:1.0.0.'r1234'
  • osgi:1.0.0.r1234
  • 1.0.0.r1234
triplet n[.n=0;[.n=0;[.S=m;]]] A variation on OSGi, with the same syntax, but where the a lack of qualifier > any qualifier, and the qualifier may contain any character. The following are all equivalent:
  • format(n[.n=0;[.n=0;[.S=m;]]]):1.0.0
  • raw:1.0.0.M
  • triplet:1.0.0
jsr277 n(.n=0;){0,3}[-S=m;] As defined by JSR 277 - but is provisional and subject to change as it is expected that compatibility with OSGi will be solved (they are now incompatible because of the fourth numeric field with default value 0). The jsr277 format is similar to triplet, but with 4 numeric segments and a '-' separating the qualifier to allow input of "1-qualifier" to mean "1.0.0.0-qualifier". As in triplet the a lack of qualifier > any qualifier. The following are all equivalent:
  • format(n(.n=0;){1,3}[-S=m;]):1.0.0
  • raw:1.0.0.0.M
  • jsr277:1.0.0
tripletSnapshot n[.n=0;[.n=0;[-n=M;.S=m;]]] Format used when maven transforms versions like 1.2.3-SNAPSHOT into 1.2.3-<buildnumber>.<timestamp> ensuring that it is compatible with triplet format if missing <buildnumber>.<timestamp> at the end (format produces max, max-string if they are missing).

Example: the following are equivalent:

  • format(n[.n=0;[.n=0;[-n=M;.S=m;]]]):1.2.3-45.20081213:1233
  • raw:1.2.3.45.'20081213:1233'
  • tripletSnapshot:1.2.3-45.20081213:1233
rpm <[n:]a(d?a)*>[-n[dS=ignore;]] RPM format matches [EPOCH:]VERSION-STRING[-PACKAGE-VERSION], where epoch is optional and numeric, version-string is auto matched to arbitrary depth >= 1, followed by a package-version, which consists of a buildnumber separated by any separator from trailing platform specification, or the string 'src' to indicate that the package is a souce package. This format allows the platform and src part to be included in the version string, but if present it is not used in the comparisons. The platform type vs source is expected to be encoded elsewhere in such an IU. Everything except the build-number is placed in an array as build number is only compared if there is a tie.

An example of equivalent expressions:

  • format(<[n:]a(d?a)*>[-n[dS=ignore;]]):33:1.2.3a-23/i386
  • raw:<33.1.2.3.'a'>.23
mozilla (<n=0;?s=m;?n=0;?s=m;?>(.<n=0;?s=m;?n=0;?s=m;?>)*)=pad(<0.m.0.m>); Mozilla versions are somewhat complicated, it consists of 1 or more parts separated by period. Each part consists of 4 optional 'fragments' (numeric, string, numeric,string), where numeric fragments are 0 if missing, and string fragments are MAX-STRING if missing. The versions use padding so that 1 == 1.0 == 1.0.0 == 1.0.0.0 etc.
string S Perhaps superflous, but makes this version format appear in a selectable list of formats.
auto a(d?a)* Perhaps superflous, but makes this version format appear in a selectable list of formats, and it serves like a "catch all".

Defining named formats

An IU can define new named formats. The named formats are defined by using a list of defined format names, and then one property per format.

org.equinox.p2.version.formats=<format-name>, <format-name>, ...
org.equinox.p2.version.format.<format-name>=formatstring

Once the format has been specified, it may be used in the IU. The format name should use java package name semantics to ensure unintentional clashes. When using the format names, the user may specify the last part of the name if it is unique. The predefined named formats should not be included in the formats property.

Thus, if an IU introduces the two named formats "org.mycorp.docver", and "org.mycorp.dbdataver" they are described like this:

org.equinox.p2.version.formats=org.mycorp.docver, org.mycorp.dbdataver
org.equinox.p2.version.format.org.mycorp.docver=n.n[s=max;]
org.equinox.p2.version.format.org.mycorp.dbdataver=n.'R'n[.s=ignore;]

When an IU is stored in a repository, the following processing is done:

  • The defined formats are extracted from the IU
  • If the fomat name does not already exist in the repository, it is added to the repositories list of contained formats.
  • If the format name already exists in the contained formats list and the format pattern is the same - nothing needs to be done
  • If the format name already exists in the contained formats list and the format pattern for the contained name is different - an exception is thrown

When using a non standard format name in an IU:

  • The format definition must also be stored in the IU.

Attempting to redefine pre-defined formats:

  • The pre-defined formats have higher precedence - should throw an exception

The user interface can:

  • collect all defined formats from all known repositories and present them when the user is defining a version or range
  • have a function to define a new format which is stored in the current profile (and thus becomes available for use)

This scheme allows format names to spread virally. The possible downside is potential clashes between repositories (same format name with different definitions in two different repositories) - but this is not a unique problem for version format. A particular IU of a particular version, or a particular artifact of a particular version, could very well be different in two repositories. As an aid/indicator, the UI can flag conflicting formats to the user.

A repository management tool could have a feature to enable modifying/replacing version fomats thus allowing repair.

Notes:

  • An issue to solve is how a user can consume formats prior to contacting repositories.
  • There should probably be a URL to a webpage that explains the format

More examples using 'format'

A version range with format equivalent to OSGi

format(n[.n=0;[.n=0;[.S=[a-zA-Z0-9_-]]]):[1.0.0.r12345, 2.0.0]

At least one string, and max 5 strings

format(S=[^.][.S=[^.];[.S=[^.][.S=[^.][.S=[^.]]]]]):vivaldi.opus.spring.bar5
format(S=[^.](.S=[^.]){0,4}):vivaldi.opus.spring.bar5  => 'vivaldi'.'opus'.'spring'.'bar5'

At least one alpha or numerical with auto format and delimiter

format(a(d?a)*):vivaldi:opus23-spring.bar5  => 'vivaldi'.'opus'.23.'spring'.'bar'.5

The texts 'opus' and 'bar' should not be included:

format(s[.'opus'n[.'bar'n]]):vivaldi.opus23.bar8   => 'vivaldi'.23.8

The first string segment should be ignored - it is a marketing name:

format(s=ignore;.n(.n)*):vivaldi.1.5.3

Classic SCCS/RCS style:

format(n(.n)*):1.1.1.1.1.1.1.4.5.6.7.8

Max depth 8 of numerical segments (limited classic SCCS/RCS type versions):

format(n(.n){0,7}):1.1.1.1.1.1.1.4

Numeric to optional depth 8, where missing input is set to 0, followed by optional string where 'emtpy > any'

format(n(d?n=0;){0,7}[a=M;]):1.1.1.4:beta   => 1.1.1.4.0.0.0.0.'beta'
format(n(d?n=0;){0,7}[a=M;]):1.1.1.4   => 1.1.1.4.0.0.0.0.M

Single string range

format(S):[andrea doria,titanic]

Range examples

Examples:

  • raw:[1.2.3.'r1234',2.0.0]
  • [1.2.3.r1234,2.0.0]
  • format(a+):[monkey.fred.ate.5.bananas,monkey.fred.ate.10.oranges]
  • [1.0.0,2.0.0] equal to osgi:[1.0.0,2.0.0]
  • format(S):[andrea doria,titanic]
  • rpm:[7:4.0.3-3.fc9,8:1] - an example KDE Admin version 7:4.0.3-3.fc9 to 8:1
  • triplet:[1.0.0.RC1,1.0.0]

Internationalization

The proposed types using alphanumerical segments are assumed to use vanilla string comparison. This does not work so well if versions are expressed in a language where lexical ordering is different. Language specific collation could be supported by combining version type name 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. 'format-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. It is also questionable if internationalization is wanted at all, as "known tools" does not support this, and "correct collation" would thus yield a different result.

Support for internationalized collation is not recommended.

Applicability

The generalization of version type applies to objects that by nature may have a different versioning scheme than OSGi. This includes:

  • Installable Unit
  • Provided Capability
  • Required Capability
  • Artifact key

These does not need to be generalized:

  • File format version numbers (content.xml, artifact.xml, etc)
  • Update Descriptor
  • Touchpoint version numbers and touchpoint action versions
  • Publisher advice versions

Implementation Steps

Enablement of an alternate implementation of Version and VersionType is wanted in 3.5 even if the OSGi resolver is still used. This enablement is available as a patch. On a parallell track - the Omni-version classes are implemented and tested with either a SAT4J based solution or an interims replacement of the OSGi resolver. It is then possible to verify the functionality and performance of the Omni-version implementation.

The Omni-version implementation is not expected to go into 3.5 unless there is a SAT4j solution replacing the OSGi resolver, the functionality and performance is satisfactory, and enough testing has taken place.

The feature to allow introduction of new named formats can wait.

FAQ

Will users just using Eclipse and OSGi bundles be affected?
No, users that only deal within the OSGi domain can continue to use version strings like before, there is no need to specify version formats. The Enablement that is proposed should also be safe as it is only a level of indirection to the current implementation of Version and VersionRange.

How does a user of something know which version type to use? This seems very complicated...
To use some non-osgi component with p2, that component must have been made available in a p2 repository. When it was made available, the publisher must have made it available with a specified version format. The publisher must understand the component's version semantics. A consumer of the component can find the version format in the repository (the user must after all know that a capability is available under a certain name, and certain version range).

Will open (osgi) ranges produce lots of false positives?
Very unlikely. One decision to minimize the risk was to specify that integer segments are considered to be later than array and string segments. (We also felt that version segments specified with integers are more "precise"). Note that to be included in the range, the required capability would still need to be in a matching name space, and have a matching name. To introduce a false positive, the publisher of the false positive would need to a) publish something already known to others (namespace and name) b) misinterpret how its versioning scheme works, and publishing it with a format of n.n.n.n (or n.n.n.s.<something>), c) having first learned how to actually specify such a format and how to publish it to a p2 repository and d) then persuaded users to use the repository.

What happens when a capability is available with several versioning schemes?
A typical case would be some java package that is versioned at the source using triplet notation, and the same package is also made available using osgi notation (which is a mistake).

As an example, the following capabilities are found:

  • org.demo.ships triplet:2.0.0
  • org.demo.ships triplet:2.0.0.RC1
  • org.demo.ships osgi:2.0.0
  • org.demo.ships osgi:2.0.0.RC1

(Reminder: in triplet notation 2.0.0.RC1 is older than 2.0.0).

The raw versions will then look like this:

  • 2.0.0.m
  • 2.0.0.'RC1'
  • 2.0.0
  • 2.0.0.'RC1'

And the newest is 2.0.0.m (which is correct for both OSGi, and triplet). When specifying a range, the outcome may depend on if the range is specified with osgi or triplet notation.

  • osgi:[1.0.0,2.0.0] == raw:[1.0.0, 2.0.0] => matches the osgi:2.0.0 version only
  • triplet:[1.0.0,2.0.0] == raw:[1.0.0.m,2.0.0.m] => matches all the versions, and picks 2.0.0.m as it is the latest.

i.e. result is correct (assuming the bits are identical as different artifacts would be picked)

Now look at the lower boundary, and assume that the following versions are the (only) available:

  • org.demo.ships triplet: 1.0.0 == raw: 1.0.0.m
  • org.demo.ships triplet: 1.0.0.RC1 == raw:1.0.0.'RC1'
  • org.demo.ships osgi: 1.0.0 == raw:1.0.0
  • org.demo.ships osgi:1.0.0.RC1 == raw:1.0.0.'RC1'

When specifying ranges:

  • osgi:[1.0.0,2.0.0] == raw:[1.0.0, 2.0.0] => matches all the version, and picks 1.0.0.maxs as this is the newest
  • triplet:[1.0.0,2.0.0] == raw:[1.0.0.m,2.0.0.m] results in 1.0.0.m as it is the only available version that matches.

i.e. the result is correct and here the exact same version is picked.

The "worst osgi/triplet crime" that can be committed is publishing an unqualified triplet version as an osgi version (if the same version is not also available as a triplet) as this would make that version older than what it is even when queried using a triplet range.

What if the publisher of a component changes versioning scheme - what happens to ranges?
The order among the versions will be correct as long as the versions are published using the correct notation. The only implication is that users must understand that a query for triplet:1.2.3 means raw:1.2.3.m - e.g. osgi:[1.0.0,2.0.0] != triplet:[1.0.0,2.0.0] (osgi upper range of 2.0.0 would not match triplet published 2.0.0, and triplet lower range of 1.0.0 would not match osgi published 1.0.0).

Why not use regexp instead of the special pattern format?
This was first considered, and would certainly work if the pattern notation was augmented with processing instructions, or if the regexp is specified as a substitution that produces the raw format. Such specifications would typically be much longer and more difficult for humans to read than the proposed format, except possibly for regexp experts :). Another immediate problem is that regexp breaks the current API requirement. It is not included in execution environment CDC-1.1/Foundation-1.1 required by p2.

Pattern parsing looks like it could have performance implications - what are the expectations here?
The intention is to use a mechanism similar to reqular expressions - when a format is first seen it is compiled to an internal structure. The compiled structure is cached and reused for all subsequent occurrences of the same format. A test will be performed to compare current parsing of an OSGi version string with the pattern based parsing. Once parsed, all comparisons are made using the raw vector, which should be comparable in speed to the current implementation.

Also note that the Engine does not have to parse and apply the format to the original string unless code explicetly asks for it, and this is not the normal case during provisioning.

Why not just let the publisher deal with transforming the version into canonical form?
The proposal allows this - the publisher is not required to make the format available. We think this is reasonable in domains where humans are not involved in the authoring.

There are several reasons why it is a good idea to include the original version string as well as the format:

  • the original version strings needs to be kept as users would probably not understand the canonical representation in many cases.
  • if the transformation pattern is not available a user would not be able to create a request without hand coding the canonical form
  • making the transformation logic used by one publisher available to others would mean that all publishers must have extensions that allow plugging in such logic, and the plugins must be made available

Would it be possible to use the current OSGi version as the canonical form?
The long answer is: To be general, the encoding would need to be made in the qualifier string part of the OSGi version. An upper length for segments must be imposed, numerical sections must be left padded with "0" to that length, and string segments must be right padded with space (else string segment parts may overlap integer segments parts). The selected segment length would need to be big enough to allow the longest anticipated string segment. A fixed length string representation of MAX must be invented. A different implementation would still be needed to be able to keep the original version strings.
The short answer is: no.

Why not use an escape in string segments to be able to have strings with a mix of quotes? There are several reasons:

  • this would mean that the version string would need to be preprocessed as it would not have \ embedded from the start
  • all version strings that use \ as a delimiter would need to be pre-processed to escape the the \
  • to date, authors of this proposal have not seen a version format that requires a mix of quotes
  • In the unlikely event that such strings are present it is possible to specify several strings in the raw format.
  • parsing performance is affected

External Links

Copyright © Eclipse Foundation, Inc. All Rights Reserved.