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

# Common info
Name:          %{realname}
Version:       %{realver}
Release:       wiz%{?extraver:0.}1%{?dist}
License:       BSD-3-Clause
Group:         Productivity/Networking/DNS/Servers
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

# Build-time parameters
BuildRequires: pkgconfig
BuildRequires: openssl-devel
BuildRequires: hiredis-devel
BuildRequires: libmnl-devel
%if 0%{?suse_version}
BuildRequires: libexpat-devel
BuildRequires: fdupes
BuildRequires: expat-devel
BuildRoot:     %{_tmppath}/%{name}-root
Source2:       unbound.init

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

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)
%setup -q -n %{realname}-%{realver}%{?extraver}

%configure \
 --enable-pie \
 --enable-relro-now \
 --disable-static \
 --enable-subnet \
%if 0%{?_unitdir:1}
 --enable-systemd \
 --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}

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

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

%doc doc/*.txt doc/example.conf doc/ietf67-design-02.pdf
%dir %{_sysconfdir}/unbound
%config(noreplace) %{_sysconfdir}/unbound/unbound.conf
%config(noreplace) %{_sysconfdir}/unbound/
%if 0%{?_unitdir:1}
%doc %{_mandir}/man1/*
%doc %{_mandir}/man5/*
%doc %{_mandir}/man8/*

# Development stuff
%files devel
%exclude %{_libdir}/*.la
%doc %{_mandir}/man3/*

%if 0%{?suse_version}

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

%if 0%{?_unitdir:1}
%{fillup_only unbound}
%{service_add_post unbound.service}
%{service_add_post unbound.socket}
%{fillup_and_insserv unbound}

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

%if 0%{?_unitdir:1}
%{service_del_postun unbound.service}
%{service_del_postun unbound.socket}
%{restart_on_update unbound}


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


openSUSE Build Service is sponsored by