py3: Switch almost all shebang lines to use `python3`.
This causes `upgrade-zulip-from-git`, as well as a no-option run of
`tools/build-release-tarball`, to produce a Zulip install running
Python 3, rather than Python 2. In particular this means that the
virtualenv we create, in which all application code runs, is Python 3.
One shebang line, on `zulip-ec2-configure-interfaces`, explicitly
keeps Python 2, and at least one external ops script, `wal-e`, also
still runs on Python 2. See discussion on the respective previous
commits that made those explicit. There may also be some other
third-party scripts we use, outside of this source tree and running
outside our virtualenv, that still run on Python 2.
2017-08-02 23:15:16 +02:00
|
|
|
#!/usr/bin/env python3
|
2020-06-11 00:54:34 +02:00
|
|
|
import glob
|
2013-11-08 22:41:12 +01:00
|
|
|
import os
|
2018-07-18 23:50:15 +02:00
|
|
|
import shutil
|
2013-11-08 22:41:12 +01:00
|
|
|
import subprocess
|
2020-06-11 00:54:34 +02:00
|
|
|
import sys
|
2013-11-08 22:41:12 +01:00
|
|
|
import tempfile
|
|
|
|
|
2015-11-16 17:40:32 +01:00
|
|
|
os.environ["PYTHONUNBUFFERED"] = "y"
|
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
sys.path.append(os.path.join(os.path.dirname(__file__), "..", ".."))
|
2017-06-21 14:32:22 +02:00
|
|
|
import version
|
2020-06-11 00:54:34 +02:00
|
|
|
from scripts.lib.zulip_tools import (
|
|
|
|
DEPLOYMENTS_DIR,
|
|
|
|
ENDC,
|
|
|
|
FAIL,
|
|
|
|
get_deployment_version,
|
|
|
|
is_invalid_upgrade,
|
|
|
|
make_deploy_path,
|
|
|
|
overwrite_symlink,
|
|
|
|
)
|
2013-11-08 22:41:12 +01:00
|
|
|
|
|
|
|
if len(sys.argv) != 2:
|
2020-06-10 06:41:04 +02:00
|
|
|
print(FAIL + f"Usage: {sys.argv[0]} <tarball>" + ENDC)
|
2013-11-08 22:41:12 +01:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
tarball_path = sys.argv[1]
|
|
|
|
|
2013-11-13 20:57:31 +01:00
|
|
|
deploy_path = make_deploy_path()
|
2013-11-08 22:41:12 +01:00
|
|
|
|
|
|
|
extract_path = tempfile.mkdtemp()
|
|
|
|
subprocess.check_call(["tar", "-xf", tarball_path, "-C", extract_path])
|
2017-06-21 14:32:22 +02:00
|
|
|
|
|
|
|
new_version = get_deployment_version(extract_path)
|
|
|
|
current_version = version.ZULIP_VERSION
|
|
|
|
if is_invalid_upgrade(current_version, new_version):
|
2021-02-12 08:19:30 +01:00
|
|
|
print(
|
|
|
|
FAIL + "Your current version is very old. Please first upgrade to version "
|
|
|
|
"1.4.3 and then upgrade to {}.".format(new_version) + ENDC
|
|
|
|
)
|
2018-07-18 23:50:15 +02:00
|
|
|
shutil.rmtree(extract_path)
|
2017-06-21 14:32:22 +02:00
|
|
|
sys.exit(1)
|
|
|
|
|
2018-07-18 23:50:15 +02:00
|
|
|
shutil.move(glob.glob(os.path.join(extract_path, "zulip-server-*"))[0], deploy_path)
|
|
|
|
os.rmdir(extract_path)
|
2021-02-12 08:19:30 +01:00
|
|
|
overwrite_symlink("/etc/zulip/settings.py", os.path.join(deploy_path, "zproject/prod_settings.py"))
|
2018-07-18 23:50:15 +02:00
|
|
|
overwrite_symlink(deploy_path, os.path.join(DEPLOYMENTS_DIR, "next"))
|
2013-11-08 22:41:12 +01:00
|
|
|
|
2016-03-10 17:15:34 +01:00
|
|
|
print(deploy_path)
|
2013-11-08 22:41:12 +01:00
|
|
|
sys.exit(0)
|