ensure_bootstrap 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/usr/bin/env bash
  2. # Copyright 2017 The Chromium Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. # TODO: This duplicates logic in "update_depot_tools". Update that script to
  6. # invoke this script instead of manually calling "cipd_bin_setup" and other
  7. # operations.
  8. usage() {
  9. cat <<EOF
  10. Usage: $0
  11. This is a shell script to ensure that all of the "depot_tools" bootstrap
  12. programs are locally downloaded and ready for execution.
  13. Unlike "update_depot_tools", this script works with the current
  14. checkout, and will not update/sync the "depot_tools" repository.
  15. EOF
  16. }
  17. if [ $# -ne 0 ]; then
  18. case $1 in
  19. -h|--help)
  20. usage
  21. exit 0
  22. ;;
  23. *)
  24. echo "$0: ERROR: script takes no arguments: $*" >&2
  25. exit 1
  26. ;;
  27. esac
  28. fi
  29. # Export for other depot_tools scripts to re-use.
  30. export DEPOT_TOOLS_DIR="${DEPOT_TOOLS_DIR:-$(dirname "${BASH_SOURCE[0]}")}"
  31. # Test if this script is running under a MinGW install. If it is, we will
  32. # hardcode the paths to Git where possible.
  33. OUTPUT="$(uname | grep 'MINGW')"
  34. MINGW=$?
  35. base_dir="${DEPOT_TOOLS_DIR}"
  36. if [ $MINGW != 0 ]; then
  37. # Don't bootstrap Python 3 on windows, since it is already done by
  38. # bootstrap/win_tools.bat.
  39. if [ "X$DEPOT_TOOLS_BOOTSTRAP_PYTHON3" != "X0" ]; then
  40. source "$base_dir/bootstrap_python3"
  41. bootstrap_python3
  42. fi
  43. fi
  44. # Sync CIPD-boostrapped packages.
  45. source "$base_dir/cipd_bin_setup.sh"
  46. cipd_bin_setup &> /dev/null
  47. # Sync "gsutil.py".
  48. python3 "$base_dir/gsutil.py" -- version 1> /dev/null &
  49. # Sync all the pylint versions.
  50. for script in "$base_dir"/pylint-[0-9].[0-9]; do
  51. # We have to silence stderr too because newer pylint versions will emit
  52. # a spurious log to tell us what pylintrc file it's using. Ugh.
  53. "$script" --version >/dev/null 2>&1 &
  54. done
  55. # Run bootstraps in parallel to help speed things up.
  56. wait
  57. # Cleanup.
  58. find "$base_dir" -iname "*.pyc" -delete || true