File unbound.spec of Package unbound
%define realname unbound
%define realver 1.17.1
%define so_ver 8
%define chroot_dir /var/lib/unbound
# 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}
Requires(pre): system-user-nobody
%endif
# Build-time parameters
BuildRequires: pkgconfig
BuildRequires: openssl-devel
BuildRequires: hiredis-devel
BuildRequires: libmnl-devel
BuildRequires: libnghttp2-devel
BuildRequires: libprotobuf-c-devel
BuildRequires: libsodium-devel
%if 0%{?suse_version}
BuildRequires: libexpat-devel
BuildRequires: fdupes
%else
BuildRequires: expat-devel
%endif
BuildRequires: pkgconfig(libsystemd)
BuildRoot: %{_tmppath}/%{name}-root
Source0: http://unbound.net/downloads/%{realname}-%{realver}.tar.gz
Source1: http://www.internic.net/domain/named.cache
%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-systemd \
--enable-subnet \
--enable-dnstap \
--enable-dnscrypt \
--enable-cachedb \
--enable-ipsecmod \
--enable-ipset \
--with-run-dir=/etc \
--with-chroot-dir=%{chroot_dir} \
--with-pidfile=%{_rundir}/%{name}.pid \
--with-rootkey-file=root.key \
--with-username=nobody \
--with-pthreads \
--with-libhiredis \
--with-libnghttp2 \
--with-dnstap-socket-path=%{_rundir}/dnstap.sock \
--with-libmnl \
CFLAGS="%{optflags} %{?gcc_lto}" \
CXXFLAGS="%{optflags} %{?gcc_lto}" \
LDFLAGS="-Wl,--as-needed -Wl,--strip-all -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro %{?gcc_lto}"
%{__make} %{?_smp_mflags}
%install
%{__make} install DESTDIR=%{buildroot}
%{__install} -d -m0755 %{buildroot}%{chroot_dir}
%{__install} -D -m644 %{S:1} %{buildroot}%{chroot_dir}/etc/root.zone
%{__install} -D -m0644 contrib/unbound.service %{buildroot}%{_unitdir}/unbound.service
%{__install} -D -m0644 contrib/unbound.socket %{buildroot}%{_unitdir}/unbound.socket
%if 0%{?suse_version}
%fdupes %{buildroot}%{_mandir}
%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
%{_sbindir}/*
%{_libdir}/libunbound.so.%{?so_ver}*
%{_unitdir}/unbound.*
%dir %{chroot_dir}
%dir %attr(0755,nobody,nobody) %{chroot_dir}/etc
%{chroot_dir}/etc/root.zone
%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}
%pre
%{service_add_pre unbound.service}
%{service_add_pre unbound.socket}
%post
unbound-anchor -a %{chroot_dir}/etc/root.key
chown nobody:nobody %{chroot_dir}/etc/root.key
%{fillup_only unbound}
%{service_add_post unbound.service}
%{service_add_post unbound.socket}
/sbin/ldconfig
%preun
%{service_del_preun unbound.service}
%{service_del_preun unbound.socket}
%postun
%{service_del_postun unbound.service}
%{service_del_postun unbound.socket}
/sbin/ldconfig
%else
%post
unbound-anchor -a %{chroot_dir}/etc/root.key
chown nobody:nobody %{chroot_dir}/etc/root.key
/sbin/ldconfig
%postun -p /sbin/ldconfig
%endif
%changelog