mirror of https://github.com/zulip/zulip.git
provision: Stop using shared var/ for caching apt state.
This didn't work at all when one did a `vagrant destroy` and then `vagrant up`, because the cache state would be preserved even though the machine is gone. Fixes #5981.
This commit is contained in:
parent
c69c38b14e
commit
2ae2a94444
|
@ -12,6 +12,7 @@ import subprocess
|
|||
import sys
|
||||
import time
|
||||
import json
|
||||
import uuid
|
||||
|
||||
if False:
|
||||
from typing import Sequence, Set, Text, Any
|
||||
|
@ -110,6 +111,27 @@ def mkdir_p(path):
|
|||
else:
|
||||
raise
|
||||
|
||||
def get_dev_uuid_var_path(create_if_missing=False):
|
||||
# type: (bool) -> str
|
||||
zulip_path = os.path.realpath(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))))
|
||||
uuid_path = os.path.join(os.path.realpath(os.path.dirname(zulip_path)), ".zulip-dev-uuid")
|
||||
if os.path.exists(uuid_path):
|
||||
with open(uuid_path) as f:
|
||||
zulip_uuid = f.read().strip()
|
||||
else:
|
||||
if create_if_missing:
|
||||
zulip_uuid = str(uuid.uuid4())
|
||||
# We need sudo here, since the path will be under /srv/ in the
|
||||
# development environment.
|
||||
subprocess.check_call(["sudo", "/bin/bash", "-c",
|
||||
"echo %s > %s" % (zulip_uuid, uuid_path)])
|
||||
else:
|
||||
raise AssertionError("Missing UUID file; please run tools/provision!")
|
||||
|
||||
result_path = os.path.join(zulip_path, "var", zulip_uuid)
|
||||
mkdir_p(result_path)
|
||||
return result_path
|
||||
|
||||
def get_deployment_lock(error_rerun_script):
|
||||
# type: (str) -> None
|
||||
start_time = time.time()
|
||||
|
|
|
@ -13,7 +13,8 @@ os.environ["PYTHONUNBUFFERED"] = "y"
|
|||
ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
sys.path.append(ZULIP_PATH)
|
||||
from scripts.lib.zulip_tools import run, subprocess_text_output, OKBLUE, ENDC, WARNING
|
||||
from scripts.lib.zulip_tools import run, subprocess_text_output, OKBLUE, ENDC, WARNING, \
|
||||
get_dev_uuid_var_path
|
||||
from scripts.lib.setup_venv import VENV_DEPENDENCIES
|
||||
from scripts.lib.node_cache import setup_node_modules, NODE_MODULES_CACHE_PATH
|
||||
|
||||
|
@ -67,7 +68,8 @@ if ram_gb < 1.5:
|
|||
sys.exit(1)
|
||||
|
||||
try:
|
||||
run(["mkdir", "-p", VAR_DIR_PATH])
|
||||
UUID_VAR_PATH = get_dev_uuid_var_path(create_if_missing=True)
|
||||
run(["mkdir", "-p", UUID_VAR_PATH])
|
||||
if os.path.exists(os.path.join(VAR_DIR_PATH, 'zulip-test-symlink')):
|
||||
os.remove(os.path.join(VAR_DIR_PATH, 'zulip-test-symlink'))
|
||||
os.symlink(
|
||||
|
@ -209,7 +211,7 @@ def main(options):
|
|||
|
||||
new_apt_dependencies_hash = sha_sum.hexdigest()
|
||||
last_apt_dependencies_hash = None
|
||||
apt_hash_file_path = 'var/apt_dependencies_hash'
|
||||
apt_hash_file_path = os.path.join(UUID_VAR_PATH, "apt_dependencies_hash")
|
||||
try:
|
||||
hash_file = open(apt_hash_file_path, 'r+')
|
||||
last_apt_dependencies_hash = hash_file.read()
|
||||
|
|
Loading…
Reference in New Issue