File qpid-cpp.spec of Package qpid-cpp

#
# spec file for package qpid-cpp
#
# Copyright (c) 2015 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/
#

%define qpid_cpp_ver 034

Name:           qpid-cpp
Version:        0.34
Release:        0
Summary:        Libraries for Qpid C++ client applications
License:        Apache-2.0
Group:          Productivity/Networking/Other
Url:            http://qpid.apache.org
Source0:        http://www.apache.org/dist/qpid/cpp/%{version}/%{name}-%{version}.tar.gz
Source1000:     %{name}-rpmlintrc
Patch0:         0001-NO-JIRA-qpidd.service-file-for-use-on-Fedora.patch
Patch3:         qpid-0.24-date.patch
Patch4:         qpid-cpp-tests.patch
Patch5:         qpid-cpp-initdir.patch
Patch8:         %{name}-0.30-cmake.patch
Patch9:         %{name}-aarch64.patch
Patch10:        qpid-boost-test-message.patch
Patch11:        qpid-cpp-werror.patch
Patch12:        qpid-cpp-boost-pic.patch
BuildRequires:  boost-static = 1.46.1
BuildRequires:  cmake
BuildRequires:  cyrus-sasl
BuildRequires:  cyrus-sasl-devel
BuildRequires:  doxygen
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  libaio-devel
BuildRequires:  libtool
BuildRequires:  libuuid-devel
BuildRequires:  nspr
BuildRequires:  nspr-devel
BuildRequires:  nss
BuildRequires:  nss-devel
BuildRequires:  perl
BuildRequires:  pkgconfig
BuildRequires:  python
BuildRequires:  python-devel
# BuildRequires:  python-xml
BuildRequires:  ruby
BuildRequires:  ruby-devel
BuildRequires:  swig >= 2.0.9
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} >= 1200
BuildRequires:  systemd
%endif

%description
Run-time libraries for AMQP client applications developed using Qpid
C++. Clients exchange messages with an AMQP message broker using
the AMQP protocol.

%package -n qpid-cpp-client%{qpid_cpp_ver}
Summary:        Libraries for Qpid C++ client applications
License:        Apache-2.0
Group:          Productivity/Networking/Other

%description -n qpid-cpp-client%{qpid_cpp_ver}
Run-time libraries for AMQP client applications developed using Qpid
C++. Clients exchange messages with an AMQP message broker using
the AMQP protocol.

%files -n qpid-cpp-client%{qpid_cpp_ver}
%defattr(-,root,root,-)
%doc DESIGN
%doc LICENSE
%doc NOTICE
%doc README.txt
%doc RELEASE_NOTES
%{_libdir}/libqpidcommon.so.*
%{_libdir}/libqpidclient.so.*
%{_libdir}/libqpidtypes.so.*
%{_libdir}/libqpidmessaging.so.*
%dir %{_libdir}/qpid
%dir %{_sysconfdir}/qpid
%config(noreplace) %{_sysconfdir}/qpid/qpidc.conf

%post -n qpid-cpp-client%{qpid_cpp_ver} -p /sbin/ldconfig

%postun -n qpid-cpp-client%{qpid_cpp_ver} -p /sbin/ldconfig

%package client-devel
Summary:        Header files, documentation and testing tools for developing Qpid C++ clients
License:        Apache-2.0
Group:          Development/Libraries/C and C++
Requires:       qpid-cpp-client%{qpid_cpp_ver} = %{version}-%{release}
Requires:       boost-static = 1.46.1
Requires:       libuuid-devel
Requires:       python

%description client-devel
Libraries, header files and documentation for developing AMQP clients
in C++ using Qpid.  Qpid implements the AMQP messaging specification.

%files client-devel
%defattr(-,root,root,-)
%dir %{_includedir}/qpid
%{_includedir}/qpid/*.h
%{_includedir}/qpid/qpid.i
%{_includedir}/qpid/swig_perl_typemaps.i
%{_includedir}/qpid/swig_python_typemaps.i
%{_includedir}/qpid/swig_ruby_typemaps.i
%{_includedir}/qpid/client
%{_includedir}/qpid/framing
%{_includedir}/qpid/sys
%{_includedir}/qpid/messaging
%{_includedir}/qpid/types
%{_libdir}/libqpidcommon.so
%{_libdir}/libqpidclient.so
%{_libdir}/libqpidtypes.so
%{_libdir}/libqpidmessaging.so
%{_libdir}/pkgconfig/qpid.pc
%{_datadir}/qpid
%defattr(755,root,root,-)
%{_bindir}/qpid-perftest
%{_bindir}/qpid-topic-listener
%{_bindir}/qpid-topic-publisher
%{_bindir}/qpid-latency-test
%{_bindir}/qpid-client-test
%{_bindir}/qpid-txtest
%{_bindir}/qpid-send
%{_bindir}/qpid-receive
%dir %{_libexecdir}/qpid
%{_libexecdir}/qpid/tests
%{_libdir}/cmake/Qpid

%post client-devel -p /sbin/ldconfig

%postun client-devel -p /sbin/ldconfig

%package client-devel-docs
Summary:        AMQP client development documentation
License:        Apache-2.0
Group:          Documentation/Other
BuildArch:      noarch

%description client-devel-docs
This package includes the AMQP clients development documentation in HTML
format for easy browsing.

%files client-devel-docs
%defattr(-,root,root,-)
%{_datadir}/doc/%{name}-%{version}

%package server
Summary:        An AMQP message broker daemon
License:        Apache-2.0
Group:          Productivity/Networking/Other
Requires:       %{name}-client = %{version}-%{release}
Requires:       cyrus-sasl
%if 0%{?fedora} || (0%{?rhel} && 0%{?rhel} >= 7)
# %systemd_requires
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
%endif

%description server
A message broker daemon that receives stores and routes messages using
the open AMQP messaging protocol.

%files server
%defattr(-,root,root,-)
%{_libdir}/libqpidbroker.so.*
%{_sbindir}/qpidd
%{_sbindir}/rcqpidd
%if 0%{?fedora} || (0%{?rhel} && 0%{?rhel} >= 7)
%{_unitdir}/qpidd.service
%else
%{_initrddir}/qpidd
%endif
%dir %{_sysconfdir}/qpid
%config(noreplace) %{_sysconfdir}/qpid/qpidd.conf
%dir %{_sysconfdir}/sasl2
%config(noreplace) %{_sysconfdir}/sasl2/qpidd.conf
%exclude %{_libdir}/qpid/daemon/ha.so
%{_mandir}/man1/qpidd*
%attr(755, qpidd, qpidd) %{_localstatedir}/lib/qpidd
%ghost %attr(755, qpidd, qpidd) /run/qpidd

%pre server
getent group qpidd >/dev/null || groupadd -r qpidd
getent passwd qpidd >/dev/null || \
  useradd -r -M -g qpidd -d %{_localstatedir}/lib/qpidd -s /sbin/nologin \
    -c "Owner of Qpidd Daemons" qpidd
%service_add_pre qpidd.service
exit 0

%post server
%if (0%{?rhel} && 0%{?rhel} < 7)
/sbin/ldconfig
%service_add_post qpidd.service
exit 0
%else
%systemd_post qpidd.service
%endif

%preun server
%if (0%{?rhel} && 0%{?rhel} < 7)
%service_del_preun qpidd.service
exit 0
%else
%systemd_preun qpidd.service
%endif

%postun server
%if (0%{?rhel} && 0%{?rhel} < 7)
/sbin/ldconfig
%if 0%{?suse_version} >= 1200
%service_del_preun qpidd.service
%endif
exit 0
%else
%systemd_postun_with_restart qpidd.service
%endif

%package server-ha
Summary:        Extensions to the AMQP message broker to provide high availability
License:        Apache-2.0
Group:          Productivity/Networking/Other
Requires:       %{name}-server = %{version}-%{release}
Requires:       python-qpid-qmf = %{version}-%{release}
%if 0%{?fedora} || (0%{?rhel} && 0%{?rhel} >= 7)
# for systemd
Requires(post): systemd-units
Requires(preun): systemd-units
Requires(postun): systemd-units
%endif

%description server-ha
Provides extensions to the AMQP message broker to provide high availability.

%files server-ha
%defattr(-,root,root,-)
# %{_bindir}/qpid-ha
%dir %{_libdir}/qpid
%dir %{_libdir}/qpid/daemon
%{_libdir}/qpid/daemon/ha.so
%if 0%{?fedora} || (0%{?rhel} && 0%{?rhel} >= 7)
%{_unitdir}/qpidd-primary.service
%else
%{_initrddir}/qpidd-primary
%endif

%pre server-ha
%service_add_pre qpidd-primary.service
exit 0

%post server-ha
%if (0%{?rhel} && 0%{?rhel} < 7)
/sbin/ldconfig
%service_add_post qpidd-primary.service
exit 0
%else
%systemd_post qpidd-primary.service
%endif

%preun server-ha
%if (0%{?rhel} && 0%{?rhel} < 7)
%service_del_preun qpidd-primary.service
exit 0
%else
%systemd_preun qpidd-primary.service
%endif

%postun server-ha
%if (0%{?rhel} && 0%{?rhel} < 7)
/sbin/ldconfig
%service_del_preun qpidd-primary.service
exit 0
%else
%systemd_postun_with_restart qpidd-primary.service
%endif

%package server-store
Summary:        Red Hat persistence extension to the Qpid messaging system
License:        LGPL-2.1+
Group:          Productivity/Networking/Other
Requires:       %{name}-server = %{version}

%description server-store
Red Hat persistence extension to the Qpid AMQP broker: persistent message
storage using either a libaio-based asynchronous journal, or synchronously
with Berkeley DB.

%files server-store
%defattr(-,root,root,-)
%dir %{_libdir}/qpid
%dir %{_libdir}/qpid/daemon

%post server-store -p /sbin/ldconfig

%postun server-store -p /sbin/ldconfig

%package -n python-qpid_messaging
Summary:        Python bindings for the Qpid messaging framework
License:        Apache-2.0
Group:          Development/Libraries/Python
Requires:       python
Requires:       python-qpid-common

%description -n python-qpid_messaging
Python bindings for the Qpid messaging framework.

%files -n python-qpid_messaging
%defattr(-,root,root,-)
%{python_sitearch}/qpid_messaging.py
%{python_sitearch}/qpid_messaging.pyc
%{python_sitearch}/qpid_messaging.pyo
%{python_sitearch}/*_qpid_messaging.so

%package -n qpid-qmf
Summary:        The QPID Management Framework
License:        Apache-2.0
Group:          Productivity/Networking/Other
Requires:       python-qpid >= 0.32
Requires:       python-qpid-qmf = %{version}
Requires:       qpid-cpp-client >= %{version}

%description -n qpid-qmf
The Qpid Management Framework is a general-purpose management bus built on Qpid
messaging. It takes advantage of the scalability, security, and rich
capabilities of Qpid to provide flexible and easy-to-use manageability to a
large set of applications.

%files -n qpid-qmf
%defattr(-,root,root,-)
%{_libdir}/libqmf2.so.*

%post -n qpid-qmf -p /sbin/ldconfig

%postun -n qpid-qmf -p /sbin/ldconfig

%package -n qpid-qmf-devel
Summary:        Header files and tools for developing QMF extensions
License:        Apache-2.0
Group:          Productivity/Networking/Other
Requires:       qpid-cpp-client-devel >= %{version}
Requires:       qpid-qmf = %{version}-%{release}

%description -n qpid-qmf-devel
Header files and code-generation tools needed for developers of QMF-managed
components.

%files -n qpid-qmf-devel
%defattr(-,root,root,-)
%{_includedir}/qmf
%{_libdir}/libqmf2.so
%{_bindir}/qmf-gen
%{python_sitelib}/qmfgen
%{_libdir}/pkgconfig/qmf2.pc

%post -n qpid-qmf-devel -p /sbin/ldconfig

%postun -n qpid-qmf-devel -p /sbin/ldconfig

%package -n python-qpid-qmf
Summary:        The QPID Management Framework bindings for python
License:        Apache-2.0
Group:          Productivity/Networking/Other
Requires:       qpid-qmf = %{version}-%{release}

%description -n python-qpid-qmf
An extensible management framework layered on QPID messaging, bindings
for python.

%files -n python-qpid-qmf
%defattr(-,root,root,-)
%{python_sitearch}/qmf2.py*
%{python_sitearch}/cqmf2.py*
%{python_sitearch}/*_cqmf2.so

%post -n python-qpid-qmf -p /sbin/ldconfig

%postun -n python-qpid-qmf -p /sbin/ldconfig

%prep
%setup -q
%patch0 -p3
%patch3 -p2 -b .date
%patch4 -p1 -b .tests
%patch5 -p1 -b .initdir
%patch8 -p1
%patch9 -p2
%patch10 -p1
%patch11 -p1
%patch12 -p1

%global perftests "qpid-perftest qpid-topic-listener qpid-topic-publisher qpid-latency-test qpid-client-test qpid-txtest"

%build
%cmake -DLIBEXEC_INSTALL_DIR=%{_libexecdir}
make %{?_smp_mflags}
make docs-user-api %{?_smp_mflags}
pushd bindings/qpid/python
make %{?_smp_mflags}
popd

%install
mkdir -p -m0755 %{buildroot}/%{_bindir}
mkdir -p -m0755 %{buildroot}/%{_unitdir}

make install DESTDIR=%{buildroot}/
install -Dp -m0755 etc/qpidd %{buildroot}%{_initrddir}/qpidd
install -Dp -m0755 etc/qpidd-primary %{buildroot}%{_initrddir}/qpidd-primary
chmod 755 %{buildroot}/%{python_sitearch}/*_qpid_messaging.so

# clean up items we're not installing
rm -f  %{buildroot}%{_bindir}/qpid-python-test
rm -f  %{buildroot}%{_libdir}/libqpidbroker.so
rm -f  %{buildroot}%{_libdir}/libcqpid_perl.so
rm -f  %{buildroot}%{_libdir}/ruby/cqpid.so
rm -rf %{buildroot}%{rb_sitelib}
rm -rf %{buildroot}%{_libexecdir}/perl5
rm -rf %{buildroot}%{_libdir}/perl5
rm -rf %{buildroot}%{python_sitearch}/qpid_python*egg-info
rm -rf %{buildroot}%{python_sitearch}/mllib
rm -rf %{buildroot}%{python_sitearch}/qpid
rm -rf %{buildroot}%{python_sitelib}/qpidtoollibs
rm -rf %{buildroot}%{_libdir}/qpid/daemon/store.so*
%if 0%{?fedora} || (0%{?rhel} && 0%{?rhel} >= 7)
rm -rf %{buildroot}%{_initddir}/qpidd
rm -rf %{buildroot}%{_initddir}/qpidd-primary
%endif
rm -rf %{buildroot}%{_datadir}/qpid-tools
rm -rf %{buildroot}%{_libexecdir}/qpid-qls-analyze

# QMF Python management
install -d %{_builddir}/cpp/managementgen/qmfgen \
           %{buildroot}/%{python_sitelib}

%if 0%{?fedora} || (0%{?rhel} && 0%{?rhel} >= 7)
# install systemd files
mkdir -p %{buildroot}/%{_unitdir}
install -pm 644 %{_builddir}/%{name}-%{version}%{_sysconfdir}/qpidd.service \
    %{buildroot}/%{_unitdir}
install -pm 644 %{_builddir}/%{name}-%{version}%{_sysconfdir}/qpidd-primary.service \
    %{buildroot}/%{_unitdir}
rm -f %{buildroot}%{_initddir}/qpidd
rm -f %{buildroot}%{_sysconfdir}/init.d/qpidd.service
rm -f %{buildroot}%{_initddir}/qpidd-primary
rm -f %{buildroot}%{_sysconfdir}/init.d/qpidd-primary.service
%endif
rm -f %{buildroot}%{_sysconfdir}/init.d/qpidd
rm -f %{buildroot}%{_sysconfdir}/init.d/qpidd-primary

# install perftests utilities
mkdir -p %{buildroot}/%{_bindir}
pushd src/tests
for ptest in %{perftests}; do
  libtool --mode=install install -m755 $ptest %{buildroot}/%{_bindir}
done
popd

mkdir -p %{buildroot}/run
touch %{buildroot}/run/qpidd
mkdir -p %{buildroot}/%{_localstatedir}/lib/qpidd

# Provide SUSE policy symlink /usr/sbin/rcFOO -> /etc/init.d/FOO
# /usr/sbin/service exists only since openSUSE 12.3:
%if 0%{?suse_version} > 1220
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rcqpidd
%else
ln -s /sbin/service %{buildroot}%{_sbindir}/rcqpidd
%endif

# clean up leftover ruby files
rm -rf %{buildroot}%{_prefix}/local/%{_lib}/ruby/site_ruby
rm -rf %{buildroot}%{_prefix}/%{_lib}/ruby/site_ruby

rm -f %{buildroot}%{python_sitearch}/*.pyo

%fdupes -s %{buildroot}

%check

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%changelog