Patchwork [RFC,1/7,dora] native-python: bad interpreter error message

login
register
mail settings
Submitter Mark Hatle
Date Dec. 5, 2013, 10:57 p.m.
Message ID <94b095e724fc929043ab63786686062d27264473.1386283669.git.mark.hatle@windriver.com>
Download mbox | patch
Permalink /patch/62935/
State New
Headers show

Comments

Mark Hatle - Dec. 5, 2013, 10:57 p.m.
From: Amy Fong <Amy.Fong@windriver.com>

-- Sent for YP compliance --

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: Mark Hatle <mark.hatle@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 8c3a979..b2895b3 100644
--- a/meta/classes/distutils.bbclass
+++ b/meta/classes/distutils.bbclass
@@ -49,7 +49,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
@@ -58,6 +64,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