File unbound.spec of Package unbound

%define realname unbound
%define realver  1.10.1

%define so_ver   8

# turn off the generation of debuginfo rpm  (RH9) ??
%global debug_package %{nil}

%if ! %{defined _rundir}
%define _rundir /var/run
%endif

# Common info
Name:          %{realname}
Version:       %{realver}
Release:       wiz%{?extraver:0.}1%{?dist}
License:       BSD-3-Clause
Group:         Productivity/Networking/DNS/Servers
URL:           http://unbound.net/
Summary:       Validating, recursive, and caching DNS resolver

# Install-time parameters
Provides:      dns_daemon
Provides:      libunbound%{?so_ver}

# Packages needed to sytemd support
%if 0%{?suse_version} >= 1230 || 0%{?rhel} >= 7
BuildRequires: pkgconfig(libsystemd)
Requires:      systemd
%endif

# Build-time parameters
BuildRequires: pkgconfig
BuildRequires: openssl-devel
BuildRequires: hiredis-devel
BuildRequires: libmnl-devel
%if 0%{?suse_version}
BuildRequires: libexpat-devel
BuildRequires: fdupes
%else
BuildRequires: expat-devel
%endif
BuildRoot:     %{_tmppath}/%{name}-root
Source0:       http://unbound.net/downloads/%{realname}-%{realver}.tar.gz
Source1:       http://www.internic.net/domain/named.cache
Source2:       unbound.init

%description
Unbound is a validating, recursive, and caching DNS resolver.

The C implementation of Unbound is developed and maintained by NLnet Labs.
It is based on ideas and algorithms taken from a java prototype developed
by Verisign labs, Nominet, Kirei and ep.net.

Unbound is designed as a set of modular components, so that also
DNSSEC (secure DNS) validation and stub-resolvers (that do not run as
a server, but are linked into an application) are easily possible.

%package devel
Group:         Development/Languages/C and C++
Summary:       Development files for %{name}
Requires:      %{name} = %{version}-%{release}
Provides:      libunbound%{?so_ver}-devel
Provides:      libunbound-devel

%description devel
Development files for %{name}

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{realver}%{?extraver}

%build
%configure \
 --enable-pie \
 --enable-relro-now \
 --disable-static \
 --enable-subnet \
%if 0%{?_unitdir:1}
 --enable-systemd \
%endif
 --enable-cachedb \
 --enable-ipset \
 --with-pidfile=%{_rundir}/%{name}.pid \
 --with-username=nobody \
 --with-pthreads \
 --with-libhiredis \
 --with-libmnl \
 CFLAGS="%{optflags} %{?gcc_lto}" \
 CXXFLAGS="%{optflags} %{?gcc_lto}" \
 LDFLAGS="-Wl,--as-needed -Wl,--strip-all %{?gcc_lto}"
%{__make} %{?_smp_mflags}

%install
%{__make} install DESTDIR=%{buildroot}
%{__install} -D -m644 %{S:1} %{buildroot}%{_sysconfdir}/unbound/root.zone
%if 0%{?_unitdir:1}
%{__install} -D -m0644 contrib/unbound.service %{buildroot}%{_unitdir}/unbound.service
%{__install} -D -m0644 contrib/unbound.socket  %{buildroot}%{_unitdir}/unbound.socket
%else
%{__install} -D -m755 %{S:2} %{buildroot}%{_initrddir}/unbound
%endif
%if 0%{?suse_version}
%fdupes %{buildroot}%{_mandir}
test -x %{buildroot}%{_initrddir}/unbound && %{__ln_s} %{_initrddir}/unbound %{buildroot}%{_sbindir}/rcunbound
%endif

%clean
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}

%files
%defattr(-,root,root)
%doc doc/CREDITS doc/FEATURES doc/LICENSE doc/README doc/README.DNS64 doc/TODO
%doc doc/*.txt doc/example.conf doc/ietf67-design-02.pdf
%dir %{_sysconfdir}/unbound
%config(noreplace) %{_sysconfdir}/unbound/unbound.conf
%config(noreplace) %{_sysconfdir}/unbound/root.zone
%{_sbindir}/*
%{_libdir}/libunbound.so.%{?so_ver}*
%if 0%{?_unitdir:1}
%{_unitdir}/unbound.*
%else
%{_initrddir}/unbound
%endif
%doc %{_mandir}/man1/*
%doc %{_mandir}/man5/*
%doc %{_mandir}/man8/*

# Development stuff
%files devel
%defattr(-,root,root)
%{_libdir}/pkgconfig/libunbound.pc
%{_includedir}/unbound.h
%{_libdir}/libunbound.so
%exclude %{_libdir}/*.la
%doc %{_mandir}/man3/*

%if 0%{?suse_version}

%if 0%{?_unitdir:1}
%pre
%{service_add_pre unbound.service}
%{service_add_pre unbound.socket}
%endif

%post
%if 0%{?_unitdir:1}
%{fillup_only unbound}
%{service_add_post unbound.service}
%{service_add_post unbound.socket}
%else
%{fillup_and_insserv unbound}
%endif
/sbin/ldconfig

%preun
%if 0%{?_unitdir:1}
%{service_del_preun unbound.service}
%{service_del_preun unbound.socket}
%else
%{stop_on_removal unbound}
%endif

%postun
%if 0%{?_unitdir:1}
%{service_del_postun unbound.service}
%{service_del_postun unbound.socket}
%else
%{restart_on_update unbound}
%{insserv_cleanup}
%endif
/sbin/ldconfig

%else

%post   -p /sbin/ldconfig
%postun -p /sbin/ldconfig

%endif

%changelog
openSUSE Build Service is sponsored by