diff --git a/epel-rpm-macros.spec b/epel-rpm-macros.spec index 60eaf6b..8efc14d 100644 --- a/epel-rpm-macros.spec +++ b/epel-rpm-macros.spec @@ -1,6 +1,6 @@ Name: epel-rpm-macros Version: 8 -Release: 11 +Release: 12 Summary: Extra Packages for Enterprise Linux RPM macros Group: System Environment/Base @@ -60,6 +60,9 @@ install -Dpm 644 %{SOURCE3} \ %changelog +* Sun Jun 07 2020 Miro HronĨok - 8-12 +- Backport %%py_shebang_fix, %%pytest, %%py_provides + * Thu Apr 30 2020 Troy Dawson - 8-11 - Install python36-rpm-macros or python38-rpm-macros correctly diff --git a/macros.epel-rpm-macros b/macros.epel-rpm-macros index e7edbba..770dc05 100644 --- a/macros.epel-rpm-macros +++ b/macros.epel-rpm-macros @@ -20,6 +20,11 @@ %python2 %__python2 %python3 %__python3 +# Simplified version backported from Fedora +%py_shebang_fix %{expand:/usr/bin/pathfix.py -pni "%{__python} %{py_shbang_opts}"} +%py2_shebang_fix %{expand:/usr/bin/pathfix.py -pni "%{__python2} %{py2_shbang_opts}"} +%py3_shebang_fix %{expand:/usr/bin/pathfix.py -pni "%{__python3} %{py3_shbang_opts}"} + # Users can use %%python only if they redefined %%__python (e.g. to %%__python3) %python() %{lua:\ __python = rpm.expand("%__python")\ @@ -45,6 +50,32 @@ end } +# This is intended for Python 3 only, hence also no Python version in the name. +%__pytest /usr/bin/pytest-3 +%pytest %{expand:\\\ + CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\ + PATH="%{buildroot}%{_bindir}:$PATH"\\\ + PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}"\\\ + PYTHONDONTWRITEBYTECODE=1\\\ + %__pytest} + +%py_provides() %{lua: + local name = rpm.expand('%1') + if name == '%1' then + rpm.expand('%{error:%%py_provides requires at least 1 argument, the name to provide}') + end + local evr = rpm.expand('%2') + if evr == '%2' then + evr = rpm.expand('%{?epoch:%{epoch}:}%{version}-%{release}') + end + print('Provides: ' .. name .. ' = ' .. evr .. '\\n') + -- NB: dash needs to be escaped! + if name:match('^python3%-') then + replaced = name:gsub('^python3%-', 'python-') + print('Provides: ' .. replaced .. ' = ' .. evr .. '\\n') + end +} + # gpgverify verifies signed sources. There is documentation in the script. %gpgverify %{_rpmconfigdir}/gpgverify