Support for python3 package (#1323248)

This commit is contained in:
Petr Menšík 2017-06-30 16:15:18 +02:00
parent 99562fb041
commit 0a45402a80

181
ldns.spec
View File

@ -1,10 +1,13 @@
%global _hardened_build 1
%{?!with_python: %global with_python 1}
%{?!with_python3: %global with_python3 1}
%{?!with_perl: %global with_perl 1}
%{?!with_ecdsa: %global with_ecdsa 1}
# GOST is not allowed in Fedora/RHEL due to legal reasons (not NIST ECC)
%{?!with_gost: %global with_gost 0}
%{?!disable_dane: %global disable_dane 0}
# Useful to build against openssl 1.0
%{?!disable_dane: %global disable_dane 0}
%{?!snapshot: %global snapshot 0}
%if %{with_python}
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
@ -27,7 +30,7 @@
Summary: Low-level DNS(SEC) library with API
Name: ldns
Version: 1.7.0
Release: 12%{?dist}
Release: 13%{?dist}
License: BSD
Url: http://www.nlnetlabs.nl/%{name}/
@ -38,9 +41,11 @@ Patch3: ldns-1.7.0-realloc.patch
Group: System Environment/Libraries
# Only needed for builds from svn snapshot
# BuildRequires: libtool
# BuildRequires: autoconf
# BuildRequires: automake
%if 0%{snapshot}
BuildRequires: libtool
BuildRequires: autoconf
BuildRequires: automake
%endif
BuildRequires: libpcap-devel
%if %{disable_dane}
@ -56,6 +61,9 @@ BuildRequires: doxygen
%if %{with_python}
BuildRequires: python2-devel, swig
%endif
%if %{with_python3}
BuildRequires: python3-devel
%endif
%if %{with_perl}
BuildRequires: perl-devel
BuildRequires: perl-ExtUtils-MakeMaker
@ -87,18 +95,31 @@ Requires: %{name}%{?_isa} = %{version}-%{release}
%description utils
Collection of tools to get, check or alter DNS(SEC) data.
%if %{with_python}
%package -n python2-ldns
%{?python_provide:%python_provide python2-ldns}
Summary: Python extensions for ldns
Summary: Python2 extensions for ldns
Group: Applications/System
Requires: %{name}%{?_isa} = %{version}-%{release}
%{?python_provide:%python_provide python2-ldns}
%description -n python2-ldns
Python extensions for ldns
Python2 extensions for ldns
%endif
%if %{with_python3}
%package -n python3-ldns
Summary: Python3 extensions for ldns
Group: Applications/System
Requires: %{name}%{?_isa} = %{version}-%{release}
%{?python_provide:%python_provide python3-ldns}
%description -n python3-ldns
Python3 extensions for ldns
%endif
%if %{with_perl}
%package -n perl-ldns
Summary: Perl extensions for ldns
@ -119,20 +140,43 @@ BuildArch: noarch
This package contains documentation for the ldns library
%prep
%setup -q
%{?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
%else
pushd %{pkgname}
%endif # with_python
%patch1 -p1
%patch2 -p1 -b .limit
%patch3 -p1 -b .realloc
# To built svn snapshots
# rm config.guess config.sub ltmain.sh
# aclocal
# libtoolize -c --install
# autoreconf --install
%if 0%{snapshot}
rm config.guess config.sub ltmain.sh
aclocal
libtoolize -c --install
autoreconf --install
%endif
%build
# fixup .pc file
sed -i "s/@includedir@/@includedir@\/ldns/" packaging/libldns.pc.in
# copy common doc files - after here, since it may be patched
cp -pr doc LICENSE README* Changelog ../
cp -p contrib/ldnsx/LICENSE ../LICENSE.ldnsx
cp -p contrib/ldnsx/README ../README.ldnsx
popd
%if 0%{?with_python3}
cp -a %{pkgname}_python2 %{pkgname}_python3
%endif # with_python3
%build
CFLAGS="%{optflags} -fPIC"
CXXFLAGS="%{optflags} -fPIC"
LDFLAGS="-Wl,-z,relro,-z,now -pie"
@ -151,36 +195,34 @@ export CFLAGS CXXFLAGS LDFLAGS
%global enable_ecdsa --disable-ecdsa
%endif
%if %{disable_dane}
%global disable_dane_ta --disable-dane-ta-usage
%endif
%global common_args \\\
--disable-rpath \\\
%{enable_gost} %{enable_ecdsa} \\\
%{enable_gost} %{enable_ecdsa} %{?disable_dane_ta} \\\
--with-ca-file=/etc/pki/tls/certs/ca-bundle.trust.crt \\\
--with-ca-path=/etc/pki/tls/certs/ \\\
--with-trust-anchor=%{_sharedstatedir}/unbound/root.key
--with-trust-anchor=%{_sharedstatedir}/unbound/root.key \\\
--disable-static \\\
%if 0%{with_python}
pushd %{pkgname}_python2
%else
pushd %{pkgname}
%endif # with_python
%configure \
%{common_args} \
--disable-static \
--with-examples \
--with-drill \
%if %{with_python}
--with-pyldns \
--with-pyldns PYTHON_VERSION=2
%endif
--enable-rrtype-cds --enable-rrtype-uri \
%if %{disable_dane}
--disable-dane-ta-usage \
%endif
pushd drill
%configure %{common_args}
popd
pushd examples
%configure %{common_args}
popd
make %{?_smp_mflags}
make -C drill %{?_smp_mflags}
make -C examples %{?_smp_mflags}
make %{?_smp_mflags} doc
# We cannot use the built-in --with-p5-dns-ldns
@ -194,31 +236,60 @@ make %{?_smp_mflags} doc
# specfic hardening options should not end up in ldns-config
sed -i "s/-Wl,-z,relro,-z,now -pie//" packaging/ldns-config
popd
%if 0%{with_python3}
pushd %{pkgname}_python3
%configure \
%{common_args} \
--with-pyldns PYTHON_VERSION=3
make %{?_smp_mflags}
popd
%endif
%install
rm -rf %{buildroot}
%if 0%{with_python}
pushd %{pkgname}_python2
%else
pushd %{pkgname}
%endif
make DESTDIR=%{buildroot} INSTALL="%{__install} -p" install
make DESTDIR=%{buildroot} INSTALL="%{__install} -p" install-doc
# remove .la files
rm -rf %{buildroot}%{_libdir}/*.la
%if 0%{with_python}
rm -rf %{buildroot}%{python2_sitearch}/*.la
%endif
# install pkg-config file
install -D -m644 packaging/libldns.pc %{buildroot}%{_libdir}/pkgconfig/ldns.pc
%if %{with_perl}
make -C contrib/DNS-LDNS DESTDIR=%{buildroot} pure_install
chmod 755 %{buildroot}%{perl_vendorarch}/auto/DNS/LDNS/LDNS.so
rm -f %{buildroot}%{perl_vendorarch}/auto/DNS/LDNS/{.packlist,LDNS.bs}
%endif
popd
%if %{with_python3}
pushd %{pkgname}_python3
make DESTDIR=%{buildroot} INSTALL="%{__install} -p" install-pyldns install-pyldnsx
rm -rf %{buildroot}%{_libdir}/*.la %{buildroot}%{python3_sitearch}/*.la
popd
%endif
# don't package xml files
rm doc/*.xml
# don't package building script for install-doc in doc section
rm doc/doxyparse.pl
# remove double set of man pages
rm -rf doc/man
# remove .la files
rm -rf %{buildroot}%{_libdir}/*.la %{buildroot}%{python_sitearch}/*.la
# install pkg-config file
install -D -m644 packaging/libldns.pc %{buildroot}%{_libdir}/pkgconfig/ldns.pc
make -C drill DESTDIR=%{buildroot} install
make -C examples DESTDIR=%{buildroot} install
%if %{with_perl}
make -C contrib/DNS-LDNS DESTDIR=%{buildroot} pure_install
chmod 755 %{buildroot}%{perl_vendorarch}/auto/DNS/LDNS/LDNS.so
rm -f %{buildroot}%{perl_vendorarch}/auto/DNS/LDNS/{.packlist,LDNS.bs}
%endif
%post -p /sbin/ldconfig
@ -238,29 +309,43 @@ make -C examples DESTDIR=%{buildroot} install
%{_mandir}/man1/*
%files devel
%doc Changelog
%doc Changelog README.git
%{_libdir}/libldns.so
%{_libdir}/pkgconfig/ldns.pc
%{_bindir}/ldns-config
%dir %{_includedir}/ldns
%{_includedir}/ldns/*.h
%{_mandir}/man3/*
%{_mandir}/man3/*.3.gz
%if %{with_python}
%files -n python2-ldns
%{python_sitearch}/*
%doc %{pkgname}_python2/contrib/python/Changelog README.ldnsx
%license LICENSE.ldnsx
%{python2_sitearch}/*
%endif
%if %{with_python3}
%files -n python3-ldns
%doc %{pkgname}_python3/contrib/python/Changelog README.ldnsx
%license LICENSE.ldnsx
%{python3_sitearch}/*
%endif
%if %{with_perl}
%files -n perl-ldns
%{perl_vendorarch}/*
%exclude %dir %{perl_vendorarch}/auto/
%{_mandir}/man3/*.3pm.gz
%endif
%files doc
%doc doc
%changelog
* Wed Feb 21 2018 Petr Menšík <pemensik@redhat.com> - 1.7.0-13
- Support for python3 package (#1323248)
- Moved perl manual pages to perl-ldns
* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.7.0-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild