File dnsdist.spec of Package powerdns-dnsdist

Name: dnsdist
Version: 2.0.2

%define pkg_version 2.0.2
%define oname dnsdist

Release: 1
License: GPL-2.0
Summary: A highly DNS-, DoS- and abuse-aware loadbalancer
Url: https://dnsdist.org/
Group: Productivity/Networking/DNS/Servers
Source0: %{oname}-%{pkg_version}.tar.xz
Source1: vendor.tar.xz
Source2: dnsdist.lua
Source3: usr.sbin.dnsdist
Source4: local.usr.sbin.dnsdist

BuildRequires: gcc11-c++
%define compiler_ver -11

BuildRequires: apparmor-profiles
BuildRequires: boost-devel >= 1.35.0
BuildRequires: libsodium-devel
BuildRequires: protobuf-devel
BuildRequires: cargo-packaging

BuildRequires: luajit-devel

BuildRequires: fstrm-devel
BuildRequires: libnghttp2-devel
BuildRequires: wslay-devel
BuildRequires: re2-devel
BuildRequires: pkgconfig(systemd)
BuildRequires: pkgconfig(libsystemd)
BuildRequires: libedit-devel
BuildRequires: systemd-devel
BuildRequires: systemd-rpm-macros
%{?systemd_requires}

BuildRequires: libopenssl-devel
BuildRequires: libgnutls-devel
BuildRequires: python3
BuildRequires: python3-PyYAML

%description
dnsdist is a highly DNS-, DoS- and abuse-aware loadbalancer. Its goal in life
is to route traffic to the best server, delivering top performance to
legitimate users while shunting or blocking abusive traffic.

dnsdist is dynamic, in the sense that its configuration can be changed at
runtime, and that its statistics can be queried from a console-like interface.

%prep
%autosetup -n %{oname}-%{pkg_version} -a1 -N

%build
export CXX=g++%{?compiler_ver}
%configure \
  --with-re2 \
  --with-libsodium \
  --enable-dnscrypt \
  --enable-dnstap \
  --enable-systemd \
  --enable-dns-over-tls \
  --enable-dns-over-https \
  --enable-yaml \
  --disable-silent-rules \
  --bindir=%{_sbindir} \
  --sysconfdir=%{_sysconfdir}/%{oname}/
make %{?_smp_mflags} -j2

%install
make install DESTDIR=%{buildroot} %{?_smp_mflags}

ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{oname}
install -D -m 0644 %{S:3} %{buildroot}%{_sysconfdir}/apparmor.d/usr.sbin.dnsdist
install -D -m 0644 %{S:4} %{buildroot}%{_sysconfdir}/apparmor.d/local/usr.sbin.dnsdist

install -Dd -m 0750 %{buildroot}%{_sysconfdir}/%{oname}/ %{buildroot}%{_var}/lib/%{oname}/
install -m 0640 %{S:2} %{buildroot}%{_sysconfdir}/%{oname}/dnsdist.conf

%pre
/usr/sbin/groupadd -r %{oname} >/dev/null 2>&1 || :
/usr/sbin/useradd -g %{oname} -s /bin/false -r -c "%{oname}" -d %{_var}/lib/%{oname} %{oname} >/dev/null 2>&1 || :

%service_add_pre %{oname}.service

%preun
%service_del_preun %{oname}.service

%post
%service_add_post %{oname}.service

%postun
%service_del_postun %{oname}.service

%files
%defattr(-,root,root)
%doc README.md
%{_sbindir}/dnsdist
%{_mandir}/man1/dnsdist.1*
%{_unitdir}/%{oname}.service
%{_unitdir}/%{oname}@.service
%{_sbindir}/rc%{oname}
%config(noreplace) %{_sysconfdir}/apparmor.d/usr.sbin.dnsdist
%config(noreplace) %{_sysconfdir}/apparmor.d/local/usr.sbin.dnsdist
%config(noreplace) %attr(-,root,%{oname}) %{_sysconfdir}/%{oname}/
%dir %attr(700,%{oname},%{oname}) %{_var}/lib/%{oname}

%changelog
openSUSE Build Service is sponsored by