From d581ad82cafaf503421a6ca7686c3867c558917f Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 18 Jul 2018 17:50:15 -0400 Subject: [PATCH] scripts/upgrade-zulip-from-git: Avoid shelling out for mkdir, ln. Signed-off-by: Anders Kaseorg --- scripts/lib/upgrade-zulip-from-git | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/scripts/lib/upgrade-zulip-from-git b/scripts/lib/upgrade-zulip-from-git index e208926d75..95adaf6367 100755 --- a/scripts/lib/upgrade-zulip-from-git +++ b/scripts/lib/upgrade-zulip-from-git @@ -24,7 +24,7 @@ os.environ["PYTHONUNBUFFERED"] = "y" sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) from scripts.lib.zulip_tools import DEPLOYMENTS_DIR, FAIL, WARNING, ENDC, make_deploy_path, \ - get_deployment_lock, release_deployment_lock, su_to_zulip, assert_running_as_root + get_deployment_lock, overwrite_symlink, release_deployment_lock, su_to_zulip, assert_running_as_root assert_running_as_root(strip_lib_from_paths=True) @@ -44,9 +44,8 @@ refname = args.refname if args.remote_url: remote_url = args.remote_url -subprocess.check_call(["mkdir", '-p', - DEPLOYMENTS_DIR, - '/home/zulip/logs']) +os.makedirs(DEPLOYMENTS_DIR, exist_ok=True) +os.makedirs('/home/zulip/logs', exist_ok=True) error_rerun_script = "%s/current/scripts/upgrade-zulip-from-git %s" % (DEPLOYMENTS_DIR, refname) get_deployment_lock(error_rerun_script) @@ -69,10 +68,9 @@ try: preexec_fn=su_to_zulip) os.chdir(deploy_path) - subprocess.check_call(["ln", "-nsf", "/etc/zulip/settings.py", - os.path.join(deploy_path, "zproject/prod_settings.py")]) + overwrite_symlink("/etc/zulip/settings.py", "zproject/prod_settings.py") - subprocess.check_call(["ln", '-nsf', deploy_path, os.path.join(DEPLOYMENTS_DIR, "next")]) + overwrite_symlink(deploy_path, os.path.join(DEPLOYMENTS_DIR, "next")) subprocess.check_call([os.path.join(deploy_path, "scripts", "lib", "upgrade-zulip-stage-2"), deploy_path, "--from-git"] + deploy_options)