Merge pull request #912 from lantz/fix-1604-install

Check for non-functional 'python'
This commit is contained in:
lantz
2019-11-29 15:59:55 -08:00
committed by GitHub
+20 -8
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Mininet install script for Ubuntu (and Debian Wheezy+) # Mininet install script for Ubuntu and Debian
# Brandon Heller (brandonh@stanford.edu) # Original author: Brandon Heller
# Fail on error # Fail on error
set -e set -e
@@ -102,14 +102,26 @@ function version_ge {
[ "$1" == "$latest" ] [ "$1" == "$latest" ]
} }
# Attempt to identify Python version # Attempt to detect Python version
PYTHON=${PYTHON:-python} PYTHON=${PYTHON:-python}
if $PYTHON --version |& grep 'Python 2' > /dev/null; then PRINTVERSION='import sys; print(sys.version_info)'
PYTHON_VERSION=2; PYPKG=python PYTHON_VERSION=unknown
else for python in $PYTHON python2 python3; do
PYTHON_VERSION=3; PYPKG=python3 if $python -c "$PRINTVERSION" |& grep 'major=2'; then
PYTHON=$python; PYTHON_VERSION=2; PYPKG=python
break
elif $python -c "$PRINTVERSION" |& grep 'major=3'; then
PYTHON=$python; PYTHON_VERSION=3; PYPKG=python3
break
fi
done
if [ "$PYTHON_VERSION" == unknown ]; then
echo "Can't find a working python command ('$PYTHON' doesn't work.)"
echo "You may wish to export PYTHON or install a working 'python'."
exit 1
fi fi
echo "${PYTHON} is version ${PYTHON_VERSION}"
echo "Detected Python (${PYTHON}) version ${PYTHON_VERSION}"
# Kernel Deb pkg to be removed: # Kernel Deb pkg to be removed:
KERNEL_IMAGE_OLD=linux-image-2.6.26-33-generic KERNEL_IMAGE_OLD=linux-image-2.6.26-33-generic