File pdns.spec of Package pdns.import5757

#
# 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/
#

# norootforbuild


Name:           pdns
Version:        2.9.22
Release:        5.<RELEASE6>
#
Group:          Productivity/Networking/DNS/Servers
License:        GPLv2+
#
%define pkg_name       pdns
%define home           %{_var}/lib/pdns
%define _localstatedir %{_var}/run/pdns
#
%if 0%{?sles_version} < 11
%define with_pdns_sqlite2 1
%endif
%if 0%{?suse_version} > 1000
%define with_pdns_sqlite3 1
%endif
#
BuildRequires:  boost-devel docbook-toys docbook-utils docbook-xsl-stylesheets gcc-c++ gdbm-devel mysql-devel openldap2-devel postgresql-devel 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 opendbx-devel
%endif
%if 0%{?with_pdns_xdb}
BuildRequires:  tdb-devel
%endif
%if 0%{?with_pdns_recursor}
BuildRequires:  lua-devel pkg-config
%endif
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
PreReq:         %insserv_prereq %fillup_prereq pwdutils
#
Url:            http://www.powerdns.com/
Source:         %{name}-%{version}.tar.bz2
Source1:        rcpdns
Source2:        README.opendbx
Patch:          pdns-2.9.22_new_boost_exceptions.patch
Patch1:         pdns-2.9.22_wrong_pgsql.patch
Patch2:         pdns-2.9.22_warnings.patch
Patch3:         pdns-2.9.22_missing_includes.patch
Patch4:         pdns-2.9.22-CVE-2012-0206.patch
#
Summary:        Modern, advanced and high performance authoritative-only nameserver

%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.



Authors:
--------
    http://www.powerdns.com

%package backend-mysql
License:        GPLv2+
Group:          Productivity/Networking/DNS/Servers
Requires:       %{name} = %{version}
Summary:        MySQL backend for pdns

%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.



Authors:
--------
    http://www.powerdns.com

%package backend-postgresql
License:        GPLv2+
Group:          Productivity/Networking/DNS/Servers
Requires:       %{name} = %{version}
Summary:        PostgreSQL backend for pdns

%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.



Authors:
--------
    http://www.powerdns.com

%if 0%{?with_pdns_sqlite2}

%package backend-sqlite2
License:        GPLv2+
Group:          Productivity/Networking/DNS/Servers
Requires:       %{name} = %{version}
Summary:        SQLite 2 backend for pdns

%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.



Authors:
--------
    http://www.powerdns.com

%endif

%if 0%{?with_pdns_sqlite3}

%package backend-sqlite3
License:        GPLv2+
Group:          Productivity/Networking/DNS/Servers
Requires:       %{name} = %{version}
Summary:        SQLite 3 backend for pdns

%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.



Authors:
--------
    http://www.powerdns.com

%endif

%package backend-ldap
License:        GPLv2+
Group:          Productivity/Networking/DNS/Servers
Requires:       %{name} = %{version}
Summary:        LDAP backend for pdns

%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.



Authors:
--------
    http://www.powerdns.com

%if 0%{?with_pdns_opendbx}

%package backend-opendbx
License:        GPLv2+
Group:          Productivity/Networking/DNS/Servers
Requires:       %{name} = %{version}
Summary:        OpenDBX backend for pdns

%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.



Authors:
--------
    http://www.powerdns.com

%endif

%if 0%{?with_pdns_xdb}

%package backend-xdb
License:        GPLv2+
Group:          Productivity/Networking/DNS/Servers
Requires:       %{name} = %{version}
Summary:        Samba TDB backend for pdns

%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.



Authors:
--------
    http://www.powerdns.com

%endif

%if 0%{?with_pdns_recursor}

%package -n pdns-recursor
License:        GPLv2+
Group:          Productivity/Networking/DNS/Servers
Requires:       %{name} = %{version}
Summary:        Modern, advanced and high performance recursing/non authoritative nameserver

%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.



Authors:
--------
    http://www.powerdns.com

%endif

%prep
%setup
%patch
%patch1
%patch2
%patch3
%patch4
%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 "
export CXXFLAGS="$CFLAGS"
# "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="" \
  --with-dynmodules="\
  pdns     \
  pipe     \
  geo      \
  gmysql   \
  gpgsql   \
  ldap     \
%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
%{__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},%{_localstatedir}}
%{__mv} %{buildroot}%{_sysconfdir}/%{pkg_name}/pdns.conf{-dist,}
%{__install} -D -m 0755 %{S:1} %{buildroot}/etc/init.d/%{pkg_name}
%{__ln_s} -f ../../etc/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 INSTALL README* TODO
%doc pdns/docs/html
%config(noreplace) /etc/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
%{_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}/libpdnsbackend.so*
%{_libdir}/%{pkg_name}/libpipebackend.so*
%{_libdir}/%{pkg_name}/libgeobackend.so*
%dir %{home}
%ghost %dir %{_localstatedir}

%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*

%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