File resource-agents.spec of Package resource-agents.2497

#
# spec file for package resource-agents
#
# Copyright (c) 2016 SUSE LINUX 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%{?fedora} || 0%{?centos_version} || 0%{?rhel}
%global agents_docdir %{_defaultdocdir}/%{name}-%{version}
%endif
%if 0%{?suse_version}
%global agents_docdir %{_defaultdocdir}/%{name}
%endif
# 
# Since this spec file supports multiple distributions, ensure we
# use the correct group for each.
#
%if 0%{?fedora} || 0%{?centos_version} || 0%{?rhel}
%define pkg_group System Environment/Daemons
%else
%define pkg_group Productivity/Clustering/HA
%endif
%define SSLeay		        perl-Net-SSLeay
%if 0%{?suse_version} < 1100
%define SSLeay			perl-Net_SSLeay
%endif

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

%define with_monitoring 1

Name:           resource-agents
Summary:        Open Source HA Reusable Cluster Resource Scripts
License:        GPL-2.0 and LGPL-2.1+ and GPL-3.0+
Group:          Productivity/Clustering/HA
Version:        3.9.6+git.1442374860.7f3628a
Release:        0
Url:            http://linux-ha.org/
Source:         resource-agents-%{version}.tar.xz
Source1:        resource-agents.conf
Source2:        monitoring-plugins-metadata.tar.bz2
# PATCH-FIX-OPENSUSE: activate VG with partial PV by default
Patch2:         lvm-vg-partial-active.diff
# PATCH-FIX-OPENSUSE: fix path to sm-notify
Patch3:         resource-agents-nfsserver-sle11.patch
# PATCH-FIX-OPENSUSE: ldirectord: don't create subsys lock
Patch4:         no-var-lock-subsys.patch
# PATCH-FIX-OPENSUSE: Revert moving binaries to /usr/libexec
Patch8:         0006-Revert-Low-build-Move-binaries-in-usr-lib-heartbeat-.patch
# PATCH-FIX-UPSTREAM: nfsserver: Add EXEC_MODE for systemd without nfs-lock.service (bsc#955114)
Patch9:         0001-nfsserver-Add-EXEC_MODE-for-systemd-without-nfs-lock.patch
# PATCH-FIX-UPSTREAM: nfsserver: Use rpc-statd.service for NFS locking in EXEC_MODE=3 (bsc#955114)
Patch10:        0002-nfsserver-Use-rpc-statd.service-for-NFS-locking-in-E.patch
# PATCH-FIX-UPSTREAM: /var/lock/subsys is non-standard, check for it first (bsc#965179)
Patch12:        0004-var-lock-subsys-is-non-standard-check-for-it-first.patch
# PATCH-FIX-UPSTREAM: Medium: exportfs: don't increment fsid for single directory (bsc#961380)
Patch13:        0005-Medium-exportfs-don-t-increment-fsid-for-single-dire.patch
# PATCH-FIX-UPSTREAM: Low: nfsserver: prevent error messages on platforms without rpcuser (again) (bsc#965179)
Patch14:        0006-Low-nfsserver-prevent-error-messages-on-platforms-wi.patch
# PATCH-FIX-UPSTREAM: Medium: nfsserver: do redhat specific stuff on redhat (bsc#956739)
Patch15:        0007-Medium-nfsserver-do-redhat-specific-stuff-on-redhat.patch
# PATCH-FIX-UPSTREAM: Low: ldirectord: Fix unset failcount error (bsc#962795)
Patch16:        0008-Low-ldirectord-Fix-unset-failcount-error.patch
# PATCH-FIX-UPSTREAM: Medium: nfsserver: fix monitor for systemd (bsc#965179)
Patch17:        0009-Medium-nfsserver-fix-monitor-for-systemd.patch
# PATCH-FIX-UPSTREAM: High: SAPDatabase: Add support for Oracle 12c (bsc#967380)
Patch18:        0007-High-SAPDatabase-Add-support-for-Oracle-12c.patch
# PATCH-FIX-UPSTREAM: Medium: symlink: Handle missing directories in target (bsc#973054)
Patch19:        0001-Medium-symlink-Handle-missing-directories-in-target-.patch
# PATCH-FIX-UPSTREAM: Low: SAPInstance: Update version support statement (bsc#965872)
Patch20:        0001-Low-SAPInstance-Update-version-support-statement-bsc.patch
# PATCH-FIX-SUSE: Medium: ldirectord: Remove IPv6 workaround (bsc#977193)
Patch21:        0001-Medium-ldirectord-Remove-IPv6-workaround-bsc-977193.patch
# PATCH-FIX-UPSTREAM: exportfs: Add pseudo resource factor (bsc#978680)
Patch22:        0001-exportfs-Add-pseudo-resource-factor-bsc-978680.patch
# PATCH-FIX-UPSTREAM: send_arp: fix for infiniband, re-merge from upstream iputils arping (bsc#985486)
Patch23:        0001-send_arp-fix-for-infiniband-bsc-985486.patch

BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Obsoletes:      heartbeat-resources
Provides:       heartbeat-resources
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  glib2-devel
BuildRequires:  pkgconfig
BuildRequires:  python-devel
%if 0%{?suse_version}  
BuildRequires:  libglue-devel
%if %suse_version > 1130
BuildRequires:  libnet-devel
%else
BuildRequires:  libnet
%endif
BuildRequires:  docbook-xsl-stylesheets
BuildRequires:  docbook_4
BuildRequires:  libxslt
%endif
%if 0%{?fedora} || 0%{?centos_version} || 0%{?rhel}
BuildRequires:  cluster-glue-libs-devel
BuildRequires:  docbook-dtds
BuildRequires:  docbook-style-xsl
BuildRequires:  libxslt
BuildRequires:  which
%endif

%description
A set of scripts to interface with several services to operate in a
High Availability environment for both Pacemaker and rgmanager
service managers.

%package -n ldirectord
Summary:        A Monitoring Daemon for Maintaining High Availability Resources
License:        GPL-2.0 and LGPL-2.1+
Group:          Productivity/Clustering/HA
Requires:       %{SSLeay}
Requires:       %{name}
Requires:       ipvsadm
Requires:       perl-libwww-perl
Obsoletes:      heartbeat-ldirectord
Provides:       heartbeat-ldirectord
Requires:       perl-IO-Socket-INET6
Requires:       perl-MailTools
Requires:       perl-Socket6
%if 0%{?suse_version}
Requires:       logrotate
%endif
%if 0%{?fedora_version}
Requires(post): /sbin/chkconfig
Requires(preun):/sbin/chkconfig
%endif
%if %{defined systemd_requires}
BuildRequires:  systemd
%{?systemd_requires}
%endif

%description -n ldirectord
The Linux Director Daemon (ldirectord) was written by Jacob Rief.
<jacob.rief@tiscover.com>

ldirectord is a stand alone daemon for monitoring the services on real
servers. Currently, HTTP, HTTPS, and FTP services are supported.
ldirectord is simple to install and works with the heartbeat code
(http://www.linux-ha.org/).

See 'ldirectord -h' and linux-ha/doc/ldirectord for more information.

%if %{with_monitoring}

%package -n monitoring-plugins-metadata
Summary:        Metadata for Monitoring plugins
License:        LGPL-2.1+ and GPL-2.0+
Group:          Productivity/Clustering/HA
Provides:       nagios-plugins-metadata
Requires:       monitoring-plugins-fping
Requires:       monitoring-plugins-http
Requires:       monitoring-plugins-ldap
Requires:       monitoring-plugins-mysql
Requires:       monitoring-plugins-pgsql
Requires:       monitoring-plugins-tcp
Requires:       resource-agents
#BuildArch:      noarch

%description -n monitoring-plugins-metadata
XML files containing metadata which facilitates using nagios
plugins as resource agents. These files were produced from help
pages of individual nagios plugins.

%endif

%prep
###########################################################
%setup -q
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
%patch17 -p1
%patch18 -p1
%patch19 -p1
%patch20 -p1
%patch21 -p1
%patch22 -p1
%patch23 -p1
###########################################################

%build
CFLAGS="${CFLAGS} ${RPM_OPT_FLAGS}"
export CFLAGS
%if %{defined _unitdir}
CONF_OPTS="--with-ras-set=linux-ha \
    --enable-fatal-warnings=yes \
    --with-systemdsystemunitdir=%{_unitdir} \
    --with-pkg-name=%{name} \
    --with-rsctmpdir=%{_rundir}/%{name}"
%else
CONF_OPTS="--with-ras-set=linux-ha \
    --enable-fatal-warnings=yes \
    --with-pkg-name=%{name}"
%endif
./autogen.sh
#because quilt push changed the permissions of  sg_persist.
chmod 775 heartbeat/sg_persist
%if 0%{?suse_version} >= 1020 || 0%{?fedora} >= 11 || 0%{?centos_version} > 5 || 0%{?rhel} > 5
%configure $CONF_OPTS \
    --docdir=%{agents_docdir}
%else
export docdir=%{agents_docdir}
%configure $CONF_OPTS
%endif
export MAKE="make %{?jobs:-j%jobs}"
make %{?jobs:-j%jobs}
###########################################################

%install
###########################################################
make DESTDIR=$RPM_BUILD_ROOT install
(
  mkdir -p $RPM_BUILD_ROOT/etc/ha.d/resource.d
  ln -s %{_sbindir}/ldirectord $RPM_BUILD_ROOT/etc/ha.d/resource.d/ldirectord
) || true
test -d $RPM_BUILD_ROOT/sbin || mkdir $RPM_BUILD_ROOT/sbin
(
  cd $RPM_BUILD_ROOT/sbin
%if %{defined _unitdir}
  ln -s /usr/sbin/service rcldirectord
%else
  ln -sf /etc/init.d/ldirectord rcldirectord 
%endif
) || true
# Dont package static libs or compiled python
find $RPM_BUILD_ROOT -name '*.a' -type f -print0 | xargs -0 rm -f
find $RPM_BUILD_ROOT -name '*.la' -type f -print0 | xargs -0 rm -f
find $RPM_BUILD_ROOT -name '*.pyc' -type f -print0 | xargs -0 rm -f
find $RPM_BUILD_ROOT -name '*.pyo' -type f -print0 | xargs -0 rm -f
# Unset execute permissions from things that shouln't have it
find $RPM_BUILD_ROOT -name 'ocf-*'  -type f -print0 | xargs -0 chmod a-x
find $RPM_BUILD_ROOT -name '*.dtd'  -type f -print0 | xargs -0 chmod a-x
chmod 0755 $RPM_BUILD_ROOT/usr/sbin/ocf-tester
chmod 0755 $RPM_BUILD_ROOT/usr/sbin/ocft
mkdir -p $RPM_BUILD_ROOT/usr/lib/tmpfiles.d
install -m 644 %{SOURCE1} $RPM_BUILD_ROOT/usr/lib/tmpfiles.d
(
cd $RPM_BUILD_ROOT/%{_libdir}/heartbeat
for f in ocf-returncodes ocf-shellfuncs
do
    ln -s /usr/lib/ocf/lib/heartbeat/$f
done
)

%if %{with_monitoring}
# install nagios plugins XML metadata
tar -xjf %{SOURCE2}
mkdir -p %{buildroot}%{_datadir}/nagios/plugins-metadata
for file in $(find plugins-metadata -type f); do
	install -m 644 $file %{buildroot}%{_datadir}/nagios/plugins-metadata
done
%endif

###########################################################

%clean
###########################################################
if
  [ -n "${RPM_BUILD_ROOT}" -a "${RPM_BUILD_ROOT}" != "/" ]
then
  rm -rf $RPM_BUILD_ROOT
fi
rm -rf $RPM_BUILD_DIR/resource-agents
###########################################################
%post
test -d %{_rundir}/resource-agents || mkdir -m 1755 %{_rundir}/resource-agents

%if 0%{?suse_version}

%preun -n ldirectord
%if %{defined _unitdir}
%service_del_preun ldirectord.service
%else
%stop_on_removal ldirectord
%endif

%postun -n ldirectord
%if %{defined _unitdir}
%service_del_postun ldirectord.service
%else
%insserv_cleanup
%endif

%post -n ldirectord
%if %{defined _unitdir}
%service_add_post ldirectord.service
%endif

%pre -n ldirectord
%if %{defined _unitdir}
%service_add_pre ldirectord.service
%endif

%endif

%if 0%{?fedora}

%preun -n ldirectord
/sbin/chkconfig --del ldirectord

%postun -n ldirectord -p /sbin/ldconfig

%post -n ldirectord
/sbin/chkconfig --add ldirectord

%endif

%files
###########################################################
%defattr(-,root,root)
%dir /usr/lib/ocf
%dir /usr/lib/ocf/resource.d
%dir /usr/lib/ocf/lib
%dir /usr/lib/tmpfiles.d
/usr/lib/tmpfiles.d/resource-agents.conf
%dir %{_datadir}/%{name}
%dir %{_datadir}/%{name}/ocft
%dir %{_datadir}/%{name}/ocft/configs
%config(noreplace) %{_datadir}/%{name}/ocft/configs/*
%{_datadir}/%{name}/ocft/caselib
%{_datadir}/%{name}/ocft/README
%{_datadir}/%{name}/ocft/README.zh_CN
/usr/lib/ocf/resource.d/heartbeat
/usr/lib/ocf/lib/heartbeat
%{_sbindir}/ocf-tester
%{_sbindir}/ocft
%{_sbindir}/sfex_init
%{_sbindir}/sfex_stat
%{_includedir}/heartbeat
%ghost %dir %attr (1755, root, root)  %{_rundir}/resource-agents
%doc AUTHORS
%doc COPYING
%doc COPYING.LGPL
%doc COPYING.GPLv3
%doc %{_datadir}/%{name}/ra-api-1.dtd
%doc %{_mandir}/man7/*.7*
%doc %{_mandir}/man8/ocf-tester.8*
%doc %{_mandir}/man8/sfex_init.8*
%doc doc/README.webapps
# For compatability with pre-existing agents
%dir /etc/ha.d
/etc/ha.d/shellfuncs
%dir %{_libdir}/heartbeat
%{_libdir}/heartbeat/ocf-shellfuncs
%{_libdir}/heartbeat/ocf-returncodes
%{_libdir}/heartbeat/send_arp
%{_libdir}/heartbeat/send_ua
%{_libdir}/heartbeat/sfex_daemon
%{_libdir}/heartbeat/findif
%{_libdir}/heartbeat/tickle_tcp

%files -n ldirectord
###########################################################
%defattr(-,root,root)
%doc ldirectord/ldirectord.cf
%doc %{_mandir}/man8/ldirectord.8*
%dir /etc/ha.d/resource.d
#%doc %{_mandir}/man8/supervise-ldirectord-config.8*
%{_sbindir}/ldirectord
/sbin/rcldirectord
%if %{defined _unitdir}
%{_unitdir}/ldirectord.service
%exclude %{_sysconfdir}/init.d/ldirectord
%else
%{_sysconfdir}/init.d/ldirectord
%endif
#%{_sbindir}/supervise-ldirectord-config
%{_sysconfdir}/ha.d/resource.d/ldirectord
%config(noreplace) %{_sysconfdir}/logrotate.d/ldirectord

%if %{with_monitoring}
%files -n monitoring-plugins-metadata
###########################################################
%defattr(-,root,root)
%dir %{_datadir}/nagios
%dir %{_datadir}/nagios/plugins-metadata
%attr(0644,root,root) %{_datadir}/nagios/plugins-metadata/*
%endif

%changelog
openSUSE Build Service is sponsored by