[OE-core] [PATCH] toolchain-shar-extract: check for available python

Jeremy A. Puhlman jpuhlman at mvista.com
Thu Mar 19 18:20:48 UTC 2020


From: Jeremy Puhlman <jpuhlman at mvista.com>

centos7 doesn't have python3 intalled by default, so running
the script errors in novel ways if it is not installed.

Signed-off-by: Jeremy A. Puhlman <jpuhlman at mvista.com>
---
 meta/files/toolchain-shar-extract.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/meta/files/toolchain-shar-extract.sh b/meta/files/toolchain-shar-extract.sh
index 2e0fe94963..04527f891f 100644
--- a/meta/files/toolchain-shar-extract.sh
+++ b/meta/files/toolchain-shar-extract.sh
@@ -1,8 +1,13 @@
 #!/bin/sh
 
 export LC_ALL=en_US.UTF-8
+#Make sure at least one python is installed
+INIT_PYTHON=$(which python3 2>/dev/null )
+[ -z "$INIT_PYTHON" ] && INIT_PYTHON=$(which python2 2>/dev/null)
+[ -z "$INIT_PYTHON" ] && echo "Error: The SDK needs a python installed" && exit 1
+
 # Remove invalid PATH elements first (maybe from a previously setup toolchain now deleted
-PATH=`python3 -c 'import os; print(":".join(e for e in os.environ["PATH"].split(":") if os.path.exists(e)))'`
+PATH=`$INIT_PYTHON -c 'import os; print(":".join(e for e in os.environ["PATH"].split(":") if os.path.exists(e)))'`
 
 tweakpath () {
     case ":${PATH}:" in
-- 
2.13.3



More information about the Openembedded-core mailing list