Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.

Bug 2265038

Summary: brp-mangle-shebangs breaks with env -S shebangs
Product: [Fedora] Fedora Reporter: Elliott Sales de Andrade <quantum.analyst>
Component: redhat-rpm-configAssignee: Miro Hrončok <mhroncok>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 39CC: ajax, awilliam, carl, ffesti, fweimer, igor.raits, j, mhroncok, ngompa13, nickc, pmatilai, sipoyare, torsava
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: AcceptedFreezeException
Fixed In Version: redhat-rpm-config-285-1.fc41 redhat-rpm-config-285-1.fc40 redhat-rpm-config-266-1.fc39 redhat-rpm-config-257-1.fc38 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-03-27 01:36:37 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2264962, 2264975    

Description Elliott Sales de Andrade 2024-02-20 03:28:11 UTC
Description of problem:
In the most recent build of visidata [1], the shebang is modified as such:

+ /usr/lib/rpm/redhat/brp-mangle-shebangs
mangling shebang in /usr/bin/vd2to3.vdx from /usr/bin/env -S vd -p to #!/usr/bin/-S vd -p

This obviously results in a broken command-line, and a dependency on a non-existent /usr/bin/-S (aka bug 2264962).

I can fix this easily, of course, but the packaging guidelines do say "Various checks are also applied to verify that the shebang lines are valid, and the build process can fail as a result of these." but this appears to have slipped through.


Version-Release number of selected component (if applicable):
redhat-rpm-config-284-1.fc41.noarch

Additional info:
[1] https://koji.fedoraproject.org/koji/buildinfo?buildID=2405440

Comment 1 Miro Hrončok 2024-02-20 08:54:51 UTC
This sounds like an obvious bug.

Comment 2 Miro Hrončok 2024-02-20 09:03:02 UTC
The code:

  # 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@')

Current problematic behavior:

  $ echo '/usr/bin/env -S /usr/bin/vd' | sed -r -e 's@^(.+)/env /(.+)$@/\2@'
  /usr/bin/env -S /usr/bin/vd
  $ echo '/usr/bin/env -S vd' | sed -r -e 's@^(.+/)env (.+)$@\1\2@'
  /usr/bin/-S vd

Proposed fix:

  $ echo '/usr/bin/env -S /usr/bin/vd' | sed -r -e 's@^(.+)/env( -[^ ]+)* /(.+)$@/\3@'
  /usr/bin/vd
  $ echo '/usr/bin/env -S vd' | sed -r -e 's@^(.+/)env( -[^ ]+)* (.+)$@\1\3@'
  /usr/bin/vd

Works even without env flags:

  $ echo '/usr/bin/env /usr/bin/vd' | sed -r -e 's@^(.+)/env( -[^ ]+)* /(.+)$@/\3@'
  /usr/bin/vd
  $ echo '/usr/bin/env vd' | sed -r -e 's@^(.+/)env( -[^ ]+)* (.+)$@\1\3@'
  /usr/bin/vd

Or with multiple env flags:

  $ echo '/usr/bin/env -X -y /usr/bin/vd' | sed -r -e 's@^(.+)/env( -[^ ]+)* /(.+)$@/\3@'
  /usr/bin/vd
  $ echo '/usr/bin/env -X -yabc -Z vd' | sed -r -e 's@^(.+/)env( -[^ ]+)* (.+)$@\1\3@'
  /usr/bin/vd

Comment 4 Fedora Update System 2024-02-21 10:12:41 UTC
FEDORA-2024-edbda6f051 (redhat-rpm-config-285-1.fc41) has been submitted as an update to Fedora 41.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-edbda6f051

Comment 5 Fedora Update System 2024-02-21 10:20:54 UTC
FEDORA-2024-edbda6f051 (redhat-rpm-config-285-1.fc41) has been pushed to the Fedora 41 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 6 Miro Hrončok 2024-02-21 10:43:59 UTC
Reopening, this affects all Fedoras (as well as RHEL).

Comment 7 Fedora Update System 2024-02-27 18:22:05 UTC
FEDORA-2024-19fc022649 (redhat-rpm-config-285-1.fc40) has been submitted as an update to Fedora 40.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-19fc022649

Comment 9 Miro Hrončok 2024-02-27 18:54:01 UTC
RHEL report: https://issues.redhat.com/browse/RHEL-26961

Comment 10 Fedora Update System 2024-02-28 22:41:15 UTC
FEDORA-2024-19fc022649 has been pushed to the Fedora 40 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-19fc022649`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-19fc022649

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 11 Miro Hrončok 2024-03-01 10:11:43 UTC
I nominate this a s a freeze exception. For the following reasons:

 - it blocks bz2264975 which is an installation failure -- we want that fixed ASAP
 - due to the nature of this package, it is unlikely to receive much testing unless pushed to stable and used in Koji

Comment 12 Fedora Update System 2024-03-01 14:57:05 UTC
FEDORA-2024-f83e42dd48 (redhat-rpm-config-266-1.fc39) has been submitted as an update to Fedora 39.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-f83e42dd48

Comment 13 Fedora Update System 2024-03-02 01:02:40 UTC
FEDORA-2024-f83e42dd48 has been pushed to the Fedora 39 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-f83e42dd48`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-f83e42dd48

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 14 Adam Williamson 2024-03-04 16:05:57 UTC
+3 in https://pagure.io/fedora-qa/blocker-review/issue/1487 , marking accepted FE.

Comment 15 Fedora Update System 2024-03-05 02:44:03 UTC
FEDORA-2024-19fc022649 (redhat-rpm-config-285-1.fc40) has been pushed to the Fedora 40 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 16 Fedora Update System 2024-03-11 08:14:50 UTC
FEDORA-2024-b45fa71757 (redhat-rpm-config-257-1.fc38) has been submitted as an update to Fedora 38.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-b45fa71757

Comment 17 Fedora Update System 2024-03-12 03:59:11 UTC
FEDORA-2024-b45fa71757 has been pushed to the Fedora 38 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-b45fa71757`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-b45fa71757

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 18 Fedora Update System 2024-03-13 01:23:34 UTC
FEDORA-2024-f83e42dd48 (redhat-rpm-config-266-1.fc39) has been pushed to the Fedora 39 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 19 Fedora Update System 2024-03-27 01:36:37 UTC
FEDORA-2024-b45fa71757 (redhat-rpm-config-257-1.fc38) has been pushed to the Fedora 38 stable repository.
If problem still persists, please make note of it in this bug report.