From: Thanh Ha Date: Thu, 13 Aug 2020 22:17:38 +0000 (-0400) Subject: Add support for Ubuntu 20.04 and newer X-Git-Tag: v0.7.0~2^2 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=00618d9fe3ea5abeee13be56e942d233d4071d7e;p=releng%2Fcommon-packer.git Add support for Ubuntu 20.04 and newer Ubuntu 20.04 no longer has python-* packages and instead the packages are now more explicitly either python2-* or python3-* with packages named python-is-python[23] to set the default. This patch when run on Ubuntu systems will check if python-is-python3 is available and installs that as the system python version, otherwise installs python-minimal. Also adjust the comments since they are no longer accurate or in the right places. Signed-off-by: Thanh Ha Change-Id: I830e0250ddbee395fdeddd78fcc7824f7855d75d --- diff --git a/provision/install-python.sh b/provision/install-python.sh index 7ede4ec..a0241f5 100755 --- a/provision/install-python.sh +++ b/provision/install-python.sh @@ -10,12 +10,12 @@ ############################################################################## # vi: ts=4 sw=4 sts=4 et : + set -eu -o pipefail -o noglob echo "----> install-python.sh" -# Ansible requires Python 2 so check availability and install as necessary. -# Ubuntu 16.04 does not come with Python 2 by default +# Ansible requires Python to be available so check availability and install as necessary. function is_ubuntu() { @@ -39,6 +39,7 @@ function is_centos8() return 1 } +# Ubuntu does not come with Python by default so we need to install it if is_ubuntu; then # Use netselect to choose a package mirror to install python-minimal in a # reliable manner. @@ -72,10 +73,16 @@ if is_ubuntu; then sed -i 's#http://us.archive.ubuntu.com/ubuntu#http://ubuntu.uberglobalmirror.com/archive#' \ /etc/apt/sources.list - echo "Installing python-minimal..." + echo "Installing Python..." apt clean all -y apt -y update - apt install -y python-minimal + + # Ubuntu 20.04 and newer can default to Python 3 + if apt-cache show python-is-python3; then + apt-get install -y python-is-python3 + else + apt-get install -y python-minimal + fi fi if is_centos8; then