| #!/usr/bin/env bash |
| # Copyright 2018 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| # Installs or updates prebuilt tools. |
| |
| set -o errexit |
| set -o pipefail |
| |
| # Increment this value when removing tools from cipd.ensure. That will ensure |
| # the corresponding executables get removed from every user's prebuilts the next |
| # time they run this script. |
| VERSION="1" |
| |
| script_root="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd)" |
| |
| tools_dir="$script_root/tools" |
| version_file="$tools_dir/version.txt" |
| |
| got_version="0" |
| if [ -f "$version_file" ]; then |
| got_version="$(cat "$version_file")" |
| fi |
| if ! [ "$got_version" = "$VERSION" ]; then |
| # Tools are out of date, remove the whole directory to garbage-collect any |
| # tools that may have been deleted from cipd.ensure. |
| rm -rf "$tools_dir" |
| fi |
| |
| "${script_root}/cipd.py" ensure \ |
| -ensure-file "${script_root}/cipd.ensure" \ |
| -root "${script_root}" \ |
| -log-level warning |
| |
| echo "$VERSION" > "$version_file" |