drop python2 conditional parts

This commit is contained in:
Dominik 'Rathann' Mierzejewski 2020-10-30 17:35:24 +01:00
parent 0e31d27abd
commit a58c7f0267

View File

@ -1,25 +1,3 @@
%if 0%{?fedora} || 0%{?rhel} >= 8
%global py2readelf %{nil}
%global py3readelf %{_bindir}/pyreadelf
%global pyreadelf pyreadelf-3
%else
%global py2readelf %{_bindir}/pyreadelf
%global py3readelf %{nil}
%global pyreadelf pyreadelf-2
%endif
%if 0%{?fedora} && 0%{?fedora} < 32
%global with_python2 1
%endif
%if 0%{?rhel} && 0%{?rhel} < 8
%global with_python2 1
%endif
%if 0%{?fedora} || 0%{?rhel} >= 7
%global with_python3 1
%endif
# main package is archful to run tests everywhere but produces noarch packages # main package is archful to run tests everywhere but produces noarch packages
%global debug_package %{nil} %global debug_package %{nil}
@ -35,21 +13,6 @@ Pure-Python library for parsing and analyzing ELF files\
and DWARF debugging information. and DWARF debugging information.
%description %_description %description %_description
%if 0%{?with_python2}
%package -n python2-%{name}
Summary: %{summary}
# https://github.com/eliben/pyelftools/issues/180
Provides: bundled(python2-construct) = 2.6
BuildRequires: python2-devel
BuildRequires: python2-setuptools
BuildArch: noarch
%{?python_provide:%python_provide python2-%{name}}
# Remove before F30
%description -n python2-%{name} %_description
%endif
# with_python2
%if 0%{?with_python3}
%package -n python3-%{name} %package -n python3-%{name}
Summary: %{summary} Summary: %{summary}
# https://github.com/eliben/pyelftools/issues/180 # https://github.com/eliben/pyelftools/issues/180
@ -59,79 +22,39 @@ BuildRequires: python3-setuptools
BuildArch: noarch BuildArch: noarch
%{?python_provide:%python_provide python3-%{name}} %{?python_provide:%python_provide python3-%{name}}
%description -n python3-%{name} %_description %description -n python3-%{name} %_description
%endif
%prep %prep
%setup -q %setup -q
%build %build
%if 0%{?with_python2}
%{py2_build}
%endif
%if 0%{?with_python3}
%{py3_build} %{py3_build}
%endif
%install %install
%if 0%{?with_python2}
%{py2_install}
pushd %{buildroot}%{_bindir}
mv readelf.py pyreadelf-%{python2_version}
ln -s pyreadelf-%{python2_version} pyreadelf-2
popd
%endif
%if 0%{?with_python3}
%{py3_install} %{py3_install}
pushd %{buildroot}%{_bindir} pushd %{buildroot}%{_bindir}
mv readelf.py pyreadelf-%{python3_version} mv readelf.py pyreadelf-%{python3_version}
ln -s pyreadelf-%{python3_version} pyreadelf-3 ln -s pyreadelf-%{python3_version} pyreadelf-3
popd ln -s pyreadelf-3 pyreadelf
%endif
pushd %{buildroot}%{_bindir}
ln -s %{pyreadelf} pyreadelf
popd popd
%check %check
%if 0%{?with_python2} %{__python3} test/run_all_unittests.py
%{__python2} test/run_all_unittests.py %{__python3} test/run_examples_test.py
%{__python2} test/run_examples_test.py
%ifarch x86_64 %ifarch x86_64
# tests may fail because of differences in output-formatting # tests may fail because of differences in output-formatting
# from binutils' readelf. See: # from binutils' readelf. See:
# https://github.com/eliben/pyelftools/wiki/Hacking-guide#tests # https://github.com/eliben/pyelftools/wiki/Hacking-guide#tests
%{__python2} test/run_readelf_tests.py || :
%endif
%endif
%if 0%{?with_python3}
%{__python3} test/run_all_unittests.py
%{__python3} test/run_examples_test.py
%ifarch x86_64
# ditto
%{__python3} test/run_readelf_tests.py || : %{__python3} test/run_readelf_tests.py || :
%endif %endif
%endif
%if 0%{?with_python2}
%files -n python2-%{name}
%license LICENSE
%doc CHANGES
%{py2readelf}
%{_bindir}/pyreadelf-%{python2_version}
%{_bindir}/pyreadelf-2
%{python2_sitelib}/elftools
%{python2_sitelib}/pyelftools-*.egg-info
%endif
%if 0%{?with_python3}
%files -n python3-%{name} %files -n python3-%{name}
%license LICENSE %license LICENSE
%doc CHANGES %doc CHANGES
%{py3readelf} %{_bindir}/pyreadelf
%{_bindir}/pyreadelf-%{python3_version} %{_bindir}/pyreadelf-%{python3_version}
%{_bindir}/pyreadelf-3 %{_bindir}/pyreadelf-3
%{python3_sitelib}/elftools %{python3_sitelib}/elftools
%{python3_sitelib}/pyelftools-*.egg-info %{python3_sitelib}/pyelftools-*.egg-info
%endif
%changelog %changelog
* Fri Oct 30 2020 Dominik Mierzejewski <rpm@greysector.net> - 0.27-1 * Fri Oct 30 2020 Dominik Mierzejewski <rpm@greysector.net> - 0.27-1