Patchwork [4/7] native-python: bad interpreter error message

login
register
mail settings
Submitter Hongxu Jia
Date March 28, 2014, 9:43 a.m.
Message ID <03f8bc4ad8c4bf496e831b883fbccd1309acdf46.1395996194.git.hongxu.jia@windriver.com>
Download mbox | patch
Permalink /patch/69525/
State New
Headers show

Comments

Hongxu Jia - March 28, 2014, 9:43 a.m.
From: Amy Fong <Amy.Fong@windriver.com>

On some builds with really long paths, we can end up exceeding the maximum
length line for an interpreter (man execve: A maximum line length of
127 characters is allowed for the first line in a #!  executable shell
script.)

To avoid this limit, we use env to execute python, with this, we will
be using python that's first found in our PATH.

The former ${bindir}/env is not a good idea for apps requiring native-python
since coreutil*-native may not have been built (${bindir}/env may not exist)
and with long paths, we can end up running into the same issue, hence we
use /usr/bin/env from the host.

Signed-off-by: Amy Fong <Amy.Fong@windriver.com>
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 meta/classes/distutils.bbclass | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

Patch

diff --git a/meta/classes/distutils.bbclass b/meta/classes/distutils.bbclass
index f3da023..1a53ebd 100644
--- a/meta/classes/distutils.bbclass
+++ b/meta/classes/distutils.bbclass
@@ -50,7 +50,13 @@  distutils_do_install() {
             for i in ${D}${bindir}/* ; do \
                 if [ ${PN} != "${BPN}-native" ]; then
                 	sed -i -e s:${STAGING_BINDIR_NATIVE}/python-native/python:${bindir}/env\ python:g $i
-		fi
+                else
+                	# The former ${bindir}/env is not a good idea for apps requiring native-python
+                	# since coreutil*-native may not have been built (${bindir}/env may not exist)
+                	# and with long paths, we can end up running into an issue where the
+                	# interpreter line is too long, hence we use /usr/bin/env from the host.
+                	sed -i -e s:${STAGING_BINDIR_NATIVE}/python-native/python:/usr/bin/env\ python:g $i
+                fi
                 sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
             done
         fi
@@ -59,6 +65,12 @@  distutils_do_install() {
             for i in ${D}${sbindir}/* ; do \
                 if [ ${PN} != "${BPN}-native" ]; then
                 	sed -i -e s:${STAGING_BINDIR_NATIVE}/python-native/python:${bindir}/env\ python:g $i
+                else
+                	# The former ${bindir}/env is not a good idea for apps requiring native-python
+                	# since coreutil*-native may not have been built (${bindir}/env may not exist)
+                	# and with long paths, we can end up running into an issue where the
+                	# interpreter line is too long, hence we use /usr/bin/env from the host.
+                	sed -i -e s:${STAGING_BINDIR_NATIVE}/python-native/python:/usr/bin/env\ python:g $i
 		fi
                 sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
             done