Commit 362bc168 authored by Robbie Iannucci's avatar Robbie Iannucci Committed by Commit Bot

Revert "[git_bootstrap.py] Remove unused options, use cipd in %PATH%."

This reverts commit 1123fea2.

Reason for revert: <INSERT REASONING HERE>

Original change's description:
> [git_bootstrap.py] Remove unused options, use cipd in %PATH%.
> 
> In particular:
>   * Rely on cipd.bat in %PATH%
>   * Always calculate --bits
>   * Rely on %CIPD_CACHE_DIR%
> 
> R=​vadimsh@chromium.org
> 
> Bug: 635421
> Change-Id: I972edfd7f48e90770696afba70ec7e11fc24ce95
> Reviewed-on: https://chromium-review.googlesource.com/495407
> Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
> Reviewed-by: Vadim Shtayura <vadimsh@chromium.org>
> 

TBR=iannucci@chromium.org,vadimsh@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Change-Id: I3536d6668432141ae1528ca49ea66d97fdeb5318
Reviewed-on: https://chromium-review.googlesource.com/495727Reviewed-by: 's avatarRobbie Iannucci <iannucci@chromium.org>
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
parent 0f2e6c53
......@@ -27,6 +27,11 @@ def _check_call(argv, **kwargs):
subprocess.check_call(argv, **kwargs)
def get_os_bitness():
"""Returns bitness of operating system as int."""
return 64 if platform.machine().endswith('64') else 32
def get_target_git_version():
"""Returns git version that should be installed."""
if os.path.exists(os.path.join(ROOT_DIR, '.git_bleeding_edge')):
......@@ -48,18 +53,24 @@ def clean_up_old_git_installations(git_directory):
def cipd_install(args, dest_directory, package, version):
"""Installs CIPD |package| at |version| into |dest_directory|."""
cipd_args = [
'cipd.bat',
'ensure',
'-ensure-file', '-',
'-root', dest_directory,
]
if args.verbose:
cipd_args.append('-verbose')
p = subprocess.Popen(cipd_args, stdin=subprocess.PIPE)
p.communicate('%s %s\n' % (package, version))
if p.wait() != 0:
raise subprocess.CalledProcessError(p.returncode, cipd_args)
manifest_file = tempfile.mktemp()
try:
with open(manifest_file, 'w') as f:
f.write('%s %s\n' % (package, version))
cipd_args = [
args.cipd_client,
'ensure',
'-list', manifest_file,
'-root', dest_directory,
]
if args.cipd_cache_directory:
cipd_args.extend(['-cache-dir', args.cipd_cache_directory])
if args.verbose:
cipd_args.append('-verbose')
_check_call(cipd_args)
finally:
os.remove(manifest_file)
def need_to_install_git(args, git_directory):
......@@ -87,9 +98,9 @@ def need_to_install_git(args, git_directory):
return False
def install_git(args, bits, git_version, git_directory):
def install_git(args, git_version, git_directory):
"""Installs |git_version| into |git_directory|."""
cipd_platform = 'windows-%s' % ('amd64' if bits == 64 else '386')
cipd_platform = 'windows-%s' % ('amd64' if args.bits == 64 else '386')
temp_dir = tempfile.mkdtemp()
try:
cipd_install(args,
......@@ -143,6 +154,14 @@ def install_git(args, bits, git_version, git_directory):
def main(argv):
parser = argparse.ArgumentParser()
parser.add_argument('--bits', type=int, choices=(32,64),
help='Bitness of the client to install. Default on this'
' system: %(default)s', default=get_os_bitness())
parser.add_argument('--cipd-client',
help='Path to CIPD client binary. default: %(default)s',
default=os.path.join(ROOT_DIR, 'cipd'+BAT_EXT))
parser.add_argument('--cipd-cache-directory',
help='Path to CIPD cache directory.')
parser.add_argument('--force', action='store_true',
help='Always re-install git.')
parser.add_argument('--verbose', action='store_true')
......@@ -153,18 +172,16 @@ def main(argv):
logging.basicConfig(level=logging.INFO if args.verbose else logging.WARN)
bits = 64 if platform.machine().endswith('64') else 32
git_version = get_target_git_version()
git_directory = os.path.join(
ROOT_DIR, 'git-%s-%s_bin' % (git_version, bits))
ROOT_DIR, 'git-%s-%s_bin' % (git_version, args.bits))
git_docs_dir = os.path.join(
git_directory, 'mingw%s' % bits, 'share', 'doc', 'git-doc')
git_directory, 'mingw%s' % args.bits, 'share', 'doc', 'git-doc')
clean_up_old_git_installations(git_directory)
if need_to_install_git(args, git_directory):
install_git(args, bits, git_version, git_directory)
install_git(args, git_version, git_directory)
# Update depot_tools files for "git help <command>"
docsrc = os.path.join(ROOT_DIR, 'man', 'html')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment