File unscd.spec of Package unscd

#
# spec file for package unscd
#
# Copyright (c) 2012 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/
#


%define         pkg_name nscd

Name:           unscd
Version:        0.48
Release:        0
Summary:        Alternative Name Service Caching Daemon
License:        GPL-2.0+
Group:          System/Daemons
Url:            http://busybox.net/~vda/unscd/
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Conflicts:      nscd
Obsoletes:      nscd < 2.10.1-6
Source0:        nscd-%version.c
Source1:        init.d
Source2:        nscd.conf
Source3:        COPYING
Source4:        nscd.service
Source5:        nscd.socket
PreReq:         %insserv_prereq
%if 0%{?suse_version} > 1140
BuildRequires:  systemd
%{?systemd_requires}
%define i_have_systemd 1
%endif

%description
unscd caches application requests for resolving hostnames,
user and group names and other things, and can dramatically improve
performance e.g. when using NIS or LDAP or even when just caching
DNS requests.

This is an alternative to the glibc-supplied nscd that has been
designed to be much simpler and more robust, but has fewer features
and may have somewhat worse performance.

%prep
%setup -q -c -T
cp $RPM_SOURCE_DIR/nscd-%version.c .

%build
%__cc -fwhole-program -Wl,-z,relro,-z,now $RPM_OPT_FLAGS -fpie -pie -o unscd nscd-%version.c

%install
install -m 0755 -D unscd $RPM_BUILD_ROOT/%_sbindir/nscd
install -m 0644 -D $RPM_SOURCE_DIR/nscd.conf $RPM_BUILD_ROOT/etc/nscd.conf
install -m 0755 -D $RPM_SOURCE_DIR/init.d $RPM_BUILD_ROOT/etc/init.d/nscd
ln -sf /etc/init.d/nscd $RPM_BUILD_ROOT/usr/sbin/rcnscd
mkdir -p $RPM_BUILD_ROOT/var/run/nscd
touch $RPM_BUILD_ROOT/var/run/nscd/{socket,nscd.pid}
%if 0%{?i_have_systemd}
install -D -m 0644  %{S:4} %{buildroot}%{_unitdir}/nscd.service
install -D -m 0644  %{S:5} %{buildroot}%{_unitdir}/nscd.socket
%endif

%clean
rm -rf $RPM_BUILD_ROOT

%pre
%if 0%{?i_have_systemd}
%service_add_pre %{pkg_name}.service %{pkg_name}.socket
%endif

%preun
%stop_on_removal nscd
%if 0%{?i_have_systemd}
%service_del_preun  %{pkg_name}.service %{pkg_name}.socket
%endif

%post
%{insserv_force_if_yast nscd}
%if 0%{?i_have_systemd}
%service_add_post %{pkg_name}.service %{pkg_name}.socket
%endif

%postun
%restart_on_update nscd
%insserv_cleanup
%if 0%{?i_have_systemd}
%service_del_postun %{pkg_name}.service %{pkg_name}.socket
%endif

%files
%defattr(-,root,root,-)
%if 0%{?i_have_systemd}
%{_unitdir}/nscd.service
%{_unitdir}/nscd.socket
%endif
%config(noreplace) /etc/nscd.conf
%config /etc/init.d/nscd
%attr(0755,root,root) %_sbindir/*
%dir %attr(0755,root,root) %ghost /var/run/nscd
%attr(0644,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/run/nscd/nscd.pid
%attr(0666,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/run/nscd/socket
%doc $RPM_SOURCE_DIR/COPYING

%changelog
openSUSE Build Service is sponsored by