Skip to contentSkip to conversation

lttng-ust: Patch python shebang appropriately for native builds

PATCH In review Phil Blundell 3 participants 4 messages Dec 14, 2016 – Dec 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lttng-ust: Patch python shebang appropriately for native builds

If we are building a native package then ${bindir}/python3 is not guaranteed to be available, and if it is available then it is probably a directory not a file. In either case, attempting to use it as an interpreter will not end well. Let's use ${bindir}/nativepython instead.

---
 meta/recipes-kernel/lttng/lttng-ust_git.bb | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
meta/recipes-kernel/lttng/lttng-ust_git.bb +3 -1
index 5869093..df22352 100644
@@ -29,10 +29,12 @@ SRC_URI = "git://git.lttng.org/lttng-ust.git;branch=stable-2.7 \
 
 PACKAGECONFIG[manpages] = "--enable-man-pages, --disable-man-pages, asciidoc-native xmlto-native libxslt-native"
 
+usepython="${bindir}/python3"
+usepython_class-native="${bindir}/nativepython"
 do_install_append() {
         # Patch python tools to use Python 3; they should be source compatible, but
         # still refer to Python 2 in the shebang
-        sed -i -e '1s,#!.*python.*,#!${bindir}/python3,' ${D}${bindir}/lttng-gen-tp
+        sed -i -e '1s,#!.*python.*,#!${usepython},' ${D}${bindir}/lttng-gen-tp
 }
 
 S = "${WORKDIR}/git"
Signature · 1 line
2.10.1
#1 lore raw
Quoted 15 lines · Phil Blundell

If we are building a native package then ${bindir}/python3 is not guaranteed to be available, and if it is available then it is probably a directory not a file. In either case, attempting to use it as an interpreter will not end well. Let's use ${bindir}/nativepython instead.

---
 meta/recipes-kernel/lttng/lttng-ust_git.bb | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
meta/recipes-kernel/lttng/lttng-ust_git.bb +0 -0
index 5869093..df22352 100644

meta/recipes-kernel/lttng/lttng-ust_git.bb SRC_URI = "git://git.lttng.org/lttng-ust.git;branch=stable-2.7 \ · line 37

Quoted 10 lines
meta/recipes-kernel/lttng/lttng-ust_git.bb +3 -1
@@ -29,10 +29,12 @@ SRC_URI = "git://git.lttng.org/lttng-ust.git;branch=stable-2.7 \
 
 PACKAGECONFIG[manpages] = "--enable-man-pages, --disable-man-pages, asciidoc-native xmlto-native libxslt-native"
 
+usepython="${bindir}/python3"
+usepython_class-native="${bindir}/nativepython"
 do_install_append() {
         # Patch python tools to use Python 3; they should be source compatible, but
         # still refer to Python 2 in the shebang
-        sed -i -e '1s,#!.*python.*,#!${bindir}/python3,' ${D}${bindir}/lttng-gen-tp
+        sed -i -e '1s,#!.*python.*,#!${usepython},' ${D}${bindir}/lttng-gen-tp

This also means we need to add a dependency on python-native may be it should inherit the python native class.

Quoted 10 lines
meta/recipes-kernel/lttng/lttng-ust_git.bb +0 -1
 }
 
 S = "${WORKDIR}/git"
--

2.10.1
--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#2 lore raw
Quoted 3 lines · Khem Raj

This also means we need to add a dependency on python-native may be it should inherit the python native class.

Indeed. For python-native, '#! /usr/bin/env python3' will always work as that should find the Python that bitbake is running in.

Ross

#3 lore raw
In reply to Khem Raj
Quoted 25 lines · Khem Raj
Quoted 24 lines · Phil Blundell

If we are building a native package then ${bindir}/python3 is not guaranteed
to be available, and if it is available then it is probably a directory not a
file.  In either case, attempting to use it as an interpreter will not end
well.  Let's use ${bindir}/nativepython instead.

---
 meta/recipes-kernel/lttng/lttng-ust_git.bb | 4 +++-

 1 file changed, 3 insertions(+), 1 deletion(-)
meta/recipes-kernel/lttng/lttng-ust_git.bb +0 -0
index 5869093..df22352 100644
@@ -29,10 +29,12 @@ SRC_URI = "git://git.lttng.org/lttng-
 ust.git;branch=stable-2.7 \
 

 PACKAGECONFIG[manpages] = "--enable-man-pages, --disable-man- pages, asciidoc-native xmlto-native libxslt-native"

Quoted 14 lines
Quoted 10 lines
meta/recipes-kernel/lttng/lttng-ust_git.bb +2 -0
+usepython="${bindir}/python3"
+usepython_class-native="${bindir}/nativepython"

 do_install_append() {
         # Patch python tools to use Python 3; they should be source compatible, but

         # still refer to Python 2 in the shebang
-        sed -i -e '1s,#!.*python.*,#!${bindir}/python3,'
${D}${bindir}/lttng-gen-tp
+        sed -i -e '1s,#!.*python.*,#!${usepython},'
${D}${bindir}/lttng-gen-tp

This also means we need to add a dependency on python-native may be it
should inherit the python native class.

I suppose it probably should. That'd be a bit suboptimal in the sense that the non-native version does not need to depend on python-native, but given that python-native is probably installed in the sysroot anyway I don't suppose it is likely to hurt very much. And I don't think it is worth the complexity of trying to do a conditional inherit of pythonnative.

p.