1 |
This will deal with cases where the shebang is defined using ${PYTHON} |
2 |
or the location of python in the PATH. |
3 |
|
4 |
Signed-off-by: James Le Cuirot <chewi@g.o> |
5 |
--- |
6 |
eclass/python-utils-r1.eclass | 22 ++++++++++++++++++++-- |
7 |
1 file changed, 20 insertions(+), 2 deletions(-) |
8 |
|
9 |
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass |
10 |
index 607af1b52f75..19cfaf2798ab 100644 |
11 |
--- a/eclass/python-utils-r1.eclass |
12 |
+++ b/eclass/python-utils-r1.eclass |
13 |
@@ -989,7 +989,8 @@ python_doheader() { |
14 |
# @DESCRIPTION: |
15 |
# Create proper 'python' executable and pkg-config wrappers |
16 |
# (if available) in the directory named by <path>. Set up PATH |
17 |
-# and PKG_CONFIG_PATH appropriately. <path> defaults to ${T}/${EPYTHON}. |
18 |
+# and PKG_CONFIG_PATH appropriately. <path> defaults to |
19 |
+# ${T}/python-wrappers/${EPYTHON}${SYSROOT:+-sysroot}. |
20 |
# |
21 |
# The wrappers will be created for implementation named by <impl>, |
22 |
# or for one named by ${EPYTHON} if no <impl> passed. |
23 |
@@ -1010,7 +1011,7 @@ python_wrapper_setup() { |
24 |
|
25 |
# Use separate directories for SYSROOT in case we need to execute |
26 |
# Python in the context of the build host by unsetting SYSROOT. |
27 |
- local workdir=${3:-${T}/${impl}${SYSROOT:+-sysroot}} |
28 |
+ local workdir=${3:-${T}/python-wrappers/${impl}${SYSROOT:+-sysroot}} |
29 |
|
30 |
[[ ${workdir} ]] || die "${FUNCNAME}: no workdir specified." |
31 |
[[ ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON specified." |
32 |
@@ -1243,8 +1244,25 @@ python_fix_shebang() { |
33 |
# Match left-to-right in a loop, to avoid matching random |
34 |
# repetitions like 'python2.7 python2'. |
35 |
for i in $(seq 0 $((${#split_shebang[@]} - 1))); do |
36 |
+ # Fix the leading path if it points to a wrapper |
37 |
+ # script created by this eclass or points to |
38 |
+ # ${BROOT} rather than ${EPREFIX}. We generally only |
39 |
+ # touch the tail end of the string as this is safer |
40 |
+ # but if a path starts with ${T} or ${BROOT}, where |
41 |
+ # the latter differs from ${EPREFIX}, then it |
42 |
+ # definitely needs fixing. We preserve the tail for |
43 |
+ # further processing in the case block below. |
44 |
+ if [[ ${split_shebang[${i}]} == ${T}/python-wrappers/*/bin/* || ( ${split_shebang[${i}]} == ${BROOT}/usr/bin/* && ${BROOT} != ${EPREFIX} ) ]]; then |
45 |
+ split_shebang[${i}]=${EPREFIX}/usr/bin/${split_shebang[${i}]##*/} |
46 |
+ fix=1 |
47 |
+ fi |
48 |
+ |
49 |
case "/${split_shebang[${i}]}" in |
50 |
*/${EPYTHON}) |
51 |
+ # EPYTHON matched but the leading path may |
52 |
+ # still need fixing. |
53 |
+ [[ ${fix} ]] && break |
54 |
+ |
55 |
debug-print "${FUNCNAME}: in file ${f#${D%/}}" |
56 |
debug-print "${FUNCNAME}: shebang matches EPYTHON: ${shebang}" |
57 |
|
58 |
-- |
59 |
2.19.2 |