summaryrefslogtreecommitdiff
path: root/packages/redhat
diff options
context:
space:
mode:
authorRyan Harper <ryan.harper@canonical.com>2017-06-09 10:34:58 -0500
committerRyan Harper <ryan.harper@canonical.com>2017-06-09 13:01:45 -0500
commitb9cd8a82ee41e235df66801a02b2244226bee5ee (patch)
tree5b3290f1690a89fca1e565049cb6249ac01c8ac1 /packages/redhat
parentd00da2d5b0d45db5670622a66d833d2abb907388 (diff)
downloadcloud-init-git-b9cd8a82ee41e235df66801a02b2244226bee5ee.tar.gz
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.
Diffstat (limited to 'packages/redhat')
-rw-r--r--packages/redhat/cloud-init.spec.in25
1 files 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