File openslp.spec of Package openslp.3206

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


Name:           openslp
BuildRequires:  bison
BuildRequires:  flex
BuildRequires:  libtool
BuildRequires:  openssl-devel
%if 0%{?suse_version} > 1140
BuildRequires:  pkgconfig(systemd)
%define has_systemd 1
%endif
Summary:        An OpenSLP Implementation of Service Location Protocol V2
License:        BSD-3-Clause
Group:          System/Daemons
Version:        2.0.0
Release:        0
Url:            http://www.openslp.org/
# bug437293
%ifarch ppc64
Obsoletes:      openslp-64bit
%endif
#
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Source0:        http://sourceforge.net/projects/openslp/files/2.0.0/%{version}/%name-%version.tar.gz
Source1:        slpd.init
Source2:        README.SUSE
Source3:        openslp.desktop
Source4:        openslp-devel.desktop
Source5:        openslp.logrotate
Source6:        slpd.xml
Source7:        openslp.SuSEfirewall2
Source8:        baselibs.conf
Source9:        slpd.service
Patch1:         openslp.audit.diff
Patch2:         extensions.diff
Patch3:         openslp.truncate.diff
Patch4:         openslp.netlink.diff
Patch5:         openslp.initda.diff
Patch6:         openslp.visibility.diff
Patch7:         openslp.daemon.diff
Patch8:         openslp.cloexec.diff
Patch9:         openslp.hardmtu.diff
Patch10:        openslp.tcplocal.diff
Patch11:        openslp.localtime.diff
Patch12:        openslp.predicatestorage.diff
Patch13:        openslp.doubleequal.diff
Patch14:        openslp.noconvenience.diff
Patch15:        openslp.xrealloc.diff
Patch16:        openslp.foldws.diff

%description
Service Location Protocol is an IETF standards track protocol that
provides a framework that allows networking applications to discover
the existence, location, and configuration of networked services in
enterprise networks.

OpenSLP is an open source implementation of the SLPv2 protocol as
defined by RFC 2608 and RFC 2614.  This package includes the slptool
and runtime libraries.

%package server
Summary:        The OpenSLP Implementation of the  Service Location Protocol V2
Group:          System/Daemons
PreReq:         /usr/sbin/useradd
%if 0%{?has_systemd}
%{?systemd_requires}
%else
PreReq:         %fillup_prereq %insserv_prereq
%endif
Recommends:     logrotate

%description server
Service Location Protocol is an IETF standards track protocol that
provides a framework that allows networking applications to discover
the existence, location, and configuration of networked services in
enterprise networks.

This package contains the SLP server. Every system, which provides any
services that should be used via an SLP client must run this server and
register the service.

%package devel
Requires:       openslp = %version
Requires:       openssl-devel
Summary:        OpenSLP Development SDK
Group:          System/Daemons
# bug437293
%ifarch ppc64
Obsoletes:      openslp-devel-64bit
%endif
#

%description devel
Service Location Protocol is an IETF standards track protocol that
provides a framework that allows networking applications to discover
the existence, location, and configuration of networked services in
enterprise networks.

This package contains header and library files to compile applications
with SLP support. It also contains developer documentation to develop
such applications.

%prep
%setup -q
%patch1
%patch2
%patch3
%patch4
%patch5
%patch6
%patch7
%patch8
%patch9
%patch10
%patch11
%patch12
%patch13
%patch14
%patch15
%patch16

%build
autoreconf -fiv
%configure --disable-static --with-pic --enable-slpv1 \
  --enable-async-api \
  --enable-slpv2-security
%{__make} %{?jobs:-j%jobs}

%install
mkdir -p ${RPM_BUILD_ROOT}/etc/slp.reg.d
mkdir -p ${RPM_BUILD_ROOT}/etc/slp.reg.d/slpd
cp etc/slp.conf ${RPM_BUILD_ROOT}/etc
cp etc/slp.reg ${RPM_BUILD_ROOT}/etc
cp etc/slp.spi ${RPM_BUILD_ROOT}/etc
mkdir -p ${RPM_BUILD_ROOT}/%_libdir
./libtool --mode=install install libslp/libslp.la ${RPM_BUILD_ROOT}/%_libdir
mkdir -p  ${RPM_BUILD_ROOT}/usr/sbin
./libtool --mode=install install slpd/slpd ${RPM_BUILD_ROOT}/usr/sbin 
mkdir -p ${RPM_BUILD_ROOT}/usr/bin
./libtool --mode=install install slptool/slptool ${RPM_BUILD_ROOT}/usr/bin
mkdir -p ${RPM_BUILD_ROOT}/usr/include
cp libslp/slp.h ${RPM_BUILD_ROOT}/usr/include
mkdir -p ${RPM_BUILD_ROOT}%_defaultdocdir/%name
find . -name CVS -o -name .cvsignore -o -name .xvpics | xargs rm -rf
cp -a AUTHORS COPYING README FAQ doc/doc/rfc doc/doc/html %SOURCE2 \
   ${RPM_BUILD_ROOT}%_defaultdocdir/%name
%if 0%{?has_systemd}
ln -s %{_sbindir}/service ${RPM_BUILD_ROOT}/usr/sbin/rcslpd
cat > ${RPM_BUILD_ROOT}/usr/sbin/rcopenslp <<'EOF'
#!/bin/sh
exec /usr/sbin/rcslpd "$@"
EOF
chmod 755 ${RPM_BUILD_ROOT}/usr/sbin/rcopenslp
%else
mkdir -p ${RPM_BUILD_ROOT}/etc/init.d/
install -m 755 %{SOURCE1} ${RPM_BUILD_ROOT}/etc/init.d/slpd
ln -sf ../../etc/init.d/slpd ${RPM_BUILD_ROOT}/usr/sbin/rcslpd
ln -sf ../../etc/init.d/slpd ${RPM_BUILD_ROOT}/usr/sbin/rcopenslp
%endif
install -D -m 0644 %{SOURCE5} ${RPM_BUILD_ROOT}/etc/logrotate.d/openslp-server
# install susehelp file
mkdir -p $RPM_BUILD_ROOT/usr/share/susehelp/meta/Administration/
install -m 0644 %SOURCE3 \
	$RPM_BUILD_ROOT/usr/share/susehelp/meta/Administration/
mkdir -p $RPM_BUILD_ROOT/usr/share/susehelp/meta/Development/Libraries/
install -m 0644 %SOURCE4 \
	$RPM_BUILD_ROOT/usr/share/susehelp/meta/Development/Libraries/
install -d -m 755 $RPM_BUILD_ROOT/usr/share/omc/svcinfo.d
install -m 0644 %SOURCE6 $RPM_BUILD_ROOT/usr/share/omc/svcinfo.d
%if 0
# actually, these files should get translated, but do we really want to
# add update-desktop-files to needed_for_build ?
%suse_update_desktop_file $RPM_BUILD_ROOT/usr/share/susehelp/meta/Administration/openslp.desktop
%suse_update_desktop_file $RPM_BUILD_ROOT/usr/share/susehelp/meta/Development/Libraries/openslp-devel.desktop
%endif
%{__rm} -f %{buildroot}%{_libdir}/*.la
%if 0%{?suse_version}
install -D -m 644 %{S:7} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/openslp
%endif

%if 0%{?has_systemd}
install -D -m 644 %{S:9} %{buildroot}%{_unitdir}/slpd.service
%endif

#XXX test suite requires root
#check
#make check

%post   -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%pre server
/usr/sbin/useradd -r -g daemon -d /var/lib/empty -s /sbin/nologin -c "openslp daemon" openslp 2>/dev/null || :
%if 0%{?has_systemd}
%service_add_pre slpd.service
%endif

%post server
%if 0%{?has_systemd}
%service_add_post slpd.service
%else
%if 0%{?sles_version} == 9 || 0%{?sles_version} == 10
%{fillup_and_insserv -y slpd}
%else
%{fillup_and_insserv slpd}
%endif
%endif

%postun server
%if 0%{?has_systemd}
%service_del_postun slpd.service
%else
%restart_on_update slpd
%insserv_cleanup
%endif

%preun server
%if 0%{?has_systemd}
%service_del_preun slpd.service
%else
%stop_on_removal slpd
%endif

%files
%defattr(-,root,root)
%dir %_defaultdocdir/%name
%dir %_defaultdocdir/%name/html
%doc %_defaultdocdir/%name/AUTHORS
%doc %_defaultdocdir/%name/COPYING
%doc %_defaultdocdir/%name/README
%doc %_defaultdocdir/%name/README.SUSE
%_libdir/libslp.so.*
/usr/bin/slptool
%config(noreplace) /etc/slp.conf
%config(noreplace) /etc/slp.spi

%files server
%defattr(-,root,root)
%dir /usr/share/susehelp
%dir /usr/share/susehelp/meta
%dir /usr/share/susehelp/meta/Administration
%doc %_defaultdocdir/%name/FAQ
%doc %_defaultdocdir/%name/html/IntroductionToSLP
%doc %_defaultdocdir/%name/html/UsersGuide
%doc %_defaultdocdir/%name/html/faq.html
%doc %_defaultdocdir/%name/rfc
%doc /usr/share/susehelp/meta/Administration/openslp.desktop
%dir /etc/slp.reg.d/
%dir /etc/slp.reg.d/slpd
/usr/sbin/rcopenslp
/usr/sbin/rcslpd
/usr/sbin/slpd
%config(noreplace) /etc/slp.reg
%config(noreplace) /etc/logrotate.d/openslp-server
/usr/share/omc/svcinfo.d/slpd.xml
%if 0%{?suse_version} > 0
%config %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/openslp
%endif
%if 0%{?has_systemd}
%{_unitdir}/slpd.service
%else
%config /etc/init.d/slpd
%endif

%files devel
%defattr(-,root,root)
%dir /usr/share/susehelp
%dir /usr/share/susehelp/meta
%dir /usr/share/susehelp/meta/Development
%dir /usr/share/susehelp/meta/Development/Libraries
%doc %_defaultdocdir/%name/html/ProgrammersGuide
%doc /usr/share/susehelp/meta/Development/Libraries/openslp-devel.desktop
/usr/include/slp.h
%_libdir/libslp.so

%changelog