From 8d9c48ef06e7660bbc2b24b64e291a77d5156200 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Tue, 28 Mar 2017 09:28:55 +0100 Subject: [PATCH] bindep: depends: Add distro family aliases CentOS, RHEL and Fedora share a lot of similarities when it comes to package names so group them together under the 'redhat' alias. Similarly, group openSUSE Leap, Tumbleweed and SLE under the 'suse' alias. Change-Id: I5bfe33cd48c21b4c94f550a27b96466f488a8df8 --- README.rst | 7 +++++++ bindep/depends.py | 6 ++++++ bindep/tests/test_depends.py | 22 ++++++++++++++++------ 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/README.rst b/README.rst index 34bcc14..072d3f6 100644 --- a/README.rst +++ b/README.rst @@ -136,6 +136,13 @@ since those entries have the ``platform:rpm`` profile, and ``dev-libs/libxml2`` on Gentoo since the entry has the ``platform:gentoo`` profile. +Additionally, you can use ``platform:redhat`` or ``platform:suse`` to only +match RedHat-like or SUSE-like distributions respectively as shown in the +following example:: + + openssh-server [platform:redhat] + openssh [platform:suse] + To select Python3 development packages, the OpenStack CI default file uses:: python3-all-dev [platform:dpkg !platform:ubuntu-precise] diff --git a/bindep/depends.py b/bindep/depends.py index d8cf63a..8ce97f2 100644 --- a/bindep/depends.py +++ b/bindep/depends.py @@ -250,6 +250,12 @@ class Depends(object): elif distro in ["opensuseproject", "opensusetumbleweed"]: # just short alias atoms.add("opensuse") + # Family aliases + if 'suse' in distro: + atoms.add("suse") + else: + atoms.add("redhat") + atoms.add("rpm") self.platform = Rpm() elif distro in ["gentoo"]: diff --git a/bindep/tests/test_depends.py b/bindep/tests/test_depends.py index a1e1192..96420b9 100644 --- a/bindep/tests/test_depends.py +++ b/bindep/tests/test_depends.py @@ -65,8 +65,9 @@ class TestDepends(TestCase): def test_detects_centos(self): with self._mock_lsb("CentOS"): depends = Depends("") - self.assertThat( - depends.platform_profiles(), Contains("platform:centos")) + platform_profiles = depends.platform_profiles() + self.assertThat(platform_profiles, Contains("platform:centos")) + self.assertThat(platform_profiles, Contains("platform:redhat")) def test_detects_rhel(self): with self._mock_lsb("RedHatEnterpriseServer"): @@ -78,12 +79,16 @@ class TestDepends(TestCase): self.assertThat( platform_profiles, Contains("platform:rhel")) + self.assertThat( + platform_profiles, + Contains("platform:redhat")) def test_detects_fedora(self): with self._mock_lsb("Fedora"): depends = Depends("") - self.assertThat( - depends.platform_profiles(), Contains("platform:fedora")) + platform_profiles = depends.platform_profiles() + self.assertThat(platform_profiles, Contains("platform:fedora")) + self.assertThat(platform_profiles, Contains("platform:redhat")) def test_detects_opensuse_project(self): with self._mock_lsb("openSUSE Project"): @@ -93,6 +98,8 @@ class TestDepends(TestCase): Contains("platform:opensuseproject")) self.assertThat(platform_profiles, Contains("platform:opensuse")) + self.assertThat(platform_profiles, + Contains("platform:suse")) def test_detects_opensuse_tumbleweed(self): with self._mock_lsb("openSUSE Tumbleweed"): @@ -102,12 +109,15 @@ class TestDepends(TestCase): Contains("platform:opensusetumbleweed")) self.assertThat(platform_profiles, Contains("platform:opensuse")) + self.assertThat(platform_profiles, + Contains("platform:suse")) def test_detects_suse_linux(self): with self._mock_lsb("SUSE Linux"): depends = Depends("") - self.assertThat( - depends.platform_profiles(), Contains("platform:suselinux")) + platform_profiles = depends.platform_profiles() + self.assertThat(platform_profiles, Contains("platform:suselinux")) + self.assertThat(platform_profiles, Contains("platform:suse")) def test_detects_ubuntu(self): with self._mock_lsb("Ubuntu"):