Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 465790 - python-utils-r1.eclass fails to change "/usr/bin/env python" shebangs that are followed a carriage return
Summary: python-utils-r1.eclass fails to change "/usr/bin/env python" shebangs that ar...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-13 14:25 UTC by Mike Auty (RETIRED)
Modified: 2013-04-14 05:47 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Auty (RETIRED) gentoo-dev 2013-04-13 14:25:18 UTC
Hiya,

Just a quick note to say that due to the _python_rewrite_shebang in python-utils-r1.eclass, lines such as "#!/usr/bin/env python" from linux-newline-formatted files give rise to:

 * A file does not seem to have a supported shebang:
...
 *   shebang: #!/usr/bin/env python

Investigating this further, it's seems to be down to the following line:

local shebang=$(head -n 1 "${f}")

On the file I'm testing, the first line finishes with \r\n, so the shebang returned is actually "#!/usr/bin/env python\r".  When the space is added the check tries to match "...python\r " against *"python "*, which then fails.  The version of head I'm using comes from sys-apps/coreutils-8.21.  I haven't checked whether older versions of coreutils suffer the same problem.

As it turns out, the program I'm trying to convert uses it's own bash scripts to launch python with the target file, so I'm going to make the change there rather than the shebangs.  It's therefore not something I'm intending to mess around with further, but if you'd like help testing fixes just let me know...  5:)
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-04-13 14:35:11 UTC
Erm, I don't think that you are supposed to install a file with CRLF line endings. I may be wrong but I think you need to 'fix' it to plain LFs first...
Comment 2 Mike Auty (RETIRED) gentoo-dev 2013-04-13 23:17:19 UTC
That would mean that every python project written in windows would require a dependency on dos2unix and extra code in the ebuild because our single bit of shebang changing code can't deal with it?  That cannot be the right way to fix this...
Comment 3 Mike Gilbert gentoo-dev 2013-04-14 00:11:14 UTC
+  14 Apr 2013; Mike Gilbert <floppym@gentoo.org> python-utils-r1.eclass:
+  Remove carriage-return from shebang before validating it, bug 465790 by
+  ikelos.
Comment 4 Mike Gilbert gentoo-dev 2013-04-14 00:15:07 UTC
I also took a look at the python_fix_shebangs function in python-single-r1.eclass; the pattern checking there should be unaffected by the line ending.
Comment 5 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-04-14 05:47:52 UTC
That still leaves the question whether we actually want CRLF files installed on Linux. They cause trouble with some simple editors, at least.