File pdns.spec of Package powerdns-authoritative

Name: pdns
Version: 5.0.0

%define pkg_version 5.0.0
%define oname pdns

Release: 1
Summary: A modern, advanced and high performance authoritative-only nameserver
Group: System Environment/Daemons
License: GPL-2.0-only
URL: https://powerdns.com
Source0: %{oname}-%{pkg_version}.tar.bz2

%global backends %{nil}

%bcond_without pdns_ixfrdist
%bcond_without unit_tests
%bcond_without pdns_godbc
%bcond_without pdns_sqlite3
%bcond_without pdns_geoip
%bcond_without pdns_protobuf
%bcond_without pdns_tools
%bcond_without pdns_pkcs11
%bcond_without pdns_mysql
%bcond_without pdns_pipe
%bcond_without pdns_remote
%bcond_without pdns_ldap
%bcond_without pdns_lmdb

BuildRequires: gcc13-c++
BuildRequires: cpp13
%define compiler_ver -13

BuildRequires: bison
BuildRequires: boost-devel
BuildRequires: libboost_program_options-devel
BuildRequires: libboost_serialization1_66_0-devel
BuildRequires: curl-devel
BuildRequires: libsodium-devel
BuildRequires: systemd-devel
BuildRequires: systemd
BuildRequires: krb5-devel
BuildRequires: lua-devel
%{?systemd_requires}

%if %{with pdns_protobuf}
BuildRequires: protobuf-devel
%endif

%if %{with pdns_pkcs11}
BuildRequires: pkgconfig(p11-kit-1)
%endif

%if %{with unit_tests}
BuildRequires: libboost_test-devel
BuildRequires: curl
%endif

%global backends %{backends} bind

%description
The PowerDNS Nameserver is a modern, advanced and high performance
authoritative-only nameserver. It is written from scratch and conforms
to all relevant DNS standards documents.
Furthermore, PowerDNS interfaces with almost any database.

%if %{with pdns_tools}
%package tools
Summary: Extra tools for %{name}
Group: System Environment/Daemons
%description tools
This package contains the extra tools for %{name}
%endif

%if %{with pdns_mysql}
%package backend-mysql
Summary: MySQL backend for %{name}
Group: Productivity/Networking/DNS/Servers
Requires: %{name} = %{version}
BuildRequires: mysql-devel
%global backends %{backends} gmysql
%description backend-mysql
This package contains the gmysql backend for %{name}
%endif

%if %{with pdns_pipe}
%package backend-pipe
Summary: Pipe backend for %{name}
Group: System Environment/Daemons
Requires: %{name} = %{version}
%global backends %{backends} pipe
%description backend-pipe
This package contains the pipe backend for %{name}
%endif

%if %{with pdns_remote}
%package backend-remote
Summary: Remote backend for %{name}
Group: System Environment/Daemons
Requires: %{name} = %{version}
%global backends %{backends} remote
%description backend-remote
This package contains the remote backend for %{name}
%endif

%if %{with pdns_ldap}
%package backend-ldap
Summary: LDAP backend for %{name}
Group: System Environment/Daemons
BuildRequires: openldap2-devel
%global backends %{backends} ldap
%description backend-ldap
This package contains the LDAP backend for %{name}
%endif

%if %{with pdns_sqlite3}
%package backend-sqlite3
Summary: SQLite backend for %{name}
Group: System Environment/Daemons
Requires: %{name} = %{version}
BuildRequires: sqlite-devel
%global backends %{backends} gsqlite3
%description backend-sqlite3
This package contains the SQLite backend for %{name}
%endif

%if %{with pdns_godbc}
%package backend-godbc
Summary: UnixODBC backend for %{name}
Group: System Environment/Daemons
Requires: %{name} = %{version}
BuildRequires: unixODBC-devel
%global backends %{backends} godbc
%description backend-godbc
This package contains the godbc backend for %{name}
%endif

%if %{with pdns_geoip}
%package backend-geoip
Summary: Geo backend for %{name}
Group: System Environment/Daemons
Requires: %{name} = %{version}
BuildRequires: GeoIP-devel
BuildRequires: yaml-cpp-devel
BuildRequires: libmaxminddb-devel
%global backends %{backends} geoip
%description backend-geoip
This package contains the geoip backend for %{name}
It allows different answers to DNS queries coming from different
IP address ranges or based on the geoipgraphic location
%endif

%if %{with pdns_lmdb}
%package backend-lmdb
Summary: LMDB backend for %{name}
Group: System Environment/Daemons
Requires: %{name} = %{version}
BuildRequires: lmdb-devel
%global backends %{backends} lmdb
%description backend-lmdb
This package contains the LMDB backend for %{name}
%endif

%if %{with pdns_ixfrdist}
%package ixfrdist
BuildRequires: yaml-cpp-devel
Summary: A progrm to redistribute zones over AXFR and IXFR
Group: System Environment/Daemons
%description ixfrdist
This package contains the ixfrdist program.
%endif

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

%build
export CPPFLAGS="-DLDAP_DEPRECATED"
export CXX=g++%{?compiler_ver}
export CC=gcc%{?compiler_ver}
export CPP=cpp%{?compiler_ver}

%configure \
  --sysconfdir=%{_sysconfdir}/%{oname} \
  --docdir=%{_datadir}/doc/packages/%{name} \
  --disable-static \
  --disable-dependency-tracking \
  --disable-silent-rules \
  --with-modules='' \
  --with-lua=lua \
  --with-dynmodules='%{backends}' \
  --with-libsodium \
  --enable-systemd \
%if %{with unit-tests}
  --enable-unit-tests \
%endif  
%if %{with pdns_pkcs11}
  --enable-experimental-pkcs11 \
%endif  
%if %{with pdns_lua-records}
  --enable-lua-records \
%endif
%if %{with pdns_tools}
  --enable-tools \
%endif
%if %{with pdns_ixfrdist}
  --enable-ixfrdist \
%endif
%if %{with pdns_protobuf}
  --with-protobuf
%endif

%make_build

%install
%make_install

%{__rm} -f %{buildroot}%{_libdir}/%{oname}/*.la

%{__install } -d %{buildroot}/%{_sharedstatedir}/%{oname}

%pre
getent group pdns >/dev/null || groupadd -r pdns
getent passwd pdns >/dev/null || \
	useradd -r -g pdns -d /var/lib/pdns -s /sbin/nologin \
	-c "PowerDNS Authoritative Server" pdns
# Change home directory to /var/lib/pdns
if [[ $(getent passwd pdns | cut -d: -f6) == "/" ]]; then
    usermod -d /var/lib/pdns pdns
fi
exit 0

%service_add_pre %{oname}.service

%post
%service_add_post %{oname}.service

%preun
%service_del_preun %{oname}.service

%postun
%service_del_postun %{oname}.service

%files
%defattr (-,root,root,-)
%dir %{_libdir}/%{oname}
%dir %attr(-,pdns,pdns) %{_sharedstatedir}/%{oname}
%dir %{_sysconfdir}/%{oname}
%doc COPYING README
%{_bindir}/pdns_control
%{_bindir}/pdnsutil
%{_bindir}/zone2sql
%{_bindir}/zone2json
%{_bindir}/zone2ldap
%{_bindir}/stubquery
%{_sbindir}/pdns_server
%{_mandir}/man1/pdns_control.1.gz
%{_mandir}/man1/pdns_server.1.gz
%{_mandir}/man1/zone2sql.1.gz
%{_mandir}/man1/zone2json.1.gz
%{_mandir}/man1/pdnsutil.1.gz
%{_mandir}/man1/zone2ldap.1.gz
%{_libdir}/%{oname}/libbindbackend.so
%{_unitdir}/pdns.service
%{_unitdir}/pdns@.service
%{_sysconfdir}/%{oname}/pdns.conf-dist

%if %{with pdns_tools}
%files tools
%defattr (-,root,root,-)
%{_bindir}/calidns
%{_bindir}/dnsgram
%{_bindir}/dnsreplay
%{_bindir}/dnsscan
%{_bindir}/dnsscope
%{_bindir}/dnswasher
%{_bindir}/dumresp
%{_bindir}/ixplore
%{_bindir}/pdns_notify
%{_bindir}/nproxy
%{_bindir}/nsec3dig
%{_bindir}/saxfr
%{_bindir}/sdig
%{_bindir}/dnsbulktest
%{_bindir}/dnspcap2calidns
%{_bindir}/dnstcpbench
%{_bindir}/dnspcap2protobuf
%{_mandir}/man1/calidns.1.gz
%{_mandir}/man1/dnsgram.1.gz
%{_mandir}/man1/dnsreplay.1.gz
%{_mandir}/man1/dnsscan.1.gz
%{_mandir}/man1/dnsscope.1.gz
%{_mandir}/man1/dnswasher.1.gz
%{_mandir}/man1/dumresp.1.gz
%{_mandir}/man1/ixplore.1.gz
%{_mandir}/man1/pdns_notify.1.gz
%{_mandir}/man1/nproxy.1.gz
%{_mandir}/man1/nsec3dig.1.gz
%{_mandir}/man1/saxfr.1.gz
%{_mandir}/man1/sdig.1.gz
%{_mandir}/man1/dnsbulktest.1.gz
%{_mandir}/man1/dnspcap2calidns.1.gz
%{_mandir}/man1/dnstcpbench.1.gz
%{_mandir}/man1/dnspcap2protobuf.1.gz
%endif

%if %{with pdns_mysql}
%files backend-mysql
%defattr (-,root,root,-)
%doc %{_docdir}/%{name}/*.mysql.sql
%{_libdir}/%{oname}/libgmysqlbackend.so
%endif

%if %{with pdns_pipe}
%files backend-pipe
%defattr (-,root,root,-)
%{_libdir}/%{oname}/libpipebackend.so
%endif

%if %{with pdns_remote}
%files backend-remote
%defattr (-,root,root,-)
%{_libdir}/%{oname}/libremotebackend.so
%endif

%if %{with pdns_ldap}
%files backend-ldap
%defattr (-,root,root,-)
%{_libdir}/%{oname}/libldapbackend.so
%doc %{_docdir}/%{name}/dnsdomain2.schema
%doc %{_docdir}/%{name}/pdns-domaininfo.schema
%endif

%if %{with pdns_sqlite3}
%files backend-sqlite3
%defattr (-,root,root,-)
%doc %{_docdir}/%{name}/*.sqlite3.sql
%{_libdir}/%{oname}/libgsqlite3backend.so
%endif

%if %{with pdns_godbc}
%files backend-godbc
%defattr (-,root,root,-)
%doc %{_docdir}/%{name}/*.mssql.sql
%{_libdir}/%{oname}/libgodbcbackend.so
%endif

%if %{with pdns_geoip}
%files backend-geoip
%defattr (-,root,root,-)
%{_libdir}/%{oname}/libgeoipbackend.so
%endif

%if %{with pdns_lmdb}
%files backend-lmdb
%defattr (-,root,root,-)
%{_libdir}/%{oname}/liblmdbbackend.so
%endif

%if %{with pdns_ixfrdist}
%files ixfrdist
%defattr (-,root,root,-)
%{_bindir}/ixfrdist
%{_mandir}/man1/ixfrdist.1.gz
%{_mandir}/man5/ixfrdist.yml.5.gz
%{_sysconfdir}/%{oname}/ixfrdist.example.yml
%{_unitdir}/ixfrdist.service
%{_unitdir}/ixfrdist@.service
%endif
openSUSE Build Service is sponsored by