Update to latest upstream

Package license and documentation
Adapt to recent guidelines
Fix other packaging issues
This commit is contained in:
Björn Esser 2017-01-25 09:49:58 +01:00
commit c9ebf6576e
3 changed files with 113 additions and 51 deletions

View file

@ -1,100 +1,161 @@
%{!?__python2: %global __python2 %{__python}}
%{!?python2_sitelib: %global python2_sitelib %{python_sitelib}}
%{!?python2_sitearch: %global python2_sitearch %{python_sitearch}}
%{!?python2_version: %global python2_version %{python_version}}
%if 0%{?rhel} >= 8 || 0%{?fedora} >= 16
%bcond_without python3
%else
%bcond_with python3
%endif
%if 0%{?rhel} && 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
%global upname html2text
%global common_sum Convert HTML to Markdown-formatted text
%global common_desc %{upname} is a Python script that converts a page \
of HTML into clean, easy-to-read plain ASCII text. Better yet, that ASCII \
also happens to be valid Markdown (a text-to-HTML format).
Name: python-%{upname}
Version: 2015.6.6
Release: 7%{?dist}
Summary: Converts a page of HTML into plain ASCII text
Version: 2016.9.19
Release: 1%{?dist}
Summary: %{common_sum}
Group: Development/Languages
License: GPLv3
URL: http://alir3z4.github.io/html2text/
Source0: https://pypi.python.org/packages/source/h/%{upname}/%{upname}-%{version}.tar.gz
Provides: html2text = %{version}-%{release}
Obsoletes: html2text <= 1.3.2a-16
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
URL: http://alir3z4.github.io/%{upname}
Source0: https://files.pythonhosted.org/packages/source/h/%{upname}/%{upname}-%{version}.tar.gz
BuildArch: noarch
BuildRequires: python-devel
BuildRequires: python-setuptools
%if %{with python3}
BuildRequires: python3-devel
%endif
BuildRequires: help2man
%description
html2text is a Python script that converts a page of HTML into clean,
easy-to-read plain ASCII text. Better yet, that ASCII also happens to
be valid Markdown (a text-to-HTML format).
%{common_desc}
Also known as: THE ASCIINATOR, html to text, htm to txt, htm2txt, ...
%package -n python2-%{upname}
Summary: %{common_sum}
BuildRequires: python-devel
BuildRequires: python-setuptools
%{?python_provide:%python_provide python2-%{upname}}
%if !%{with python3}
Provides: %{upname} = %{version}-%{release}
Obsoletes: %{upname} <= 1.3.2a-16
%endif
%description -n python2-%{upname}
%{common_desc}
%if %{with python3}
%package -n python3-%{upname}
Summary: Easily build and distribute Python 3 packages
Group: Applications/System
Summary: %{common_sum}
BuildRequires: python3-devel
BuildRequires: python3-setuptools
%{?python_provide:%python_provide python3-%{upname}}
Provides: %{upname} = %{version}-%{release}
Obsoletes: %{upname} <= 1.3.2a-16
%description -n python3-%{upname}
html2text is a Python script that converts a page of HTML into clean,
easy-to-read plain ASCII text. Better yet, that ASCII also happens to
be valid Markdown (a text-to-HTML format).
Also known as: THE ASCIINATOR, html to text, htm to txt, htm2txt, ...
This package contains python3 version of the package.
%{common_desc}
%endif # with_python3
%prep
%setup -q -n %{upname}-%{version}
%autosetup -n %{upname}-%{version}
%{__rm} -fr *.egg-info
%build
%py2_build
%if %{with python3}
%py3_build
%endif
%install
%{__mkdir} -p %{buildroot}%{_mandir}/man1
%py2_install
export PYTHONPATH="%{buildroot}%{python2_sitelib}"
%{__mv} -f %{buildroot}%{_bindir}/%{upname} %{buildroot}%{_bindir}/%{upname}-%{python2_version}
%{_bindir}/help2man -s 1 -N -o %{buildroot}%{_mandir}/man1/%{upname}-%{python2_version}.1 %{buildroot}%{_bindir}/%{upname}-%{python2_version}
/bin/echo '%{_bindir}/%{upname}-%{python2_version}' > py2.mf
/bin/echo '%{_mandir}/man1/%{upname}-%{python2_version}.1*' >> py2.mf
for f in $(%{_bindir}/find %{buildroot}%{python2_sitelib} -name '*.py' -type f); do
%{__sed} -e'/^#!.*/d' < ${f} > ${f}.new
/bin/touch -r ${f} ${f}.new
%{__mv} -f ${f}.new ${f}
done
%{_bindir}/find %{buildroot}%{python2_sitelib} -type f | %{_bindir}/xargs %{__chmod} -c 0644
%if %{with python3}
%{__python3} setup.py install --root %{buildroot}
# we don't need second binary
rm -fv $RPM_BUILD_ROOT%{_bindir}/html2text
export PYTHONPATH="%{buildroot}%{python3_sitelib}"
%py3_install
%{__mv} -f %{buildroot}%{_bindir}/%{upname} %{buildroot}%{_bindir}/%{upname}-%{python3_version}
/bin/ln -f %{buildroot}%{_bindir}/%{upname}-%{python3_version} %{buildroot}%{_bindir}/%{upname}
/bin/ln -f %{buildroot}%{_bindir}/%{upname}-%{python3_version} %{buildroot}%{_bindir}/%{name}
%{_bindir}/help2man -s 1 -N -o %{buildroot}%{_mandir}/man1/%{upname}-%{python3_version}.1 %{buildroot}%{_bindir}/%{upname}-%{python3_version}
%{_bindir}/help2man -s 1 -N -o %{buildroot}%{_mandir}/man1/%{upname}.1 %{buildroot}%{_bindir}/%{upname}
%{_bindir}/help2man -s 1 -N -o %{buildroot}%{_mandir}/man1/%{name}.1 %{buildroot}%{_bindir}/%{name}
/bin/echo '%{_bindir}/%{upname}-%{python3_version}' > py3.mf
/bin/echo '%{_mandir}/man1/%{upname}-%{python3_version}.1*' >> py3.mf
/bin/echo '%{_bindir}/%{upname}' >> py3.mf
/bin/echo '%{_mandir}/man1/%{upname}.1*' >> py3.mf
/bin/echo '%{_bindir}/%{name}' >> py3.mf
/bin/echo '%{_mandir}/man1/%{name}.1*' >> py3.mf
for f in $(%{_bindir}/find %{buildroot}%{python3_sitelib} -name '*.py' -type f); do
%{__sed} -e'/^#!.*/d' < ${f} > ${f}.new
/bin/touch -r ${f} ${f}.new
%{__mv} -f ${f}.new ${f}
done
%{_bindir}/find %{buildroot}%{python3_sitelib} -type f | %{_bindir}/xargs %{__chmod} -c 0644
%else
export PYTHONPATH="%{buildroot}%{python2_sitelib}"
/bin/ln -f %{buildroot}%{_bindir}/%{upname}-%{python2_version} %{buildroot}%{_bindir}/%{upname}
/bin/ln -f %{buildroot}%{_bindir}/%{upname}-%{python2_version} %{buildroot}%{_bindir}/%{name}
%{_bindir}/help2man -s 1 -N -o %{buildroot}%{_mandir}/man1/%{upname}.1 %{buildroot}%{_bindir}/%{upname}
%{_bindir}/help2man -s 1 -N -o %{buildroot}%{_mandir}/man1/%{name}.1 %{buildroot}%{_bindir}/%{name}
/bin/echo '%{_bindir}/%{upname}' >> py2.mf
/bin/echo '%{_mandir}/man1/%{upname}.1*' >> py2.mf
/bin/echo '%{_bindir}/%{name}' >> py2.mf
/bin/echo '%{_mandir}/man1/%{name}.1*' >> py2.mf
%endif
%{__python2} setup.py install --root %{buildroot}
# new script in 3.200.3 : conflicts with package' html2text' obviously
mv $RPM_BUILD_ROOT%{_bindir}/html2text $RPM_BUILD_ROOT%{_bindir}/%{name}
%check
%{__python} setup.py test
%{__python2} setup.py test -vv
%if %{with python3}
%{__python3} setup.py test || /bin/true
%{__python3} setup.py test -vv
%endif
%files
%{_bindir}/%{name}
%{python2_sitelib}/*
%doc COPYING
%files -n python2-%{upname} -f py2.mf
%license AUTHORS.* COPYING
%doc README.* ChangeLog.* PKG-INFO
%{python2_sitelib}/%{upname}
%{python2_sitelib}/%{upname}-%{version}-py%{python2_version}.egg-info
%if %{with python3}
%files -n python3-%{upname}
%{python3_sitelib}/*
%doc COPYING
%files -n python3-%{upname} -f py3.mf
%license AUTHORS.* COPYING
%doc README.* ChangeLog.* PKG-INFO
%{python3_sitelib}/%{upname}
%{python3_sitelib}/%{upname}-%{version}-py%{python3_version}.egg-info
%endif
%changelog
* Wed Jan 25 2017 Björn Esser <besser82@fedoraproject.org> - 2016.9.19-1
- Update to latest upstream
- Package license and documentation
- Adapt to recent guidelines
- Fix other packaging issues
* Mon Dec 19 2016 Miro Hrončok <mhroncok@redhat.com> - 2015.6.6-7
- Rebuild for Python 3.6