Only use LONGSIZE in rpm.info if available. Otherwise, use SIZE.

Fixes #31366
This commit is contained in:
rallytime 2016-02-23 17:20:47 -07:00
parent e553f18dc4
commit 294371243d

View File

@ -422,6 +422,14 @@ def info(*packages, **attr):
salt '*' lowpkg.info apache2 bash attr=version salt '*' lowpkg.info apache2 bash attr=version
salt '*' lowpkg.info apache2 bash attr=version,build_date_iso,size salt '*' lowpkg.info apache2 bash attr=version,build_date_iso,size
''' '''
# LONGSIZE is not a valid tag for all versions of rpm. If LONGSIZE isn't
# available, then we can just use SIZE for older versions. See Issue #31366.
rpm_tags = __salt__['cmd.run_all']('rpm --querytags')
rpm_tags = rpm_tags.get('stdout').split('\n')
if 'LONGSIZE' in rpm_tags:
size_tag = '%{LONGSIZE}'
else:
size_tag = '%{SIZE}'
cmd = packages and "rpm -q {0}".format(' '.join(packages)) or "rpm -qa" cmd = packages and "rpm -q {0}".format(' '.join(packages)) or "rpm -qa"
@ -440,7 +448,7 @@ def info(*packages, **attr):
"build_host": "build_host: %{BUILDHOST}\\n", "build_host": "build_host: %{BUILDHOST}\\n",
"group": "group: %{GROUP}\\n", "group": "group: %{GROUP}\\n",
"source_rpm": "source_rpm: %{SOURCERPM}\\n", "source_rpm": "source_rpm: %{SOURCERPM}\\n",
"size": "size: %{LONGSIZE}\\n", "size": "size: " + size_tag + "\\n",
"arch": "arch: %{ARCH}\\n", "arch": "arch: %{ARCH}\\n",
"license": "%|LICENSE?{license: %{LICENSE}\\n}|", "license": "%|LICENSE?{license: %{LICENSE}\\n}|",
"signature": "signature: %|DSAHEADER?{%{DSAHEADER:pgpsig}}:{%|RSAHEADER?{%{RSAHEADER:pgpsig}}:" "signature": "signature: %|DSAHEADER?{%{DSAHEADER:pgpsig}}:{%|RSAHEADER?{%{RSAHEADER:pgpsig}}:"