build/ops: rpm: introduce _python_buildid macro

This eliminates several ugly conditional blocks. This commit also does some
cleanup like dropping the ceph-base runtime dependency on "python", which is
implicit in "python-requests".

Signed-off-by: Nathan Cutler <ncutler@suse.com>
This commit is contained in:
Nathan Cutler 2018-01-24 09:17:29 +01:00
parent e9e62cbf81
commit d688b23ff8

View File

@ -48,6 +48,7 @@
%endif %endif
%if 0%{?suse_version} >= 1500 %if 0%{?suse_version} >= 1500
%bcond_with python2 %bcond_with python2
%global _defined_if_python2_absent 1
%else %else
%bcond_without python2 %bcond_without python2
%endif %endif
@ -60,6 +61,9 @@
%{!?_udevrulesdir: %global _udevrulesdir /lib/udev/rules.d} %{!?_udevrulesdir: %global _udevrulesdir /lib/udev/rules.d}
%{!?tmpfiles_create: %global tmpfiles_create systemd-tmpfiles --create} %{!?tmpfiles_create: %global tmpfiles_create systemd-tmpfiles --create}
%{!?python3_pkgversion: %global python3_pkgversion 3} %{!?python3_pkgversion: %global python3_pkgversion 3}
# define _python_buildid macro which will expand to the empty string when
# building with python2
%global _python_buildid %{?_defined_if_python2_absent:%{python3_pkgversion}}
# unify libexec for all targets # unify libexec for all targets
%global _libexecdir %{_exec_prefix}/lib %global _libexecdir %{_exec_prefix}/lib
@ -142,22 +146,11 @@ BuildRequires: parted
BuildRequires: perl BuildRequires: perl
BuildRequires: pkgconfig BuildRequires: pkgconfig
BuildRequires: procps BuildRequires: procps
%if 0%{with python2} BuildRequires: python%{_python_buildid}
BuildRequires: python BuildRequires: python%{_python_buildid}-devel
BuildRequires: python-devel BuildRequires: python%{_python_buildid}-nose
BuildRequires: python-nose BuildRequires: python%{_python_buildid}-requests
BuildRequires: python-requests BuildRequires: python%{_python_buildid}-virtualenv
BuildRequires: python-virtualenv
%else
BuildRequires: python%{python3_pkgversion}
%if 0%{?suse_version}
BuildRequires: python%{python3_pkgversion}-base
%endif
BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: python%{python3_pkgversion}-nose
BuildRequires: python%{python3_pkgversion}-requests
BuildRequires: python%{python3_pkgversion}-virtualenv
%endif
BuildRequires: snappy-devel BuildRequires: snappy-devel
%if 0%{with make_check} %if 0%{with make_check}
BuildRequires: socat BuildRequires: socat
@ -189,15 +182,10 @@ BuildRequires: libopenssl-devel
BuildRequires: lsb-release BuildRequires: lsb-release
BuildRequires: openldap2-devel BuildRequires: openldap2-devel
BuildRequires: cunit-devel BuildRequires: cunit-devel
%if 0%{with python2} BuildRequires: python%{_python_buildid}-base
BuildRequires: python-Cython BuildRequires: python%{_python_buildid}-Cython
BuildRequires: python-PrettyTable BuildRequires: python%{_python_buildid}-PrettyTable
BuildRequires: python-Sphinx BuildRequires: python%{_python_buildid}-Sphinx
%else
BuildRequires: python%{python3_pkgversion}-Cython
BuildRequires: python%{python3_pkgversion}-PrettyTable
BuildRequires: python%{python3_pkgversion}-Sphinx
%endif
BuildRequires: rdma-core-devel BuildRequires: rdma-core-devel
%endif %endif
%if 0%{?fedora} || 0%{?rhel} %if 0%{?fedora} || 0%{?rhel}
@ -211,15 +199,9 @@ BuildRequires: openldap-devel
BuildRequires: openssl-devel BuildRequires: openssl-devel
BuildRequires: CUnit-devel BuildRequires: CUnit-devel
BuildRequires: redhat-lsb-core BuildRequires: redhat-lsb-core
%if 0%{with python2} BuildRequires: Cython%{_python_buildid}
BuildRequires: Cython BuildRequires: python%{_python_buildid}-prettytable
BuildRequires: python-prettytable BuildRequires: python%{_python_buildid}-sphinx
BuildRequires: python-sphinx
%else
BuildRequires: Cython%{python3_pkgversion}
BuildRequires: python%{python3_pkgversion}-prettytable
BuildRequires: python%{python3_pkgversion}-sphinx
%endif
%endif %endif
# python34-... for RHEL, python3-... for all other supported distros # python34-... for RHEL, python3-... for all other supported distros
%if 0%{?rhel} %if 0%{?rhel}
@ -234,28 +216,15 @@ BuildRequires: python3-Cython
# distro-conditional make check dependencies # distro-conditional make check dependencies
%if 0%{with make_check} %if 0%{with make_check}
%if 0%{?fedora} || 0%{?rhel} %if 0%{?fedora} || 0%{?rhel}
%if 0%{with python2} BuildRequires: python%{_python_buildid}-cherrypy
BuildRequires: python-cherrypy BuildRequires: python%{_python_buildid}-pecan
BuildRequires: python-pecan BuildRequires: python%{_python_buildid}-werkzeug
BuildRequires: python-werkzeug
%else
BuildRequires: python%{python3_pkgversion}-cherrypy
BuildRequires: python%{python3_pkgversion}-pecan
BuildRequires: python%{python3_pkgversion}-werkzeug
%endif
%endif %endif
%if 0%{?suse_version} %if 0%{?suse_version}
%if 0%{with python2} BuildRequires: python%{_python_buildid}-CherryPy
BuildRequires: python-CherryPy BuildRequires: python%{_python_buildid}-Werkzeug
BuildRequires: python-Werkzeug BuildRequires: python%{_python_buildid}-pecan
BuildRequires: python-pecan BuildRequires: python%{_python_buildid}-numpy-devel
BuildRequires: python-numpy-devel
%else
BuildRequires: python%{python3_pkgversion}-CherryPy
BuildRequires: python%{python3_pkgversion}-Werkzeug
BuildRequires: python%{python3_pkgversion}-pecan
BuildRequires: python%{python3_pkgversion}-numpy-devel
%endif
%endif %endif
%endif %endif
# lttng and babeltrace for rbd-replay-prep # lttng and babeltrace for rbd-replay-prep
@ -301,22 +270,15 @@ Requires: librgw2 = %{_epoch_prefix}%{version}-%{release}
%if 0%{with selinux} %if 0%{with selinux}
Requires: ceph-selinux = %{_epoch_prefix}%{version}-%{release} Requires: ceph-selinux = %{_epoch_prefix}%{version}-%{release}
%endif %endif
%if 0%{with python2}
Requires: python
Requires: python-requests
Requires: python-setuptools
%else
Requires: python%{python3_pkgversion}
Requires: python%{python3_pkgversion}-requests
Requires: python%{python3_pkgversion}-setuptools
%endif
Requires: grep
Requires: xfsprogs
Requires: logrotate
Requires: util-linux
Requires: cryptsetup Requires: cryptsetup
Requires: findutils Requires: findutils
Requires: grep
Requires: logrotate
Requires: psmisc Requires: psmisc
Requires: python%{_python_buildid}-requests
Requires: python%{_python_buildid}-setuptools
Requires: util-linux
Requires: xfsprogs
Requires: which Requires: which
%if 0%{?suse_version} %if 0%{?suse_version}
Recommends: ntp-daemon Recommends: ntp-daemon
@ -332,34 +294,17 @@ Group: System/Filesystems
Requires: librbd1 = %{_epoch_prefix}%{version}-%{release} Requires: librbd1 = %{_epoch_prefix}%{version}-%{release}
Requires: librados2 = %{_epoch_prefix}%{version}-%{release} Requires: librados2 = %{_epoch_prefix}%{version}-%{release}
Requires: libcephfs2 = %{_epoch_prefix}%{version}-%{release} Requires: libcephfs2 = %{_epoch_prefix}%{version}-%{release}
%if 0%{with python2} Requires: python%{_python_buildid}-rados = %{_epoch_prefix}%{version}-%{release}
Requires: python-rados = %{_epoch_prefix}%{version}-%{release} Requires: python%{_python_buildid}-rbd = %{_epoch_prefix}%{version}-%{release}
Requires: python-rbd = %{_epoch_prefix}%{version}-%{release} Requires: python%{_python_buildid}-cephfs = %{_epoch_prefix}%{version}-%{release}
Requires: python-cephfs = %{_epoch_prefix}%{version}-%{release} Requires: python%{_python_buildid}-rgw = %{_epoch_prefix}%{version}-%{release}
Requires: python-rgw = %{_epoch_prefix}%{version}-%{release}
%else
Requires: python%{python3_pkgversion}-rados = %{_epoch_prefix}%{version}-%{release}
Requires: python%{python3_pkgversion}-rbd = %{_epoch_prefix}%{version}-%{release}
Requires: python%{python3_pkgversion}-cephfs = %{_epoch_prefix}%{version}-%{release}
Requires: python%{python3_pkgversion}-rgw = %{_epoch_prefix}%{version}-%{release}
%endif
%if 0%{?fedora} || 0%{?rhel} %if 0%{?fedora} || 0%{?rhel}
%if 0%{with python2} Requires: python%{_python_buildid}-prettytable
Requires: python-prettytable Requires: python%{_python_buildid}-requests
Requires: python-requests
%else
Requires: python%{python3_pkgversion}-prettytable
Requires: python%{python3_pkgversion}-requests
%endif
%endif %endif
%if 0%{?suse_version} %if 0%{?suse_version}
%if 0%{with python2} Requires: python%{_python_buildid}-PrettyTable
Requires: python-PrettyTable Requires: python%{_python_buildid}-requests
Requires: python-requests
%else
Requires: python%{python3_pkgversion}-PrettyTable
Requires: python%{python3_pkgversion}-requests
%endif
%endif %endif
%{?systemd_requires} %{?systemd_requires}
%if 0%{?suse_version} %if 0%{?suse_version}
@ -388,18 +333,10 @@ Group: System/Filesystems
Requires: ceph-base = %{_epoch_prefix}%{version}-%{release} Requires: ceph-base = %{_epoch_prefix}%{version}-%{release}
# For ceph-rest-api # For ceph-rest-api
%if 0%{?fedora} || 0%{?rhel} %if 0%{?fedora} || 0%{?rhel}
%if 0%{with python2} Requires: python%{_python_buildid}-flask
Requires: python-flask
%else
Requires: python%{python3_pkgversion}-flask
%endif
%endif %endif
%if 0%{?suse_version} %if 0%{?suse_version}
%if 0%{with python2} Requires: python%{_python_buildid}-Flask
Requires: python-Flask
%else
Requires: python%{python3_pkgversion}-Flask
%endif
%endif %endif
%description mon %description mon
ceph-mon is the cluster monitor daemon for the Ceph distributed file ceph-mon is the cluster monitor daemon for the Ceph distributed file
@ -414,36 +351,19 @@ Group: System/Filesystems
%endif %endif
Requires: ceph-base = %{_epoch_prefix}%{version}-%{release} Requires: ceph-base = %{_epoch_prefix}%{version}-%{release}
%if 0%{?fedora} || 0%{?rhel} %if 0%{?fedora} || 0%{?rhel}
%if 0%{with python2} Requires: python%{_python_buildid}-cherrypy
Requires: python-cherrypy Requires: python%{_python_buildid}-jinja2
Requires: python-jinja2 Requires: python%{_python_buildid}-pecan
Requires: python-pecan Requires: python%{_python_buildid}-werkzeug
Requires: python-werkzeug Requires: pyOpenSSL%{_python_buildid}
Requires: pyOpenSSL
%else
Requires: python%{python3_pkgversion}-cherrypy
Requires: python%{python3_pkgversion}-jinja2
Requires: python%{python3_pkgversion}-pecan
Requires: python%{python3_pkgversion}-werkzeug
Requires: pyOpenSSL%{python3_pkgversion}
%endif
%endif %endif
%if 0%{?suse_version} %if 0%{?suse_version}
%if 0%{with python2} Requires: python%{_python_buildid}-CherryPy
Requires: python-CherryPy Requires: python%{_python_buildid}-Jinja2
Requires: python-Jinja2 Requires: python%{_python_buildid}-Werkzeug
Requires: python-Werkzeug Requires: python%{_python_buildid}-pecan
Requires: python-pecan Requires: python%{_python_buildid}-pyOpenSSL
Requires: python-pyOpenSSL Recommends: python%{_python_buildid}-influxdb
Recommends: python-influxdb
%else
Requires: python%{python3_pkgversion}-CherryPy
Requires: python%{python3_pkgversion}-Jinja2
Requires: python%{python3_pkgversion}-Werkzeug
Requires: python%{python3_pkgversion}-pecan
Requires: python%{python3_pkgversion}-pyOpenSSL
Recommends: python%{python3_pkgversion}-influxdb
%endif
%endif %endif
%description mgr %description mgr
ceph-mgr enables python modules that provide services (such as the REST ceph-mgr enables python modules that provide services (such as the REST