We try to run %sysctl_apply in %post. But that will only work if the
systemd requires are there. Also since there is a circular dependency
(systemd -> elfutils-libs -> default-yama-scope -> systemd) we need
to double check that systemd-sysctl has already been installed before
calling it.

Signed-off-by: Mark Wielaard <m...@klomp.org>
---
 config/ChangeLog        | 5 +++++
 config/elfutils.spec.in | 7 +++++++
 2 files changed, 12 insertions(+)

diff --git a/config/ChangeLog b/config/ChangeLog
index ae40cc0..83263bd 100644
--- a/config/ChangeLog
+++ b/config/ChangeLog
@@ -1,3 +1,8 @@
+2017-11-08  Mark Wielaard  <m...@klomp.org>
+
+       * elfutils.spec.in: Add systemd_requires.
+       Check systemd-sysctl exists.
+
 2017-11-02  Mark Wielaard  <m...@klomp.org>
 
        * elfutils.spec.in: Config files under /usr/lib/sysctl.d (_sysctldir)
diff --git a/config/elfutils.spec.in b/config/elfutils.spec.in
index 1d0a4f8..21a18b2 100644
--- a/config/elfutils.spec.in
+++ b/config/elfutils.spec.in
@@ -107,6 +107,9 @@ Group: Development/Tools
 License: GPLv2+ or LGPLv3+
 Provides: default-yama-scope
 BuildArch: noarch
+# For the sysctl_apply macro
+%{?systemd_requires}
+BuildRequires: systemd >= 215
 
 %description default-yama-scope
 Yama sysctl setting to enable default attach scope settings
@@ -157,7 +160,11 @@ rm -rf ${RPM_BUILD_ROOT}
 %postun libelf -p /sbin/ldconfig
 
 %post default-yama-scope
+# Due to circular dependencies might not be installed yet, so double check.
+# (systemd -> elfutils-libs -> default-yama-scope -> systemd)
+if [ -x /usr/lib/systemd/systemd-sysctl ] ; then
 %sysctl_apply 10-default-yama-scope.conf
+fi
 
 %files
 %defattr(-,root,root)
-- 
1.8.3.1

Reply via email to