diff --git a/provision.py b/provision.py index 3a80236fb1..b5ee137586 100644 --- a/provision.py +++ b/provision.py @@ -17,6 +17,7 @@ SUPPORTED_PLATFORMS = { ], } +NPM_VERSION = '3.9.3' VENV_PATH = "/srv/zulip-venv" PY3_VENV_PATH = "/srv/zulip-py3-venv" ZULIP_PATH = os.path.dirname(os.path.abspath(__file__)) @@ -142,9 +143,10 @@ def main(): run(["sudo", "apt-get", "update"]) run(["sudo", "apt-get", "-y", "install"] + APT_DEPENDENCIES[codename]) - temp_deb_path = subprocess.check_output(["mktemp", "package_XXXXXX.deb", "--tmpdir"]) - run(["wget", "-O", temp_deb_path, TSEARCH_URL]) - run(["sudo", "dpkg", "--install", temp_deb_path]) + if subprocess.call(['dpkg', '-s', TSEARCH_PACKAGE_NAME]): + temp_deb_path = subprocess.check_output(["mktemp", "package_XXXXXX.deb", "--tmpdir"]) + run(["wget", "-O", temp_deb_path, TSEARCH_URL]) + run(["sudo", "dpkg", "--install", temp_deb_path]) setup_virtualenv(PY3_VENV_PATH, os.path.join(ZULIP_PATH, "tools", "setup", "py3_test_reqs.txt"), @@ -187,8 +189,10 @@ def main(): run(["tools/setup/postgres-init-test-db"]) run(["tools/do-destroy-rebuild-test-database"]) run(["python", "./manage.py", "compilemessages"]) - # Install the latest npm. - run(["sudo", "npm", "install", "-g", "npm"]) + if subprocess.check_output(['npm', '--version']).strip() != NPM_VERSION: + # Install the pinned version of npm. + run(["sudo", "npm", "install", "-g", "npm@{}".format(NPM_VERSION)]) + # Run npm install last because it can be flaky, and that way one # only needs to rerun `npm install` to fix the installation. run(["npm", "install"]) diff --git a/tools/setup/download-zxcvbn b/tools/setup/download-zxcvbn index d3fb2535d6..214e6858f1 100755 --- a/tools/setup/download-zxcvbn +++ b/tools/setup/download-zxcvbn @@ -2,5 +2,22 @@ set -e set -x -mkdir -p static/third/zxcvbn/ -wget https://raw.githubusercontent.com/dropbox/zxcvbn/0890678ede1488ecb02cda7eb793cd308a59c49d/zxcvbn.js -O static/third/zxcvbn/zxcvbn.js +output_path=static/third/zxcvbn +commit_file_path=$output_path/commit +commit=0890678ede1488ecb02cda7eb793cd308a59c49d # Change this to upgrade + +mkdir -p "$output_path" + +if [ -e "$commit_file_path" ] +then + current_commit=`cat $commit_file_path` +else + current_commit=00 +fi + +if [ "$current_commit" == "$commit" ]; then + echo "Already at latest version of zxcvbn.js" +else + echo "$commit" > "$commit_file_path" + wget "https://raw.githubusercontent.com/dropbox/zxcvbn/$commit/zxcvbn.js" -O "$output_path/zxcvbn.js" +fi