4f95e99
%define with_systemd 0%{!?_without_systemd:0}
4f95e99
4f95e99
%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7
4f95e99
%define with_systemd 1
4f95e99
%endif
4f95e99
4f95e99
%if 0%{?fedora} >= 18 || 0%{?rhel} >= 7
4f95e99
%define with_systemd_macros 1
4f95e99
%else
4f95e99
%define with_systemd_macros 0
4f95e99
%endif
4f95e99
Angus Salkeld 12dcdb9
Name:           sanlock
bceaa98
Version:        2.6
4f95e99
Release:        8%{?dist}
Angus Salkeld 12dcdb9
Summary:        A shared disk lock manager
Angus Salkeld 12dcdb9
Angus Salkeld 12dcdb9
Group:          System Environment/Base
d3e4a61
License:        GPLv2 and GPLv2+ and LGPLv2+
Angus Salkeld 12dcdb9
URL:            https://fedorahosted.org/sanlock/
Angus Salkeld 12dcdb9
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
3c5a0c1
BuildRequires:  libblkid-devel libaio-devel python python-devel
4f95e99
%if %{with_systemd}
d30e384
BuildRequires:  systemd-units
d30e384
%endif
6973248
%if 0%{?rhel} >= 6
6973248
ExclusiveArch:  x86_64
6973248
%endif
3778194
Requires:       %{name}-lib = %{version}-%{release}
949ca9b
Requires(pre):  /usr/sbin/groupadd
949ca9b
Requires(pre):  /usr/sbin/useradd
4f95e99
%if %{with_systemd}
4f95e99
Requires(post): systemd-units
4f95e99
Requires(post): systemd-sysv
4f95e99
Requires(preun): systemd-units
4f95e99
Requires(postun): systemd-units
4f95e99
%endif
4f95e99
Source0:        http://git.fedorahosted.org/cgit/sanlock.git/snapshot/%{name}-%{version}.tar.gz
Angus Salkeld 12dcdb9
e2260cb
Patch0: 0001-fix-systemd-service-files.patch
812c258
Patch1: 0002-wdmd-use-mode-775-for-run-dir.patch
812c258
Patch2: 0003-systemd-add-wdmd-dependency-for-sanlock.patch
3c28fa9
Patch3: 0004-wdmd-make-the-watchdog-device-configurable.patch
572ceee
Patch4: 0005-wdmd-fix-miscellaneous-build-warnings.patch
572ceee
Patch5: 0006-wdmd-dynamically-select-working-watchdog-device.patch
572ceee
e2260cb
Angus Salkeld 12dcdb9
%description
Angus Salkeld 12dcdb9
sanlock uses disk paxos to manage leases on shared storage.
Angus Salkeld 12dcdb9
Hosts connected to a common SAN can use this to synchronize their
Angus Salkeld 12dcdb9
access to the shared disks.
Angus Salkeld 12dcdb9
Angus Salkeld 12dcdb9
%prep
Angus Salkeld 12dcdb9
%setup -q
3c28fa9
%patch0 -p1 -b .0001-fix-systemd-service-files
3c28fa9
%patch1 -p1 -b .0002-wdmd-use-mode-775-for-run-dir
3c28fa9
%patch2 -p1 -b .0003-systemd-add-wdmd-dependency-for-sanlock
3c28fa9
%patch3 -p1 -b .0004-wdmd-make-the-watchdog-device-configurable
7a72797
%patch4 -p1 -b .0005-wdmd-fix-miscellaneous-build-warnings
7a72797
%patch5 -p1 -b .0006-wdmd-dynamically-select-working-watchdog-device
Angus Salkeld 12dcdb9
Angus Salkeld 12dcdb9
%build
Angus Salkeld 12dcdb9
# upstream does not require configure
Angus Salkeld 12dcdb9
# upstream does not support _smp_mflags
11fb958
CFLAGS=$RPM_OPT_FLAGS make -C wdmd
11fb958
CFLAGS=$RPM_OPT_FLAGS make -C src
3778194
CFLAGS=$RPM_OPT_FLAGS make -C python
bceaa98
CFLAGS=$RPM_OPT_FLAGS make -C fence_sanlock
Angus Salkeld 12dcdb9
Angus Salkeld 12dcdb9
%install
Angus Salkeld 12dcdb9
rm -rf $RPM_BUILD_ROOT
11fb958
make -C src \
fcd8b9e
        install LIBDIR=%{_libdir} \
Angus Salkeld 12dcdb9
        DESTDIR=$RPM_BUILD_ROOT
2a871d0
make -C wdmd \
fcd8b9e
        install LIBDIR=%{_libdir} \
2a871d0
        DESTDIR=$RPM_BUILD_ROOT
3778194
make -C python \
fcd8b9e
        install LIBDIR=%{_libdir} \
3778194
        DESTDIR=$RPM_BUILD_ROOT
bceaa98
make -C fence_sanlock \
bceaa98
        install LIBDIR=%{_libdir} \
bceaa98
        DESTDIR=$RPM_BUILD_ROOT
d3e4a61
4f95e99
4f95e99
%if %{with_systemd}
e15699a
install -D -m 0755 init.d/sanlock $RPM_BUILD_ROOT/lib/systemd/systemd-sanlock
e15699a
install -D -m 0644 init.d/sanlock.service $RPM_BUILD_ROOT/%{_unitdir}/sanlock.service
e15699a
install -D -m 0755 init.d/wdmd $RPM_BUILD_ROOT/lib/systemd/systemd-wdmd
e15699a
install -D -m 0644 init.d/wdmd.service $RPM_BUILD_ROOT/%{_unitdir}/wdmd.service
bceaa98
install -D -m 0755 init.d/fence_sanlockd $RPM_BUILD_ROOT/lib/systemd/systemd-fence_sanlockd
bceaa98
install -D -m 0644 init.d/fence_sanlockd.service $RPM_BUILD_ROOT/%{_unitdir}/fence_sanlockd.service
e15699a
%else
17a4652
install -D -m 0755 init.d/sanlock $RPM_BUILD_ROOT/%{_initddir}/sanlock
17a4652
install -D -m 0755 init.d/wdmd $RPM_BUILD_ROOT/%{_initddir}/wdmd
17a4652
install -D -m 0755 init.d/fence_sanlockd $RPM_BUILD_ROOT/%{_initddir}/fence_sanlockd
e15699a
%endif
d3e4a61
17a4652
install -D -m 0644 src/logrotate.sanlock \
d3e4a61
	$RPM_BUILD_ROOT/etc/logrotate.d/sanlock
d3e4a61
3c28fa9
install -D -m 0644 src/sysconfig.sanlock \
a16b207
	$RPM_BUILD_ROOT/etc/sysconfig/sanlock
a16b207
3c28fa9
install -D -m 0644 wdmd/sysconfig.wdmd \
bceaa98
        $RPM_BUILD_ROOT/etc/sysconfig/wdmd
bceaa98
17a4652
install -Dd -m 0755 $RPM_BUILD_ROOT/etc/wdmd.d
17a4652
install -Dd -m 0775 $RPM_BUILD_ROOT/%{_localstatedir}/run/sanlock
17a4652
install -Dd -m 0775 $RPM_BUILD_ROOT/%{_localstatedir}/run/fence_sanlock
17a4652
install -Dd -m 0775 $RPM_BUILD_ROOT/%{_localstatedir}/run/fence_sanlockd
59eef4e
Angus Salkeld 12dcdb9
%clean
Angus Salkeld 12dcdb9
rm -rf $RPM_BUILD_ROOT
Angus Salkeld 12dcdb9
3778194
%pre
d3e4a61
getent group sanlock > /dev/null || /usr/sbin/groupadd \
d3e4a61
	-g 179 sanlock
d3e4a61
getent passwd sanlock > /dev/null || /usr/sbin/useradd \
d3e4a61
	-u 179 -c "sanlock" -s /sbin/nologin -r \
d3e4a61
	-g 179 -d /var/run/sanlock sanlock
bceaa98
/usr/sbin/usermod -a -G disk sanlock
3778194
3778194
%post
4f95e99
%if %{with_systemd}
4f95e99
%if %{with_systemd_macros}
4f95e99
%systemd_post wdmd.service sanlock.service
4f95e99
%else
e15699a
if [ $1 -eq 1 ] ; then
e15699a
  /bin/systemctl daemon-reload >/dev/null 2>&1 || :
4f95e99
fi
4f95e99
%endif
e15699a
%else
4f95e99
if [ $1 -eq 1 ] ; then
e15699a
  /sbin/chkconfig --add sanlock
e15699a
  /sbin/chkconfig --add wdmd
e15699a
fi
4f95e99
%endif
Angus Salkeld 12dcdb9
3778194
%preun
4f95e99
%if %{with_systemd}
4f95e99
%if %{with_systemd_macros}
4f95e99
%systemd_preun sanlock.service
4f95e99
%systemd_preun wdmd.service
4f95e99
%else
3778194
if [ $1 = 0 ]; then
4f95e99
  /bin/systemctl --no-reload disable sanlock.service > /dev/null 2>&1 || :
e15699a
  /bin/systemctl stop sanlock.service > /dev/null 2>&1 || :
4f95e99
  /bin/systemctl --no-reload disable wdmd.service > /dev/null 2>&1 || :
e15699a
  /bin/systemctl stop wdmd.service > /dev/null 2>&1 || :
4f95e99
fi
4f95e99
%endif
e15699a
%else
4f95e99
if [ $1 = 0 ]; then
e15699a
  /sbin/service sanlock stop > /dev/null 2>&1
e15699a
  /sbin/chkconfig --del sanlock
4f95e99
  /sbin/service wdmd stop > /dev/null 2>&1
e15699a
  /sbin/chkconfig --del wdmd
3778194
fi
4f95e99
%endif
3778194
3778194
%postun
4f95e99
%if %{with_systemd}
4f95e99
%if %{with_systemd_macros}
4f95e99
%systemd_postun_with_restart sanlock.service
4f95e99
%systemd_postun_with_restart wdmd.service
4f95e99
%else
4f95e99
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
e15699a
if [ $1 -ge 1 ] ; then
e15699a
  /bin/systemctl try-restart sanlock.service >/dev/null 2>&1 || :
e15699a
  /bin/systemctl try-restart wdmd.service >/dev/null 2>&1 || :
4f95e99
fi
4f95e99
%endif
e15699a
%else
4f95e99
if [ $1 -ge 1 ] ; then
e15699a
  /sbin/service sanlock condrestart >/dev/null 2>&1 || :
e15699a
  /sbin/service wdmd condrestart >/dev/null 2>&1 || :
e15699a
fi
4f95e99
%endif
Angus Salkeld 12dcdb9
Angus Salkeld 12dcdb9
%files
Angus Salkeld 12dcdb9
%defattr(-,root,root,-)
4f95e99
%if %{with_systemd}
07c4039
/lib/systemd/systemd-sanlock
07c4039
/lib/systemd/systemd-wdmd
07c4039
%{_unitdir}/sanlock.service
07c4039
%{_unitdir}/wdmd.service
e15699a
%else
e15699a
%{_initddir}/sanlock
e15699a
%{_initddir}/wdmd
e15699a
%endif
Angus Salkeld 12dcdb9
%{_sbindir}/sanlock
2a871d0
%{_sbindir}/wdmd
d30e384
%dir /etc/wdmd.d
59eef4e
%dir %attr(-,sanlock,sanlock) %{_localstatedir}/run/sanlock
fcd8b9e
%{_mandir}/man8/wdmd*
fcd8b9e
%{_mandir}/man8/sanlock*
d3e4a61
%config(noreplace) %{_sysconfdir}/logrotate.d/sanlock
a16b207
%config(noreplace) %{_sysconfdir}/sysconfig/sanlock
bceaa98
%config(noreplace) %{_sysconfdir}/sysconfig/wdmd
3778194
3778194
%package        lib
3778194
Summary:        A shared disk lock manager library
3778194
Group:          System Environment/Libraries
3778194
3778194
%description    lib
3778194
The %{name}-lib package contains the runtime libraries for sanlock,
3778194
a shared disk lock manager.
3778194
Hosts connected to a common SAN can use this to synchronize their
3778194
access to the shared disks.
3778194
3778194
%post lib -p /sbin/ldconfig
3778194
3778194
%postun lib -p /sbin/ldconfig
3778194
3778194
%files          lib
3778194
%defattr(-,root,root,-)
Angus Salkeld 12dcdb9
%{_libdir}/libsanlock.so.*
fcd8b9e
%{_libdir}/libsanlock_client.so.*
3778194
%{_libdir}/libwdmd.so.*
3778194
3778194
%package        python
3778194
Summary:        Python bindings for the sanlock library
3778194
Group:          Development/Libraries
fcd8b9e
Requires:       %{name}-lib = %{version}-%{release}
3778194
3778194
%description    python
3778194
The %{name}-python package contains a module that permits applications
3778194
written in the Python programming language to use the interface
3778194
supplied by the sanlock library.
3778194
3778194
%files          python
3778194
%defattr(-,root,root,-)
e15699a
%{python_sitearch}/Sanlock-1.0-py*.egg-info
fcd8b9e
%{python_sitearch}/sanlock.so
Angus Salkeld 12dcdb9
Angus Salkeld 12dcdb9
%package        devel
Angus Salkeld 12dcdb9
Summary:        Development files for %{name}
Angus Salkeld 12dcdb9
Group:          Development/Libraries
fcd8b9e
Requires:       %{name}-lib = %{version}-%{release}
Angus Salkeld 12dcdb9
Angus Salkeld 12dcdb9
%description    devel
Angus Salkeld 12dcdb9
The %{name}-devel package contains libraries and header files for
Angus Salkeld 12dcdb9
developing applications that use %{name}.
Angus Salkeld 12dcdb9
Angus Salkeld 12dcdb9
%files          devel
Angus Salkeld 12dcdb9
%defattr(-,root,root,-)
3778194
%{_libdir}/libwdmd.so
3778194
%{_includedir}/wdmd.h
Angus Salkeld 12dcdb9
%{_libdir}/libsanlock.so
fcd8b9e
%{_libdir}/libsanlock_client.so
Angus Salkeld 12dcdb9
%{_includedir}/sanlock.h
3778194
%{_includedir}/sanlock_rv.h
3778194
%{_includedir}/sanlock_admin.h
Angus Salkeld 12dcdb9
%{_includedir}/sanlock_resource.h
3778194
%{_includedir}/sanlock_direct.h
Angus Salkeld 12dcdb9
bceaa98
%package -n     fence-sanlock
bceaa98
Summary:        Fence agent using sanlock and wdmd
bceaa98
Group:          System Environment/Base
bceaa98
Requires:       sanlock = %{version}-%{release}
bceaa98
bceaa98
%description -n fence-sanlock
bceaa98
The fence-sanlock package contains the fence agent and
bceaa98
daemon for using sanlock and wdmd as a cluster fence agent.
bceaa98
bceaa98
%files -n       fence-sanlock
bceaa98
%defattr(-,root,root,-)
4f95e99
%if %{with_systemd}
bceaa98
/lib/systemd/systemd-fence_sanlockd
bceaa98
%{_unitdir}/fence_sanlockd.service
bceaa98
%else
bceaa98
%{_initddir}/fence_sanlockd
bceaa98
%endif
bceaa98
%{_sbindir}/fence_sanlock
bceaa98
%{_sbindir}/fence_sanlockd
bceaa98
%dir %attr(-,root,root) %{_localstatedir}/run/fence_sanlock
bceaa98
%dir %attr(-,root,root) %{_localstatedir}/run/fence_sanlockd
bceaa98
%{_mandir}/man8/fence_sanlock*
bceaa98
bceaa98
%post -n        fence-sanlock
bceaa98
if [ $1 -eq 1 ] ; then
4f95e99
%if %{with_systemd}
bceaa98
  /bin/systemctl daemon-reload >/dev/null 2>&1 || :
bceaa98
%else
bceaa98
  /sbin/chkconfig --add fence_sanlockd
bceaa98
%endif
bceaa98
ccs_update_schema > /dev/null 2>&1 ||:
bceaa98
fi
bceaa98
bceaa98
%preun -n       fence-sanlock
bceaa98
if [ $1 = 0 ]; then
4f95e99
%if %{with_systemd}
bceaa98
  /bin/systemctl --no-reload fence_sanlockd.service > /dev/null 2>&1 || :
bceaa98
%else
bceaa98
  /sbin/service fence_sanlockd stop > /dev/null 2>&1
bceaa98
  /sbin/chkconfig --del fence_sanlockd
bceaa98
%endif
bceaa98
fi
bceaa98
bceaa98
%postun -n      fence-sanlock
bceaa98
if [ $1 -ge 1 ] ; then
4f95e99
%if %{with_systemd}
bceaa98
  /bin/systemctl try-restart fence_sanlockd.service > /dev/null 2>&1 || :
bceaa98
%else 
bceaa98
  /sbin/service fence_sanlockd condrestart >/dev/null 2>&1 || :
bceaa98
%endif
bceaa98
fi
bceaa98
Angus Salkeld 12dcdb9
%changelog
4f95e99
* Tue Apr  2 2013 Federico Simoncelli <fsimonce@redhat.com> - 2.6-8
4f95e99
- introduce the new systemd-rpm macros (#857397)
4f95e99
31d8bda
* Sun Jan 13 2013 Federico Simoncelli <fsimonce@redhat.com> 2.6-7
31d8bda
- applying the missing patches
31d8bda
572ceee
* Sun Jan 13 2013 Federico Simoncelli <fsimonce@redhat.com> 2.6-6
572ceee
- wdmd: fix miscellaneous build warnings
572ceee
- wdmd: dynamically select working watchdog device
572ceee
3c28fa9
* Wed Jan  2 2013 Federico Simoncelli <fsimonce@redhat.com> 2.6-5
3c28fa9
- wdmd: make the watchdog device configurable
3c28fa9
812c258
* Tue Nov 13 2012 David Teigland <teigland@redhat.com> - 2.6-4
812c258
- systemd: add wdmd dependency for sanlock
812c258
e2260cb
* Mon Nov 05 2012 David Teigland <teigland@redhat.com> - 2.6-3
e2260cb
- fix systemd service files and install them on rhel7
e2260cb
d30e384
* Wed Oct 24 2012 David Teigland <teigland@redhat.com> - 2.6-2
d30e384
- move creation of /etc/wdmd.d
d30e384
bceaa98
* Tue Oct 09 2012 David Teigland <teigland@redhat.com> - 2.6-1
bceaa98
- Update to sanlock-2.6
bceaa98
aacb875
* Mon Sep 24 2012 David Teigland <teigland@redhat.com> - 2.5-1
aacb875
- Update to sanlock-2.5
aacb875
59eef4e
* Tue Jul 24 2012 David Teigland <teigland@redhat.com> - 2.4-3
59eef4e
- fix lockfile ownership
59eef4e
f6f89f6
* Mon Jul 23 2012 David Teigland <teigland@redhat.com> - 2.4-2
f6f89f6
- fix missing include
f6f89f6
312c0bc
* Mon Jul 23 2012 David Teigland <teigland@redhat.com> - 2.4-1
312c0bc
- Update to sanlock-2.4
312c0bc
bf22c27
* Sat Jul 21 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.3-4
bf22c27
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
bf22c27
949ca9b
* Fri Jun 15 2012 David Teigland <teigland@redhat.com> - 2.3-3
949ca9b
- Require useradd and groupadd
949ca9b
af90824
* Mon Jun 04 2012 David Teigland <teigland@redhat.com> - 2.3-2
af90824
- Remove exclusive arch
af90824
af90824
* Wed May 30 2012 David Teigland <teigland@redhat.com> - 2.3-1
e15699a
- Update to sanlock-2.3
e15699a
e15699a
* Fri May 25 2012 Federico Simoncelli <fsimonce@redhat.com> 2.2-2
e15699a
- Support multiple platforms in the spec file
e15699a
a16b207
* Mon May 07 2012 David Teigland <teigland@redhat.com> - 2.2-1
a16b207
- Update to sanlock-2.2
a16b207
07c4039
* Thu Apr 05 2012 David Teigland <teigland@redhat.com> - 2.1-2
07c4039
- Install service files instead of init files
07c4039
d3e4a61
* Wed Mar 21 2012 David Teigland <teigland@redhat.com> - 2.1-1
d3e4a61
- Update to sanlock-2.1
d3e4a61
e15699a
* Fri Mar 02 2012 David Teigland <teigland@redhat.com> - 2.0-1
e15699a
- Update to sanlock-2.0
e15699a
e15699a
* Tue Sep 20 2011 David Teigland <teigland@redhat.com> - 1.8-2
e15699a
- fix useradd command in spec file
33ad3ed
fcd8b9e
* Fri Sep 16 2011 Chris Feist 
fcd8b9e
- Update to sanlock-1.8
fcd8b9e
6f0b9fc
* Fri Aug 19 2011 Dan HorĂ¡k <dan[at]danny.cz> - 1.6-2
6f0b9fc
- build on all arches again
6f0b9fc
e15699a
* Sun Aug 07 2011 Chris Feist <cfeist@redhat.com> - 1.7-4
e15699a
- Fix for minor file include issues
e15699a
e15699a
* Fri Aug 05 2011 David Teigland <teigland@redhat.com> - 1.7-3
e15699a
- fix man page mode
e15699a
e15699a
* Fri Aug 05 2011 David Teigland <teigland@redhat.com> - 1.7-1
e15699a
- Update to sanlock-1.7
e15699a
8f74c37
* Fri Jul 08 2011 David Teigland <teigland@redhat.com> - 1.6-1
8f74c37
- Update to sanlock-1.6
0ea4f1f
8f74c37
* Thu Jun 30 2011 David Teigland <teigland@redhat.com> - 1.5-1
8f74c37
- Update to sanlock-1.5
2c03a4c
8f74c37
* Tue Jun 21 2011 David Teigland <teigland@redhat.com> - 1.4-1
8f74c37
- Update to sanlock-1.4
8f74c37
8f74c37
* Fri Jun 10 2011 David Teigland <teigland@redhat.com> - 1.3-6
8f74c37
- fix python version, build i686 also
8f74c37
8f74c37
* Thu Jun 09 2011 David Teigland <teigland@redhat.com> - 1.3-5
8f74c37
- build exclusive x86_64, at least for now
8f74c37
8f74c37
* Thu Jun 09 2011 David Teigland <teigland@redhat.com> - 1.3-4
8f74c37
- build only x86_64, at least for now
8f74c37
8f74c37
* Thu Jun 09 2011 David Teigland <teigland@redhat.com> - 1.3-3
8f74c37
- fix libwdmd linking
8f74c37
8f74c37
* Thu Jun 09 2011 David Teigland <teigland@redhat.com> - 1.3-2
8f74c37
- shut up build warnings for wdmd and sanlock
8f74c37
8f74c37
* Thu Jun 09 2011 David Teigland <teigland@redhat.com> - 1.3-1
8f74c37
- Update to sanlock-1.3
3c5a0c1
0a87f16
* Mon May 09 2011 Chris Feist <cfeist@redhat.com> - 1.2.0-3
0a87f16
- Add python and python-devel to build requires
882e6d8
3778194
* Mon May 09 2011 Chris Feist <cfeist@redhat.com> - 1.2.0-1
3778194
- Use latest sources
3778194
- Sync .spec file
3778194
3778194
* Mon Apr  4 2011 Federico Simoncelli <fsimonce@redhat.com> - 1.1.0-3
3778194
- Add sanlock_admin.h header
3778194
2a871d0
* Fri Feb 18 2011 Chris Feist <cfeist@redhat.com> - 1.1.0-2
2a871d0
- Fixed install for wdmd
2a871d0
11fb958
* Thu Feb 17 2011 Chris Feist <cfeist@redhat.com> - 1.1.0-1
11fb958
- Updated to latest sources
11fb958
- Now include wdmd
11fb958
Angus Salkeld 12dcdb9
* Tue Feb 8 2011 Angus Salkeld <asalkeld@redhat.com> - 1.0-2
3778194
- SPEC: Add docs and make more consistent with the fedora template
Angus Salkeld 12dcdb9
Angus Salkeld 12dcdb9
* Mon Jan 10 2011 Fabio M. Di Nitto <fdinitto@redhat.com> - 1.0-1
Angus Salkeld 12dcdb9
- first cut at rpm packaging