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

#
# spec file for package resource-agents
#
# Copyright (c) 2019 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 https://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

%if 0%{?suse_version} >= 1210
%bcond_without systemd
%else
%bcond_with systemd
%endif

Name:           resource-agents
Summary:        Open Source HA Reusable Cluster Resource Scripts
License:        GPL-2.0-only AND LGPL-2.1-or-later AND GPL-3.0-or-later
Group:          Productivity/Clustering/HA
Version:        3.9.7+git.1461938976.cb7c36a
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-OPENSUSE: Medium: ldirectord: Remove IPv6 workaround (bsc#977193)
Patch9:         0001-Medium-ldirectord-Remove-IPv6-workaround-bsc-977193.patch
# PATCH-FIX-OPENSUSE: Medium: CTDB: Use --logging syntax for ctdbd (bsc#981863)
Patch10:        0001-Medium-CTDB-Use-logging-syntax-for-ctdbd-bsc-981863.patch
# PATCH-FIX-UPSTREAM: exportfs: Add pseudo resource factor (bsc#978680)
Patch11:        0001-exportfs-Add-pseudo-resource-factor-bsc-978680.patch
# PATCH-FIX-UPSTREAM: Low: ocf-shellfuncs: update HA_RSCTMP documentation
Patch12:        0002-Low-ocf-shellfuncs-update-HA_RSCTMP-documentation.patch
# PATCH-FIX-UPSTREAM: exportfs: Add IPv6 support
Patch13:        0003-exportfs-Add-IPv6-support.patch
# PATCH-FIX-UPSTREAM: oracle: fix MONPROFILE to use monprofile parameter when set
Patch14:        0004-oracle-fix-MONPROFILE-to-use-monprofile-parameter-wh.patch
# PATCH-FIX-UPSTREAM: oracle: fix issue with C## in monprofile (bsc#1005424)
Patch15:        0005-oracle-fix-issue-with-C-in-monprofile.patch
# PATCH-FIX-UPSTREAM: oracle: add quotes for monuser and monpassword
Patch16:        0006-oracle-add-quotes-for-monuser-and-monpassword-and-in.patch
# PATCH-FIX-UPSTREAM: High: nfsserver: Delete the temp file correctly.
Patch17:        0007-High-nfsserver-Delete-the-temp-file-correctly.patch
# PATCH-FIX-UPSTREAM: adjusting sapdb.sh to work with HANA Multi-Tenant Databases (bsc#1007142)
Patch18:        0008-adjusting-sapdb.sh-to-work-with-HANA-Multi-Tenant-Da.patch
# PATCH-FIX-UPSTREAM: Medium: docker: Use docker exec for monitor_cmd if supported (bsc#1007867)
Patch19:        0009-Medium-docker-Use-docker-exec-for-monitor_cmd-if-sup.patch
# PATCH-FIX-UPSTREAM: Fix missing ocf_script definitions
Patch20:        0010-Fix-missing-ocf_script-definitions.patch
# PATCH-FIX-UPSTREAM: Medium: docker: Reduce monitor log spam
Patch21:        0011-Medium-docker-Reduce-monitor-log-spam.patch
# PATCH-FIX-UPSTREAM: Doc: docker: Clarify limitations of monitor_cmd in parameter description
Patch22:        0012-Doc-docker-Clarify-limitations-of-monitor_cmd-in-par.patch
# PATCH-FIX-UPSTREAM: Medium: exportfs: Only strip brackets from edges of clientspec (bsc#1022223)
Patch23:        0013-Medium-exportfs-Only-strip-brackets-from-edges-of-cl.patch
# PATCH-FIX-UPSTREAM: Medium: SAPInstance: Add IS_ERS parameter (bsc#1036486)
Patch24:        0014-Medium-SAPInstance-Add-IS_ERS-parameter-bsc-1036486.patch
# PATCH-FIX-UPSTREAM: High: aws-vpc-route53: Add agent for AWS Route 53 (fate#322781)
Patch25:        0015-High-aws-vpc-route53-Add-agent-for-AWS-Route-53-fate.patch
# PATCH-FIX-UPSTREAM: Low: sg_persist: Read empty value when when no attribute exists (bsc#1048288)
Patch26:        0016-Low-sg_persist-Read-empty-value-when-when-no-attribu.patch
# PATCH-FIX-UPSTREAM: sg_persist: fix matching of hex node ids (bsc#1048170)
Patch27:        0017-sg_persist-fix-matching-of-hex-node-ids-bsc-1048170.patch
# PATCH-FIX-UPSTREAM: DB2: fix HADR support for DB2 V98+ (bsc#1035470)
Patch28:        0018-DB2-fix-HADR-support-for-DB2-V98.patch
# PATCH-FIX-UPSTREAM: High: galera: Backport fixes from upstream (bsc#1055017) (bsc#1056635)
Patch29:        0019-High-galera-Backport-patches-from-upstream-bsc-10550.patch
# PATCH-FIX-UPSTREAM: Medium: Raid1: Handle case when mddev is a symlink(bsc#1047991)
Patch30:        0020-Medium-Raid1-Handle-case-when-mddev-is-a-symlink.patch
# PATCH-FIX-UPSTREAM: Low: SAPInstance: Mention monitor support in documentation (bsc#1051913)
Patch31:        0021-Low-SAPInstance-Mention-monitor-support-in-documenta.patch
# PATCH-FIX-UPSTREAM: Medium: aws-vpc-route53: Fix tempfile race (bsc#1059312)
Patch32:        0022-High-aws-vpc-route53-Add-agent-for-AWS-Route-53-fate.patch
# PATCH-FIX-UPSTREAM: Medium: aws-vpc-route53: Fix tempfile race (bsc#1059312)
Patch33:        0023-Low-aws-vpc-route53-Fix-missing-ocf_log-in-log-messa.patch
# PATCH-FIX-UPSTREAM: Medium: aws-vpc-route53: Fix tempfile race (bsc#1059312)
Patch34:        0024-Medium-aws-vpc-route53-Fix-tempfile-race-bsc-1059312.patch
# PATCH-FIX-UPSTREAM: Medium: aws-vpc-route53: Fix tempfile race (bsc#1059312)
Patch35:        0025-Dev-aws-vpc-route53-Eliminate-duplicated-code.patch
# PATCH-FIX-UPSTREAM: Medium: aws-vpc-route53: Fix tempfile race (bsc#1059312)
Patch36:        0026-Dev-aws-vpc-route53-Clean-up-logging.patch
# PATCH-FIX-UPSTREAM: Midumu: docker: fix to deal with the image name correctly. (bsc#1058318)
Patch37:        0027-Midumu-docker-fix-to-deal-with-the-image-name-correc.patch
# PATCH-FIX-UPSTREAM: Low: Raid1: remove unnecessary wait flags (bsc#1077416)
Patch38:        0028-Low-Raid1-remove-unnecessary-wait-flags-bsc-1077416.patch
# PATCH-FIX-UPSTREAM: Medium: Raid1: Ignore transient devices after stopping a device (bsc#1077416)
Patch39:        0029-Medium-Raid1-Ignore-transient-devices-after-stopping.patch
# PATCH-FIX-UPSTREAM: SAPInstance: implemeted reload method
Patch40:        0030-SAPInstance-implemeted-reload-method.patch
# PATCH-FIX-UPSTREAM: SAPInstance: Improved indents
Patch41:        0031-SAPInstance-Improved-indents.patch
# PATCH-FIX-UPSTREAM: Medium: SAPInstance: Add monitored services for ENSA2
Patch42:        0032-Medium-SAPInstance-Add-monitored-services-for-ENSA2-.patch
# PATCH-FIX-UPSTREAM: SAPInstance: Improved SAP instance profile detection
Patch43:        0033-SAPInstance-Improved-SAP-instance-profile-detection.patch
# PATCH-FIX-UPSTREAM: systemd: add resource-agents-deps target
Patch44:        0034-systemd-add-resource-agents-deps-target.patch
# PATCH-FIX-UPSTREAM: Low: Refactor systemd detection
Patch45:        0035-Low-Refactor-systemd-detection.patch
# PATCH-FIX-UPSTREAM: VirtualDomain: Properly migrate VMs on node shutdown (bsc#1074014)
Patch46:        0036-VirtualDomain-Properly-migrate-VMs-on-node-shutdown-.patch
# PATCH-FIX-UPSTREAM: Low: VirtualDomain: fix warning messages in log
Patch47:        0037-Low-VirtualDomain-fix-warning-messages-in-log.patch
# PATCH-FIX-UPSTREAM: CTDB: fix initial probe
Patch48:        0038-CTDB-fix-initial-probe.patch
# PATCH-FIX-UPSTREAM: CTDB: fix incorrect db corruption reports (bsc#1101668)
Patch49:        0039-CTDB-fix-incorrect-db-corruption-reports-bsc-1101668.patch
# PATCH-FIX-UPSTREAM: CTDB: fix OCF_RESKEY_ctdb_recovery_lock validation (bsc#1097656)
Patch50:        0040-CTDB-fix-OCF_RESKEY_ctdb_recovery_lock-validation-bs.patch
# PATCH-FIX-UPSTREAM: galera: Ignore safe_to_bootstrap in grastate.dat in some cases (bsc#1131793)
Patch51:        0051-galera-Ignore-safe_to_bootstrap-in-grastate.dat-in-s.patch
# PATCH-FIX-UPSTREAM: galera: Allow empty password for "check_passwd" parameter (bsc#1131793)
Patch52:        0052-galera-Allow-empty-password-for-check_passwd-paramet.patch
# PATCH-FIX-UPSTREAM: galera: Log message when changing content of grastate.dat file (bsc#1131793)
Patch53:        0053-galera-Log-message-when-changing-content-of-grastate.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-only AND LGPL-2.1-or-later
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 %{with systemd}
BuildRequires:  systemd-rpm-macros
%{?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-or-later AND GPL-2.0-or-later
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
%patch11 -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
%patch24 -p1
%patch25 -p1
%patch26 -p1
%patch27 -p1
%patch28 -p1
%patch29 -p1
%patch30 -p1
%patch31 -p1
%patch32 -p1
%patch33 -p1
%patch34 -p1
%patch35 -p1
%patch36 -p1
%patch37 -p1
%patch38 -p1
%patch39 -p1
%patch40 -p1
%patch41 -p1
%patch42 -p1
%patch43 -p1
%patch44 -p1
%patch45 -p1
%patch46 -p1
%patch47 -p1
%patch48 -p1
%patch49 -p1
%patch50 -p1
%patch51 -p1
%patch52 -p1
%patch53 -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

%post
test -d %{_rundir}/resource-agents || mkdir -m 1755 %{_rundir}/resource-agents
%if %{with systemd}
%tmpfiles_create %_tmpfilesdir/resource-agents.conf
%service_add_post resource-agents-deps.target
%endif

%if %{with systemd}
%preun
%service_del_preun resource-agents-deps.target

%postun
%service_del_postun resource-agents-deps.target

%pre
%service_add_pre resource-agents-deps.target
%endif

%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
%{_datadir}/%{name}/ocft/helpers.sh
%{_datadir}/%{name}/ocft/runocft
%{_datadir}/%{name}/ocft/runocft.prereq
/usr/lib/ocf/resource.d/heartbeat
/usr/lib/ocf/lib/heartbeat
%if %{with systemd}
%{_unitdir}/resource-agents-deps.target
%endif
%{_sbindir}/ocf-tester
%{_sbindir}/ocft
%{_sbindir}/sfex_init
%{_sbindir}/sfex_stat
%{_includedir}/heartbeat
%ghost %dir %attr (1755, root, root)  %{_rundir}/resource-agents
%doc AUTHORS
%license COPYING
%license COPYING.LGPL
%license 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