Compare Linux RPM versions in the relevance

Dear Guru,
I am trying to write a relevance which would match

version of package “gnupg2” of rpm as string is less than “2.0.22-5” ?

I have found the discussion (URL below), but I hoped for the “native” comparison for the RPM versions.
https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014756281 [Relevance help with rpm versions with “-” in version]

Thank you,
Aleksandr

Aleksandr,

Are you trying to get a true/false out of this or the package version if it is less than 2.0.22-5?

-Matt

Matt,
Thank you for your attention. Apologies, I am only seeing it now :frowning:

Yes.

Essentially:
issue is fixed in version “A”, need to find systems which have rpm older than “A”.

Right now I check for the latest version, forcing updates on every system which runs anything but the latest version. Relevance:

not (version of package “initscripts” of rpm as string contains “9.03.61” )

Relevance will return true if version of “initscripts” is other than “9.03.61”. 6 months from now “9.03.62” will arrive and relevance will match for systems with “9.03.62” (undesired).

Thank you,
Aleksandr

You might look into using the extended RPM-specific version records for comparisons…

Q: rpm version record of (package “bzip2” of rpm)
A: 1.0.5-7.el6_0

Those will allow direct comparisons such as <=

https://developer.bigfix.com/relevance/reference/rpm-package-version-record.html

3 Likes

Jason,
Many thanks! This looks promising!

Q: rpm version record of (package “bzip2” of rpm)
A: 1.0.5-7.el6_0
T: 529389

Q: rpm version record of (package “bzip2” of rpm) > "1.0.4"
E: Invalid RPM package version record string format. [epoch:]version-release expected. String must not contain whitespace characters. Version and release components must not contain ‘-’ characters.
T: 298

Q: rpm version record of (package “bzip2” of rpm) > "1.0.4-9"
A: True
T: 4483

Q: rpm version record of (package “bzip2” of rpm) > "1.0.5.1-8"
A: False
T: 255

Q: rpm version record of (package “bzip2” of rpm) > "1.0.4.9-8"
A: True
T: 240