From 4f342e45be19d0bb8e32f38664dc29a12092dfe9 Mon Sep 17 00:00:00 2001 From: Ryan Moeller Date: Thu, 12 Sep 2019 16:32:32 -0400 Subject: Canonicalize Python shebangs /usr/bin/env python3 is the suggested[1] shebang for Python in general (likewise for python2) and is conventional across platforms. This eases development on systems where python is not installed in /usr/bin (FreeBSD for example) and makes it possible to develop in virtual environments (venv) for isolating dependencies. Many packaging guidelines discourage the use of /usr/bin/env, but since this is the canonical way of writing shebangs in the Python community, many packaging scripts are already equipped to handle substituting the appropriate absolute path to python automatically. Some RPM package builders lacking brp-mangle-shebangs need a small fallback mechanism in the package spec to stamp the appropriate shebang on installed Python scripts. [1]: https://docs.python.org/3/using/unix.html?#miscellaneous Reviewed-by: Richard Laager Reviewed-by: Brian Behlendorf Reviewed-by: George Melikov Signed-off-by: Ryan Moeller Closes #9314 --- rpm/generic/zfs.spec.in | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'rpm') diff --git a/rpm/generic/zfs.spec.in b/rpm/generic/zfs.spec.in index 5ef6f7bcf..545627d4b 100644 --- a/rpm/generic/zfs.spec.in +++ b/rpm/generic/zfs.spec.in @@ -53,10 +53,6 @@ %bcond_with asan %bcond_with systemd -# Exclude test-runner.py from the rpmbuild shebang check to allow it to run -# under Python 2 and 3. -%global __brp_mangle_shebangs_exclude_from test-runner.py - # Generic enable switch for systemd %if %{with systemd} %define _systemd 1 @@ -354,6 +350,14 @@ make %{?_smp_mflags} %{__rm} -rf $RPM_BUILD_ROOT make install DESTDIR=%{?buildroot} find %{?buildroot}%{_libdir} -name '*.la' -exec rm -f {} \; +%if 0%{!?__brp_mangle_shebangs:1} +find %{?buildroot}%{_bindir} \ + \( -name arc_summary -or -name arcstat -or -name dbufstat \) \ + -exec %{__sed} -i 's|^#!.*|#!%{__python}|' {} \; +find %{?buildroot}%{_datadir} \ + \( -name test-runner.py -or -name zts-report.py \) \ + -exec %{__sed} -i 's|^#!.*|#!%{__python}|' {} \; +%endif %post %if 0%{?_systemd} -- cgit v1.2.3