From 3a8717e17fbf9904cd6671a3c477a45d5be31a5a Mon Sep 17 00:00:00 2001 From: Dan Jacques Date: Tue, 11 Jul 2017 18:09:20 -0700 Subject: [PATCH] [bootstrap/win] Remove legacy Git support. Remove non-CIPD Git installation code path. This changes the stable Git version to use the Git package and removes legacy Git support. Note that this is different from legacy (non-CIPD-managed) bootstrap. This will be removed in a future patch. This is effectively a roll of bleeding-edge into stable. BUG=chromium:740171 TEST=local Change-Id: Ia320efd7866f6c11e8aa18d6ce6157614b44fcab Reviewed-on: https://chromium-review.googlesource.com/567764 Commit-Queue: Daniel Jacques Reviewed-by: Robbie Iannucci --- bootstrap/win/git_version.txt | 2 +- bootstrap/win/win_tools.py | 67 ++++++++--------------------------- 2 files changed, 15 insertions(+), 54 deletions(-) diff --git a/bootstrap/win/git_version.txt b/bootstrap/win/git_version.txt index 10c2c0c3d..ccbf84fb0 100644 --- a/bootstrap/win/git_version.txt +++ b/bootstrap/win/git_version.txt @@ -1 +1 @@ -2.10.0 +version:2.10.0 diff --git a/bootstrap/win/win_tools.py b/bootstrap/win/win_tools.py index 986d5c0c0..d796f0f61 100644 --- a/bootstrap/win/win_tools.py +++ b/bootstrap/win/win_tools.py @@ -282,20 +282,13 @@ def cipd_ensure(args, dest_directory, package, version): _check_call(cipd_args, stdin_input=manifest_text) -def need_to_install_git(args, git_directory, legacy): +def need_to_install_git(args, git_directory): """Returns True if git needs to be installed.""" if args.force: return True is_cipd_managed = os.path.exists(os.path.join(git_directory, '.cipd')) - if legacy: - if is_cipd_managed: - # Converting from non-legacy to legacy, need reinstall. - return True - if not os.path.exists(os.path.join( - git_directory, 'etc', 'profile.d', 'python.sh')): - return True - elif not is_cipd_managed: + if not is_cipd_managed: # Converting from legacy to CIPD, need reinstall. return True @@ -320,48 +313,19 @@ def need_to_install_git(args, git_directory, legacy): return False -def install_git_legacy(args, git_version, git_directory, cipd_platform): - _safe_rmtree(git_directory) - with _tempdir() as temp_dir: - cipd_ensure(args, temp_dir, - package='infra/depot_tools/git_installer/%s' % cipd_platform, - version='v' + git_version.replace('.', '_')) - - # 7-zip has weird expectations for command-line syntax. Pass it as a string - # to avoid subprocess module quoting breaking it. Also double-escape - # backslashes in paths. - _check_call(' '.join([ - os.path.join(temp_dir, 'git-installer.exe'), - '-y', - '-InstallPath="%s"' % git_directory.replace('\\', '\\\\'), - '-Directory="%s"' % git_directory.replace('\\', '\\\\'), - ])) - - -def install_git(args, git_version, git_directory, legacy): +def install_git(args, git_version, git_directory): """Installs |git_version| into |git_directory|.""" # TODO: Remove legacy version once everyone is on bundled Git. cipd_platform = 'windows-%s' % ('amd64' if args.bits == 64 else '386') - if legacy: - install_git_legacy(args, git_version, git_directory, cipd_platform) - else: - # When migrating from legacy, we want to nuke this directory. In other - # cases, CIPD will handle the cleanup. - if not os.path.isdir(os.path.join(git_directory, '.cipd')): - logging.info('Deleting legacy Git directory: %s', git_directory) - _safe_rmtree(git_directory) - - cipd_ensure(args, git_directory, - package='infra/git/%s' % (cipd_platform,), - version=git_version) + # When migrating from legacy, we want to nuke this directory. In other + # cases, CIPD will handle the cleanup. + if not os.path.isdir(os.path.join(git_directory, '.cipd')): + logging.info('Deleting legacy Git directory: %s', git_directory) + _safe_rmtree(git_directory) - if legacy: - # The non-legacy Git bundle includes "python.sh". - # - # TODO: Delete "profile.d.python.sh" after legacy mode is removed. - shutil.copyfile( - os.path.join(THIS_DIR, 'profile.d.python.sh'), - os.path.join(git_directory, 'etc', 'profile.d', 'python.sh')) + cipd_ensure(args, git_directory, + package='infra/git/%s' % (cipd_platform,), + version=git_version) def ensure_git(args, template): @@ -378,11 +342,8 @@ def ensure_git(args, template): GIT_BIN_RELDIR=git_bin_dir, GIT_BIN_RELDIR_UNIX=git_bin_dir) - # Modern Git versions use CIPD tags beginning with "version:". If the tag - # does not begin with that, use the legacy installer. - legacy = not git_version.startswith('version:') - if need_to_install_git(args, git_directory, legacy): - install_git(args, git_version, git_directory, legacy) + if need_to_install_git(args, git_directory): + install_git(args, git_version, git_directory) git_postprocess(template, git_directory) @@ -466,7 +427,7 @@ def main(argv): template = Template.empty() if not args.win_tools_name: - # Legacy support. + # Legacy (non-CIPD) support. template = template._replace( PYTHON_RELDIR='python276_bin', PYTHON_BIN_RELDIR='python276_bin',