0

I wrote a wrapper for rpmbuild that creates the source.tgz file in the ~/rpmbuild/SOURCES/. However when I use this script on an older operating system; rpm's are built in /usr/src/.... So inside my bash script I would like to get the version number of rpmbuild; like this for example:

rpmbuild --version

which gives: RPM version 4.11.1. I'll get that into a variable; lets say

VERSION=4.11.1

Now how can I check easily inside my script that this is a version >=4.6.0 ? Do I really need to start parsing it into major, minor and bugfix and compare the three numbers, or is there another better way to do this? something like:

if [[ $VERSION >= 4.6.0 ]]
then
    # do stuff...
fi
Chris Maes
  • 35,025
  • 12
  • 111
  • 136

1 Answers1

0

Unfortunately the answer is not as simple as it may look like. Beside regular MAJOR.MINOR.PATCHLEVEL form any rpm also has release and sometimes epoch which takes precedence over version. Also as far as I remember different rpm-based Linux vendors have (or had in the past) a slightly different processing of "corner cases". So a technically correct answer should mention a specialized tool like rpmvercmp (this is one of many rpmvercmp implementations :) )

user3159253
  • 16,836
  • 3
  • 30
  • 56