mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 21:43:21 +00:00
provision: Avoid spending ~3s on apt operations in no-op provision.
Fixes #5186
This commit is contained in:
@@ -6,6 +6,7 @@ import logging
|
|||||||
import argparse
|
import argparse
|
||||||
import platform
|
import platform
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import hashlib
|
||||||
|
|
||||||
os.environ["PYTHONUNBUFFERED"] = "y"
|
os.environ["PYTHONUNBUFFERED"] = "y"
|
||||||
|
|
||||||
@@ -183,12 +184,35 @@ def main(options):
|
|||||||
# project.
|
# project.
|
||||||
os.chdir(ZULIP_PATH)
|
os.chdir(ZULIP_PATH)
|
||||||
|
|
||||||
|
# setup-apt-repo does an `apt-get update`
|
||||||
|
# hash the apt dependencies
|
||||||
|
sha_sum = hashlib.sha1()
|
||||||
|
|
||||||
|
for apt_depedency in APT_DEPENDENCIES[codename]:
|
||||||
|
sha_sum.update(apt_depedency.encode('utf8'))
|
||||||
|
# hash the content of setup-apt-repo
|
||||||
|
sha_sum.update(open('scripts/lib/setup-apt-repo').read().encode('utf8'))
|
||||||
|
|
||||||
|
new_apt_dependencies_hash = sha_sum.hexdigest()
|
||||||
|
last_apt_dependencies_hash = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
install_apt_deps()
|
hash_file = open('var/apt_dependenices_hash', 'r+')
|
||||||
except subprocess.CalledProcessError:
|
last_apt_dependencies_hash = hash_file.read()
|
||||||
# Might be a failure due to network connection issues. Retrying...
|
except IOError:
|
||||||
print(WARNING + "`apt-get -y install` failed while installing dependencies; retrying..." + ENDC)
|
run(['touch', 'var/apt_dependenices_hash'])
|
||||||
install_apt_deps()
|
hash_file = open('var/apt_dependenices_hash', 'r+')
|
||||||
|
|
||||||
|
if (new_apt_dependencies_hash != last_apt_dependencies_hash):
|
||||||
|
try:
|
||||||
|
install_apt_deps()
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
# Might be a failure due to network connection issues. Retrying...
|
||||||
|
print(WARNING + "`apt-get -y install` failed while installing dependencies; retrying..." + ENDC)
|
||||||
|
install_apt_deps()
|
||||||
|
hash_file.write(new_apt_dependencies_hash)
|
||||||
|
else:
|
||||||
|
print("No need to apt operations.")
|
||||||
|
|
||||||
if options.is_travis:
|
if options.is_travis:
|
||||||
if PY2:
|
if PY2:
|
||||||
|
|||||||
Reference in New Issue
Block a user