From b9cd8a82ee41e235df66801a02b2244226bee5ee Mon Sep 17 00:00:00 2001 From: Ryan Harper Date: Fri, 9 Jun 2017 10:34:58 -0500 Subject: Use distro release version to determine if we use systemd in redhat spec The typical rpm build process will examine the spec file to determine which packages should be installed in the boot root. This requires the specfile to declare that it needs system. Provide this information by checking which version in which the rpm is being built and exporting requirements for systemd. --- packages/redhat/cloud-init.spec.in | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/packages/redhat/cloud-init.spec.in b/packages/redhat/cloud-init.spec.in index 1939ca88..3e92c98f 100644 --- a/packages/redhat/cloud-init.spec.in +++ b/packages/redhat/cloud-init.spec.in @@ -1,10 +1,12 @@ ## template: cheetah %{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} -%if %{undefined systemd_requires} -%define init_system sysvinit -%else +%define use_systemd (0%{?fedora} && 0%{?fedora} >= 18) || (0%{?rhel} && 0%{?rhel} >= 7) + +%if %{use_systemd} %define init_system systemd +%else +%define init_system sysvinit %endif # See: http://www.zarb.org/~jasonc/macros.php @@ -29,6 +31,18 @@ BuildRequires: python-setuptools %if "%{?el6}" == "1" BuildRequires: python-argparse %endif +%if %{use_systemd} +Requires: systemd +BuildRequires: systemd +Requires: systemd-units +BuildRequires: systemd-units +%else +Requires: initscripts >= 8.36 +Requires(postun): initscripts +Requires(post): chkconfig +Requires(preun): chkconfig +%endif + # These are runtime dependencies, but declared as BuildRequires so that # - tests can be run here. # - parts of cloud-init such (setup.py) use these dependencies. @@ -68,8 +82,9 @@ Patch${size}: $p #end for %if "%{init_system}" == "systemd" -BuildRequires: systemd-units -%{systemd_requires} +Requires(post): systemd +Requires(preun): systemd +Requires(postun): systemd %else Requires(post): chkconfig Requires(postun): initscripts -- cgit v1.2.3