From 424b441bb174caad8271fe0a25b665b5a9cada8f Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 2 Sep 2020 15:29:59 -0700 Subject: [PATCH] provision: Check for old Ubuntu or Python before starting Python. This unblocks us from being able to use Python 3.6 syntax in provision.py and its dependencies. Signed-off-by: Anders Kaseorg --- .circleci/config.yml | 4 ++-- tools/lib/provision.py | 6 ------ tools/provision | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4f05b83127..b5167c3032 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -154,8 +154,8 @@ aliases: run: name: check tools/provision error message on xenial command: | - ! tools/provision > >(tee provision.out) - grep -Fqx 'CRITICAL:root:Unsupported platform: ubuntu 16.04' provision.out + ! tools/provision 2> >(tee provision.err >&2) + grep -Fqx 'Error: ubuntu 16.04 is no longer a supported platform for Zulip.' provision.err - &check_xenial_upgrade_error run: diff --git a/tools/lib/provision.py b/tools/lib/provision.py index 2b4d08feba..d75b5e0057 100755 --- a/tools/lib/provision.py +++ b/tools/lib/provision.py @@ -104,12 +104,6 @@ elif vendor == "centos" and os_version == "7": POSTGRES_VERSION = "10" else: logging.critical("Unsupported platform: %s %s", vendor, os_version) - if vendor == 'ubuntu' and os_version == '14.04': - print() - print("Ubuntu Trusty reached end-of-life upstream and is no longer a supported platform for Zulip") - if os.path.exists('/home/vagrant'): - print("To upgrade, run `vagrant destroy`, and then recreate the Vagrant guest.\n") - print("See: https://zulip.readthedocs.io/en/latest/development/setup-vagrant.html") sys.exit(1) VENV_DEPENDENCIES = get_venv_dependencies(vendor, os_version) diff --git a/tools/provision b/tools/provision index 169e446f27..5efce99945 100755 --- a/tools/provision +++ b/tools/provision @@ -10,6 +10,27 @@ if [ "$EUID" -eq 0 ]; then exit 1 fi +os="$(. /etc/os-release && echo "$ID $VERSION_ID")" +case "$os" in + 'ubuntu 14.04' | 'ubuntu 16.04') + echo "Error: $os is no longer a supported platform for Zulip." >&2 + if [ -e /home/vagrant ]; then + # shellcheck disable=SC2016 + echo 'To upgrade, run `vagrant destroy`, and then recreate the Vagrant guest.' >&2 + echo 'See: https://zulip.readthedocs.io/en/latest/development/setup-vagrant.html' >&2 + fi + exit 1 + ;; +esac + +python_version="$(python3 --version)" +case "$python_version" in + Python\ 3.[0-5].*) + echo 'Error: Zulip requires an OS with Python 3.6 or later.' >&2 + exit 1 + ;; +esac + FAIL='\033[91m' WARNING='\033[93m' ENDC='\033[0m'