bindep: Query for RPM capabilities as well
It's possible for a bindep file to list capabilities instead of actual package names so it can cover different packages that provide the same functionality. It's also possible to use capabilities to 'capture' multiple releases of the same distribution that may have different rpm package names for the same application. RPMs normally provide at least one capability named after their actual package name so this change actual extends the behavior of bindep without alterning it. For example, here are some results on the openSUSE Leap 42.2 distribution where the package name is 'mariadb' > rpm -q mariadb mariadb-10.0.30-20.4.1.x86_64 > rpm --whatprovides -q mariadb mariadb-10.0.30-20.4.1.x86_64 > rpm -q mariadb-server package mariadb-server is not installed > rpm --whatprovides -q mariadb-server mariadb-10.0.30-20.4.1.x86_64 As we can see, using '--whatprovides' results in bindep picking up the correct package name based on the capabilities of that package. Change-Id: I36945d3528013250f3a8617ea63ba1883733f91c
This commit is contained in:
parent
c47e81959e
commit
de6726520b
|
@ -319,13 +319,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
|
||||
|
|
|
@ -531,8 +531,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"))
|
||||
|
||||
|
@ -544,8 +544,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)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue