Fix python3 detection logic
The python_cmd function code is copied from already merged tripleo-quicstart/quickstart.sh version. In the future we plan to use it form a single location. Previous version was using python3 on CentOS-7 if it was installed which was not desired behavior. Change-Id: Id03b7ff76054c807e46c2483510313b4de66d678 Story: https://tree.taiga.io/project/tripleo-ci-board/task/153
This commit is contained in:
parent
e9f128b32c
commit
bf325848f4
|
@ -159,7 +159,58 @@ function sanitize_ip_address {
|
|||
}
|
||||
|
||||
function python_cmd() {
|
||||
basename $(command -v python3 || command -v python2)
|
||||
distribution=unknown
|
||||
distribution_major_version=unknown
|
||||
# we prefer python2 because on few systems python->python3
|
||||
python_cmd=python2
|
||||
|
||||
if [ -f /etc/os-release ]; then
|
||||
. /etc/os-release
|
||||
distribution_major_version=${VERSION_ID%.*}
|
||||
case $NAME in
|
||||
"Red Hat"*) distribution="RedHat"
|
||||
if [ "$distribution_major_version" -ge "8" ]; then
|
||||
python_cmd=python3
|
||||
fi
|
||||
;;
|
||||
"CentOS"*)
|
||||
distribution="CentOS"
|
||||
if [ "$distribution_major_version" -ge "8" ]; then
|
||||
python_cmd=python3
|
||||
fi
|
||||
;;
|
||||
"Fedora"*)
|
||||
distribution="Fedora"
|
||||
if [ "$distribution_major_version" -ge "28" ]; then
|
||||
python_cmd=python3
|
||||
fi
|
||||
;;
|
||||
"Ubuntu"*)
|
||||
distribution="Ubuntu"
|
||||
;;
|
||||
"Debian"*)
|
||||
distribution="Debian"
|
||||
;;
|
||||
esac
|
||||
elif [ -f /etc/lsb-release ]; then
|
||||
. /etc/lsb-release
|
||||
distribution=${DISTRIB_ID}xx
|
||||
distribution_major_version=${DISTRIB_RELEASE%.*}
|
||||
elif [ -f /etc/debian_version ]; then
|
||||
distribution="Debian"
|
||||
distribution_major_version=$(cat /etc/debian_version | cut -d. -f1)
|
||||
else
|
||||
# Covers for FreeBSD and many others
|
||||
distribution=$(uname -s)
|
||||
if [ $distribution = Darwin ]; then
|
||||
distribution="MacOSX"
|
||||
distribution_major_version=$(sw_vers -productVersion | cut -d. -f1)
|
||||
fi
|
||||
which $python_cmd 2>&1 >/dev/null || {
|
||||
python_cmd=/usr/local/bin/python2.7
|
||||
}
|
||||
fi
|
||||
echo $python_cmd
|
||||
}
|
||||
|
||||
function package_manager() {
|
||||
|
|
Loading…
Reference in New Issue