[sanlock/f18] introduce the new systemd-rpm macros
Federico Simoncelli
fsimonce at fedoraproject.org
Tue Apr 2 14:32:37 UTC 2013
commit 4f95e997e589e515240be59128935fdf0d5c57a3
Author: Federico Simoncelli <fsimonce at redhat.com>
Date: Tue Apr 2 16:04:51 2013 +0200
introduce the new systemd-rpm macros
Conflicts:
sanlock.spec
sanlock.spec | 79 ++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 61 insertions(+), 18 deletions(-)
---
diff --git a/sanlock.spec b/sanlock.spec
index 0b7cb55..5b35185 100644
--- a/sanlock.spec
+++ b/sanlock.spec
@@ -1,6 +1,18 @@
+%define with_systemd 0%{!?_without_systemd:0}
+
+%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7
+%define with_systemd 1
+%endif
+
+%if 0%{?fedora} >= 18 || 0%{?rhel} >= 7
+%define with_systemd_macros 1
+%else
+%define with_systemd_macros 0
+%endif
+
Name: sanlock
Version: 2.6
-Release: 7%{?dist}
+Release: 8%{?dist}
Summary: A shared disk lock manager
Group: System Environment/Base
@@ -8,7 +20,7 @@ License: GPLv2 and GPLv2+ and LGPLv2+
URL: https://fedorahosted.org/sanlock/
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: libblkid-devel libaio-devel python python-devel
-%if 0%{?fedora} >= 16 || 0%{?rhel} >= 7
+%if %{with_systemd}
BuildRequires: systemd-units
%endif
%if 0%{?rhel} >= 6
@@ -17,7 +29,13 @@ ExclusiveArch: x86_64
Requires: %{name}-lib = %{version}-%{release}
Requires(pre): /usr/sbin/groupadd
Requires(pre): /usr/sbin/useradd
-Source0: https://fedorahosted.org/releases/s/a/sanlock/%{name}-%{version}.tar.gz
+%if %{with_systemd}
+Requires(post): systemd-units
+Requires(post): systemd-sysv
+Requires(preun): systemd-units
+Requires(postun): systemd-units
+%endif
+Source0: http://git.fedorahosted.org/cgit/sanlock.git/snapshot/%{name}-%{version}.tar.gz
Patch0: 0001-fix-systemd-service-files.patch
Patch1: 0002-wdmd-use-mode-775-for-run-dir.patch
@@ -64,7 +82,8 @@ make -C fence_sanlock \
install LIBDIR=%{_libdir} \
DESTDIR=$RPM_BUILD_ROOT
-%if 0%{?fedora} >= 16 || 0%{?rhel} >= 7
+
+%if %{with_systemd}
install -D -m 0755 init.d/sanlock $RPM_BUILD_ROOT/lib/systemd/systemd-sanlock
install -D -m 0644 init.d/sanlock.service $RPM_BUILD_ROOT/%{_unitdir}/sanlock.service
install -D -m 0755 init.d/wdmd $RPM_BUILD_ROOT/lib/systemd/systemd-wdmd
@@ -103,44 +122,65 @@ getent passwd sanlock > /dev/null || /usr/sbin/useradd \
/usr/sbin/usermod -a -G disk sanlock
%post
+%if %{with_systemd}
+%if %{with_systemd_macros}
+%systemd_post wdmd.service sanlock.service
+%else
if [ $1 -eq 1 ] ; then
-%if 0%{?fedora} >= 16 || 0%{?rhel} >= 7
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
+%endif
%else
+if [ $1 -eq 1 ] ; then
/sbin/chkconfig --add sanlock
/sbin/chkconfig --add wdmd
-%endif
fi
+%endif
%preun
+%if %{with_systemd}
+%if %{with_systemd_macros}
+%systemd_preun sanlock.service
+%systemd_preun wdmd.service
+%else
if [ $1 = 0 ]; then
-%if 0%{?fedora} >= 16 || 0%{?rhel} >= 7
- /bin/systemctl --no-reload sanlock.service > /dev/null 2>&1 || :
- /bin/systemctl --no-reload wdmd.service > /dev/null 2>&1 || :
+ /bin/systemctl --no-reload disable sanlock.service > /dev/null 2>&1 || :
/bin/systemctl stop sanlock.service > /dev/null 2>&1 || :
+ /bin/systemctl --no-reload disable wdmd.service > /dev/null 2>&1 || :
/bin/systemctl stop wdmd.service > /dev/null 2>&1 || :
+fi
+%endif
%else
+if [ $1 = 0 ]; then
/sbin/service sanlock stop > /dev/null 2>&1
- /sbin/service wdmd stop > /dev/null 2>&1
/sbin/chkconfig --del sanlock
+ /sbin/service wdmd stop > /dev/null 2>&1
/sbin/chkconfig --del wdmd
-%endif
fi
+%endif
%postun
+%if %{with_systemd}
+%if %{with_systemd_macros}
+%systemd_postun_with_restart sanlock.service
+%systemd_postun_with_restart wdmd.service
+%else
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
if [ $1 -ge 1 ] ; then
-%if 0%{?fedora} >= 16 || 0%{?rhel} >= 7
/bin/systemctl try-restart sanlock.service >/dev/null 2>&1 || :
/bin/systemctl try-restart wdmd.service >/dev/null 2>&1 || :
+fi
+%endif
%else
+if [ $1 -ge 1 ] ; then
/sbin/service sanlock condrestart >/dev/null 2>&1 || :
/sbin/service wdmd condrestart >/dev/null 2>&1 || :
-%endif
fi
+%endif
%files
%defattr(-,root,root,-)
-%if 0%{?fedora} >= 16 || 0%{?rhel} >= 7
+%if %{with_systemd}
/lib/systemd/systemd-sanlock
/lib/systemd/systemd-wdmd
%{_unitdir}/sanlock.service
@@ -226,7 +266,7 @@ daemon for using sanlock and wdmd as a cluster fence agent.
%files -n fence-sanlock
%defattr(-,root,root,-)
-%if 0%{?fedora} >= 16 || 0%{?rhel} >= 7
+%if %{with_systemd}
/lib/systemd/systemd-fence_sanlockd
%{_unitdir}/fence_sanlockd.service
%else
@@ -240,7 +280,7 @@ daemon for using sanlock and wdmd as a cluster fence agent.
%post -n fence-sanlock
if [ $1 -eq 1 ] ; then
-%if 0%{?fedora} >= 16 || 0%{?rhel} >= 7
+%if %{with_systemd}
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
%else
/sbin/chkconfig --add fence_sanlockd
@@ -250,7 +290,7 @@ fi
%preun -n fence-sanlock
if [ $1 = 0 ]; then
-%if 0%{?fedora} >= 16 || 0%{?rhel} >= 7
+%if %{with_systemd}
/bin/systemctl --no-reload fence_sanlockd.service > /dev/null 2>&1 || :
%else
/sbin/service fence_sanlockd stop > /dev/null 2>&1
@@ -260,7 +300,7 @@ fi
%postun -n fence-sanlock
if [ $1 -ge 1 ] ; then
-%if 0%{?fedora} >= 16 || 0%{?rhel} >= 7
+%if %{with_systemd}
/bin/systemctl try-restart fence_sanlockd.service > /dev/null 2>&1 || :
%else
/sbin/service fence_sanlockd condrestart >/dev/null 2>&1 || :
@@ -268,6 +308,9 @@ if [ $1 -ge 1 ] ; then
fi
%changelog
+* Tue Apr 2 2013 Federico Simoncelli <fsimonce at redhat.com> - 2.6-8
+- introduce the new systemd-rpm macros (#857397)
+
* Sun Jan 13 2013 Federico Simoncelli <fsimonce at redhat.com> 2.6-7
- applying the missing patches
More information about the scm-commits
mailing list