Merge "Make dib-python use the default python for distro"
This commit is contained in:
commit
8ddbc6425d
@ -1,2 +1,3 @@
|
||||
debootstrap
|
||||
dib-python
|
||||
pkg-map
|
||||
|
@ -54,4 +54,13 @@ $apt_get update
|
||||
$apt_get clean
|
||||
$apt_get dist-upgrade -y
|
||||
|
||||
$apt_get install -y busybox python sudo
|
||||
$apt_get install -y busybox sudo
|
||||
|
||||
if [ "$DIB_PYTHON_VERSION" == "2" ]; then
|
||||
$apt_get install -y python
|
||||
elif [ "$DIB_PYTHON_VERSION" == "3" ]; then
|
||||
$apt_get install -y python3
|
||||
else
|
||||
echo "ERROR: DIB_PYTHON_VERSION is '$DIB_PYTHON_VERSION' but needs to be 2 or 3"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -7,3 +7,6 @@ or python3 executable. This is useful for creating #! lines for scripts that
|
||||
are compatible with both python2 and python3.
|
||||
|
||||
This does not install a python if one does not exist, and instead fails.
|
||||
|
||||
This also exports a variable DIB_PYTHON_VERSION which will either be '2' or
|
||||
'3' depending on the python version which dib-python points to.
|
||||
|
24
elements/dib-python/environment.d/50-dib-python-version
Normal file
24
elements/dib-python/environment.d/50-dib-python-version
Normal file
@ -0,0 +1,24 @@
|
||||
# Pick which distros we need to force python2
|
||||
if [ -z "${DIB_PYTHON_VERSION:-}" ]; then
|
||||
if [ "$DISTRO_NAME" == "ubuntu" ]; then
|
||||
if [ "$DIB_RELEASE" == "trusty" ]; then
|
||||
DIB_PYTHON_VERSION=2
|
||||
fi
|
||||
elif [ "$DISTRO_NAME" == "debian" ]; then
|
||||
DIB_PYTHON_VERSION=2
|
||||
elif [ "$DISTRO_NAME" == "fedora" ]; then
|
||||
if [ "$DIB_RELEASE" -le 22 ]; then
|
||||
DIB_PYTHON_VERSION=2
|
||||
fi
|
||||
elif [ "$DISTRO_NAME" == "centos" ]; then
|
||||
DIB_PYTHON_VERSION=2
|
||||
elif [ "$DISTRO_NAME" == "centos7" ]; then
|
||||
DIB_PYTHON_VERSION=2
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "${DIB_PYTHON_VERSION:-}" ]; then
|
||||
DIB_PYTHON_VERSION=3
|
||||
fi
|
||||
|
||||
export DIB_PYTHON_VERSION
|
@ -6,9 +6,9 @@ fi
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
python_path=$(command -v python2 || command -v python3)
|
||||
python_path=$(command -v python${DIB_PYTHON_VERSION})
|
||||
if [ -z "$python_path" ]; then
|
||||
echo "Could not find python2 or python3 executable."
|
||||
echo "Could not find python${DIB_PYTHON_VERSION} executable."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -43,4 +43,13 @@ $apt_get update
|
||||
$apt_get clean
|
||||
$apt_get dist-upgrade -y
|
||||
|
||||
$apt_get install -y busybox python sudo
|
||||
$apt_get install -y busybox sudo
|
||||
|
||||
if [ "$DIB_PYTHON_VERSION" == "2" ]; then
|
||||
$apt_get install -y python
|
||||
elif [ "$DIB_PYTHON_VERSION" == "3" ]; then
|
||||
$apt_get install -y python3
|
||||
else
|
||||
echo "ERROR: DIB_PYTHON_VERSION is '$DIB_PYTHON_VERSION' but needs to be 2 or 3"
|
||||
exit 1
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user