File pacemaker.spec of Package pacemaker.12290

# spec file for package pacemaker
# 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

#Compat macro for new _fillupdir macro introduced in Nov 2017
%if ! %{defined _fillupdir}
  %define _fillupdir /var/adm/fillup-templates

# Globals and defines to control package behavior (configure these as desired)

## User and group to use for nonprivileged services
%global uname hacluster
%global gname haclient

## Where to install Pacemaker documentation
%global pcmk_docdir %{_docdir}/%{name}

## Path to Python interpreter (leave commented to auto-detect,
## or uncomment and edit to use a specific version)
%global python_path /usr/bin/python%{python3_version}

## Corosync version
%define cs_version 2

%define with_nagios             1
%define with_cibsecrets         1
%define enable_lib_cluster_pkg  0
%define enable_fatal_warnings   0
%define with_regression_tests   0

# Define conditionals so that "rpmbuild --with <feature>" and
# "rpmbuild --without <feature>" can enable and disable specific features

## Add option to enable support for stonith/external fencing agents
%bcond_without stonithd

## Add option to create binaries suitable for use with profiling tools
%bcond_with profiling

## Add option to create binaries with coverage analysis
%bcond_with coverage

## Add option to skip generating documentation
## (the build tools aren't available everywhere)
%bcond_with doc

## Add option to turn off hardening of libraries and daemon executables
%bcond_with hardening

## Add option to disable links for legacy daemon names
%bcond_without legacy_links

# Keep sane profiling data if requested
%if %{with profiling}

## Disable -debuginfo package and stripping binaries/libraries
%define debug_package %{nil}


Name:           pacemaker
Version:        2.0.1+20190417.13d370ca9
Release:        0
Summary:        Scalable High-Availability cluster resource manager
# AGPL-3.0 licensed extra/ is not present in the binary
License:        GPL-2.0-only AND GPL-2.0-or-later AND LGPL-2.1-or-later
Group:          Productivity/Clustering/HA
# Hint: use "spectool -s 0 pacemaker.spec" (rpmdevtools) to check the final URL:
Source0:        %{name}-%{version}.tar.xz
Source100:      pacemaker.rpmlintrc
Patch1:         bug-806256_pacemaker-log-level-notice.patch
Patch3:         pacemaker-nagios-plugin-dir.patch
Patch4:         bug-812269_pacemaker-fencing-device-register-messages.patch
Patch5:         pacemaker-Wno-format-signedness.patch
Patch6:         bug-943295_pacemaker-lrmd-log-notice.patch
Patch7:         bug-977201_pacemaker-controld-self-fencing.patch
Patch8:         bug-995365_pacemaker-cts-restart-systemd-journald.patch
Patch9:         pacemaker-cts-StartCmd.patch
Patch10:        0001-Revert-Fix-service-lib-avoid-call-pattern-leading-to.patch
Patch11:        0002-Revert-use-common-service-interface-for-fence-agents.patch
Patch12:        bug-728579_pacemaker-stonith-dev-id.patch
Patch13:        bsc#1131353-bsc#1131356-0001-Fix-libcrmcommon-avoid-use-of-NULL-when-checking-whe.patch
Patch14:        bsc#1131353-bsc#1131356-0001-Low-libcrmcommon-return-proper-code-if-testing-pid-i.patch
Patch15:        0001-Low-controller-avoid-memory-leak-when-duplicate-moni.patch
Patch16:        bsc#1127716-0001-Fix-libcrmcommon-correctly-apply-XML-diffs-with-mult.patch
Patch17:        bsc#1127716-0002-Fix-libcrmcommon-avoid-possible-use-of-NULL-when-app.patch
Patch18:        bsc#1127716-0003-Fix-libcrmcommon-return-error-when-applying-XML-diff.patch
Patch19:        bsc#1133866-0001-Fix-controller-confirm-cancel-of-failed-monitors.patch
Patch20:        bsc#1135317-0001-Low-stonith_admin-help-specify-the-usage-of-cleanup.patch
Patch21:        bsc#1130122-0001-Fix-scheduler-wait-for-probe-actions-to-complete-to-.patch
Patch22:        bsc#1130122-0002-Test-scheduler-wait-for-probe-actions-to-complete-to.patch
# Required for core functionality
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  coreutils
BuildRequires:  fdupes
BuildRequires:  findutils
BuildRequires:  gcc
BuildRequires:  grep
BuildRequires:  help2man
BuildRequires:  libtool
BuildRequires:  ncurses-devel
BuildRequires:  pam-devel
BuildRequires:  pkgconfig
# Required for agent_config.h which specifies the correct scratch directory
BuildRequires:  resource-agents
BuildRequires:  sed
%if %{with_cibsecrets}
BuildRequires:  openssh
BuildRequires:  procps
BuildRequires:  pkgconfig(bzip2)
BuildRequires:  pkgconfig(corosync) >= 2.0.0
BuildRequires:  pkgconfig(dbus-1)
BuildRequires:  pkgconfig(glib-2.0) >= 2.16
BuildRequires:  pkgconfig(gnutls)
BuildRequires:  pkgconfig(libexslt)
# Pacemaker requires a minimum libqb functionality
BuildRequires:  pkgconfig(libqb) > 0.13.0
BuildRequires:  pkgconfig(libxml-2.0)
BuildRequires:  pkgconfig(libxslt)
# Pacemaker requires a minimum Python functionality
BuildRequires:  pkgconfig(python3)
BuildRequires:  pkgconfig(systemd)
BuildRequires:  pkgconfig(uuid)
Requires:       %{name}-cli = %{version}-%{release}
Requires:       corosync >= 2.0.0
Requires:       libpacemaker3 = %{version}-%{release}
Requires:       psmisc
Requires:       python3
Requires:       resource-agents
Recommends:     crmsh
Recommends:     fence-agents
Recommends:     libdlm
Recommends:     sbd
Suggests:       graphviz
Conflicts:      heartbeat < 3.0
Conflicts:      libheartbeat2 < 3.0.0
Provides:       pacemaker-ticket-support = 2.0
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if %{enable_lib_cluster_pkg}
Requires:       libpacemaker3-cluster = %{version}-%{release}
# Enables optional functionality
%if 0%{?suse_version} > 1100
BuildRequires:  docbook-xsl-stylesheets
BuildRequires:  docbook-style-xsl
%if %{with stonithd}
%if 0%{?suse_version}
BuildRequires:  libglue-devel
BuildRequires:  cluster-glue-libs-devel
%if %{with doc}
BuildRequires:  asciidoc
BuildRequires:  inkscape
BuildRequires:  publican
%if %{with_regression_tests}
BuildRequires:  procps
BuildRequires:  python3-curses
BuildRequires:  python3-xml

Pacemaker is an advanced, scalable High-Availability cluster resource

It supports more than 16 node clusters with significant capabilities
for managing resources and dependencies.

It will run scripts at initialization, when machines go up or down,
when related resources fail and can be configured to periodically check
resource health.

%package cli
Summary:        Command line tools for controlling Pacemaker clusters
Group:          Productivity/Clustering/HA
Requires:       libpacemaker3 = %{version}-%{release}
Requires:       logrotate
Requires:       perl-TimeDate
Requires:       procps
Requires:       psmisc
Requires(post): coreutils

%description cli
Pacemaker is an advanced, scalable High-Availability cluster resource

The %{name}-cli package contains command line tools that can be used
to query and control the cluster from machines that may, or may not,
be part of the cluster.

%package -n libpacemaker3
Summary:        Core Pacemaker libraries
Group:          Productivity/Clustering/HA
Requires(pre):  shadow
# sbd 1.4.0+ supports the libpe_status API for pe_working_set_t
Conflicts:      sbd < 1.4.0

%description -n libpacemaker3
Pacemaker is an advanced, scalable High-Availability cluster resource

The libpacemaker3 package contains shared libraries needed for cluster
nodes and those just running the CLI tools.

%package -n libpacemaker3-cluster
Summary:        Cluster Libraries used by Pacemaker
Group:          Productivity/Clustering/HA
Requires:       libpacemaker3 = %{version}-%{release}

%description -n libpacemaker3-cluster
Pacemaker is an advanced, scalable High-Availability cluster resource

The libpacemaker3-cluster package contains cluster-aware shared
libraries needed for nodes that will form part of the cluster nodes.

%package remote
Summary:        Pacemaker remote daemon for non-cluster nodes
Group:          Productivity/Clustering/HA
Requires:       %{name}-cli = %{version}-%{release}
Requires:       libpacemaker3 = %{version}-%{release}
Requires:       procps
Requires:       resource-agents

%description remote
Pacemaker is an advanced, scalable High-Availability cluster resource

The %{name}-remote package contains the Pacemaker Remote daemon
which is capable of extending pacemaker functionality to remote
nodes not running the full corosync/cluster stack.

%package -n libpacemaker-devel
Summary:        Pacemaker development package
Group:          Development/Libraries/C and C++
Requires:       libpacemaker3 = %{version}-%{release}
Requires:       libtool-ltdl-devel
Requires:       pkgconfig
Requires:       pkgconfig(bzip2)
Requires:       pkgconfig(corosync) >= 2.0.0
Requires:       pkgconfig(glib-2.0)
Requires:       pkgconfig(libqb)
Requires:       pkgconfig(libxml-2.0)
Requires:       pkgconfig(libxslt)
Requires:       pkgconfig(uuid)
%if %{enable_lib_cluster_pkg}
Requires:       libpacemaker3-cluster = %{version}-%{release}
%if %{with_regression_tests}
# For the regression tests, we can run them only if all pacemaker
# packages are installed, so we pull that in here for the regression
# builds; this is supposed to be disabled for shipping code.
Requires:       pacemaker

%description -n libpacemaker-devel
Pacemaker is an advanced, scalable High-Availability cluster resource

The libpacemaker-devel package contains headers and shared libraries
for developing tools for Pacemaker.

%package       cts
Summary:        Test framework for cluster-related technologies
Group:          Productivity/Clustering/HA
Requires:       libpacemaker3 = %{version}-%{release}
Requires:       procps
Requires:       psmisc
Requires:       python3
BuildArch:      noarch
#Requires:       python3-systemd
Recommends:     python3-systemd

%description   cts
Test framework for cluster-related technologies like Pacemaker

%package       doc
Summary:        Documentation for Pacemaker
Group:          Productivity/Clustering/HA
BuildArch:      noarch

%description   doc
Documentation for Pacemaker.

Pacemaker is an advanced, scalable High-Availability cluster resource

%setup -q -n %{name}-%{version}
%patch1 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -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


export systemdunitdir=%{?_unitdir}%{!?_unitdir:no}

%if %{with hardening}
# prefer distro-provided hardening flags in case they are defined
# through _hardening_{c,ld}flags macros, configure script will
# use its own defaults otherwise; if such hardenings are completely
# undesired, rpmbuild using "--without hardening"
# (or "--define '_without_hardening 1'")
export CFLAGS_HARDENED_EXE="%{?_hardening_cflags}"
export CFLAGS_HARDENED_LIB="%{?_hardening_cflags}"
export LDFLAGS_HARDENED_EXE="%{?_hardening_ldflags}"
export LDFLAGS_HARDENED_LIB="%{?_hardening_ldflags}"

autoreconf -fvi

%configure \
        --docdir=%{_docdir}/%{name}                \
        --disable-static                           \
        --disable-silent-rules                     \
        --with-acl=true                            \
%if %{with_nagios}
        --with-nagios=true                         \
%if %{with_cibsecrets}
        --with-cibsecrets=true                     \
%if !%{enable_fatal_warnings}
        --enable-fatal-warnings=no                 \
        PYTHON=%{python_path}                          \
        %{!?with_hardening:    --disable-hardening}    \
        %{!?with_legacy_links: --disable-legacy-links} \
        %{?with_profiling:     --with-profiling}       \
        %{?with_coverage:      --with-coverage}        \
        %{!?with_doc:          --with-brand=}          \
        --with-initdir=%{_initddir}                    \
        --localstatedir=%{_var}                        \

make %{?_smp_mflags} all


install -d -m755 %{buildroot}%{_fillupdir}
install -m 644 daemons/pacemakerd/pacemaker.sysconfig %{buildroot}%{_fillupdir}/sysconfig.pacemaker
install -m 644 tools/crm_mon.sysconfig %{buildroot}%{_fillupdir}/sysconfig.crm_mon

# Don't package static libs
find %{buildroot} -type f -name "*.a" -delete -print
find %{buildroot} -type f -name "*.la" -delete -print

# For now, don't package the servicelog-related binaries built only for
# ppc64le when certain dependencies are installed. If they get more exercise by
# advanced users, we can reconsider.
rm -f %{buildroot}/%{_sbindir}/notifyServicelogEvent
rm -f %{buildroot}/%{_sbindir}/ipmiservicelogd

# Don't ship init scripts for systemd based platforms
rm -f %{buildroot}/%{_initddir}/pacemaker
rm -f %{buildroot}/%{_initddir}/pacemaker_remote

%if %{with coverage}
mkdir -p $GCOV_BASE
find . -name '*.gcno' -type f | while read F ; do
        D=`dirname $F`
        mkdir -p ${GCOV_BASE}/$D
        cp $F ${GCOV_BASE}/$D

ln -s service %{buildroot}%{_sbindir}/rcpacemaker
ln -s service %{buildroot}%{_sbindir}/rcpacemaker_remote
ln -s service %{buildroot}%{_sbindir}/rccrm_mon

mv %{buildroot}%{_sbindir}/crm_report %{buildroot}%{_sbindir}/crm_report.pacemaker
install -m 755 %{SOURCE1} %{buildroot}%{_sbindir}/crm_report

ln -s ../heartbeat/NodeUtilization %{buildroot}%{_libexecdir}/ocf/resource.d/pacemaker/

%fdupes -s %{buildroot}

# Prevent false positives in rpmlint
./cts/cts-regression -V scheduler cli 2>&1

%service_add_pre pacemaker.service

%service_add_post pacemaker.service

%service_del_preun pacemaker.service

%service_del_postun pacemaker.service

%pre remote
%service_add_pre pacemaker_remote.service

%post remote
%service_add_post pacemaker_remote.service

%preun remote
%service_del_preun pacemaker_remote.service

%postun remote
%service_del_postun pacemaker_remote.service

%pre cli
%service_add_pre crm_mon.service

%post cli
if [ ! -e %{_sysconfdir}/sysconfig/pacemaker ]; then
    %fillup_only -n pacemaker

%service_add_post crm_mon.service

if [ ! -e %{_sysconfdir}/sysconfig/crm_mon ]; then
    %fillup_only -n crm_mon

if [ "$1" -eq "2" ]; then
    # Package upgrade, not initial install:
    # Move any pre-2.0 logs to new location to ensure they get rotated
    { mv -fbS.rpmsave %{_var}/log/pacemaker.log* %{_var}/log/pacemaker \
      || mv -f %{_var}/log/pacemaker.log* %{_var}/log/pacemaker
    } >/dev/null 2>/dev/null || :

%preun cli
%service_del_preun crm_mon.service

%postun cli
%service_del_postun crm_mon.service

%pre -n libpacemaker3
getent group %{gname} >/dev/null || groupadd -r %{gname} -g 189
getent passwd %{uname} >/dev/null || useradd -r -g %{gname} -u 189 -s /sbin/nologin -c "cluster user" %{uname}
exit 0

%post -n libpacemaker3 -p /sbin/ldconfig
%postun -n libpacemaker3 -p /sbin/ldconfig

%if %{enable_lib_cluster_pkg}
%post -n libpacemaker3-cluster -p /sbin/ldconfig
%postun -n libpacemaker3-cluster -p /sbin/ldconfig

%if %{with_regression_tests}
%post -n libpacemaker-devel
if [ ! -e /tmp/.pcmk_regression_tests_ran ]; then
	touch /tmp/.pcmk_regression_tests_ran
	# Needed so that the shell doesn't get stuck on escape
	# sequences
	export TERM=dumb
	%{_datadir}/pacemaker/tests/cts-cli || true
	%{_datadir}/pacemaker/tests/cts-scheduler -V || true



%exclude %{_libexecdir}/pacemaker/cts-log-watcher
%exclude %{_libexecdir}/pacemaker/cts-support
%exclude %{_sbindir}/pacemaker-remoted
%if %{with legacy_links}
%exclude %{_sbindir}/pacemaker_remoted
%dir %{_libexecdir}/pacemaker



%doc %{_datadir}/pacemaker/alerts

#%license licenses/GPLv2
%doc COPYING ChangeLog

%dir %attr (750, %{uname}, %{gname}) %{_var}/lib/pacemaker/cib
%dir %attr (750, %{uname}, %{gname}) %{_var}/lib/pacemaker/pengine

%files cli
%dir %attr (750, root, %{gname}) %{_sysconfdir}/pacemaker
%config(noreplace) %{_sysconfdir}/logrotate.d/pacemaker
%exclude %{_datadir}/pacemaker/alerts
%exclude %{_datadir}/pacemaker/tests

%exclude %{_libexecdir}/ocf/resource.d/pacemaker/controld
%exclude %{_libexecdir}/ocf/resource.d/pacemaker/o2cb
%exclude %{_libexecdir}/ocf/resource.d/pacemaker/remote

%dir %{_libexecdir}/ocf
%dir %{_libexecdir}/ocf/resource.d

%config(noreplace) %{_fillupdir}/sysconfig.pacemaker
%config(noreplace) %{_fillupdir}/sysconfig.crm_mon
%exclude %{_mandir}/man7/pacemaker-controld.*
%exclude %{_mandir}/man7/pacemaker-schedulerd.*
%exclude %{_mandir}/man7/pacemaker-fenced.*
%exclude %{_mandir}/man7/ocf_pacemaker_controld.*
%exclude %{_mandir}/man7/ocf_pacemaker_o2cb.*
%exclude %{_mandir}/man7/ocf_pacemaker_remote.*
%exclude %{_mandir}/man8/cibsecret.*
%exclude %{_mandir}/man8/fence_legacy.*
%exclude %{_mandir}/man8/pacemakerd.*
%exclude %{_mandir}/man8/pacemaker-remoted.*

#%license licenses/GPLv2
%doc COPYING ChangeLog

%dir %attr (750, %{uname}, %{gname}) %{_var}/lib/pacemaker
%dir %attr (750, %{uname}, %{gname}) %{_var}/lib/pacemaker/blackbox
%dir %attr (750, %{uname}, %{gname}) %{_var}/lib/pacemaker/cores
%dir %attr (770, %{uname}, %{gname}) %{_var}/log/pacemaker
%dir %attr (770, %{uname}, %{gname}) %{_var}/log/pacemaker/bundles

%files -n libpacemaker3

#%license licenses/LGPLv2.1
%doc COPYING ChangeLog

%if %{enable_lib_cluster_pkg}
%files -n libpacemaker3-cluster
#%license licenses/LGPLv2.1
%doc COPYING ChangeLog

%files remote

%if %{with legacy_links}
#%license licenses/GPLv2
%doc COPYING ChangeLog

%if %{with doc}
%files doc
%doc %{pcmk_docdir}
#%license licenses/CC-BY-SA-4.0

%files cts


#%license licenses/GPLv2
%doc COPYING ChangeLog

%files -n libpacemaker-devel
%if %{with coverage}
#%license licenses/LGPLv2.1
%doc COPYING ChangeLog

openSUSE Build Service is sponsored by