File rpcbind.spec of Package rpcbind.12560

#
# spec file for package rpcbind
#
# Copyright (c) 2017 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

Name:           rpcbind
Version:        0.2.3
Release:        0
Summary:        Transport independent RPC portmapper
License:        BSD-4-Clause
Group:          Productivity/Networking/System
Url:            git://git.infradead.org/users/steved/rpcbind.git
Source:         %{name}-%{version}.tar.bz2
Source2:        sysconfig.rpcbind
Source3:        rpcbind.xml
Source4:        pmap_set.c
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} >= 1330
BuildRequires:  libnsl-devel
%endif
BuildRequires:  libtirpc-devel >= 1.0.1
BuildRequires:  libtool
BuildRequires:  pkgconfig
BuildRequires:  systemd-rpm-macros
BuildRequires:  tcpd-devel
BuildRequires:  pkgconfig(libsystemd)
PreReq:         %fillup_prereq
Requires(pre):  /usr/sbin/useradd
%if 0%{?suse_version} >= 1330
Requires(pre):  group(nobody)
%endif
Patch1:         0001-systemd-unit-files.patch
Patch2:         0002-handle_reply-Don-t-use-the-xp_auth-pointer-directly.patch
Patch3:         0003-Delete-the-unix-socket-only-if-we-have-created-it.patch
Patch4:         0004-Fix-memory-corruption-in-PMAP_CALLIT-code.patch
Patch5:         0005-security.c-removed-warning.patch
Patch6:         0006-don-t-use-svc_fdset.patch
Patch8:         0008-First-part-of-init_transport-refactoring.patch
Patch9:         0009-init_transport-move-the-registration-code-into-a-sep.patch
Patch10:        0010-Fix-the-behavior-when-specifying-the-h-option.patch
Patch11:        0011-Clean-up-the-way-we-handle-the-h-option-in-init_tran.patch
Patch12:        0012-Move-default-state-dir-to-a-subdirectory-of-var-run.patch
Patch14:        0014-When-using-systemd-redirect-syslog-calls-to-the-syst.patch
Patch30:        0030-systemd-fix-rmtcall.patch
Patch31:        0031-rpcbind-manpage.patch
Patch32:        svc-freeargs.patch
Patch33:        0001-rpcinfo-Fix-stack-buffer-overflow.patch
Patch34:        0001-change-lockingdir-to-run.patch
Patch35:        0001-rpcbind-look-for-an-exact-match-of-the-ip-address-fo.patch

%{?systemd_requires}
Provides:       portmap

%description
Rpcbind is a replacement for portmap. Whereas portmap supports only UDP
and TCP transports over INET (IPv4), rpcbind can be configured to work
on various transports supported by the TI-RPC. This includes TCP and
UDP over IPv6. Moreover, rpcbind provides additional functions in
regards to portmap.

%prep
%setup -q
cp %{SOURCE4} .
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
#%patch8 -p1
#%patch9 -p1
#%patch10 -p1
#%patch11 -p1
%patch12 -p1
#%patch14 -p1
#%patch30 -p1
%patch31 -p1
%patch32 -p1
%patch33 -p1
%patch34 -p1
%patch35 -p1

%build
autoreconf -fiv
export  CFLAGS="$RPM_OPT_FLAGS -fpie"
export LDFLAGS="-pie -Wl,-z,relro,-z,now"
%configure \
	    --bindir=/sbin \
	    --enable-libwrap \
	    --enable-warmstarts \
	    --disable-debug \
	    --with-statedir=%{_rundir}/rpcbind \
	    --with-rpcuser=rpc \
	    --with-systemdsystemunitdir=%{_unitdir}

%{__make} %{?jobs:-j%jobs}
%{__cc} -I/usr/include/tirpc -pie -fpie -fwhole-program -Wl,-z,relro,-z,now %{optflags} pmap_set.c -o pmap_set -ltirpc

%install
make install DESTDIR=$RPM_BUILD_ROOT
# fillup template
mkdir -p $RPM_BUILD_ROOT%{_fillupdir}
install -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_fillupdir}/
mkdir -p $RPM_BUILD_ROOT%_datadir/omc/svcinfo.d
install -m 644 %{SOURCE3} $RPM_BUILD_ROOT%_datadir/omc/svcinfo.d/
#
install -m 755 pmap_set $RPM_BUILD_ROOT/sbin/pmap_set2
# create symlink for rcrpcbind
mkdir -p $RPM_BUILD_ROOT%{_sbindir}
ln -s /sbin/service $RPM_BUILD_ROOT%{_sbindir}/rcrpcbind

%clean
rm -rf $RPM_BUILD_ROOT

%pre
%service_add_pre %{name}.service %{name}.socket

# Add "rpc" user
getent passwd rpc >/dev/null || /usr/sbin/useradd -r -g nobody -d /var/lib/empty -s /sbin/nologin -c "user for rpcbind" rpc
exit 0

%preun
%service_del_preun %{name}.service %{name}.socket

%post
%{fillup_only -n rpcbind}
%service_add_post %{name}.socket %{name}.service

%postun
%service_del_postun %{name}.socket %{name}.service

%files
%defattr(-,root,root)
%doc AUTHORS ChangeLog COPYING NEWS README
/sbin/pmap_set2
/sbin/rpcbind
/sbin/rpcinfo
%{_sbindir}/rcrpcbind
%{_mandir}/*/*
%{_fillupdir}/sysconfig.rpcbind
%{_datadir}/omc/svcinfo.d/rpcbind.xml
%{_unitdir}/%{name}.service
%{_unitdir}/%{name}.socket

%changelog
openSUSE Build Service is sponsored by