Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Mar 2001 00:04:56 +0900
From:      "Akinori MUSHA" <knu@iDaemons.org>
To:        "Bruce A. Mah" <bmah@freebsd.org>
Cc:        freebsd-ports@freebsd.org, knu@freebsd.org
Subject:   Re: pkg_version comparison routine
Message-ID:  <86y9tqc4tj.wl@archon.local.idaemons.org>
In-Reply-To: <200103280237.f2S2bUP02277@bmah-freebsd-0.cisco.com>
References:  <200103280237.f2S2bUP02277@bmah-freebsd-0.cisco.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

At Tue, 27 Mar 2001 18:37:30 -0800,
Bruce A. Mah wrote:
> I'm going to revisit an issue long overdue...the fact that the algorithm
> used by pkg_version(1) for comparing versions doesn't work in all the
> cases specified by the Porter's Handbook.  knu tried to get my attention
> on this issue a number of months ago, even going so far as to submit
> some patches to fix this problem.  Unfortunately I dropped the ball on
> this, and I'm sure he's understandably annoyed at me.

Honestly yes, kind of.. ;)

> Let me apologize now to knu for my being a bad maintainer and ignoring
> his email.  I'm sorry...and I didn't mean it personally.

I'd certainly accept your apology and fully understand that you didn't
mean it.

> What I've done is to take some of knu's code and ideas and to try to
> cover what the Porter's Handbook does, plus one or two other cases I've
> seen (plus, admittedly, rewrite it so that my meager Perl skills stand a
> chance of maintaining it in the future).  I also took a variant of his
> -t feature.

Nice to hear it.  Thanks for cleaning it up to make more readable. :)

> I've got a new version now that handles all the forms of version 
> numbers below:
> 
> 	1.0.5		The usual, run-of-the mill version number.
> 
> 	1.0.b2		Recommended form for "1.0beta2".
> 
> 	1.0c		Not allowed by the Porter's Handbook, but
> 			plenty of ports use this syntax.  Should be
> 			"1.0.c".
> 
> 	1.0.b2c		A combination of the preceding two cases.
> 			Again, not technically allowed.
> 
> (The use of PORTEPOCH and PORTREVISION are of course supported; they're 
> actually orthogonal, as the code is implemented.)

Actually, the PkgVersion module used in my portupgrade/portversion has
a unit test suite to validate its comparison algorithm.  I bet you can
just grasp it even if you're not familiar with Ruby at all:

http://www.idaemons.org/cgi-bin/cvsweb.cgi/~checkout~/pkgtools/tests/test_pkgversion.rb?rev=.&content-type=text/plain&cvsroot=local

I think something similar to this can be written in Bourne shell using
the `pkg_version -t' feature, so that we can always ensure the
correctness of its behavior.

> The -t option below is a little different than what knu did originally; 
> what this version does is to take two version strings and return "=", 
> "<", or ">" on standard out.  (knu's version took a test and returned a 
> truth value for the test.)  I've got a usage in mind where I think that 
> this form of -t will be more useful.

Good idea.  That'd be more convenient for shell scripts.

> The following is a patch against the RELENG_4 branch, but it should
> apply equally well to the HEAD.  Comments would be most welcome.

I'll check it out later.  Thanks for adopting my code! :)

-- 
                     /
                    /__  __            Akinori.org / MUSHA.org
                   / )  )  ) )  /     FreeBSD.org / Ruby-lang.org
Akinori MUSHA aka / (_ /  ( (__(  @ iDaemons.org / and.or.jp

"We're only at home when we're on the run, on the wing, on the fly"

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86y9tqc4tj.wl>