File corosync.spec of Package corosync

#
# spec file for package corosync
#
# 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 http://bugs.opensuse.org/
#


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

# Conditionals
# Invoke "rpmbuild --without <feature>" or "rpmbuild --with <feature>"
# to disable or enable specific features
%bcond_with watchdog
%bcond_with monitoring
%bcond_with snmp
%bcond_with nozzle
%bcond_with dbus
%bcond_with xmlconf
%bcond_with vqsim
%bcond_without runautogen
%bcond_without systemd
%bcond_with userflags

%if 0%{?sles_version} == 12
%ifnarch s390 s390x
%define buildib 1
%endif
%endif
%if 0%{?suse_version}
%define _libexecdir %{_libdir}
%endif

Name:           corosync
Summary:        The Corosync Cluster Engine and Application Programming Interfaces
License:        BSD-3-Clause
Group:          Productivity/Clustering/HA
Version:        3.1.8+20231106.40e08b21
Release:        0
Url:            http://corosync.github.io/corosync/
Source0:        %{name}-%{version}.tar.gz
Source99:       dummy-version
Patch1:         0001-add_upgrade_shell.patch

BuildRoot:      %{_tmppath}/%{name}-%{version}-build
# provide openais on purpose, the package has been deleted.

# Runtime bits
# The automatic dependency overridden in favor of explicit version lock
Requires:    corosynclib = %{version}-%{release}

# Build bits
BuildRequires:  gcc

BuildRequires:  groff-full
BuildRequires:  libqb-devel
BuildRequires:  libknet1-devel
BuildRequires:  zlib-devel
%if %{with runautogen}
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  libtool
%endif
%if %{with monitoring}
BuildRequires:  libstatgrab-devel
%endif
%if %{with snmp}
BuildRequires:  net-snmp-devel
%endif
%if %{with dbus}
BuildRequires:  dbus-1-devel
%endif
%if %{with nozzle}
BuildRequires: libnozzle1-devel
%endif
%if %{with systemd}
BuildRequires:  pkgconfig(systemd)
BuildRequires:	systemd-devel
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
%endif
%if %{with xmlconf}
Requires:       libxslt
%endif
%if %{with vqsim}
BuildRequires: readline-devel
%endif
#Obsoletes: libcfg6
Obsoletes: libcmap4
Obsoletes: libcorosync_common4
Obsoletes: libcpg4
Obsoletes: libquorum5
Obsoletes: libsam4
Obsoletes: libtotem_pg5
Obsoletes: libvotequorum8

BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%prep
%setup -q -n %{name}-%{version}
%patch1 -p1

cp %{_sourcedir}/dummy-version %{_builddir}/%{name}-%{version}/.tarball-version

%build
%if %{with runautogen}
./autogen.sh
%endif

%{configure} \
%if %{with watchdog}
	--enable-watchdog \
%endif
%if %{with monitoring}
	--enable-monitoring \
%endif
%if %{with snmp}
	--enable-snmp \
%endif
%if %{with dbus}
	--enable-dbus \
%endif
%if %{with systemd}
	--enable-systemd \
%endif
%if %{with xmlconf}
	--enable-xmlconf \
%endif
%if %{with nozzle}
	--enable-nozzle \
%endif
%if %{with vqsim}
  --enable-vqsim \
%endif
%if %{with userflags}
   --enable-user-flags \
%endif
	--with-initddir=%{_initrddir} \
	--with-systemddir=%{_unitdir} \
	--with-tmpfilesdir=%{_tmpfilesdir}

make %{_smp_mflags}

%install
%make_install

%if %{with dbus}
mkdir -p -m 0700 %{buildroot}/%{_sysconfdir}/dbus-1/system.d
install -m 644 %{_builddir}/%{name}-%{version}/conf/corosync-signals.conf %{buildroot}/%{_sysconfdir}/dbus-1/system.d/corosync-signals.conf
%endif
%if %{with systemd}
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rccorosync
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rccorosync-notifyd
%endif

## tree fixup
# drop static libs
rm -f %{buildroot}%{_libdir}/*.a
rm -f %{buildroot}%{_libdir}/*.la
# drop docs and html docs for now
rm -rf %{buildroot}%{_docdir}/*
mkdir -p %{buildroot}%{_sysconfdir}/sysconfig
mkdir -p  %{buildroot}/usr/lib/tmpfiles.d/
mkdir -p  %{buildroot}/usr/share/doc/packages/corosync/
mkdir -p  %{buildroot}%{_fillupdir}/
mkdir -p  %{buildroot}%{_sysconfdir}/init.d/
install -m 0644 tools/corosync-notifyd.sysconfig.example  %{buildroot}/usr/lib/tmpfiles.d/corosync-notifyd
install -m 0644 conf/corosync.conf.example* %{buildroot}/usr/share/doc/packages/corosync/
mkdir -p %{buildroot}/usr/lib/corosync
install -m 0755 init/upgrade.sh %{buildroot}/usr/lib/corosync
rm -rf %{buildroot}/etc/corosync/corosync.conf.example*
rm -rf %{buildroot}/etc/logrotate.d/
mkdir -p %{buildroot}%{_sysconfdir}/sysconfig
install -m 644 init/corosync.sysconfig.example \
   %{buildroot}%{_fillupdir}/sysconfig.corosync
rm -rf %{buildroot}%{localstatedir}/run/

%description
This package contains the Corosync Cluster Engine Executive, several default
APIs and libraries, default configuration files, and an init script.

%pre
rpm -qa corosync|grep -q '^corosync-2' && touch %{_localstatedir}/lib/rpm/%{name}.migrate-corosync-conf-2-to-3
%service_add_pre corosync.service corosync-notifyd.service

%post
if [ -e %{_localstatedir}/lib/rpm/%{name}.migrate-corosync-conf-2-to-3 ]; then
	/usr/lib/corosync/upgrade.sh
	rm -f %{_localstatedir}/lib/rpm/%{name}.migrate-corosync-conf-2-to-3
fi
%tmpfiles_create /usr/lib/tmpfiles.d/corosync-notifyd
%{fillup_and_insserv -n corosync}
%service_add_post corosync.service corosync-notifyd.service

rm -rf  %{_sysconfdir}/corosync/corosync.conf.example %{_sysconfdir}/corosync/corosync.conf.example.unicast
ln -s /usr/share/doc/packages/corosync/corosync.conf.example %{_sysconfdir}/corosync/

%preun
%service_del_preun corosync.service corosync-notifyd.service

%postun
if [ -f /etc/sysconfig/corosync ]; then
    rm /etc/sysconfig/corosync
fi

%files
%defattr(-,root,root,-)
%doc LICENSE
%{_sbindir}/corosync
%{_sbindir}/corosync-keygen
%{_sbindir}/corosync-cmapctl
%{_sbindir}/corosync-cfgtool
%{_sbindir}/corosync-cpgtool
%{_sbindir}/corosync-quorumtool
%{_sbindir}/corosync-notifyd
%if %{with systemd}
%{_sbindir}/rccorosync
%{_sbindir}/rccorosync-notifyd
%endif
%{_bindir}/corosync-blackbox
%if %{with xmlconf}
%{_bindir}/corosync-xmlproc
%dir %{_datadir}/corosync
%config(noreplace) %{_sysconfdir}/corosync/corosync.xml.example
%{_datadir}/corosync/xml2conf.xsl
%{_mandir}/man8/corosync-xmlproc.8*
%{_mandir}/man5/corosync.xml.5*
%endif
%dir %{_sysconfdir}/corosync
%dir %{_sysconfdir}/corosync/uidgid.d
%dir %{_datadir}/doc/corosync/
%dir /usr/lib/corosync/
/usr/lib/corosync/upgrade.sh
%config(noreplace) /usr/share/doc/packages/corosync/corosync.conf.example
%config(noreplace) /usr/lib/tmpfiles.d/corosync-notifyd
%config(noreplace) %{_fillupdir}/sysconfig.corosync

%if %{with dbus}
%{_sysconfdir}/dbus-1/system.d/corosync-signals.conf
%endif
%if %{with snmp}
%{_datadir}/snmp/mibs/COROSYNC-MIB.txt
%endif
%if %{with systemd}
%{_unitdir}/corosync.service
%{_unitdir}/corosync-notifyd.service
%else
%dir %{_datadir}/corosync
%{_datadir}/corosync/corosync
%{_datadir}/corosync/corosync-notifyd
%endif
%dir %{_localstatedir}/lib/corosync
%dir %{_localstatedir}/log/cluster
%{_mandir}/man7/corosync_overview.7*
%{_mandir}/man8/corosync.8*
%{_mandir}/man8/corosync-blackbox.8*
%{_mandir}/man8/corosync-cmapctl.8*
%{_mandir}/man8/corosync-keygen.8*
%{_mandir}/man8/corosync-cfgtool.8*
%{_mandir}/man8/corosync-cpgtool.8*
%{_mandir}/man8/corosync-notifyd.8*
%{_mandir}/man8/corosync-quorumtool.8*
%{_mandir}/man5/corosync.conf.5*
%{_mandir}/man5/votequorum.5*
%{_mandir}/man7/cmap_keys.7*
%{_datadir}/doc/corosync/*

#library
#
%package -n corosynclib
Summary: The corosync Cluster Engine Libraries

%description -n corosynclib
This package contains corosync libraries.

%files -n corosynclib
%doc LICENSE
%{_libdir}/libcfg.so.*
%{_libdir}/libcpg.so.*
%{_libdir}/libcmap.so.*
%{_libdir}/libquorum.so.*
%{_libdir}/libvotequorum.so.*
%{_libdir}/libsam.so.*
%{_libdir}/libcorosync_common.so.*

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

%package -n corosynclib-devel
Summary:        The Corosync Cluster Engine Development Kit
Group:          Development/Libraries/C and C++
Requires:       corosynclib = %{version}-%{release}
Requires:       pkgconfig
Provides:       corosync-devel = %{version}

%description -n corosynclib-devel
This package contains include files and man pages used to develop using
The Corosync Cluster Engine APIs.

%files -n corosynclib-devel
%defattr(-,root,root,-)
%doc LICENSE
%dir %{_includedir}/corosync/
%{_includedir}/corosync/corodefs.h
%{_includedir}/corosync/cfg.h
%{_includedir}/corosync/cmap.h
%{_includedir}/corosync/corotypes.h
%{_includedir}/corosync/cpg.h
%{_includedir}/corosync/hdb.h
%{_includedir}/corosync/sam.h
%{_includedir}/corosync/quorum.h
%{_includedir}/corosync/votequorum.h
%{_libdir}/libcfg.so
%{_libdir}/libcpg.so
%{_libdir}/libcmap.so
%{_libdir}/libquorum.so
%{_libdir}/libvotequorum.so
%{_libdir}/libsam.so
%{_libdir}/libcorosync_common.so
%{_libdir}/pkgconfig/*.pc
%{_mandir}/man3/cpg_*3*
%{_mandir}/man3/quorum_*3*
%{_mandir}/man3/votequorum_*3*
%{_mandir}/man3/sam_*3*
%{_mandir}/man3/cmap_*3*

%if %{with vqsim}
%package -n corosync-vqsim
Summary: The Corosync Cluster Engine - Votequorum Simulator
Requires: corosynclib = %{version}-%{release}
Requires: pkgconfig

%description -n corosync-vqsim
A command-line simulator for the corosync votequorum subsystem.
It uses the same code as the corosync quorum system but forks
them into subprocesses to simulate nodes.
Nodes can be added and removed as well as partitioned (to simulate
network splits)

%files -n corosync-vqsim
%doc LICENSE
%{_bindir}/corosync-vqsim
%{_mandir}/man8/corosync-vqsim.8*
%endif

%changelog
openSUSE Build Service is sponsored by