brp-mangle-shebangs: Strip env flags when mangling shebangs

For example, mangle "#!/usr/bin/env -S vd" to "#!/usr/bin/vd".

Backported from commit 65de6e6beb990dfb880ac1263698f5b109a1d62e in
Fedora.

Resolves: RHEL-26961
This commit is contained in:
Miro Hrončok 2024-07-12 12:31:48 +02:00 committed by Michal Domonkos
parent 74cfcb57bf
commit 0cd67ff078
2 changed files with 8 additions and 5 deletions

View File

@ -137,10 +137,10 @@ while IFS= read -r line; do
fi
# Replace "special" env shebang:
# /whatsoever/env /whatever/foo → /whatever/foo
shebang=$(echo "$shebang" | sed -r -e 's@^(.+)/env /(.+)$@/\2@')
# /whatsoever/env foo → /whatsoever/foo
shebang=$(echo "$shebang" | sed -r -e 's@^(.+/)env (.+)$@\1\2@')
# /whatsoever/env -whatever /whatever/foo → /whatever/foo
shebang=$(echo "$shebang" | sed -r -e 's@^(.+)/env( -[^ ]+)* /(.+)$@/\3@')
# /whatsoever/env -whatever foo → /whatsoever/foo
shebang=$(echo "$shebang" | sed -r -e 's@^(.+/)env( -[^ ]+)* (.+)$@\1\3@')
# If the shebang now starts with /bin, change it to /usr/bin
# https://bugzilla.redhat.com/show_bug.cgi?id=1581757

View File

@ -6,7 +6,7 @@
Summary: Red Hat specific rpm configuration files
Name: redhat-rpm-config
Version: 207
Version: 208
Release: 1%{?dist}
# No version specified.
License: GPL+
@ -254,6 +254,9 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora/srpm forge.lua
%doc buildflags.md
%changelog
* Fri Jul 12 2024 Michal Domonkos <mdomonko@redhat.com> - 208-1
- brp-mangle-shebangs: Strip env flags when mangling shebangs (RHEL-26961)
* Thu Jan 18 2024 Miro Hrončok <mhroncok@redhat.com> - 207-1
- brp-python-bytecompile: Pass --invalidation-mode=timestamp to compileall
- Resolves: RHEL-22139