Subject: Re: Comparing version numbers
To: Julien Letessier <julien.letessier@sun.com>
From: Alistair Crooks <agc@wasabisystems.com>
List: tech-pkg
Date: 08/01/2002 22:58:42
On Thu, Aug 01, 2002 at 01:36:35PM +0200, Julien Letessier wrote:
> Hi list,
> 
> I'm writing a dselect-like tool for NetBSD binary package repositories, 
> and was wondering if there is an 'official' reference / code blob about:
>   * how package version strings are to be compared;
>   * how requirement strings are to be expanded in a boolean expression.
> 
> pkg_info(1)'s man page gives strong hints about this, but is not really 
> a spec :)

Hmmm. OK, it's a fair cop, guv, I'll come quietly.

My only defence is that some time ago I beefed up the version comparison
code, and, although I modified the pkg_info(1) manual page, not enough
information was added.

Basically, all of the comparison work is done in

	pkg_install/lib/str.c

An array of 64-bit integers is constructed, using the rules in the comment
in line 156 (ish).

'.' encodes as '0'
'_' encodes as 'patchlevel', or '0'
'pl' encodes as 'patchlevel', or '0'
'rc' encodes as release candidate, which is -1
'nb' encodes as 'netbsd version', which is used after all the other tests

Alphabetics are encoded as <letter> - 'a' + 1, i.e. 'c' is '3'

csh-style alternates are allowed.

Hope this helps,
Alistair