Red Hat Bugzilla – Bug 165335
RFE: rpm --compare-versions ver1 op ver2
Last modified: 2007-11-30 17:11:11 EST
It is difficult to compare version numbers of packages to find out which one is
the most recent with RPM. Trying to do this in a simple shell script is near
impossible... It would be cool if you could feed `rpm` two packages and have it
return which is more recent. Debian's dpkg does this and it's quite nice. From
dpkg --compare-versions ver1 op ver2
Compare version numbers, where op is a binary operator. dpkg returns
success (zero result) if the specified condition is satisfied, and failure
(nonzero result) otherwise. There are two groups of operators, which differ in
how they treat an empty ver1 or ver2. These treat an empty version as earlier
than any version: lt le eq ne ge gt. These treat an empty version as
later than any version: lt-nl le-nl ge-nl gt-nl. These are provided only for
compatibility with control file syntax: < << <= = >= >> >.
This script can be done in 10-20 lines of python, actually exists someplace.
Meanwhile, comparing versions has almost nothing to do with package management,
and so this does *NOT* belong on the rpm CLI (IMHO).
missed this one when it came through. see: ORC-rpm-ver-cmp at:
ftp://ftp.owlriver.com/pub/mirror/ORC/buildfarm/, which wrappes and adds sanity
checking to Seth's /usr/bin/fedora-rpmvercmp (which is itself already in:
This performs the requested comparisons