%global TARBALL_FORMAT gz %global UPSTREAM_VERSION 9.11.15 %global PACKAGE_VERSION 9.11.15 %global PACKAGE_RELEASE 1.1 %global MAJOR_VERSION 9 %global MINOR_VERSION 11 %global PATCH_VERSION 15 %bcond_without scl %if %{with scl} %global scl isc-bind %endif %{?scl:%scl_package bind} %{!?scl:%global pkg_name %{name}} ##### Macro and variable definitions %define replace_tokens \ sed \\\ -e "s|@LOCALSTATEDIR@|%{_localstatedir}|g;" \\\ -e "s|@SCL_ROOT@|%{?_scl_root}|g;" \\\ -e "s|@SYSCONFDIR@|%{_sysconfdir}|g;" # On some systems, %%scl_prefix is a macro rather than a %%global variable; # thus, a helper variable is used to prevent "Too many levels of recursion in # macro expansion" errors on such systems, caused by passing an argument # containing %%{?scl_prefix} to a macro using the %%{?*} construct %global service_name %{?scl_prefix}named %if 0%{?rhel} >= 8 || 0%{?fedora} >= 31 %global python_version python3 %global python_version_sitelib %{python3_sitelib} %else %global python_version python %global python_version_sitelib %{python_sitelib} %endif ##### Conditionally enabled features %bcond_without dnstap %if 0%{?rhel} >= 7 || 0%{?fedora} >= 14 %bcond_without python %else %bcond_with python %endif %if 0%{?rhel} >= 7 || 0%{?fedora} >= 15 %bcond_without systemd %else %bcond_with systemd %endif %bcond_with tuninglarge ##### Package metadata # 'bind' package Name: %{?scl:%scl_pkg_name}%{?!scl:isc-bind} Version: %{PACKAGE_VERSION} Release: %{PACKAGE_RELEASE}%{?dist} Summary: The Berkeley Internet Name Domain (BIND) DNS (Domain Name System) server License: MPL 2.0 URL: https://www.isc.org/downloads/BIND/ BuildRequires: docbook-style-xsl BuildRequires: json-c-devel BuildRequires: krb5-devel BuildRequires: libxml2-devel BuildRequires: libxslt BuildRequires: openssl-devel BuildRequires: perl %if %{with python} BuildRequires: %{python_version} BuildRequires: %{python_version}-rpm-macros %endif Requires: %{name}-libs = %{PACKAGE_VERSION} %{?!scl:Conflicts: bind} %if %{MINOR_VERSION} >= 13 BuildRequires: libcap-devel %endif %if %{MINOR_VERSION} >= 15 BuildRequires: %{?scl_prefix}libuv-devel Requires: %{?scl_prefix}libuv %endif %if %{with dnstap} BuildRequires: %{?scl_prefix}fstrm-devel BuildRequires: %{?scl_prefix}protobuf-c-compiler BuildRequires: %{?scl_prefix}protobuf-c-devel BuildRequires: %{?scl_prefix}protobuf-compiler BuildRequires: %{?scl_prefix}protobuf-devel %endif %if %{with python} %if %{MINOR_VERSION} >= 11 BuildRequires: %{python_version}-ply Requires: %{python_version}-ply %endif %if %{MINOR_VERSION} >= 13 BuildRequires: %{python_version}-dns %endif %endif %if %{with systemd} BuildRequires: systemd %{?systemd_requires} %endif %{?scl:BuildRequires: %{scl}-build} %{?scl:BuildRequires: %scl_runtime} %{?scl:Requires: %scl_runtime} Source0: https://ftp.isc.org/isc/bind9/%{UPSTREAM_VERSION}/bind-%{UPSTREAM_VERSION}.tar.%{TARBALL_FORMAT} Source1: named.service.in Source2: named.init.in Source3: named.sysconfig Source4: named.conf.in %description BIND (Berkeley Internet Name Domain) is an implementation of the DNS (Domain Name System) protocol. BIND includes a DNS server (named), which resolves host names to IP addresses; a resolver library (routines for applications to use when interfacing with DNS); and tools for verifying that the DNS server is operating properly. # 'bind-devel' package %package devel Summary: Header files and libraries needed for BIND DNS development Requires: %{name}-libs = %{PACKAGE_VERSION} %{?!scl:Conflicts: bind-devel} %description devel The isc-bind-devel package contains full version of the header files and libraries required for development with ISC BIND 9. # 'bind-libs' package %package libs Summary: Libraries used by the BIND DNS packages %{?!scl:Conflicts: bind-libs} %description libs Contains heavyweight version of BIND suite libraries used by both named DNS server and utilities in isc-bind-utils package. # 'bind-utils' package %package utils Summary: Utilities for querying DNS name servers Requires: %{name}-libs = %{PACKAGE_VERSION} %{?!scl:Conflicts: bind-utils} %description utils isc-bind-utils contains a collection of utilities for querying DNS (Domain Name System) name servers to find out information about Internet hosts. These tools will provide you with the IP addresses for given host names, as well as other information about registered domains and network addresses. You should install isc-bind-utils if you need to get information from DNS name servers. ##### Build instructions # 'bind' package %prep %setup -q -n bind-%{UPSTREAM_VERSION} %build %{?scl:scl enable %scl -- <<\EOF} set -e -v export LDFLAGS="${LDFLAGS} -L%{_libdir}" export STD_CINCLUDES="-I%{_includedir}" %configure \ --disable-static \ %if %{MINOR_VERSION} <= 11 --enable-threads \ --enable-ipv6 \ %endif %if %{with dnstap} --enable-dnstap \ %else --disable-dnstap \ %endif --with-pic \ --with-gssapi \ %if %{MINOR_VERSION} >= 15 --with-json-c \ %else --with-libjson \ %endif --with-libtool \ --with-libxml2 \ --without-lmdb \ --with-docbook-xsl=%{?scl:%_root_datadir}%{?!scl:%_datadir}/sgml/docbook/xsl-stylesheets \ %if %{with python} --with-python \ %else --without-python \ %endif %if %{with tuninglarge} --with-tuning=large \ %endif ; make %{?_smp_mflags} # Do not generate Bv9ARM.pdf to avoid pulling LaTeX make -C doc/arm Bv9ARM.html notes.html %{?scl:EOF} %install make install DESTDIR=${RPM_BUILD_ROOT} # Remove redundant files installed by "make install" rm -f ${RPM_BUILD_ROOT}%{_sysconfdir}/bind.keys rm -f ${RPM_BUILD_ROOT}%{_libdir}/*.la # systemd unit file / init script %if %{with systemd} install -d ${RPM_BUILD_ROOT}%{_unitdir} %replace_tokens %{SOURCE1} > ${RPM_BUILD_ROOT}%{_unitdir}/%{service_name}.service %else install -d ${RPM_BUILD_ROOT}%{?scl:%_root_initddir}%{!?scl:%_initddir} %replace_tokens %{SOURCE2} > ${RPM_BUILD_ROOT}%{?scl:%_root_initddir}%{!?scl:%_initddir}/%{service_name} %endif # /etc files install -d ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig install %{SOURCE3} ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/named %replace_tokens %{SOURCE4} > ${RPM_BUILD_ROOT}%{_sysconfdir}/named.conf touch ${RPM_BUILD_ROOT}%{_sysconfdir}/rndc.key # /var directories install -d ${RPM_BUILD_ROOT}%{_localstatedir}/named/data install -d ${RPM_BUILD_ROOT}%{_localstatedir}/run/named %if %{with systemd} # tmpfiles.d entry required to recreate /run/named on reboot (/tmp is a tmpfs) install -d ${RPM_BUILD_ROOT}%{_tmpfilesdir} echo "d %{_localstatedir}/run/named 0770 named named -" > ${RPM_BUILD_ROOT}%{_tmpfilesdir}/%{service_name}.conf %endif %files %defattr(-,root,root,-) %doc CHANGES README doc/arm/*.html %if %{MINOR_VERSION} >= 14 %{_libdir}/named/*.so %endif %{_mandir}/man5 %{_mandir}/man8 %{_sbindir}/* %if %{with python} %{?_scl_root}%{python_version_sitelib}/* %endif %if %{with systemd} %attr(0644,root,root) %{_unitdir}/%{service_name}.service %else %attr(0755,root,root) %{?scl:%_root_initddir}%{!?scl:%_initddir}/%{service_name} %endif %config(noreplace) %attr(0644,root,root) %{_sysconfdir}/sysconfig/named %defattr(0640, root, named, 0750) %config(noreplace) %{_sysconfdir}/named.conf %ghost %config(noreplace) %{_sysconfdir}/rndc.key %dir %{_localstatedir}/named %defattr(0660, named, named, 0770) %dir %{_localstatedir}/named/data %if %{with systemd} %defattr(-,root,root,-) %{_tmpfilesdir}/%{service_name}.conf %else %defattr(0660, named, named, 0770) %dir %{_localstatedir}/run/named %endif # 'bind-devel' package %files devel %defattr(-,root,root,-) %{_includedir}/* %if %{MINOR_VERSION} <= 14 %{_bindir}/bind9-config %{_bindir}/isc-config.sh %{_mandir}/man1/bind9-config.1.* %{_mandir}/man1/isc-config.sh.1.* %endif %if %{MINOR_VERSION} <= 11 %{_mandir}/man3 %endif # 'bind-libs' package %files libs %defattr(-,root,root,-) %{_libdir}/*.so* # 'bind-utils' package %files utils %defattr(-,root,root,-) %{_bindir}/arpaname %{_bindir}/delv %{_bindir}/dig %{_bindir}/host %{_bindir}/mdig %{_bindir}/named-rrchecker %{_bindir}/nslookup %{_bindir}/nsupdate %{_mandir}/man1/arpaname.1.* %{_mandir}/man1/delv.1.* %{_mandir}/man1/dig.1.* %{_mandir}/man1/host.1.* %{_mandir}/man1/mdig.1.* %{_mandir}/man1/named-rrchecker.1.* %{_mandir}/man1/nslookup.1.* %{_mandir}/man1/nsupdate.1.* %if %{with dnstap} %{_bindir}/dnstap-read %{_mandir}/man1/dnstap-read.1.* %endif ##### Installation/upgrade/removal scriptlets # 'bind' package %pre if [ "$1" -eq 1 ]; then # Initial installation, not upgrade groupadd -f -r named if ! cut -d: -f1 /etc/passwd | grep -F -x -q named; then useradd -c named -d %{_localstatedir}/named -g named -r -s /sbin/nologin named fi fi %post %if %{with systemd} %systemd_post %{service_name}.service if [ "$1" -eq 1 ]; then # Initial installation, not upgrade %tmpfiles_create %{service_name}.conf fi %else if [ "$1" -eq 1 ]; then # Initial installation, not upgrade chkconfig --add %{service_name} fi %endif %if %{MINOR_VERSION} >= 13 %global RNDC_CONFGEN_CMD %{_sbindir}/rndc-confgen -a %else %global RNDC_CONFGEN_CMD %{_sbindir}/rndc-confgen -a -r /dev/urandom %endif if [ "$1" -eq 1 ]; then # Initial installation, not upgrade if [ ! -s %{_sysconfdir}/rndc.key ] && [ ! -s %{_sysconfdir}/rndc.conf ]; then if %{RNDC_CONFGEN_CMD} > /dev/null 2>&1; then chown root:named %{_sysconfdir}/rndc.key chmod 640 %{_sysconfdir}/rndc.key [ -x /sbin/restorecon ] && /sbin/restorecon %{_sysconfdir}/rndc.key fi fi fi %preun %if %{with systemd} %systemd_preun %{service_name}.service %else if [ "$1" -eq 0 ]; then # Package removal, not upgrade service %{service_name} stop > /dev/null 2>&1 || true chkconfig --del %{service_name} || true fi %endif %postun %if %{with systemd} %if 0%{?rhel} >= 8 || 0%{?fedora} >= 24 systemctl daemon-reload >/dev/null 2>&1 || : %endif %systemd_postun_with_restart %{service_name}.service %else if [ "$1" -eq 1 ]; then # Upgrade, not removal if service %{service_name} status > /dev/null 2>&1; then service %{service_name} restart > /dev/null 2>&1 || true fi fi %endif # 'bind-libs' package %post libs if [ "$1" -eq 1 ]; then # Initial installation, not upgrade ldconfig fi # ldconfig is intentionally not run in %%post during an upgrade; if the newer # version of the 'bind-libs' package contains a library with the same interface # number, but an older revision number than the library present in the # currently installed version of this package, running ldconfig will reset the # relevant symlink in /usr/lib64 so that it points to the library with highest # revision number (i.e. the one installed by the version of the package which # is about to be removed); this in turn will likely break restarting named upon # upgrade (in %%postun for the 'bind' package), because it will attempt to # dynamically load an incorrect version of the library %postun libs ldconfig