[sanlock/f19] introduce the new systemd-rpm macros
Federico Simoncelli
fsimonce at fedoraproject.org
Tue Apr 2 14:32:53 UTC 2013
commit c6e393e57b3de0452f45831286d97caff1d1b504
Author: Federico Simoncelli <fsimonce at redhat.com>
Date: Tue Apr 2 16:04:51 2013 +0200
introduce the new systemd-rpm macros
sanlock.spec | 77 +++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 60 insertions(+), 17 deletions(-)
---
diff --git a/sanlock.spec b/sanlock.spec
index 6423fdf..c13117d 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.7
-Release: 1%{?dist}
+Release: 2%{?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,6 +29,12 @@ ExclusiveArch: x86_64
Requires: %{name}-lib = %{version}-%{release}
Requires(pre): /usr/sbin/groupadd
Requires(pre): /usr/sbin/useradd
+%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: foo.patch
@@ -53,7 +71,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
@@ -92,44 +111,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
@@ -215,7 +255,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
@@ -229,7 +269,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
@@ -239,7 +279,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
@@ -249,7 +289,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 || :
@@ -257,6 +297,9 @@ if [ $1 -ge 1 ] ; then
fi
%changelog
+* Tue Apr 2 2013 Federico Simoncelli <fsimonce at redhat.com> - 2.7-2
+- introduce the new systemd-rpm macros (#857397)
+
* Wed Mar 06 2013 David Teigland <teigland at redhat.com> - 2.7-1
- Update to sanlock-2.7
More information about the scm-commits
mailing list