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:
Tim Abbott
2017-10-17 19:14:06 -07:00
parent c69c38b14e
commit 2ae2a94444
2 changed files with 27 additions and 3 deletions

View File

@@ -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()