Convert multi line if statement to case
Having multi-line if-elif statements is not ideal, case improves readability clarifying the code. Change-Id: I3383584e09763d4ae8eab2f36a93ee399dae8382
This commit is contained in:
parent
b4f768117f
commit
256c798bc4
@ -1,31 +1,39 @@
|
|||||||
# Pick which distros we need to force python2 and which to python3
|
# Pick which distros we need to force python2 and which to python3
|
||||||
if [ -z "${DIB_PYTHON_VERSION:-}" ]; then
|
if [ -z "${DIB_PYTHON_VERSION:-}" ]; then
|
||||||
if [ "$DISTRO_NAME" == "ubuntu" ]; then
|
case "$DISTRO_NAME" in
|
||||||
|
ubuntu)
|
||||||
if [ "$DIB_RELEASE" == "trusty" ]; then
|
if [ "$DIB_RELEASE" == "trusty" ]; then
|
||||||
DIB_PYTHON_VERSION=2
|
DIB_PYTHON_VERSION=2
|
||||||
fi
|
fi
|
||||||
elif [ "$DISTRO_NAME" == "debian" ]; then
|
;;
|
||||||
|
debian)
|
||||||
DIB_PYTHON_VERSION=2
|
DIB_PYTHON_VERSION=2
|
||||||
elif [ "$DISTRO_NAME" == "fedora" ]; then
|
;;
|
||||||
|
fedora)
|
||||||
if [ "$DIB_RELEASE" -le 22 ]; then
|
if [ "$DIB_RELEASE" -le 22 ]; then
|
||||||
DIB_PYTHON_VERSION=2
|
DIB_PYTHON_VERSION=2
|
||||||
fi
|
fi
|
||||||
elif [ "$DISTRO_NAME" == "centos7" ]; then
|
;;
|
||||||
|
centos7)
|
||||||
DIB_PYTHON_VERSION=2
|
DIB_PYTHON_VERSION=2
|
||||||
elif [ "$DISTRO_NAME" == "rhel7" ]; then
|
;;
|
||||||
|
rhel7)
|
||||||
# TODO(nmagnezi): Remove this when the 'rhel7' element gets replaced by 'rhel'
|
# TODO(nmagnezi): Remove this when the 'rhel7' element gets replaced by 'rhel'
|
||||||
DIB_PYTHON_VERSION=2
|
DIB_PYTHON_VERSION=2
|
||||||
elif [[ "$DISTRO_NAME" =~ (rhel|centos) ]]; then
|
;;
|
||||||
if [[ "${DIB_RELEASE}" == "7" ]]; then
|
rhel|centos)
|
||||||
|
if [ "$DIB_RELEASE" == "7" ]; then
|
||||||
DIB_PYTHON_VERSION=2
|
DIB_PYTHON_VERSION=2
|
||||||
else
|
else
|
||||||
DIB_PYTHON_VERSION=3
|
DIB_PYTHON_VERSION=3
|
||||||
fi
|
fi
|
||||||
elif [ "$DISTRO_NAME" == "opensuse" ]; then
|
;;
|
||||||
|
opensuse)
|
||||||
if [ "${DIB_RELEASE:0:2}" == "42" ]; then
|
if [ "${DIB_RELEASE:0:2}" == "42" ]; then
|
||||||
DIB_PYTHON_VERSION=2
|
DIB_PYTHON_VERSION=2
|
||||||
fi
|
fi
|
||||||
fi
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "${DIB_PYTHON_VERSION:-}" ]; then
|
if [ -z "${DIB_PYTHON_VERSION:-}" ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user