File ypbind.spec of Package ypbind

#
# spec file for package ypbind
#
# Copyright (c) 2014 SUSE LINUX Products 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:           ypbind
PreReq:         %insserv_prereq %fillup_prereq
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Version:        2.4
Release:        0
Url:            http://www.linux-nis.org/nis/ypbind-mt
Summary:        NIS client daemon
License:        GPL-2.0
Group:          Productivity/Networking/NIS
BuildRequires:  pkgconfig
%if %{suse_version} >= 1310
BuildRequires:  pkgconfig(libsystemd-daemon)
BuildRequires:  pkgconfig(libtirpc) >= 1.0.1
BuildRequires:  pkgconfig(libnsl) >= 1.0.1
%else
BuildRequires:  libtirpc-devel >= 1.0.1
BuildRequires:  libnsl-devel => 1.0.1
%endif
Requires:       rpcbind
Requires:       yp-tools
Source:         http://www.linux-nis.org/download/%name-mt/%name-mt-%version.tar.bz2
Source1:        SuSEfirewall.ypbind
Source2:        ypbind.service
Source3:        ypbind-systemd-pre
Source4:        ypbind-systemd-post
Source5:        ypbind-systemd-exec

%description
This package provides the ypbind daemon. The ypbind daemon binds NIS
clients to an NIS domain and searches a new NIS server if the old one
goes down.

Ypbind must be running on any machines which are running NIS client
programs.

%prep
%setup -q -n ypbind-mt-%{version}

%build
export CFLAGS=$RPM_OPT_FLAGS
./configure --mandir=%{_mandir} --prefix=%{_prefix} --disable-dbus-nm
make

%install
mkdir -p $RPM_BUILD_ROOT/etc/sysconfig/SuSEfirewall2.d/services
mkdir -p $RPM_BUILD_ROOT/var/adm/fillup-templates
mkdir -p $RPM_BUILD_ROOT/var/yp/binding
make install DESTDIR=$RPM_BUILD_ROOT
# Install SuSEfirewall2 service file
install -m 644 %SOURCE1 $RPM_BUILD_ROOT/etc/sysconfig/SuSEfirewall2.d/services/ypbind
# Install rc.config add-on
install -m 644 etc/sysconfig.ypbind $RPM_BUILD_ROOT/var/adm/fillup-templates/
# Create dummy yp.conf
touch $RPM_BUILD_ROOT/etc/yp.conf
# Create filelist with translatins
%{find_lang} ypbind-mt
%if %{suse_version} >= 1310
# Install systemd stuff
install -D -m 644 %SOURCE2 %{buildroot}%{_unitdir}/ypbind.service
mkdir -p $RPM_BUILD_ROOT%{_libexecdir}/ypbind
install -m 755 %SOURCE3 $RPM_BUILD_ROOT%{_libexecdir}/ypbind/ypbind-systemd-pre
install -m 755 %SOURCE4 $RPM_BUILD_ROOT%{_libexecdir}/ypbind/ypbind-systemd-post
install -m 755 %SOURCE5 $RPM_BUILD_ROOT%{_libexecdir}/ypbind/ypbind-systemd-exec
# create symlink for rcypbind
ln -s /sbin/service $RPM_BUILD_ROOT/usr/sbin/rcypbind
%else
mkdir -p $RPM_BUILD_ROOT/etc/init.d
install -m 755 etc/ypbind.init $RPM_BUILD_ROOT/etc/init.d/ypbind
ln -sf /etc/init.d/ypbind $RPM_BUILD_ROOT/usr/sbin/rcypbind
%endif

%if %{suse_version} >= 1310
%pre
%service_add_pre ypbind.service

%post
%{fillup_only -n ypbind}
%service_add_post ypbind.service

%preun
%service_del_preun ypbind.service
if [ "$1" = "0" ]; then
   test -d /var/yp/binding && rm -f /var/yp/binding/*
fi

%postun
%service_del_postun ypbind.service
%else
%post
%{fillup_and_insserv ypbind}

%preun
%stop_on_removal ypbind
if [ "$1" = "0" ]; then
   rm -f var/yp/binding/*
fi
exit 0

%postun
%restart_on_update ypbind
%insserv_cleanup
exit 0
%endif

%files -f ypbind-mt.lang
%defattr(-,root,root)
%doc AUTHORS NEWS README THANKS
%ghost %config(noreplace) /etc/yp.conf
%config /etc/sysconfig/SuSEfirewall2.d/services/ypbind
/var/adm/fillup-templates/sysconfig.ypbind
%doc %{_mandir}/man5/yp.conf.5.gz
%doc %{_mandir}/man8/ypbind.8.gz
/usr/sbin/ypbind
/usr/sbin/rcypbind
%dir /var/yp
%dir /var/yp/binding
%if %{suse_version} >= 1310
%{_unitdir}/ypbind.service
%dir %{_libexecdir}/ypbind
%{_libexecdir}/ypbind/*
%else
%config /etc/init.d/ypbind
%endif

%changelog
openSUSE Build Service is sponsored by