Replace option 'i' with an explicit queryformat

Option 'i' uses a predefined queryformat that is not necessarily compatible with the code used to parse it.

For example: an exception was being thrown on my CentOS 6.7 machines because the default queryformat was placing multiple keys on a signle line.

I have therefore replaced the 'i' option with a hardcoded queryformat to ensure consistancy across all systems.
This commit is contained in:
Brendan McGrath 2015-10-19 00:55:22 -07:00
parent a2128c8f80
commit 4987530986

View file

@ -426,10 +426,27 @@ def info(*packages):
salt '*' lowpkg.info apache2 bash
'''
cmd = packages and "rpm -qi {0}".format(' '.join(packages)) or "rpm -qai"
cmd = packages and "rpm -q {0}".format(' '.join(packages)) or "rpm -qa"
# Locale needs to be en_US instead of C, because RPM otherwise will yank the timezone from the timestamps
call = __salt__['cmd.run_all'](cmd + " --queryformat '-----\n'",
call = __salt__['cmd.run_all'](cmd + (" --queryformat 'Name: %-27{NAME}\n"
"Relocations: %|PREFIXES?{[%{PREFIXES} ]}:{(not relocatable)}|\n"
"Version: %-27{VERSION}\n"
"Vendor: %{VENDOR}\n"
"Release: %-27{RELEASE}\n"
"Build Date: %{BUILDTIME:date}\n"
"Install Date: %|INSTALLTIME?{%-27{INSTALLTIME:date}}:{(not installed) }|\n"
"Build Host: %{BUILDHOST}\n"
"Group: %-27{GROUP}\n"
"Source RPM: %{SOURCERPM}\n"
"Size: %-27{LONGSIZE}\n"
"%|LICENSE?{License: %{LICENSE}\n}|"
"Signature: %|DSAHEADER?{%{DSAHEADER:pgpsig}}:{%|RSAHEADER?{%{RSAHEADER:pgpsig}}:{%|SIGGPG?{%{SIGGPG:pgpsig}}:{%|SIGPGP?{%{SIGPGP:pgpsig}}:{(none)}|}|}|}|\n"
"%|PACKAGER?{Packager: %{PACKAGER}\n}|"
"%|URL?{URL: %{URL}\n}|"
"Summary: %{SUMMARY}\n"
"Description:\n%{DESCRIPTION}\n"
"-----\n'"),
output_loglevel='trace', env={'LC_ALL': 'en_US', 'TZ': 'UTC'}, clean_env=True)
if call['retcode'] != 0:
comment = ''