From e2528537ddb0c01c3fc8a25ed876fbb91c677841 Mon Sep 17 00:00:00 2001
From: Robert Nelson <robertcnelson@gmail.com>
Date: Tue, 29 May 2018 11:46:50 -0500
Subject: [PATCH] bbio: install both python2/python3 variants

Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
---
 target/chroot/beagleboard.org-bionic.sh      | 25 ++++++++--------
 target/chroot/beagleboard.org-buster.sh      | 25 ++++++++--------
 target/chroot/beagleboard.org-stretch-2gb.sh | 25 ++++++++--------
 target/chroot/beagleboard.org-stretch.sh     | 25 ++++++++--------
 target/chroot/elinux.sh                      | 17 +++++++++++
 target/chroot/machinekit-stretch.sh          | 31 ++++++++------------
 6 files changed, 82 insertions(+), 66 deletions(-)

diff --git a/target/chroot/beagleboard.org-bionic.sh b/target/chroot/beagleboard.org-bionic.sh
index 01b422f15..46b8d478f 100755
--- a/target/chroot/beagleboard.org-bionic.sh
+++ b/target/chroot/beagleboard.org-bionic.sh
@@ -153,18 +153,19 @@ setup_desktop () {
 }
 
 install_pip_pkgs () {
-	if [ -f /usr/bin/python3 ] ; then
-		if [ -f /usr/bin/pip3 ] ; then
-			if [ -f /usr/bin/make ] ; then
-				echo "Installing pip packages"
-				git_repo="https://github.com/adafruit/adafruit-beaglebone-io-python.git"
-				git_target_dir="/opt/source/adafruit-beaglebone-io-python"
-				git_clone
-				if [ -f ${git_target_dir}/.git/config ] ; then
-					cd ${git_target_dir}/
-					sed -i -e 's:4.1.0:3.4.0:g' setup.py
-					python3 setup.py install
-				fi
+	if [ -f /usr/bin/make ] ; then
+		echo "Installing pip packages"
+		git_repo="https://github.com/adafruit/adafruit-beaglebone-io-python.git"
+		git_target_dir="/opt/source/adafruit-beaglebone-io-python"
+		git_clone
+		if [ -f ${git_target_dir}/.git/config ] ; then
+			cd ${git_target_dir}/
+			sed -i -e 's:4.1.0:3.4.0:g' setup.py
+			if [ -f /usr/bin/python2 ] ; then
+				python2 setup.py install || true
+			fi
+			if [ -f /usr/bin/python3 ] ; then
+				python3 setup.py install || true
 			fi
 		fi
 	fi
diff --git a/target/chroot/beagleboard.org-buster.sh b/target/chroot/beagleboard.org-buster.sh
index 04eceb224..60393bca7 100755
--- a/target/chroot/beagleboard.org-buster.sh
+++ b/target/chroot/beagleboard.org-buster.sh
@@ -153,18 +153,19 @@ setup_desktop () {
 }
 
 install_pip_pkgs () {
-	if [ -f /usr/bin/python3 ] ; then
-		if [ -f /usr/bin/pip3 ] ; then
-			if [ -f /usr/bin/make ] ; then
-				echo "Installing pip packages"
-				git_repo="https://github.com/adafruit/adafruit-beaglebone-io-python.git"
-				git_target_dir="/opt/source/adafruit-beaglebone-io-python"
-				git_clone
-				if [ -f ${git_target_dir}/.git/config ] ; then
-					cd ${git_target_dir}/
-					sed -i -e 's:4.1.0:3.4.0:g' setup.py
-					python3 setup.py install
-				fi
+	if [ -f /usr/bin/make ] ; then
+		echo "Installing pip packages"
+		git_repo="https://github.com/adafruit/adafruit-beaglebone-io-python.git"
+		git_target_dir="/opt/source/adafruit-beaglebone-io-python"
+		git_clone
+		if [ -f ${git_target_dir}/.git/config ] ; then
+			cd ${git_target_dir}/
+			sed -i -e 's:4.1.0:3.4.0:g' setup.py
+			if [ -f /usr/bin/python2 ] ; then
+				python2 setup.py install || true
+			fi
+			if [ -f /usr/bin/python3 ] ; then
+				python3 setup.py install || true
 			fi
 		fi
 	fi
diff --git a/target/chroot/beagleboard.org-stretch-2gb.sh b/target/chroot/beagleboard.org-stretch-2gb.sh
index 6b84bab3e..fade45908 100755
--- a/target/chroot/beagleboard.org-stretch-2gb.sh
+++ b/target/chroot/beagleboard.org-stretch-2gb.sh
@@ -179,18 +179,19 @@ setup_desktop () {
 }
 
 install_pip_pkgs () {
-	if [ -f /usr/bin/python3 ] ; then
-		if [ -f /usr/bin/pip3 ] ; then
-			if [ -f /usr/bin/make ] ; then
-				echo "Installing pip packages"
-				git_repo="https://github.com/adafruit/adafruit-beaglebone-io-python.git"
-				git_target_dir="/opt/source/adafruit-beaglebone-io-python"
-				git_clone
-				if [ -f ${git_target_dir}/.git/config ] ; then
-					cd ${git_target_dir}/
-					sed -i -e 's:4.1.0:3.4.0:g' setup.py
-					python3 setup.py install
-				fi
+	if [ -f /usr/bin/make ] ; then
+		echo "Installing pip packages"
+		git_repo="https://github.com/adafruit/adafruit-beaglebone-io-python.git"
+		git_target_dir="/opt/source/adafruit-beaglebone-io-python"
+		git_clone
+		if [ -f ${git_target_dir}/.git/config ] ; then
+			cd ${git_target_dir}/
+			sed -i -e 's:4.1.0:3.4.0:g' setup.py
+			if [ -f /usr/bin/python2 ] ; then
+				python2 setup.py install || true
+			fi
+			if [ -f /usr/bin/python3 ] ; then
+				python3 setup.py install || true
 			fi
 		fi
 	fi
diff --git a/target/chroot/beagleboard.org-stretch.sh b/target/chroot/beagleboard.org-stretch.sh
index 2522dbc1a..d4747b07e 100755
--- a/target/chroot/beagleboard.org-stretch.sh
+++ b/target/chroot/beagleboard.org-stretch.sh
@@ -179,18 +179,19 @@ setup_desktop () {
 }
 
 install_pip_pkgs () {
-	if [ -f /usr/bin/python3 ] ; then
-		if [ -f /usr/bin/pip3 ] ; then
-			if [ -f /usr/bin/make ] ; then
-				echo "Installing pip packages"
-				git_repo="https://github.com/adafruit/adafruit-beaglebone-io-python.git"
-				git_target_dir="/opt/source/adafruit-beaglebone-io-python"
-				git_clone
-				if [ -f ${git_target_dir}/.git/config ] ; then
-					cd ${git_target_dir}/
-					sed -i -e 's:4.1.0:3.4.0:g' setup.py
-					python3 setup.py install
-				fi
+	if [ -f /usr/bin/make ] ; then
+		echo "Installing pip packages"
+		git_repo="https://github.com/adafruit/adafruit-beaglebone-io-python.git"
+		git_target_dir="/opt/source/adafruit-beaglebone-io-python"
+		git_clone
+		if [ -f ${git_target_dir}/.git/config ] ; then
+			cd ${git_target_dir}/
+			sed -i -e 's:4.1.0:3.4.0:g' setup.py
+			if [ -f /usr/bin/python2 ] ; then
+				python2 setup.py install || true
+			fi
+			if [ -f /usr/bin/python3 ] ; then
+				python3 setup.py install || true
 			fi
 		fi
 	fi
diff --git a/target/chroot/elinux.sh b/target/chroot/elinux.sh
index 539597e89..935f4ff6d 100755
--- a/target/chroot/elinux.sh
+++ b/target/chroot/elinux.sh
@@ -107,6 +107,23 @@ install_git_repos () {
 	git_repo="https://github.com/beagleboard/bb.org-overlays"
 	git_target_dir="/opt/source/bb.org-overlays"
 	git_clone
+
+	if [ -f /usr/bin/make ] ; then
+		echo "Installing pip packages"
+		git_repo="https://github.com/adafruit/adafruit-beaglebone-io-python.git"
+		git_target_dir="/opt/source/adafruit-beaglebone-io-python"
+		git_clone
+		if [ -f ${git_target_dir}/.git/config ] ; then
+			cd ${git_target_dir}/
+			sed -i -e 's:4.1.0:3.4.0:g' setup.py
+			if [ -f /usr/bin/python2 ] ; then
+				python2 setup.py install || true
+			fi
+			if [ -f /usr/bin/python3 ] ; then
+				python3 setup.py install || true
+			fi
+		fi
+	fi
 }
 
 
diff --git a/target/chroot/machinekit-stretch.sh b/target/chroot/machinekit-stretch.sh
index 9a19bcdd6..d1c57c1c7 100755
--- a/target/chroot/machinekit-stretch.sh
+++ b/target/chroot/machinekit-stretch.sh
@@ -191,24 +191,19 @@ setup_desktop () {
 }
 
 install_pip_pkgs () {
-	if [ -f /usr/bin/python ] ; then
-		wget https://bootstrap.pypa.io/get-pip.py || true
-		if [ -f get-pip.py ] ; then
-			python get-pip.py
-			rm -f get-pip.py || true
-
-			if [ -f /usr/local/bin/pip ] ; then
-				if [ -f /usr/bin/make ] ; then
-					echo "Installing pip packages"
-					git_repo="https://github.com/adafruit/adafruit-beaglebone-io-python.git"
-					git_target_dir="/opt/source/adafruit-beaglebone-io-python"
-					git_clone
-					if [ -f ${git_target_dir}/.git/config ] ; then
-						cd ${git_target_dir}/
-						sed -i -e 's:4.1.0:3.4.0:g' setup.py
-						python setup.py install
-					fi
-				fi
+	if [ -f /usr/bin/make ] ; then
+		echo "Installing pip packages"
+		git_repo="https://github.com/adafruit/adafruit-beaglebone-io-python.git"
+		git_target_dir="/opt/source/adafruit-beaglebone-io-python"
+		git_clone
+		if [ -f ${git_target_dir}/.git/config ] ; then
+			cd ${git_target_dir}/
+			sed -i -e 's:4.1.0:3.4.0:g' setup.py
+			if [ -f /usr/bin/python2 ] ; then
+				python2 setup.py install || true
+			fi
+			if [ -f /usr/bin/python3 ] ; then
+				python3 setup.py install || true
 			fi
 		fi
 	fi
-- 
GitLab