File ctdb.spec of Package ctdb

#
# spec file for package ctdb
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


%if 0%{?suse_version} > 1140 && 0%{?suse_version} != 1315
%define         build_pmda 1
%endif

%define libtalloc_version 2.0.8
%define libtdb_version 1.2.12
%define libtevent_version 0.9.18

%{!?_tmpfilesdir:%global _tmpfilesdir /usr/lib/tmpfiles.d}

Summary:        Clustered TDB
License:        GPL-3.0+
Group:          System/Daemons

Name:           ctdb
Version:        2.5.5
Release:        0
Url:            http://ctdb.samba.org/
Source:         https://ftp.samba.org/pub/ctdb/ctdb-%{version}.tar.gz
Source1:        ctdb-sysconfig-suse.template
Source100:      ctdb-pcp-pmda-rpmlintrc
Patch1:         ctdb-socket-path.patch
Patch2:         0001-build-offer-with-rundir-configure-argument.patch
Patch3:         0002-tcp-use-RUNDIR-for-.socket_lock-path.patch
Patch100:       ctdb-xsltproc-catalogs.patch
%if 0%{?suse_version}
Requires(pre):  %{?fillup_prereq}
%if 0%{?suse_version} > 1220
BuildRequires:  pkgconfig(systemd)
%{?systemd_requires}
# bnc886095: The CTDB resource agent could be split out into a separate rpm,
# with corresponding ctdb and tdb-tools requirements. Until then, just add the
# tdb-tools requirement to ctdb.
Requires:       tdb-tools
%else
Requires(pre):  %{insserv_prereq}
%endif
%else
Requires(pre): /sbin/chkconfig
%endif
Requires(pre): coreutils
Requires(pre): /bin/mktemp
Requires(pre): /usr/bin/killall
Requires(pre): sed
%define         initdir %{_sysconfdir}/init.d
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} == 0 || 0%{?suse_version} > 1140
BuildRequires:  autoconf
%endif
%if 0%{?suse_version} > 1020
BuildRequires:  pkg-config
%else
BuildRequires:  pkgconfig
%endif
%if 0%{?build_pmda}
BuildRequires:  libpcp-devel
%endif
BuildRequires:  libtalloc-devel >= %{libtalloc_version}
BuildRequires:  libtdb-devel >= %{libtdb_version}
BuildRequires:  libtevent-devel >= %{libtevent_version}
# to generate the man pages
BuildRequires:  docbook-xsl-stylesheets
%if 0%{?centos_version} > 499 || 0%{?fedora_version} > 11 || 0%{?rhel_version} > 499 || 0%{?suse_version} > 0 && 0%{?suse_version} < 1141
BuildRequires:  libxslt
%endif
%if 0%{?suse_version} > 1140 && 0%{?suse_version} < 1211
BuildRequires:  libxslt1
%endif
%if 0%{?suse_version} > 1210
BuildRequires:  libxslt-tools
%endif

%if ! %{defined _rundir}
%define _rundir %{_localstatedir}/run
%endif

%description
ctdb is the clustered database used by Samba

%package devel
Summary:        Libraries and Header Files to Develop Programs with ctdb support
Group:          Development/Libraries/C and C++

%description devel
This package contains the static libraries and header files needed to
develop programs which make use of ctdb.

%if 0%{?build_pmda}
%package pcp-pmda
Summary:        Performance Co-Pilot (PCP) monitoring agent
Group:          System/Monitoring

%description pcp-pmda
The CTDB Performance Co-Pilot (PCP) monitoring agent allows remote PCP
clients to view and capture detailed real-time performance metrics for
one or more cluster nodes.
%endif

%prep
%setup -q
%patch1 -p1
%patch2 -p1
%patch3 -p1
%if 0%{?suse_version} == 1010
%patch100 -p1
%endif

%build
%if 0%{?suse_version} && 0%{?suse_version} < 1141
%{?suse_update_config:%{suse_update_config -f}}
%endif
%if 0%{?suse_version} > 1140 || 0%{?centos_version} > 599 || 0%{?rhel_version} > 599
./autogen.sh
%endif
export CFLAGS="$RPM_OPT_FLAGS $EXTRA -D_GNU_SOURCE -DCTDB_VERS=\"%{version}-%{release}\""
%{configure} \
%if 0%{?build_pmda}
	--enable-pmda \
%endif
	--with-logdir=%{_localstatedir}/log/ctdb/ \
	--with-rundir=%{_rundir} \
	--with-socketpath=%{_localstatedir}/lib/ctdb/ctdb.socket

%{__make} %{?_smp_mflags} docdir=%{_docdir}

%install
mkdir -p \
	${RPM_BUILD_ROOT}/%{_sysconfdir}/sysconfig \
%if 0%{?suse_version} > 1220
    ${RPM_BUILD_ROOT}/%{_unitdir} \
%else
	${RPM_BUILD_ROOT}/%{_sysconfdir}/init.d \
%endif
	${RPM_BUILD_ROOT}/%{_localstatedir}/lib/ctdb/persistent \
	${RPM_BUILD_ROOT}/%{_localstatedir}/log/ctdb \
	${RPM_BUILD_ROOT}/%{_rundir}/ctdb

%if 0%{?suse_version} == 1010
export SGML_CATALOG_FILES=/usr/share/xml/docbook/stylesheet/nwalsh/1.69.1/catalog.xml
%endif

%{__make} install \
	DESTDIR=${RPM_BUILD_ROOT} \
	docdir=%{_docdir}
%if 0%{?suse_version}
mkdir -p ${RPM_BUILD_ROOT}/%{_var}/adm/fillup-templates
%{__install} -m 0644 ${RPM_SOURCE_DIR}/ctdb-sysconfig-suse.template ${RPM_BUILD_ROOT}/%{_var}/adm/fillup-templates/sysconfig.ctdb
%else
%{__install} -m 0644 config/ctdb.sysconfig ${RPM_BUILD_ROOT}/%{_sysconfdir}/sysconfig/ctdb
%endif
%if 0%{?suse_version} > 1220
%{__install} -m 0755 config/ctdb.service %{buildroot}%{_unitdir}/ctdb.service
ln -s service %{buildroot}/%{_sbindir}/rcctdb
# create tmpfile conf
install -d -m 0755 %{buildroot}/%{_tmpfilesdir}
echo "d /run/ctdbd 0755 root root" >%{buildroot}/%{_tmpfilesdir}/ctdb.conf
%else
%{__install} -m 0755 config/ctdb.init ${RPM_BUILD_ROOT}/%{initdir}/ctdb
ln -s %{_sysconfdir}/init.d/ctdb %{buildroot}/%{_sbindir}/rcctdb
%endif
install -m 0644 -p config/events.d/README README.eventscripts
install -m 0644 -p config/notify.d.README README.notify.d
# sudo can be used by statd-callout, but is not needed
rm ${RPM_BUILD_ROOT}/%{_sysconfdir}/sudoers.d/ctdb

%pre
%if 0%{?suse_version} > 1220
%service_add_pre ctdb.service
%endif

%preun
%if 0%{?suse_version} > 1220
%service_del_preun ctdb.service
%endif
%if 0%{?suse_version} == 0
if [ $1 = 0 ] ; then
	test -x /sbin/chkconfig && /sbin/chkconfig --del ctdb
fi
%endif
exit 0

%post
%if 0%{?suse_version}
%if 0%{?suse_version} > 1220
%{fillup_only}
%service_add_post ctdb.service
%{_bindir}/systemd-tmpfiles --create %{_tmpfilesdir}/ctdb.conf
%else
%{fillup_and_insserv}
%endif
%endif

%postun
%if 0%{?suse_version}
%if 0%{?suse_version} > 1220
%service_del_postun ctdb.service
%else
%{insserv_cleanup}
%endif
%else
if [ "$1" -ge "1" ]; then
	%{initdir}/ctdb restart >/dev/null
fi
%endif
exit 0

%files
%defattr(-,root,root)
%dir %{_sysconfdir}/ctdb
%dir %{_sysconfdir}/ctdb/events.d
%dir %{_sysconfdir}/ctdb/nfs-rpc-checks.d
%if 0%{?suse_version}
%{_var}/adm/fillup-templates/sysconfig.ctdb
%else
%config(noreplace) %{_sysconfdir}/sysconfig/ctdb
%endif
%config(noreplace) %{_sysconfdir}/ctdb/notify.sh
%config(noreplace) %{_sysconfdir}/ctdb/debug-hung-script.sh
%config(noreplace) %{_sysconfdir}/ctdb/ctdb-crash-cleanup.sh
%config(noreplace) %{_sysconfdir}/ctdb/gcore_trace.sh
%if 0%{?suse_version} > 1220
%attr(644,root,root) %{_unitdir}/ctdb.service
%dir %{_tmpfilesdir}
%{_tmpfilesdir}/ctdb.conf
%ghost %dir /run/ctdbd
%else
%attr(755,root,root) %{initdir}/ctdb
%endif
%{_sysconfdir}/ctdb/functions
%attr(775,root,root) %verify(not mode) %{_sysconfdir}/ctdb/events.d/00.ctdb
%attr(644,root,root) %verify(not mode) %{_sysconfdir}/ctdb/events.d/01.reclock
%attr(644,root,root) %verify(not mode) %{_sysconfdir}/ctdb/events.d/10.interface
%attr(644,root,root) %verify(not mode) %{_sysconfdir}/ctdb/events.d/11.natgw
%attr(644,root,root) %verify(not mode) %{_sysconfdir}/ctdb/events.d/11.routing
%attr(644,root,root) %verify(not mode) %{_sysconfdir}/ctdb/events.d/13.per_ip_routing
%attr(644,root,root) %verify(not mode) %{_sysconfdir}/ctdb/events.d/20.multipathd
%attr(644,root,root) %verify(not mode) %{_sysconfdir}/ctdb/events.d/31.clamd
%attr(644,root,root) %verify(not mode) %{_sysconfdir}/ctdb/events.d/40.vsftpd
%attr(644,root,root) %verify(not mode) %{_sysconfdir}/ctdb/events.d/41.httpd
%attr(644,root,root) %verify(not mode) %{_sysconfdir}/ctdb/events.d/50.samba
%attr(644,root,root) %verify(not mode) %{_sysconfdir}/ctdb/events.d/60.nfs
%attr(644,root,root) %verify(not mode) %{_sysconfdir}/ctdb/events.d/60.ganesha
%attr(644,root,root) %verify(not mode) %{_sysconfdir}/ctdb/events.d/62.cnfs
%attr(644,root,root) %verify(not mode) %{_sysconfdir}/ctdb/events.d/70.iscsi
%attr(644,root,root) %verify(not mode) %{_sysconfdir}/ctdb/events.d/91.lvs
%attr(644,root,root) %verify(not mode) %{_sysconfdir}/ctdb/events.d/40.fs_use
%attr(644,root,root) %verify(not mode) %{_sysconfdir}/ctdb/events.d/49.winbind
%attr(644,root,root) %verify(not mode) %{_sysconfdir}/ctdb/events.d/99.timeout
%attr(644,root,root) %verify(not mode) %{_sysconfdir}/ctdb/nfs-rpc-checks.d/10.statd.check
%attr(644,root,root) %verify(not mode) %{_sysconfdir}/ctdb/nfs-rpc-checks.d/20.nfsd.check
%attr(644,root,root) %verify(not mode) %{_sysconfdir}/ctdb/nfs-rpc-checks.d/30.lockd.check
%attr(644,root,root) %verify(not mode) %{_sysconfdir}/ctdb/nfs-rpc-checks.d/40.mountd.check
%attr(644,root,root) %verify(not mode) %{_sysconfdir}/ctdb/nfs-rpc-checks.d/50.rquotad.check
%attr(644,root,root) %verify(not mode) %{_sysconfdir}/ctdb/debug_locks.sh
%{_sysconfdir}/ctdb/statd-callout
%{_sbindir}/ctdbd
%{_sbindir}/ctdbd_wrapper
%{_sbindir}/rcctdb
%{_bindir}/ctdb
%{_bindir}/smnotify
%{_bindir}/ctdb_diagnostics
%{_bindir}/ctdb_event_helper
%{_bindir}/ltdbtool
%{_bindir}/onnode
%{_bindir}/ping_pong
%{_bindir}/ctdb_lock_helper
%dir %{_localstatedir}/lib/ctdb
%dir %{_localstatedir}/lib/ctdb/persistent
%dir %{_localstatedir}/log/ctdb
%ghost %dir %{_rundir}/ctdb
%{_mandir}/man1/*
%{_mandir}/man5/ctdbd.conf.5.*
%{_mandir}/man7/ctdb-statistics.7.*
%{_mandir}/man7/ctdb-tunables.7.*
%{_mandir}/man7/ctdb.7.*
%doc README COPYING NEWS
%doc README.eventscripts README.notify.d
%doc doc/recovery-process.txt
%doc doc/*.html
%doc doc/examples

%files devel
%defattr(-,root,root)
%{_includedir}/ctdb.h
%{_includedir}/ctdb_client.h
%{_includedir}/ctdb_private.h
%{_includedir}/ctdb_protocol.h
%{_includedir}/ctdb_typesafe_cb.h
%{_libdir}/pkgconfig/ctdb.pc

%if 0%{?build_pmda}
%files pcp-pmda
%defattr(-,root,root)
%dir %{_localstatedir}/lib/pcp
%dir %{_localstatedir}/lib/pcp/pmdas
%dir %{_localstatedir}/lib/pcp/pmdas/ctdb
%{_localstatedir}/lib/pcp/pmdas/ctdb/Install
%{_localstatedir}/lib/pcp/pmdas/ctdb/README
%{_localstatedir}/lib/pcp/pmdas/ctdb/Remove
%{_localstatedir}/lib/pcp/pmdas/ctdb/domain.h
%{_localstatedir}/lib/pcp/pmdas/ctdb/help
%{_localstatedir}/lib/pcp/pmdas/ctdb/pmdactdb
%{_localstatedir}/lib/pcp/pmdas/ctdb/pmns
%endif

%changelog