File bind.spec of Package bind

%define bind9_sonum 1302
%define libbind9 libbind9-%{bind9_sonum}
# lib/bind9/api:LIBINTERFACE = 1302

%define dns_sonum 1310
%define libdns libdns%{dns_sonum}
# lib/dns/api:LIBINTERFACE = 1310

%define irs_sonum 1301
%define libirs libirs%{irs_sonum}
# lib/irs/api:LIBINTERFACE = 1301

%define isc_sonum 1309
%define libisc libisc%{isc_sonum}
# lib/isc/api:LIBINTERFACE = 1309

%define isccc_sonum 1302
%define libisccc libisccc%{isccc_sonum}
# lib/isccc/api:LIBINTERFACE = 1302

%define isccfg_sonum 1302
%define libisccfg libisccfg%{isccfg_sonum}
# lib/isccfg/api:LIBINTERFACE = 1302

%define ns_sonum 1307
%define libns libns%{ns_sonum}
# lib/ns/api:LIBINTERFACE = 1307


# Defines for user and group add
%define	NAMED_UID 44
%define	NAMED_UID_NAME named
%define	NAMED_GID 44
%define	NAMED_GID_NAME named
%define	NAMED_COMMENT Name server daemon
%define	NAMED_HOMEDIR %{_localstatedir}/lib/named
%define	NAMED_SHELL /bin/false
%define	GROUPADD_NAMED getent group %{NAMED_GID_NAME} >/dev/null || %{_sbindir}/groupadd -g %{NAMED_GID} -o -r %{NAMED_GID_NAME}
%define	USERADD_NAMED getent passwd %{NAMED_UID_NAME} >/dev/null || %{_sbindir}/useradd -r -o -g %{NAMED_GID_NAME} -u %{NAMED_UID} -s %{NAMED_SHELL} -c "%{NAMED_COMMENT}" -d %{NAMED_HOMEDIR} %{NAMED_UID_NAME}
%define	USERMOD_NAMED getent passwd %{NAMED_UID_NAME} >/dev/null || %{_sbindir}/usermod -s %{NAMED_SHELL} -d  %{NAMED_HOMEDIR} %{NAMED_UID_NAME}

#Source: ftp://ftp.isc.org/isc/bind9/


Name:           bind
Version:        9.14.7
Release:        0
Summary:        Domain Name System (DNS) Server (named)
License:        MPL-2.0
Group:          Productivity/Networking/DNS/Servers
Url:            http://isc.org/sw/bind/
Source0:        %{name}-%{version}.tar.gz
Source1:        named.service
BuildRequires:  libcap-devel
BuildRequires:  libopenssl-devel
BuildRequires:  libtool
BuildRequires:  openssl
BuildRequires:  pkgconfig
BuildRequires:  update-desktop-files
BuildRequires:  pkgconfig(geoip)
BuildRequires:  pkgconfig(json)
BuildRequires:  pkgconfig(krb5)
BuildRequires:  pkgconfig(libidn)
BuildRequires:  pkgconfig(libxml-2.0)
Requires:       %{name}-utils
Requires(post): %fillup_prereq
Requires(post): bind-utils
Requires(post): coreutils
Requires(pre):  shadow
Provides:       bind9
BuildRequires:  systemd-rpm-macros
BuildRequires:  pkgconfig(libsystemd)
BuildRequires:  pkgconfig(systemd)

BuildRequires: fstrm-devel
BuildRequires: libprotobuf-c-devel
BuildRequires: protobuf-devel
BuildRequires: protobuf-c

%description
Berkeley Internet Name Domain (BIND) is an implementation of the Domain
Name System (DNS) protocols and provides an openly redistributable
reference implementation of the major components of the Domain Name
System.  This package includes the components to operate a DNS server.

%package -n %{libbind9}
Summary:        BIND9 shared library used by BIND
Group:          System/Libraries

%description -n %{libbind9}
This library contains a few utility functions used by the BIND
server and utilities.

%package -n %{libdns}
Summary:        DNS library used by BIND
Group:          System/Libraries

%description -n %{libdns}
This subpackage contains the "DNS client" module. This is a higher
level API that provides an interface to name resolution, single DNS
transaction with a particular server, and dynamic update. Regarding
name resolution, it supports advanced features such as DNSSEC
validation and caching. This module supports both synchronous and
asynchronous mode.

%package -n %{libirs}
Summary:        The BIND Information Retrieval System library
Group:          System/Libraries

%description -n %{libirs}
libirs provides an interface to parse the traditional resolv.conf file and an
"advanced" configuration file related to the DNS library for configuration
parameters that would be beyond the capability of the resolv.conf file.
Specifically, it is intended to provide DNSSEC related configuration
parameters. By default, the path to this configuration file is %{_sysconfdir}/dns.conf.

%package -n libirs-devel
Summary:        Development files for IRS
Group:          Development/Libraries/C and C++
Requires:       %{libirs} = %{version}

%description -n libirs-devel
libirs provides an interface to parse the traditional resolv.conf file and an
"advanced" configuration file related to the DNS library for configuration
parameters that would be beyond the capability of the resolv.conf file.  This
subpackage contains the header files needed for building programs with it.

%package -n %{libisc}
Summary:        ISC shared library used by BIND
Group:          System/Libraries
Provides:       bind-libs = %{version}-%{release}
Obsoletes:      bind-libs < %{version}-%{release}

%description -n %{libisc}
This library contains miscellaneous utility function used by the BIND
server and utilities. It includes functions for assertion handling,
balanced binary (AVL) trees, bit masks comparison, event based
programs, heap-based priority queues, memory handling, and program
logging.

%package -n %{libisccc}
Summary:        Command Channel Library used by BIND
Group:          System/Libraries

%description -n %{libisccc}
This library is used for communicating with BIND servers'
administrative command channel (port 953 by default).

%package -n %{libisccfg}
Summary:        Exported ISC configuration shared library
Group:          System/Libraries

%description -n %{libisccfg}
This BIND library contains the configuration file parser.

%package -n %{libns}
Summary:        Bind9 library
Group:          System/Libraries

%description -n %{libns}
A BIND 9 library

%package devel
Summary:        Development Libraries and Header Files of BIND
Group:          Development/Libraries/C and C++
Requires:       %{libbind9} = %{version}
Requires:       %{libdns} = %{version}
Requires:       %{libirs} = %{version}
Requires:       %{libisccc} = %{version}
Requires:       %{libisccfg} = %{version}
Requires:       %{libisc} = %{version}
Requires:       %{libns} = %{version}

%description devel
This package contains the header files, libraries, and documentation
for building programs using the libraries of the Berkeley Internet Name
Domain (BIND) Domain Name System implementation of the Domain Name
System (DNS) protocols.

%package doc
Summary:        BIND documentation
Group:          Documentation/Other
BuildArch:      noarch

%description doc
Documentation of the Berkeley Internet Name Domain (BIND) Domain Name
System implementation of the Domain Name System (DNS) protocols.  This
includes also the BIND Administrator Reference Manual (ARM).

%package libns
Summary:        Bind9 library
Group:          Productivity/Networking/DNS/Utilities

%description libns
Bind9 library

%package utils
Summary:        Utilities to query and test DNS
Group:          Productivity/Networking/DNS/Utilities

%description utils
This package includes the utilities "host", "dig", and "nslookup" used to
test and query the Domain Name System (DNS).  The Berkeley Internet
Name Domain (BIND) DNS server is found in the package named bind.

%prep
%setup -q

%build
autoreconf -fvi
export CFLAGS="$CFLAGS %{optflags} -fPIE"
export LDFLAGS="$LDFLAGS -pie"
%configure \
        --without-python \
	--includedir=%{_includedir}/bind \
	--disable-static \
	--with-openssl \
	--enable-threads \
	--with-libtool \
	--with-libxml2 \
	--with-libjson \
	--with-randomdev=/dev/urandom \
	--enable-ipv6 \
	--with-pic \
	--disable-openssl-version-check \
	--with-tuning=large \
	--with-geoip \
	--with-dlopen \
	--with-gssapi=yes \
	--disable-isc-spnego \
	--enable-fixed-rrset \
        --with-systemd \
	--enable-full-report \
        --enable-dnstap

make %{?_smp_mflags} 

%install
mkdir -p \
        %{buildroot}%{_prefix}/{bin,%{_lib},sbin,include} \
        %{buildroot}/%{_defaultdocdir}/bind \
        %{buildroot}%{_localstatedir}/lib/named \
        %{buildroot}%{_mandir}/{man1,man3,man5,man8} \
        %{buildroot}%{_fillupdir} \
        %{buildroot}/%{_libdir}/named \
        %{buildroot}%{_includedir}/bind/dns \
        %{buildroot}%{_libexecdir}/bind \
        %{buildroot}%{_sysconfdir}

echo '//named.conf' > %{buildroot}/%{_sysconfdir}/named.conf

%make_install
install -D -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/named.service
ln -s /sbin/service %{buildroot}%{_sbindir}/rcnamed

# remove useless .la files
rm -f %{buildroot}/%{_libdir}/lib*.{la,a}

find %{buildroot}/%{_libdir} -type f -name '*.so*' -print0 | xargs -0 chmod 0755

# Cleanup doc
rm doc/misc/Makefile*
find doc/arm -type f ! -name '*.html' -print0 | xargs -0 rm -f

# Create doc as we want it in bind and not bind-doc
mkdir -p %{buildroot}/%{_defaultdocdir}/bind/

for file in CHANGES COPYRIGHT README version contrib doc/{arm,misc}; do
   basename=$( basename ${file})
   cp -a ${file} %{buildroot}/%{_defaultdocdir}/bind/${basename}
   echo "%doc %{_defaultdocdir}/bind/${basename}" >>filelist-bind-doc
done

%pre
%{GROUPADD_NAMED}
%{USERADD_NAMED}
%{USERMOD_NAMED}
%service_add_pre named.service

%preun
%service_del_preun named.service

%post
%service_add_post named.service

%postun
%service_del_postun named.service

%post   -n %{libbind9} -p /sbin/ldconfig
%postun -n %{libbind9} -p /sbin/ldconfig
%post   -n %{libdns} -p /sbin/ldconfig
%postun -n %{libdns} -p /sbin/ldconfig
%post   -n %{libirs} -p /sbin/ldconfig
%postun -n %{libirs} -p /sbin/ldconfig
%post   -n %{libisc} -p /sbin/ldconfig
%postun -n %{libisc} -p /sbin/ldconfig
%post   -n %{libisccc} -p /sbin/ldconfig
%postun -n %{libisccc} -p /sbin/ldconfig
%post   -n %{libisccfg} -p /sbin/ldconfig
%postun -n %{libisccfg} -p /sbin/ldconfig
%post   -n %{libns} -p /sbin/ldconfig
%postun -n %{libns} -p /sbin/ldconfig

%post utils

%files
%defattr (-,root,root,-)
%license LICENSE
%{_unitdir}/named.service
%{_bindir}/bind9-config
%{_bindir}/named-rrchecker
%{_sbindir}/rcnamed
%{_sbindir}/named
%{_sbindir}/named-checkconf
%{_sbindir}/named-checkzone
%{_sbindir}/named-compilezone
%{_mandir}/man1/bind9-config.1%{ext_man}
%{_mandir}/man1/named-rrchecker.1%{ext_man}
%{_mandir}/man5/named.conf.5%{ext_man}
%{_mandir}/man8/named-checkconf.8%{ext_man}
%{_mandir}/man8/named-checkzone.8%{ext_man}
%{_mandir}/man8/named.8%{ext_man}
%{_mandir}/man8/named-compilezone.8%{ext_man}
%{_mandir}/man8/filter-aaaa.8%{ext_man}
%attr(-,named,named) %dir %{_libdir}/named
%attr(-,named,named) %dir %{_var}/lib/named
%dir %{_libexecdir}/bind
%dir %{_libdir}/named
%{_libdir}/named/filter-aaaa.so

%files -n %{libbind9}
%defattr (-,root,root,-)
%{_libdir}/libbind9.so.%{bind9_sonum}*

%files -n %{libdns}
%defattr (-,root,root,-)
%{_libdir}/libdns.so.%{dns_sonum}*

%files -n %{libirs}
%defattr (-,root,root,-)
%{_libdir}/libirs.so.%{irs_sonum}*

%files -n libirs-devel
%defattr (-,root,root,-)
%{_libdir}/libirs.so

%files -n %{libisc}
%defattr (-,root,root,-)
%{_libdir}/libisc.so.%{isc_sonum}*

%files -n %{libisccc}
%defattr (-,root,root,-)
%{_libdir}/libisccc.so.%{isccc_sonum}*

%files -n %{libisccfg}
%defattr (-,root,root,-)
%{_libdir}/libisccfg.so.%{isccfg_sonum}*

%files -n %{libns}
%defattr (-,root,root,-)
%{_libdir}/libns.so.%{ns_sonum}*

%files devel
%defattr (-,root,root,-)
%{_bindir}/isc-config.sh
%{_libdir}/libbind9.so
%{_libdir}/libdns.so
%{_libdir}/libisc.so
%{_libdir}/libisccc.so
%{_libdir}/libisccfg.so
%{_libdir}/libns.so
%{_includedir}/bind

%files doc -f filelist-bind-doc
%defattr (-,root,root,-)
%dir %doc %{_defaultdocdir}/bind

%files utils
%defattr (-,root,root,-)
%config(noreplace) %{_sysconfdir}/bind.keys
%config(noreplace) %{_sysconfdir}/named.conf
%{_bindir}/delv
%{_bindir}/dig
%{_bindir}/host
%{_bindir}/mdig
%{_bindir}/nslookup
%{_bindir}/nsupdate
%{_bindir}/arpaname
%{_bindir}/dnstap-read
%{_sbindir}/ddns-confgen
%{_sbindir}/dnssec-dsfromkey
%{_sbindir}/dnssec-importkey
%{_sbindir}/dnssec-keyfromlabel
%{_sbindir}/dnssec-keygen
%{_sbindir}/dnssec-revoke
%{_sbindir}/dnssec-settime
%{_sbindir}/dnssec-signzone
%{_sbindir}/dnssec-verify
%{_sbindir}/dnssec-cds
%{_sbindir}/named-journalprint
%{_sbindir}/nsec3hash
%{_sbindir}/rndc
%{_sbindir}/rndc-confgen
%{_sbindir}/tsig-keygen
%dir %doc %{_defaultdocdir}/bind
%{_mandir}/man1/arpaname.1%{ext_man}
%{_mandir}/man1/delv.1%{ext_man}
%{_mandir}/man1/dig.1%{ext_man}
%{_mandir}/man1/host.1%{ext_man}
%{_mandir}/man1/isc-config.sh.1%{ext_man}
%{_mandir}/man1/mdig.1%{ext_man}
%{_mandir}/man1/nslookup.1%{ext_man}
%{_mandir}/man1/nsupdate.1%{ext_man}
%{_mandir}/man1/dnstap-read.1%{ext_man}
%{_mandir}/man5/rndc.conf.5%{ext_man}
%{_mandir}/man8/ddns-confgen.8%{ext_man}
%{_mandir}/man8/dnssec-dsfromkey.8%{ext_man}
%{_mandir}/man8/dnssec-importkey.8%{ext_man}
%{_mandir}/man8/dnssec-keyfromlabel.8%{ext_man}
%{_mandir}/man8/dnssec-keygen.8%{ext_man}
%{_mandir}/man8/dnssec-revoke.8%{ext_man}
%{_mandir}/man8/dnssec-settime.8%{ext_man}
%{_mandir}/man8/dnssec-signzone.8%{ext_man}
%{_mandir}/man8/dnssec-verify.8%{ext_man}
%{_mandir}/man8/dnssec-cds.8%{ext_man}
%{_mandir}/man8/named-journalprint.8%{ext_man}
%{_mandir}/man8/nsec3hash.8%{ext_man}
%{_mandir}/man8/rndc.8%{ext_man}
%{_mandir}/man8/rndc-confgen.8%{ext_man}
%{_mandir}/man8/tsig-keygen.8%{ext_man}

%changelog