Bug 1020164 - find-requires should explicitly check shebang existence before extracting it
find-requires should explicitly check shebang existence before extracting it
Product: Fedora
Classification: Fedora
Component: rpm (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: packaging-team-maint
Fedora Extras Quality Assurance
: EasyFix
Depends On:
  Show dependency treegraph
Reported: 2013-10-17 03:46 EDT by Robin Lee
Modified: 2015-02-17 12:43 EST (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2015-02-17 12:43:11 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Sample script (2.44 KB, text/x-python)
2013-10-17 03:46 EDT, Robin Lee
no flags Details
Proposed patch (510 bytes, patch)
2013-10-17 03:47 EDT, Robin Lee
no flags Details | Diff

  None (edit)
Description Robin Lee 2013-10-17 03:46:04 EDT
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):

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:

Additional info:
Comment 1 Robin Lee 2013-10-17 03:47:31 EDT
Created attachment 813219 [details]
Proposed patch
Comment 2 Panu Matilainen 2013-10-17 04:00:59 EDT
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 05:31:11 EDT
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 05:54:08 EDT
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 

# 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"
Comment 5 Robin Lee 2013-10-17 06:17:23 EDT
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 15:17:01 EST
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 12:43:11 EST
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

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

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