Comparing Versions in RPM Conditionals

10 Apr 2012

It’s easy to check a distribution’s version in a spec file since it is usually an integer:

%if 0%{?fedora} > 16

But this scheme doesn’t usually work for comparing program versions because they typically contain periods, which blow rpmbuild’s little mind. But if you have rpm 4.7 or later, you can use a bit of inline Lua to do it:

%if %{lua:rpm.vercmp('%{version}', '2.0.2')} > 0