Bug 1581757 - `/bin/env *` shebang should be mangled to `/usr/bin/*`
Summary: `/bin/env *` shebang should be mangled to `/usr/bin/*`
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: redhat-rpm-config
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miro Hrončok
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-05-23 14:56 UTC by Petr Viktorin (pviktori)
Modified: 2018-08-23 17:11 UTC (History)
11 users (show)

Fixed In Version: redhat-rpm-config-117-1.fc29
Clone Of:
Environment:
Last Closed: 2018-08-14 12:39:59 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Petr Viktorin (pviktori) 2018-05-23 14:56:43 UTC
Current shebang mangling changed:
    /bin/env python3
to:
    #!/bin/python3

While /bin/python3 (without /usr) does exist as a command, it is not *provided* by the python3 RPM, which only provides /usr/bin/python3.
So, rpmbuild uses the shebang to auto-generate a dependency that can't be satisfied.

The mangling should probably prepend /usr in this case.

See log: https://copr-be.cloud.fedoraproject.org/results/abbra/cockpit-apps/fedora-28-x86_64/00758206-cockpit-app-samba/build.log.gz

Comment 1 Miro Hrončok 2018-05-23 15:01:29 UTC
The log is gone, so just to preserve it:

+ /usr/lib/rpm/redhat/brp-mangle-shebangs '' '' mangling shebang in /usr/libexec/cockpit-app-samba-ad-check-install from /bin/env python3 to #!/bin/python3

Comment 3 Miro Hrončok 2018-07-23 09:52:32 UTC
I'd rather not touch this in F28, but please reopen if you need it.

Comment 4 Panu Matilainen 2018-08-14 11:11:51 UTC
Guys, you can't just go mangling ALL /bin paths to /usr/bin because some things, notably /bin/sh is, well, special.

Comment 5 Jiri Konecny 2018-08-14 11:18:45 UTC
This change broke our tests.

In our test we are creating dummy rpm with file which has shebang:

#!/bin/sh

echo "TEST"

The script is now changed after rpmbuild to this:

#!/usr/bin/sh

echo "TEST"


Could you please look on this and fix this issue?

Comment 6 Panu Matilainen 2018-08-14 11:22:08 UTC
Hmm okay bash has actually been usrmove-converted with /bin/sh being just a provide. Still, it's quite a sledgehammer and a source of incompatibilities across distros. Certainly not F28 material.

Comment 7 Miro Hrončok 2018-08-14 11:24:10 UTC
> The script is now changed after rpmbuild to this...

Could you please describe how is this a problem exactly?

Comment 8 Jiri Konecny 2018-08-14 11:29:27 UTC
We are doing rpm extraction to get kernel modules for the driver disk feature. This is a test to check if the extraction works correctly.

I can change those tests but this is more question if it should behave this way. It is a regression from F28.

In short if RPM team will agree that this behavior is correct than we can close this and I'll change our test. If not please make this correct.

Comment 9 Miro Hrončok 2018-08-14 11:43:15 UTC
Please tell me exactly how the changed shebang breaks your tests to help me understand what's wrong.

Comment 10 Jiri Konecny 2018-08-14 12:26:37 UTC
We are testing that the content of the file won't change by the extraction process. It is not hard to change the test to work correctly. Those tests are just the example. The point is if the /bin/* shebang should automatically change everywhere.

I understand why it is useful for '/bin/env python' but I'm not that sure this should works for everything in '/bin'. Even from bug name this looks like a not planned side effect.

Comment 11 Miro Hrončok 2018-08-14 12:33:11 UTC
So you take a file, put it in rpm by building it, extract the rpm and compare the contents? Any buildroot policy could change that and relying on the fact that is unchanged is not very bulletproof. Sorry but I think your test is too naive.

> The point is if the /bin/* shebang should automatically change everywhere.

They should, unless we find a case where it is broken. We should fix that case in there. /bin hasn't been a thing for years.

> Even from bug name this looks like a not planned side effect.

The side effect was discussed in https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/29

I suggest you go trough the discussion in there and please let me know where we are breaking normal things (other than your naive test, sorry).

Comment 12 Jiri Konecny 2018-08-14 12:39:59 UTC
In that case I will change our tests. 

Thanks for looking into that.

Comment 13 Miro Hrončok 2018-08-14 12:47:28 UTC
Panu,
give me some example of what's wrong so we can fix it.

Yes, this is a sledgehammer. No, I don't agree that we "can't just go mangling ALL /bin paths to /usr/bin because some things are special". The special things need to be fixed. But we found none.

Comment 14 Panu Matilainen 2018-08-14 13:04:39 UTC
Perhaps I'm just surprised to see such a massive distro-wide change go in as a kind of side-effect of something much smaller, without going through the change process, and without wider discussion. OTOH I was on vacation at the time this went in so I might've missed something. Shrug.

Comment 15 Miro Hrončok 2018-08-14 13:11:43 UTC
I'll go with change propsal next time every time we change this buidroot policy script.


Note You need to log in before you can comment on or make changes to this bug.