Re: RPM version comparison algorithm

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 1 Jan 2005, Robert Schiele wrote:

> On Sat, Jan 01, 2005 at 11:32:41PM +0100, Jos Vos wrote:
> > Hi,
> > 
> > For some reason I thought the rpm version/release comparison was done
> > by comparing the dotted components, but this does not seem to be
> > the case.  For example:
> > 
> >   pkg-1.0-3 < pkg-1.0-3A
> > 
> > but
> > 
> >   pkg-1.0-3.B > pkg-1.0-3A.B
> > 
> > To me, this looks strange.  What is the explanation for this?
> 
> A change between alphabetic characters and numeric ones is considered as two
> components as if there was a dot in between.
> 
> Thus you have for your first example 3 < 3.A and for the second one 3.B >
> 3.A.B.

Or:

			first	second
	pkg-1.0-3	3
	pkg-1.0-3A	3	A
	pkg-1.0-3A.B	3	A.B
	pkg-1.0-3.B	3	B

Explained in:

	/usr/share/doc/rpm-4.3.1/dependencies

as:

	The algorithm that RPM uses to determine the version ordering of
	packages is simple and developers are encouraged not to rely on 
	the details of its working.  Developers should keep their 
	numbering scheme simple so any reasonable ordering algorithm would 
	work.  The version comparison algorithm is in the routine 
	rpmvercmp() and it is just a segmented strcmp(3).  First, the 
	boundaries of the segments are found using isdigit(3)/isalpha(3).  
	Each segment is then compared in order with the right most segment 
	being the least significant.  The alphabetical portions are 
	compared using a lexical graphical ascii ordering, the digit 
	segments strip leading zeroes and compare the strlen before doing 
	a strcmp. If both numerical strings are equal, the longer string 
	is larger.  Notice that the algorithm has no knowledge of decimal 
	fractions, and perl-5.6 is "older" than perl-5.00503 because the 
	number 6 is less thanthe number 503.

--   dag wieers,  dag@xxxxxxxxxx,  http://dag.wieers.com/   --
[all I want is a warm bed and a kind word and unlimited power]

_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/rpm-list

[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux