File pdns.spec of Package pdns

#
# spec file for package pdns
#
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#



Name:           pdns
Version:        3.1.0
Release:        0
#
#
%define pkg_name       pdns
%define pkg_version 3.1
%define polarssl_version 1.1.2
%define home           %{_var}/lib/pdns
%define _localstatedir %{_var}/run/pdns
#
%if 0%{?sles_version} < 11
%define with_pdns_sqlite2 1
%else
%define with_pdns_sqlite3 1
%endif
%define with_pdns_lua     1
%define with_pdns_mongo   0
%define with_pdns_mydns   1
%define with_pdns_tinydns 0
#
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  Botan-devel
BuildRequires:  boost-devel
BuildRequires:  docbook-toys
BuildRequires:  docbook-utils
BuildRequires:  docbook-xsl-stylesheets
BuildRequires:  gcc-c++
BuildRequires:  gdbm-devel
BuildRequires:  libtool
%if 0%{?with_pdns_lua}
%if 0%{?suse_version} < 1030 || 0%{?suse_version} > 1210
BuildRequires:  lua51-devel
%else
BuildRequires:  lua-devel
%endif
%endif
%if 0%{?with_pdns_tinydns}
# FIXME: Could not find libcdb/tinycdb
%endif
%if 0%{?with_pdns_mongo}
# FIXME: needs mongo devel package
%endif
BuildRequires:  mysql-devel
BuildRequires:  openldap2-devel
BuildRequires:  pkg-config
BuildRequires:  postgresql-devel
BuildRequires:  pwdutils
# we add opendbx-backend-sqlite2 as we pull in sqlite2 anyway and we need one installed backend
%if 0%{?with_pdns_sqlite3}
BuildRequires:  sqlite-devel >= 3
%endif
#
%if 0%{?with_pdns_sqlite2}
%if 0%{?sles_version} == 9
BuildRequires:  sqlite-devel
%else
BuildRequires:  sqlite2-devel
%endif
%endif
#
%if 0%{?with_pdns_opendbx}
BuildRequires:  opendbx-backend-pgsql
BuildRequires:  opendbx-devel
%endif
%if 0%{?with_pdns_xdb}
BuildRequires:  tdb-devel
%endif
PreReq:         %fillup_prereq
PreReq:         %insserv_prereq
PreReq:         pwdutils
#
Url:            http://www.powerdns.com/
Source:         %{name}-%{pkg_version}.tar.gz
Source1:        rcpdns
Source2:        README.opendbx
# PATCH-MISSING-TAG -- See http://en.opensuse.org/openSUSE:Packaging_Patches_guidelines
Patch:          pdns-3.0.rc1_polarssl.patch
Patch1:         pdns-3.1_lib_lua.patch
#
Summary:        Modern, advanced and high performance authoritative-only nameserver
License:        GPL-2.0
Group:          Productivity/Networking/DNS/Servers
%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.

%package backend-mysql
Requires:       %{name} = %{version}
#
Summary:        MySQL backend for pdns
Group:          Productivity/Networking/DNS/Servers
%description backend-mysql
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.

This package holds the MySQL backend for pdns.

%if 0%{?with_pdns_mydns}
%package backend-mydns
Requires:       %{name} = %{version}
#
Summary:        MyDNS backend for pdns
Group:          Productivity/Networking/DNS/Servers
%description backend-mydns
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.

This package holds the MyDNS backend for pdns.

%endif

%package backend-postgresql
Requires:       %{name} = %{version}
#
Summary:        PostgreSQL backend for pdns
Group:          Productivity/Networking/DNS/Servers
%description backend-postgresql
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.

This package holds the PostgreSQL backend for pdns.

%if 0%{?with_pdns_sqlite2}
%package backend-sqlite2
Requires:       %{name} = %{version}
#
Summary:        SQLite 2 backend for pdns
Group:          Productivity/Networking/DNS/Servers
%description backend-sqlite2
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.

This package holds the SQLite 2 backend for pdns.

%endif

%if 0%{?with_pdns_sqlite3}
%package backend-sqlite3
Requires:       %{name} = %{version}
#
Summary:        SQLite 3 backend for pdns
Group:          Productivity/Networking/DNS/Servers
%description backend-sqlite3
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.

This package holds the SQLite 3 backend for pdns.

%endif

%package backend-ldap
Requires:       %{name} = %{version}
#
Summary:        LDAP backend for pdns
Group:          Productivity/Networking/DNS/Servers
%description backend-ldap
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.

This package holds the LDAP backend for pdns.

%if 0%{?with_pdns_opendbx}
%package backend-opendbx
Requires:       %{name} = %{version}
#
Summary:        OpenDBX backend for pdns
Group:          Productivity/Networking/DNS/Servers
%description backend-opendbx
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.

This package holds the OpenDBX backend for pdns.

%endif

%if 0%{?with_pdns_lua}
%package backend-lua
Requires:       %{name} = %{version}
#
Summary:        Lua backend for pdns
Group:          Productivity/Networking/DNS/Servers
%description backend-lua
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.

This package holds the Lua backend for pdns.

%endif


%if 0%{?with_pdns_xdb}
%package backend-xdb
Requires:       %{name} = %{version}
#
Summary:        Samba TDB backend for pdns
Group:          Productivity/Networking/DNS/Servers
%description backend-xdb
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.

This package holds the Samba TDB backend for pdns.

%endif

%if 0%{?with_pdns_recursor}
%package -n pdns-recursor
Requires:       %{name} = %{version}
#
Summary:        Modern, advanced and high performance recursing/non authoritative nameserver
Group:          Productivity/Networking/DNS/Servers
%description -n pdns-recursor
PowerDNS Recursor is a non authoritative/recursing DNS server. Use this
package if you need a dns cache for your network.

%endif

%prep
%setup -n %{name}-%{pkg_version}
%patch
%patch1
%if 0%{?with_pdns_opendbx}
cp %{S:2} README.opendbx
%endif
cp modules/geobackend/README     README.geobackend
# module-dir=/usr/local/lib
perl -p -i.back -e 's|module-dir=.*|module-dir=%{_libdir}/%{pkg_name}|g' pdns/pdns.conf-dist
diff -urN pdns/pdns.conf-dist{.back,} ||:
rm -v pdns/pdns.conf-dist.back

%build
touch NEWS AUTHORS COPYING
#autoreconf -fiv
export CFLAGS="%{optflags} -DLDAP_DEPRECATED -g -fpic -DPIC"
export CXXFLAGS="$CFLAGS"
export LIBS="-pie"
# "mysql" backend is legacy crap. dont build it!
%configure \
  --disable-static \
  --with-pic \
  --sysconfdir=%{_sysconfdir}/%{pkg_name} \
  --libdir=%{_libdir}/%{pkg_name} \
  --with-sqlite-lib=%{_libdir} \
  --with-sqlite3-lib=%{_libdir} \
  --with-pgsql-lib=%{_libdir} \
  --with-mysql-lib=%{_libdir} \
  --with-modules="" \
%if 0%{?with_pdns_lua}
  --with-lua \
%endif
  --with-dynmodules="\
  pipe     \
  geo      \
  gmysql   \
  gpgsql   \
  ldap     \
%if 0%{?with_pdns_lua}
  lua      \
%endif
%if 0%{?with_pdns_mongo}
  mongodb  \
%endif
%if 0%{?with_pdns_mydns}
  mydns    \
%endif
%if 0%{?with_pdns_tinydns}
  tinydns  \
%endif
%if 0%{?with_pdns_sqlite3}
  gsqlite3 \
%endif
%if 0%{?with_pdns_sqlite2}
  gsqlite  \
%endif
%if 0%{?with_pdns_opendbx}
  opendbx  \
%endif
%if 0%{?with_pdns_xdb}
  xdb      \
%endif
%if 0%{?with_pdns_db2}
  db2      \
%endif
%if 0%{?with_pdns_odbc}
  odbc     \
%endif
%if 0%{?with_pdns_oracle}
  goracle  \
  oracle   \
%endif
  "\
%if 0%{?with_pdns_recursor}
  --enable-recursor
%else
  --disable-recursor # we have an external package for that.
%endif
pushd pdns/ext/polarssl-%{polarssl_version}/library
  make OFLAGS="%{optflags}" static shared
popd
make
%if 0%{?build_debugging_tools}
pushd pdns
for i in $(awk -F= '/EXTRA_PROGRAMS/ {print $2}' Makefile.am ) ; do
  if ! [ $(echo $i | grep -c 'pdns' 2>&1) ] ; then
    make $i ;
  fi
done
popd
%endif

# pushd pdns/docs
#   db2html -o html pdns.sgml
#   find . -type d -exec chmod 755 {} \;
#   find . -type f -exec chmod 644 {} \;
#   ln -s book1.html html/index.html
# popd

%install
%makeinstall
%if 0%{?build_debugging_tools}
pushd pdns
for i in $(awk -F= '/EXTRA_PROGRAMS/ {print $2}' Makefile.am ) ; do
  if ! [ $(echo $i | grep -c 'pdns' 2>&1) ] ; then
    install -D -m 0755 $i %{buildroot}%{_sbindir}/$i ;
  fi
done
popd
%endif
install -Dd -m 0755 %{buildroot}{%{home},%{_var}}
mv %{buildroot}%{_sysconfdir}/%{pkg_name}/pdns.conf{-dist,}
install -D -m 0755 %{SOURCE1} %{buildroot}%{_sysconfdir}/init.d/%{pkg_name}
ln -s -f ../..%{_sysconfdir}/init.d/%{pkg_name} %{buildroot}%{_sbindir}/rc%{pkg_name}
rm -rfv %{buildroot}%{_libdir}/pdns/*.la

%clean
rm -rf %{buildroot}

%pre
/usr/sbin/groupadd -r pdns &>/dev/null || :
/usr/sbin/useradd -o -g pdns -s /bin/false -r -c "pdns" -d %{home} pdns &>/dev/null || :

%post
%{fillup_and_insserv pdns}

%preun
%stop_on_removal pdns

%postun
%restart_on_update pdns
%insserv_cleanup

%files
%defattr (-,root,root,-)
%doc ChangeLog HACKING README* TODO
#doc pdns/docs/html
%{_sysconfdir}/init.d/%{pkg_name}
%dir %attr(750,root,pdns) %{_sysconfdir}/%{pkg_name}
%config(noreplace)  %attr(640,root,pdns) %{_sysconfdir}/%{pkg_name}/%{pkg_name}.conf
%{_bindir}/pdns_control
%{_bindir}/zone2ldap
%{_bindir}/zone2sql
%{_bindir}/dnsreplay
%{_bindir}/pdnssec
%{_sbindir}/rcpdns
%{_sbindir}/pdns_server
%{_mandir}/man8/pdns_control.8.gz
%{_mandir}/man8/pdns_server.8.gz
%{_mandir}/man8/zone2sql.8.gz
%dir %{_libdir}/%{pkg_name}
%{_libdir}/%{pkg_name}/libpipebackend.so*
%{_libdir}/%{pkg_name}/libgeobackend.so*
%dir %attr(750,root,pdns) %{home}

%if 0%{?with_pdns_recursor}
%files -n pdns-recursor
%defattr (-,root,root,-)
%{_sbindir}/pdns_recursor
%endif

%files backend-mysql
%defattr (-,root,root,-)
%{_libdir}/%{pkg_name}/libgmysqlbackend.so*

%if 0%{?with_pdns_mydns}
%files backend-mydns
%defattr (-,root,root,-)
%{_libdir}/%{pkg_name}/libmydnsbackend.so*
%endif

%if 0%{?with_pdns_lua}
%files backend-lua
%defattr (-,root,root,-)
%{_libdir}/%{pkg_name}/libluabackend.so*
%endif

%files backend-postgresql
%defattr (-,root,root,-)
%{_libdir}/%{pkg_name}/libgpgsqlbackend.so*

%if 0%{?with_pdns_sqlite2}
%files backend-sqlite2
%defattr (-,root,root,-)
%{_libdir}/%{pkg_name}/libgsqlitebackend.so*
%endif

%if 0%{?with_pdns_sqlite3}
%files backend-sqlite3
%defattr (-,root,root,-)
%{_libdir}/%{pkg_name}/libgsqlite3backend.so*
%endif

%files backend-ldap
%defattr (-,root,root,-)
%{_libdir}/%{pkg_name}/libldapbackend.so*

%if 0%{?with_pdns_opendbx}
%files backend-opendbx
%defattr (-,root,root,-)
%{_libdir}/%{pkg_name}/libopendbxbackend.so*
%endif

%if 0%{?with_pdns_xdb}
%files backend-xdb
%defattr (-,root,root,-)
%{_bindir}/xdb-fill
%{_libdir}/%{pkg_name}/libxdbbackend.so*
%endif

%changelog