Don't build Python 2 subpackage on EL > 7 and Fedora > 28

This commit is contained in:
Miro Hrončok 2018-03-16 14:25:54 +01:00
parent 04792bcea2
commit 859c30f8fe

View File

@ -1,10 +1,18 @@
%define pkg_version 5.6 %define pkg_version 5.6
%define api_version 0.6.7 %define api_version 0.6.7
%global with_python3 1
%if 0%{?rhel} && 0%{?rhel} <= 7 %if 0%{?rhel} && 0%{?rhel} <= 7
%global with_python3 0 # disable python3 by default
%bcond_with python3
%else
%bcond_without python3
%endif
%if 0%{?rhel} > 7 || 0%{?fedora} > 28
# disable python2 by default
%bcond_with python2
%else
%bcond_without python2
%endif %endif
%{!?tcl_version: %global tcl_version %(echo 'puts $tcl_version' | tclsh)} %{!?tcl_version: %global tcl_version %(echo 'puts $tcl_version' | tclsh)}
@ -25,7 +33,7 @@
Name: brltty Name: brltty
Version: %{pkg_version} Version: %{pkg_version}
Release: 6%{?dist} Release: 7%{?dist}
License: LGPLv2+ License: LGPLv2+
URL: http://mielke.cc/brltty/ URL: http://mielke.cc/brltty/
Source0: http://mielke.cc/brltty/archive/%{name}-%{version}.tar.xz Source0: http://mielke.cc/brltty/archive/%{name}-%{version}.tar.xz
@ -42,7 +50,6 @@ BuildRequires: gettext, at-spi2-core-devel
BuildRequires: espeak-devel BuildRequires: espeak-devel
%endif %endif
BuildRequires: espeak-ng-devel BuildRequires: espeak-ng-devel
BuildRequires: python2-tools
BuildRequires: /usr/bin/2to3 BuildRequires: /usr/bin/2to3
BuildRequires: autoconf BuildRequires: autoconf
@ -156,6 +163,7 @@ Summary: Tcl binding for BrlAPI
%description -n tcl-brlapi %description -n tcl-brlapi
This package provides the Tcl binding for BrlAPI. This package provides the Tcl binding for BrlAPI.
%if %{with python2}
%package -n python2-brlapi %package -n python2-brlapi
%{?python_provide:%python_provide python2-brlapi} %{?python_provide:%python_provide python2-brlapi}
Version: %{api_version} Version: %{api_version}
@ -166,15 +174,21 @@ BuildRequires: python2-devel
BuildRequires: python2-setuptools BuildRequires: python2-setuptools
Summary: Python binding for BrlAPI Summary: Python binding for BrlAPI
%description -n python2-brlapi %description -n python2-brlapi
This package provides the Python binding for BrlAPI. This package provides the Python 2 binding for BrlAPI.
%endif
%if 0%{?with_python3} %if %{with python3}
%package -n python3-brlapi %package -n python3-brlapi
%{?python_provide:%python_provide python3-brlapi}
Version: %{api_version} Version: %{api_version}
License: LGPLv2+ License: LGPLv2+
Requires: brlapi%{?_isa} = %{api_version}-%{release} Requires: brlapi%{?_isa} = %{api_version}-%{release}
BuildRequires: Cython BuildRequires: python3-Cython
BuildRequires: python3-devel BuildRequires: python3-devel
%if %{without python2}
Obsoletes: python2-brlapi < %{api_version}-%{release}
Obsoletes: python-brlapi < %{api_version}-%{release}
%endif
Summary: Python 3 binding for BrlAPI Summary: Python 3 binding for BrlAPI
%description -n python3-brlapi %description -n python3-brlapi
This package provides the Python 3 binding for BrlAPI. This package provides the Python 3 binding for BrlAPI.
@ -217,10 +231,10 @@ pushd python2
rm -f Programs/brltty-ktb rm -f Programs/brltty-ktb
popd popd
%if 0%{?with_python3}
# Make a copy of the source tree for building the Python 3 module # Make a copy of the source tree for building the Python 3 module
# Make it all time, we just gonna ignore python2 or python3 when not needed
cp -a python2 python3 cp -a python2 python3
%endif
%build %build
# If MAKEFLAGS=-jN is set it would break local builds. # If MAKEFLAGS=-jN is set it would break local builds.
@ -253,6 +267,9 @@ configure_opts=" \
export PYTHONCOERCECLOCALE=0 export PYTHONCOERCECLOCALE=0
PYTHONS=
%if %{with python2}
# First build everything with Python 2 support # First build everything with Python 2 support
pushd python2 pushd python2
./autogen ./autogen
@ -260,52 +277,60 @@ pushd python2
# Parallel build seems broken, thus disabling it # Parallel build seems broken, thus disabling it
make make
popd popd
PYTHONS="$PYTHONS python2"
%endif
%if 0%{?with_python3} %if %{with python3}
# ... and then do it again for the Python 3 module # ... and then do it again for the Python 3 module
pushd python3 pushd python3
./autogen ./autogen
%configure $configure_opts PYTHON=%{__python3} %configure $configure_opts PYTHON=%{__python3} CYTHON=%{_bindir}/cython3
make make
popd popd
PYTHONS="$PYTHONS python3"
%endif %endif
pushd python2
find . -name '*.sgml' |
while read file; do
iconv -f iso8859-1 -t utf-8 $file > $file.conv && mv -f $file.conv $file
done
find . -name '*.txt' |
while read file; do
iconv -f iso8859-1 -t utf-8 $file > $file.conv && mv -f $file.conv $file
done
find . -name 'README*' |
while read file; do
iconv -f iso8859-1 -t utf-8 $file > $file.conv && mv -f $file.conv $file
done
find . \( -path ./doc -o -path ./Documents \) -prune -o \ for python in $PYTHONS
\( -name 'README*' -o -name '*.txt' -o -name '*.html' -o \ do pushd $python
-name '*.sgml' -o -name '*.patch' -o \ find . -name '*.sgml' |
\( -path './Bootdisks/*' -type f -perm /ugo=x \) \) -print | while read file; do
while read file; do iconv -f iso8859-1 -t utf-8 $file > $file.conv && mv -f $file.conv $file
mkdir -p ../doc/${file%/*} && cp -rp $file ../doc/$file || exit 1 done
find . -name '*.txt' |
while read file; do
iconv -f iso8859-1 -t utf-8 $file > $file.conv && mv -f $file.conv $file
done
find . -name 'README*' |
while read file; do
iconv -f iso8859-1 -t utf-8 $file > $file.conv && mv -f $file.conv $file
done
find . \( -path ./doc -o -path ./Documents \) -prune -o \
\( -name 'README*' -o -name '*.txt' -o -name '*.html' -o \
-name '*.sgml' -o -name '*.patch' -o \
\( -path './Bootdisks/*' -type f -perm /ugo=x \) \) -print |
while read file; do
mkdir -p ../doc/${file%/*} && cp -rp $file ../doc/$file || exit 1
done
popd
done done
popd
%install %install
%if 0%{?with_ocaml} %if 0%{?with_ocaml}
mkdir -p $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs mkdir -p $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs
%endif %endif
%if %{with python2}
# Python 2 # Python 2
pushd python2 pushd python2
make install JAVA_JAR_DIR=%{_jnidir} \ make install JAVA_JAR_DIR=%{_jnidir} \
JAVA_JNI_DIR=%{_libdir}/brltty \ JAVA_JNI_DIR=%{_libdir}/brltty \
JAVA_JNI=yes JAVA_JNI=yes
popd popd
%endif
%if 0%{?with_python3} %if %{with python3}
# Python 3 # Python 3
pushd python3 pushd python3
make install JAVA_JAR_DIR=%{_jnidir} \ make install JAVA_JAR_DIR=%{_jnidir} \
@ -314,7 +339,13 @@ make install JAVA_JAR_DIR=%{_jnidir} \
popd popd
%endif %endif
%if %{with python3}
# just use the higher number here
pushd python3
%else
pushd python2 pushd python2
%endif
install -d -m 755 "${RPM_BUILD_ROOT}%{_sysconfdir}" "$RPM_BUILD_ROOT%{_mandir}/man5" install -d -m 755 "${RPM_BUILD_ROOT}%{_sysconfdir}" "$RPM_BUILD_ROOT%{_mandir}/man5"
install -m 644 Documents/brltty.conf "${RPM_BUILD_ROOT}%{_sysconfdir}" install -m 644 Documents/brltty.conf "${RPM_BUILD_ROOT}%{_sysconfdir}"
echo ".so man1/brltty.1" > $RPM_BUILD_ROOT%{_mandir}/man5/brltty.conf.5 echo ".so man1/brltty.1" > $RPM_BUILD_ROOT%{_mandir}/man5/brltty.conf.5
@ -453,11 +484,13 @@ fi
%files -n tcl-brlapi %files -n tcl-brlapi
%{tcl_sitearch}/brlapi-%{api_version} %{tcl_sitearch}/brlapi-%{api_version}
%if %{with python2}
%files -n python2-brlapi %files -n python2-brlapi
%{python2_sitearch}/brlapi.so %{python2_sitearch}/brlapi.so
%{python2_sitearch}/Brlapi-%{api_version}-*.egg-info %{python2_sitearch}/Brlapi-%{api_version}-*.egg-info
%endif
%if 0%{?with_python3} %if %{with python3}
%files -n python3-brlapi %files -n python3-brlapi
%{python3_sitearch}/brlapi.cpython-*.so %{python3_sitearch}/brlapi.cpython-*.so
%{python3_sitearch}/Brlapi-%{api_version}-*.egg-info %{python3_sitearch}/Brlapi-%{api_version}-*.egg-info
@ -474,6 +507,10 @@ fi
%endif %endif
%changelog %changelog
* Fri Mar 16 2018 Miro Hrončok <mhroncok@redhat.com> - 5.6-7
- Don't build Python 2 subpackage on EL > 7 and Fedora > 28
- Use bconditionals
* Thu Mar 08 2018 Ondřej Lysoněk <olysonek@redhat.com> - 5.6-6 * Thu Mar 08 2018 Ondřej Lysoněk <olysonek@redhat.com> - 5.6-6
- Build with espeak support only on Fedora - Build with espeak support only on Fedora