Bug 1541057 - redhat-rpm-config unexpected error from brp-mangle-shebangs
Summary: redhat-rpm-config unexpected error from brp-mangle-shebangs
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: redhat-rpm-config
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Florian Festi
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On: 1541318
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-02-01 15:39 UTC by Jun Aruga
Modified: 2018-02-08 14:16 UTC (History)
10 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2018-02-01 16:33:59 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Jun Aruga 2018-02-01 15:39:15 UTC
Description of problem:

I love the added automatic shebang check in redhat-rpm-config.
However below file

The brp-mangle-shebangs script returns an error for 
https://github.com/bundler/bundler/blob/v1.16.1/lib/bundler/templates/Executable
included in rubygem-bundler RPM package.

This file works as a template file. So, this result of the check is wrong.
I wish the brp-mangle-shebangs file will be improved to skip this kind of valid files.

Right now I will set `%undefine __brp_mangle_shebangs` to avoid this check.
But ideally I want to use this awesome check.

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

How reproducible:


Steps to Reproduce:
1. $ cd git:bundler/bundler.git
2. $ cd bundler/lib/bundler/templates
3. Then

$ RPM_BUILD_ROOT=$(pwd) sh -x ~/fed/redhat-rpm-config/brp-mangle-shebangs
+ '[' -z /home/jaruga/git/bundler/lib/bundler/templates -o /home/jaruga/git/bundler/lib/bundler/templates = / ']'
+ cd /home/jaruga/git/bundler/lib/bundler/templates
+ fail=0
++ find -executable -type f
++ xargs --no-run-if-empty file -N --mime-type
++ grep -Po '^\K.+(?=: text/)'
+ for f in $(find -executable -type f | xargs --no-run-if-empty file -N --mime-type | grep -Po "^\K.+(?=: text/)")
++ stat -c %y ./Executable
+ ts='2018-01-02 14:51:39.505092825 +0100'
+ read orig_shebang
+++ grep -Po '#!\K.*'
+++ echo '#!/usr/bin/env <%= Bundler.settings[:shebang] || RbConfig::CONFIG["ruby_install_name"] %>'
++ trim /usr/bin/env '<%=' 'Bundler.settings[:shebang]' '||' 'RbConfig::CONFIG["ruby_install_name"]' '%>'
++ printf %s '/usr/bin/env <%= Bundler.settings[:shebang] || RbConfig::CONFIG["ruby_install_name"] %>'
+ shebang='/usr/bin/env <%= Bundler.settings[:shebang] || RbConfig::CONFIG["ruby_install_name"] %>'
+ '[' -z '/usr/bin/env <%= Bundler.settings[:shebang] || RbConfig::CONFIG["ruby_install_name"] %>' ']'
+ '[' '/usr/bin/env <%= Bundler.settings[:shebang] || RbConfig::CONFIG["ruby_install_name"] %>' '!=' / ']'
+ echo '*** ERROR: ./Executable has shebang which doesn'\''t start with '\''/'\'' (/usr/bin/env <%= Bundler.settings[:shebang] || RbConfig::CONFIG["ruby_install_name"] %>)'
*** ERROR: ./Executable has shebang which doesn't start with '/' (/usr/bin/env <%= Bundler.settings[:shebang] || RbConfig::CONFIG["ruby_install_name"] %>)
+ fail=1
+ continue
+ exit 1

The message "ERROR: ./Executable has shebang which doesn't start with '/' (/usr/bin/env <%= Bundler.settings[:shebang] || RbConfig::CONFIG["ruby_install_name"] %>)" is not right.
Because the line starts with "/".

Actual results:
The script file exits error status.

Expected results:
The script file exits success status (= 0).

Additional info:

Comment 1 Vít Ondruch 2018-02-01 16:33:59 UTC
The file should not have executable bit.

https://src.fedoraproject.org/rpms/rubygem-bundler/c/774469dcf8fe0b5c839880bbf5aa3f6b17652b24?branch=master

Comment 2 Vít Ondruch 2018-02-01 16:35:18 UTC
Just to elaborate a bit, although I worry about templates, this case does not qualify IMO.

Comment 3 Jun Aruga 2018-02-02 10:17:11 UTC
OK.

But the message "ERROR: ./Executable has shebang which doesn't start with '/' is not correct. Because actually the line starts with '/'.
I still think the message can be improved.

Comment 4 Vít Ondruch 2018-02-02 12:19:24 UTC
Actually, thx for pointing this out, because looking into the code, it seems the error message is correct, but the code is wrong. Created PR fixing this:

https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/16

Unfortunately, I am not happy with the outcome, since if the code was correct, Bundler would be building with modified template without notice ...

Comment 5 Vít Ondruch 2018-02-08 14:16:39 UTC
So the error should be gone:

https://src.fedoraproject.org/rpms/redhat-rpm-config/c/51f1c667482c3852a61087df24fbc72a4ae45ed6

Although now the shebang would be mangled, which is not what we want. The discussion should continue in bug 1541318.


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