On Thu, Jun 17, 2004 at 10:28:05PM +0200, Enrique Perez-Terron wrote: > What is the proper way of comparing versions of rpms in a bash script? > There is no "proper way". When the semantics of a package's version diverges from the de facto standard, it can only be done reliably by associating the version comparison function with the packages. An approximate heuristic that will work with most cases can be used. Just compare the first three period-delimited integers (as integers, not strings). Subsequent strings can be ignored or compared using an arbitrary comparison function. > > This is actually two questions, what is the proper order, and what is > the simplest way of implementing that order. > > To the first part, is this right? > 4.01-3 > 4.01-3p # letter suffixes sort like strings > 4.01-3q > 4.1-3p # leading zeros before no leading zero > 4.2 > 4.10 # otherwise numeric part sort as numbers > 4.10-4 > 4.10.3-1 # components separated with dots are "more important" than > the dash, i.e. 4.10-4 is a "smaller variation" of 4.10 than 4.10.3 > > I think I have seen versions with letter prefixes too. How do they sort? > > ( <rant> > And why the heck do people invent such versions strings!! > </rant> ) > For a world of reasons. -- Robert Lehr (concatenate 'string "bozzio" "@" "the-lehrs" ".com") _______________________________________________ Rpm-list mailing list Rpm-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/rpm-list