diff --git a/unbound.spec b/unbound.spec index 9b586a0..6463fb7 100644 --- a/unbound.spec +++ b/unbound.spec @@ -1,18 +1,18 @@ %{?!with_python: %global with_python 1} -%{?!with_munin: %global with_munin 1} - -%if %{with_python} -%if 0%{?fedora} >= 22 -%global python python3 -%global __python %{__python3} -%else -%global python python2 -%global __python %{__python2} -%endif - -%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} -%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")} -%endif +%{?!with_python3: %global with_python3 1} +%{?!with_munin: %global with_munin 1} + +%if 0%{with_python} == 0 +# if not building Python, don't build Python3 +%global with_python3 0 +%else # with_python +# needed just for EPEL +%if 0%{?rhel} <= 6 +%{!?__python2: %global __python2 /usr/bin/python2} +%{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")} +%{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")} +%endif # rhel <= 6 +%endif # with_python %global _hardened_build 1 @@ -21,7 +21,7 @@ Summary: Validating, recursive, and caching DNS(SEC) resolver Name: unbound Version: 1.5.3 -Release: 1%{?extra_version:.%{extra_version}}%{?dist} +Release: 2%{?extra_version:.%{extra_version}}%{?dist} License: BSD Url: http://www.nlnetlabs.nl/unbound/ Source: http://www.unbound.net/downloads/%{name}-%{version}%{?extra_version}.tar.gz @@ -43,16 +43,25 @@ Source14: unbound.sysconfig Source15: unbound.cron Source16: unbound-munin.README +# https://www.nlnetlabs.nl/bugs-script/show_bug.cgi?id=664 +Patch0: 0001-Use-print_function-also-for-Python2.patch +Patch1: 0002-libunbound-examples-produce-sorted-output.patch +Patch2: 0003-libunbound-Python-libldns-is-not-used-anymore.patch +Patch3: 0004-Resolve-Python-3-incompatibilities-in-libunbound-and.patch + Group: System Environment/Daemons BuildRequires: flex, openssl-devel BuildRequires: libevent-devel expat-devel -%if %{with_python} -BuildRequires: %{python}-devel swig -%endif +%if 0%{with_python} +BuildRequires: python2-devel swig +%endif # with_python +%if 0%{with_python3} +BuildRequires: python3-devel +%endif # with_python3 BuildRequires: systemd # Required for SVN versions # BuildRequires: bison -# BuildRequires: automake autoconf +BuildRequires: automake autoconf libtool Requires(post): systemd Requires(preun): systemd @@ -103,40 +112,115 @@ Requires: crontabs %description libs Contains libraries used by the unbound server and client applications -%if %{with_python} -%package python -Summary: Python modules and extensions for unbound +%if 0%{with_python} +%package -n python-unbound +Summary: Python 2 modules and extensions for unbound Group: Applications/System Requires: %{name}-libs%{?_isa} = %{version}-%{release} +Provides: unbound-python = %{version}-%{release} +Obsoletes: unbound-python < %{version}-%{release} + +%description -n python-unbound +Python 2 modules and extensions for unbound +%endif # with_python + +%if 0%{with_python3} +%package -n python3-unbound +Summary: Python 3 modules and extensions for unbound +Group: Applications/System +Requires: %{name}-libs%{?_isa} = %{version}-%{release} + +%description -n python3-unbound +Python 3 modules and extensions for unbound +%endif # with_python3 -%description python -Python modules and extensions for unbound -%endif %prep -%setup -q %{?extra_version:-n %{name}-%{version}%{extra_version}} +%{?extra_version:%global pkgname %{name}-%{version}%{extra_version}}%{!?extra_version:%global pkgname %{name}-%{version}} +%setup -qcn %{pkgname} + +%if 0%{with_python} +mv %{pkgname} %{pkgname}_python2 +pushd %{pkgname}_python2 +%endif # with_python + +#Add patches here +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 + +autoreconf -iv + +%if 0%{with_python} +# copy common doc files - after here, since it may be patched +cp -pr doc pythonmod libunbound ../ +popd +%endif # with_python + +%if 0%{?with_python3} +cp -a %{pkgname}_python2 %{pkgname}_python3 +%endif # with_python3 + %build # This is needed to rebuild the configure script to support Python 3.x -#autoreconf +# autoreconf -iv export LDFLAGS="-Wl,-z,relro,-z,now -pie -specs=/usr/lib/rpm/redhat/redhat-hardened-ld" export CFLAGS="$RPM_OPT_FLAGS -fPIE -pie" export CXXFLAGS="$RPM_OPT_FLAGS -fPIE -pie" -%configure --with-libevent --with-pthreads --with-ssl \ - --disable-rpath --disable-static \ - --with-conf-file=%{_sysconfdir}/%{name}/unbound.conf \ - --with-pidfile=%{_localstatedir}/run/%{name}/%{name}.pid \ -%if %{with_python} - --with-pythonmodule --with-pyunbound PYTHON=%{__python} \ -%endif - --enable-sha2 --disable-gost --enable-ecdsa \ + +# ./configure script common arguments +%global configure_args --with-libevent --with-pthreads --with-ssl \\\ + --disable-rpath --disable-static \\\ + --with-conf-file=%{_sysconfdir}/%{name}/unbound.conf \\\ + --with-pidfile=%{_localstatedir}/run/%{name}/%{name}.pid \\\ + --enable-sha2 --disable-gost --enable-ecdsa \\\ --with-rootkey-file=%{_sharedstatedir}/unbound/root.key +%if 0%{with_python} +pushd %{pkgname}_python2 +%endif # with_python + +%configure \ +%if %{with_python} + --with-pythonmodule --with-pyunbound PYTHON=%{__python2} \ +%endif # with_python + %{configure_args} + %{__make} %{?_smp_mflags} %{__make} %{?_smp_mflags} streamtcp +%if 0%{with_python} +popd +%endif # with_python + +%if 0%{with_python3} +pushd %{pkgname}_python3 +%configure \ + --with-pythonmodule --with-pyunbound PYTHON=%{__python3} \ + %{configure_args} + +%{__make} %{?_smp_mflags} +popd +%endif # with_python3 + + %install +%if 0%{with_python3} +pushd %{pkgname}_python3 +%{__make} DESTDIR=%{buildroot} install +popd +%endif # with_python3 + +%if 0%{with_python} +pushd %{pkgname}_python2 +%endif # with_python %{__make} DESTDIR=%{buildroot} install +%if 0%{with_python} +popd +%endif # with_python + install -d -m 0755 %{buildroot}%{_unitdir} %{buildroot}%{_sysconfdir}/sysconfig install -p -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/unbound.service install -p -m 0644 %{SOURCE7} %{buildroot}%{_unitdir}/unbound-keygen.service @@ -157,11 +241,19 @@ for plugin in unbound_munin_hits unbound_munin_queue unbound_munin_memory unboun done %endif +%if 0%{with_python} +pushd %{pkgname}_python2 +%endif # with_python + # install streamtcp used for monitoring / debugging unbound's port 80/443 modes install -m 0755 streamtcp %{buildroot}%{_sbindir}/unbound-streamtcp # install streamtcp man page install -m 0644 testcode/streamtcp.1 %{buildroot}/%{_mandir}/man1/unbound-streamtcp.1 +%if 0%{with_python} +popd +%endif # with_python + # Install tmpfiles.d config install -d -m 0755 %{buildroot}%{_tmpfilesdir} %{buildroot}%{_sharedstatedir}/unbound install -m 0644 %{SOURCE8} %{buildroot}%{_tmpfilesdir}/unbound.conf @@ -173,9 +265,14 @@ install -m 0644 %{SOURCE13} %{buildroot}%{_sharedstatedir}/unbound/root.key # remove static library from install (fedora packaging guidelines) rm %{buildroot}%{_libdir}/*.la -%if %{with_python} -rm %{buildroot}%{python_sitearch}/*.la -%endif + +%if 0%{with_python} +rm %{buildroot}%{python2_sitearch}/*.la +%endif # with_python + +%if 0%{with_python3} +rm %{buildroot}%{python3_sitearch}/*.la +%endif # with_python3 # create softlink for all functions of libunbound man pages for mpage in ub_ctx ub_result ub_ctx_create ub_ctx_delete ub_ctx_set_option ub_ctx_get_option ub_ctx_config ub_ctx_set_fwd ub_ctx_resolvconf ub_ctx_hosts ub_ctx_add_ta ub_ctx_add_ta_file ub_ctx_trustedkeys ub_ctx_debugout ub_ctx_debuglevel ub_ctx_async ub_poll ub_wait ub_fd ub_process ub_resolve ub_resolve_async ub_cancel ub_resolve_free ub_strerror ub_ctx_print_local_zones ub_ctx_zone_add ub_ctx_zone_remove ub_ctx_data_add ub_ctx_data_remove; @@ -195,11 +292,70 @@ install -p %{SOURCE11} %{buildroot}%{_sysconfdir}/unbound/local.d/ # Link unbound-control-setup.8 manpage to unbound-control.8 echo ".so man8/unbound-control.8" > %{buildroot}/%{_mandir}/man8/unbound-control-setup.8 + +%pre libs +getent group unbound >/dev/null || groupadd -r unbound +getent passwd unbound >/dev/null || \ +useradd -r -g unbound -d %{_sysconfdir}/unbound -s /sbin/nologin \ +-c "Unbound DNS resolver" unbound + +%post +%systemd_post unbound.service +%systemd_post unbound-keygen.service + +%post libs +/sbin/ldconfig +%{_sbindir}/runuser --command="%{_sbindir}/unbound-anchor -a %{_sharedstatedir}/unbound/root.anchor -c %{_sysconfdir}/unbound/icannbundle.pem" --shell /bin/sh unbound ||: + +%preun +%systemd_preun unbound.service +%systemd_preun unbound-keygen.service + +%postun +%systemd_postun_with_restart unbound.service +%systemd_postun unbound-keygen.service + +%postun libs -p /sbin/ldconfig + +%triggerun -- unbound < 1.4.12-4 +# Save the current service runlevel info +# User must manually run systemd-sysv-convert --apply unbound +# to migrate them to systemd targets +/usr/bin/systemd-sysv-convert --save unbound >/dev/null 2>&1 ||: + +# Run these because the SysV package being removed won't do them +/sbin/chkconfig --del unbound >/dev/null 2>&1 || : +/bin/systemctl try-restart unbound.service >/dev/null 2>&1 || : +/bin/systemctl try-restart unbound-keygen.service >/dev/null 2>&1 || : + + %check +%if 0%{with_python} +pushd %{pkgname}_python2 + +#pushd pythonmod +#make test +#popd +%endif # with_python + make check +%if 0%{with_python} +popd +%endif # with_python + +%if 0%{with_python3} +pushd %{pkgname}_python3 +#pushd pythonmod +#make test +#popd +make check +popd +%endif # with_python3 + + %files -%doc doc/README doc/CREDITS doc/LICENSE doc/FEATURES +%doc doc/CREDITS doc/FEATURES %{_unitdir}/%{name}.service %{_unitdir}/%{name}-keygen.service %attr(0755,unbound,unbound) %dir %{_localstatedir}/run/%{name} @@ -222,27 +378,37 @@ make check %{_mandir}/man5/* %{_mandir}/man8/* -%if %{with_python} -%files python -%{python_sitearch}/* +%if 0%{with_python} +%files -n python-unbound +%license pythonmod/LICENSE +%{python2_sitearch}/* %doc libunbound/python/examples/* %doc pythonmod/examples/* %endif -%if %{with_munin} +%if 0%{with_python3} +%files -n python3-unbound +%license pythonmod/LICENSE +%{python3_sitearch}/* +%doc libunbound/python/examples/* +%doc pythonmod/examples/* +%endif + +%if 0%{with_munin} %files munin +%doc unbound-munin.README %config(noreplace) %{_sysconfdir}/munin/plugin-conf.d/unbound %{_datadir}/munin/plugins/unbound* -%doc unbound-munin.README %endif %files devel %{_libdir}/libunbound.so %{_includedir}/unbound.h %{_mandir}/man3/* -%doc README %files libs +%doc doc/README +%license doc/LICENSE %attr(0755,root,root) %dir %{_sysconfdir}/%{name} %{_sbindir}/unbound-anchor %{_libdir}/libunbound.so.* @@ -253,45 +419,13 @@ make check %attr(0644,root,root) %config(noreplace) %{_sysconfdir}/%{name}/dlv.isc.org.key # just left for backwards compat with user changed unbound.conf files - format is different! %attr(0644,root,root) %config(noreplace) %{_sysconfdir}/%{name}/root.key -%doc doc/README doc/LICENSE -%pre libs -getent group unbound >/dev/null || groupadd -r unbound -getent passwd unbound >/dev/null || \ -useradd -r -g unbound -d %{_sysconfdir}/unbound -s /sbin/nologin \ --c "Unbound DNS resolver" unbound -exit 0 - -%post -%systemd_post unbound.service -%systemd_post unbound-keygen.service - -%post libs -/sbin/ldconfig -%{_sbindir}/runuser --command="%{_sbindir}/unbound-anchor -a %{_sharedstatedir}/unbound/root.anchor -c %{_sysconfdir}/unbound/icannbundle.pem" --shell /bin/sh unbound ||: - -%preun -%systemd_preun unbound.service -%systemd_preun unbound-keygen.service - -%postun -%systemd_postun_with_restart unbound.service -%systemd_postun unbound-keygen.service - -%postun libs -p /sbin/ldconfig - -%triggerun -- unbound < 1.4.12-4 -# Save the current service runlevel info -# User must manually run systemd-sysv-convert --apply unbound -# to migrate them to systemd targets -/usr/bin/systemd-sysv-convert --save unbound >/dev/null 2>&1 ||: - -# Run these because the SysV package being removed won't do them -/sbin/chkconfig --del unbound >/dev/null 2>&1 || : -/bin/systemctl try-restart unbound.service >/dev/null 2>&1 || : -/bin/systemctl try-restart unbound-keygen.service >/dev/null 2>&1 || : %changelog +* Thu Apr 16 2015 Tomas Hozza - 1.5.3-2 +- Fix FTBFS (#1206129) +- Build python3-unbound and python-unbound bindings for Python 3 and 2 (#1188080) + * Mon Mar 16 2015 Paul Wouters - 1.5.3-1 - Updated to 1.5.3 which is a bugfix on 1.5.2 for sighup handling - Updated to 1.5.2 which fixes DNSSEC validation with different