Bug 1020164

Summary: find-requires should explicitly check shebang existence before extracting it
Product: [Fedora] Fedora Reporter: Robin Lee <robinlee.sysu>
Component: rpmAssignee: Packaging Maintenance Team <packaging-team-maint>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 19CC: ffesti, jzeleny, novyjindrich, packaging-team-maint, pknirsch, pmatilai
Target Milestone: ---Keywords: EasyFix
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-02-17 17:43:11 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:
Attachments:
Description Flags
Sample script
none
Proposed patch none

Description Robin Lee 2013-10-17 07:46:04 UTC
Created attachment 813217 [details]
Sample script

Description of problem:
autodeps/find-requires script will fail to extract the shebang of check-perf-trace.py, since the first line is a usual comment but not a shebang.
The result of the extraction is simply '#'.

I propose to add an explicit check of shebang existence.

Version-Release number of selected component (if applicable):
rpm-4.11.1-3.fc19.x86_64


How reproducible:


Steps to Reproduce:
1. download check-perf-trace.py (actually from perf)
2. chmod +x check-perf-trace.py
3. echo check-perf-trace.py | /usr/lib/rpm/find-requires


Actual results:

#

Expected results:
(empty)

Additional info:

Comment 1 Robin Lee 2013-10-17 07:47:31 UTC
Created attachment 813219 [details]
Proposed patch

Comment 2 Panu Matilainen 2013-10-17 08:00:59 UTC
Ack, but note that the find-requires script is not what's normally used in the last ~10 years. Basically any package still using find-requires is "buggy" because find-requires will miss various dependencies and assorted other side-effects.

Comment 3 Robin Lee 2013-10-17 09:31:11 UTC
Is /usr/lib/rpm/redhat/find-requires the script actually used?
The same issue may also exist in that script.

Comment 4 Panu Matilainen 2013-10-17 09:54:08 UTC
No, that one is just as dead as the other find-requires script. The automatic dependency discovery is done on per-file basis as defined by the type/path rules in /usr/lib/rpm/fileattr/*.attr files. For she-bang scripts, that involves these two files:

[pmatilai@localhost ~]$ cat /usr/lib/rpm/fileattrs/script.attr 
%__script_requires	%{_rpmconfigdir}/script.req
%__script_magic		^.* script[, ].*$
%__script_flags		exeonly
[pmatilai@localhost ~]$ cat /usr/lib/rpm/script.req 
#!/bin/sh

# TODO: handle "#!/usr/bin/env foo" somehow
while read filename; do
    # common cases 
    sed -n -e '1s:^#![[:space:]]*\(/[^[:space:]]\{1,\}\).*:\1:p' "$filename"
    #!/usr/bin/env /foo/bar
    sed -n -e '1s:^#![[:space:]]*[^[:space:]]*/bin/env[[:space:]]\{1,\}\(/[^[:space:]]\{1,\}\):\1:p' "$filename"
done

Comment 5 Robin Lee 2013-10-17 10:17:23 UTC
Oh, I see! Thank you!

The problem I met is actually when building kernel on CentOS 6.
In the specfile of kernel of CentOS6, it has:
%global _use_internal_dependency_generator 0
%define __find_provides %_sourcedir/find-provides %{_tmppath}
%define __find_requires /usr/lib/rpm/redhat/find-requires kernel

Does that mean rpmbuild will really use /usr/lib/rpm/redhat/find-requires to find requires?
And then I encountered error when the script run on the scripts provided by perf.

Comment 6 Fedora End Of Life 2015-01-09 20:17:01 UTC
This message is a notice that Fedora 19 is now at end of life. Fedora 
has stopped maintaining and issuing updates for Fedora 19. It is 
Fedora's policy to close all bug reports from releases that are no 
longer maintained. Approximately 4 (four) weeks from now this bug will
be closed as EOL if it remains open with a Fedora 'version' of '19'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 19 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 7 Fedora End Of Life 2015-02-17 17:43:11 UTC
Fedora 19 changed to end-of-life (EOL) status on 2015-01-06. Fedora 19 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.