saltstack/salt — Issue #605: pkg.installed fails on odd rpm version numbers with yum
Author: mrballcb
Created: 2012-01-30 16:01:34+00:00
State: open

I have some packages that are installed on my CentOS boxen that pkg.installed says are not installed:

pam_ccreds.i386 3-5 base
epel-release.noarch 5-4 installed
pcmciautils.x86_64 014-5 installed

The above lines are copy/paste from the minion log file in debug mode, as generated by the command yum -q list.

I hacked up a quick salt.states.pkg.is_present function which basically only does the first check that the installed function does. It returns true for all packages I tested except for the three listed above.

The pkg.installed function uses python's distutils package and LooseVersion does not accept the \d+-\d+ package version as valid. According to the LooseVersion documentation, only the following are considered valid:
1.5.1
1.5.2b2
161
3.10a
8.02
3.4j
1996.07.12
3.2.pl0
3.1.1.6
2g6
11g
0.960923
2.2beta29
1.13++
5.5.kw
2.0b1pl0
In fact, there is no such thing as an invalid version number under
this scheme; the rules for comparison are simple and predictable,
but may not always give the results you want (for some definition
of "want").

But it obviously did not expect to see the version listed above.