File knot.spec of Package knot

%global _hardened_build 1
%{!?_pkgdocdir: %global _pkgdocdir %{_docdir}/%{name}}

%define GPG_CHECK 0
%define VERSION 2.8.4
%define repodir %{_builddir}/%{name}-%{version}

Summary:	High-performance authoritative DNS server
Name:		knot
Version:	%{VERSION}
Release:	1%{?dist}
License:	GPLv3
Source0:	%{name}_%{version}.orig.tar.xz

%if 0%{GPG_CHECK}
# PGP keys used to sign upstream releases
# Export with --armor using command from
# Don't forget to update %%prep section when adding/removing keys
Source100:	gpgkey-742FA4E95829B6C5EAC6B85710BB7AF6FEBBD6AB.gpg.asc
BuildRequires:	gnupg2

# Test fails on F30+ aarch/s390x for unknown reason, but it is not neccassary for Knot DNS
Patch1:		01-test_net-disable-udp-send-on-unconnected.patch

# Required dependencies
BuildRequires:	gcc
BuildRequires:	pkgconfig(liburcu)
BuildRequires:	pkgconfig(gnutls) >= 3.3
BuildRequires:	pkgconfig(libedit)

# Optional dependencies
BuildRequires:	pkgconfig(libcap-ng)
BuildRequires:	pkgconfig(libfstrm)
BuildRequires:	pkgconfig(libidn2)
BuildRequires:	pkgconfig(libmaxminddb)
BuildRequires:	pkgconfig(libprotobuf-c)
BuildRequires:	pkgconfig(libsystemd)
BuildRequires:	pkgconfig(systemd)

# Distro-dependent dependencies
%if 0%{?suse_version}
BuildRequires:	python3-Sphinx
BuildRequires:	lmdb-devel
BuildRequires:	protobuf-c
Requires(pre):  pwdutils
%if 0%{?rhel}
BuildRequires:	python-sphinx
BuildRequires:	lmdb-devel
%if 0%{?fedora}
BuildRequires:	python3-sphinx
BuildRequires:	pkgconfig(lmdb)

Requires(post):		systemd %{_sbindir}/runuser
Requires(preun):	systemd
Requires(postun):	systemd

# Knot DNS 2.7+ isn't compatible with earlier knot-resolver
Conflicts:	knot-resolver < 3.0.0

Requires:	%{name}-libs%{?_isa} = %{version}-%{release}

Knot DNS is a high-performance authoritative DNS server implementation.

%package libs
Summary:	Libraries used by the Knot DNS server and client applications

%description libs
The package contains shared libraries used by the Knot DNS server and

%package devel
Summary:	Development header files for the Knot DNS libraries
Requires:	%{name}-libs%{?_isa} = %{version}-%{release}

%description devel
The package contains development header files for the Knot DNS libraries
included in knot-libs package.

%package utils
Summary:	DNS client utilities shipped with the Knot DNS server
Requires:	%{name}-libs%{?_isa} = %{version}-%{release}

%description utils
The package contains DNS client utilities shipped with the Knot DNS server.

%package doc
Summary:	Documentation for the Knot DNS server
License:	GPLv3 and BSD and MIT
BuildArch:	noarch
Provides:	bundled(jquery) = 3.1.0

%description doc
The package contains documentation for the Knot DNS server.
On-line version is available on

%if 0%{GPG_CHECK}
export GNUPGHOME=./gpg-keyring
mkdir ${GNUPGHOME}
gpg2 --import %{SOURCE100}
gpg2 --verify %{SOURCE1} %{SOURCE0}
%setup -q
%patch1 -p1

# disable debug code (causes unused warnings)
CFLAGS="%{optflags} -DNDEBUG -Wno-unused"

%ifarch armv7hl i686
# 32-bit architectures sometimes do not have sufficient amount of
# contiguous address space to handle default values
%define configure_db_sizes --with-conf-mapsize=64

%configure \
  --sysconfdir=/etc \
  --localstatedir=/var/lib \
  --libexecdir=/usr/lib/knot \
  --with-rundir=/run/knot \
  --with-storage=/var/lib/knot \
  %{?configure_db_sizes} \
  --disable-static \
  --enable-dnstap=yes \
make %{?_smp_mflags}
make html

make install DESTDIR=%{buildroot}

# install documentation
install -d -m 0755 %{buildroot}%{_pkgdocdir}/samples
install -p -m 0644 -t %{buildroot}%{_pkgdocdir}/samples samples/*.zone*
install -p -m 0644 NEWS README %{buildroot}%{_pkgdocdir}
cp -av doc/_build/html %{buildroot}%{_pkgdocdir}
[ -r %{buildroot}%{_pkgdocdir}/html/index.html ] || exit 1
rm -f %{buildroot}%{_pkgdocdir}/html/.buildinfo

# install configuration file
rm %{buildroot}%{_sysconfdir}/%{name}/*
install -p -m 0644 -D %{repodir}/samples/%{name}.sample.conf %{buildroot}%{_sysconfdir}/%{name}/%{name}.conf

# install systemd files
install -p -m 0644 -D %{repodir}/distro/common/%{name}.service %{buildroot}%{_unitdir}/%{name}.service
install -p -m 0644 -D %{repodir}/distro/common/%{name}.tmpfiles %{buildroot}%{_tmpfilesdir}/%{name}.conf

# create storage dir and key dir
install -d %{buildroot}%{_sharedstatedir}
install -d -m 0775 -D %{buildroot}%{_sharedstatedir}/%{name}
install -d -m 0770 -D %{buildroot}%{_sharedstatedir}/%{name}/keys

# remove libarchive files
find %{buildroot} -type f -name "*.la" -delete -print

make check

getent group knot >/dev/null || groupadd -r knot
getent passwd knot >/dev/null || \
  useradd -r -g knot -d %{_sysconfdir}/knot -s /sbin/nologin \
  -c "Knot DNS server" knot
%if 0%{?suse_version}
%service_add_pre knot.service

systemd-tmpfiles --create %{_tmpfilesdir}/knot.conf &>/dev/null || :
%if 0%{?suse_version}
%service_add_post knot.service
%systemd_post knot.service

%if 0%{?suse_version}
%service_del_preun knot.service
%systemd_preun knot.service

%if 0%{?suse_version}
%service_del_postun knot.service
%systemd_postun_with_restart knot.service

%if 0%{?fedora}
%post libs -p /sbin/ldconfig
%postun libs -p /sbin/ldconfig

%license COPYING
%dir %attr(750,root,knot) %{_sysconfdir}/%{name}
%config(noreplace) %attr(640,root,knot) %{_sysconfdir}/%{name}/%{name}.conf
%dir %attr(775,root,knot) %{_sharedstatedir}/%{name}
%dir %attr(770,root,knot) %{_sharedstatedir}/%{name}/keys

%files utils

%files libs
%license COPYING
%doc NEWS

%files devel

%files doc
%dir %{_pkgdocdir}

* Wed Feb 21 2018 Tomas Krizek <> - 2.6.5-1
- move spec upstream
- see NEWS or