diff --git a/.gitignore b/.gitignore index 3e06bcb8ff..e9233cee3a 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,9 @@ /.cipd_client* /.versions +# Ignore "disable auto update" sentinel file. +.disable_auto_update + # Ignore the batch files produced by the Windows bootstrapping. /git-bash /git.bat diff --git a/update_depot_tools b/update_depot_tools index 631fe1d999..4dcdcf77af 100755 --- a/update_depot_tools +++ b/update_depot_tools @@ -39,6 +39,10 @@ else fi fi +if [ -e $base_dir/.disable_auto_update ]; then + exit +fi + # We want to update the bundled tools even under MinGW. if [ $MINGW = 0 ]; then $COMSPEC /c `cygpath -w "$base_dir/bootstrap/win/win_tools.bat"` diff --git a/update_depot_tools.bat b/update_depot_tools.bat index dd5a6117d3..f3c1126eab 100644 --- a/update_depot_tools.bat +++ b/update_depot_tools.bat @@ -19,6 +19,8 @@ IF "%~nx0"=="update_depot_tools.bat" ( set DEPOT_TOOLS_DIR=%~1 SHIFT +IF EXIST "%DEPOT_TOOLS_DIR%.disable_auto_update" GOTO :EOF + set GIT_URL=https://chromium.googlesource.com/chromium/tools/depot_tools.git :: Will download git, svn and python. diff --git a/update_depot_tools_toggle.py b/update_depot_tools_toggle.py new file mode 100644 index 0000000000..1bc537c01b --- /dev/null +++ b/update_depot_tools_toggle.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +# Copyright (c) 2017 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Small utility script to enable/disable `depot_tools` automatic updating.""" + +import argparse +import datetime +import os +import sys + + +DEPOT_TOOLS_ROOT = os.path.abspath(os.path.dirname(__file__)) +SENTINEL_PATH = os.path.join(DEPOT_TOOLS_ROOT, '.disable_auto_update') + + +def main(): + parser = argparse.ArgumentParser() + group = parser.add_mutually_exclusive_group(required=True) + group.add_argument('--enable', action='store_true', + help='Enable auto-updating.') + group.add_argument('--disable', action='store_true', + help='Disable auto-updating.') + args = parser.parse_args() + + if args.enable: + if os.path.exists(SENTINEL_PATH): + os.unlink(SENTINEL_PATH) + if args.disable: + if not os.path.exists(SENTINEL_PATH): + with open(SENTINEL_PATH, 'w') as fd: + fd.write('Disabled by %s at %s\n' % (__file__, datetime.datetime.now())) + return 0 + + +if __name__ == '__main__': + sys.exit(main())