Roy Marples wrote: > On Tue, 2007-10-02 at 08:35 +0200, Natanael Copa wrote: >> After a quick look I wonder how/if it deals with: >> >> 1.01 < 1.1 > > It treats them the same way > > [EMAIL PROTECTED] ~ $ bash -c '. /usr/portage/eclass/versionator.eclass; > version_compare 1.01 1.1; echo $?' > 2 > [EMAIL PROTECTED] ~ $ bash -c '. ./versionator.eclass; version_compare 1.01 > 1.1; echo $?' > 2 > > I'm also glad you asked as spb claims my version is broken with repsect > to this. I disagree as it matches the portage version. > My understanding of how portage deals with this is that, since one of the components begins with 0, a `floating-point' comparison is used. IOW 1.10 > 1.01 and they are not the same at all.
I am pretty sure this is how it works, as we had to do a verCompare for update (consistency check for depclean originally) and looked at the portage code as well as the bash interrev code for prefix(?) portage, before coming up with our own version in bash[1] based on the spec. We particularly wanted to shortcut stuff and not use any externals iirc (it was a while ago.) The test script is used with eg: ./verCmp 1.01 1.1 ./verCmp older 1.1-r3 1.1-r2 ./verCmp newer 1.1a_alpha20070822-r1 1.1_alpha20070822-r1 It does handles interrevs for comparison, but doesn't yet provide the "distance" which is needed for prefix portage. It's enough for our purposes in update, where we simply need to know whether the two are equal, or if a is older or newer than b. [1] http://phpfi.com/266380 -- there was a small bug in the one we pasted before in #gentoo-portage, which had been corrected in update. (Please don't have a go at me about GPL3-- it's not my call, and Gentoo can use it under GPL2, should you ever want to.) Bug-reports welcomed :) -- [EMAIL PROTECTED] mailing list
