Merge "bindep: Query for RPM capabilities as well"

This commit is contained in:
Jenkins 2017-07-13 13:27:39 +00:00 committed by Gerrit Code Review
commit 125de90c2a
2 changed files with 8 additions and 7 deletions

View File

@ -324,13 +324,14 @@ class Rpm(Platform):
try:
output = subprocess.check_output(
["rpm", "--qf",
"%{NAME} %|EPOCH?{%{EPOCH}:}|%{VERSION}-%{RELEASE}\n", "-q",
pkg_name],
"%{NAME} %|EPOCH?{%{EPOCH}:}|%{VERSION}-%{RELEASE}\n",
"--whatprovides", "-q", pkg_name],
stderr=subprocess.STDOUT).decode(getpreferredencoding(False))
except subprocess.CalledProcessError as e:
eoutput = e.output.decode(getpreferredencoding(False))
if (e.returncode == 1 and
eoutput.strip().endswith('is not installed')):
(eoutput.strip().endswith('is not installed') or
(eoutput.strip().startswith('no package provides')))):
return None
raise
# output looks like

View File

@ -541,8 +541,8 @@ class TestRpm(TestCase):
self.assertEqual(None, platform.get_pkg_version("foo"))
mock_checkoutput.assert_called_once_with(
["rpm", "--qf",
"%{NAME} %|EPOCH?{%{EPOCH}:}|%{VERSION}-%{RELEASE}\n", "-q",
"foo"],
"%{NAME} %|EPOCH?{%{EPOCH}:}|%{VERSION}-%{RELEASE}\n",
"--whatprovides", "-q", "foo"],
stderr=subprocess.STDOUT)
self.assertEqual(None, platform.get_pkg_version("foo"))
@ -554,8 +554,8 @@ class TestRpm(TestCase):
self.assertEqual("4.0.0-0.el6", platform.get_pkg_version("foo"))
mock_checkoutput.assert_called_once_with(
["rpm", "--qf",
"%{NAME} %|EPOCH?{%{EPOCH}:}|%{VERSION}-%{RELEASE}\n", "-q",
"foo"],
"%{NAME} %|EPOCH?{%{EPOCH}:}|%{VERSION}-%{RELEASE}\n",
"--whatprovides", "-q", "foo"],
stderr=subprocess.STDOUT)