Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: bootstrap/win/git_bootstrap.py

Issue 2280973002: git_bootstrap.py: add a switch to controll client bitness (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import argparse 5 import argparse
6 import fnmatch 6 import fnmatch
7 import logging 7 import logging
8 import os 8 import os
9 import shutil 9 import shutil
10 import subprocess 10 import subprocess
(...skipping 25 matching lines...) Expand all
36 36
37 def clean_up_old_git_installations(git_directory): 37 def clean_up_old_git_installations(git_directory):
38 """Removes git installations other than |git_directory|.""" 38 """Removes git installations other than |git_directory|."""
39 for entry in fnmatch.filter(os.listdir(ROOT_DIR), 'git-*_bin'): 39 for entry in fnmatch.filter(os.listdir(ROOT_DIR), 'git-*_bin'):
40 full_entry = os.path.join(ROOT_DIR, entry) 40 full_entry = os.path.join(ROOT_DIR, entry)
41 if full_entry != git_directory: 41 if full_entry != git_directory:
42 logging.info('Cleaning up old git installation %r', entry) 42 logging.info('Cleaning up old git installation %r', entry)
43 shutil.rmtree(full_entry, ignore_errors=True) 43 shutil.rmtree(full_entry, ignore_errors=True)
44 44
45 45
46 def bootstrap_cipd(cipd_directory): 46 def bootstrap_cipd(cipd_directory, cipd_platform):
47 """Bootstraps CIPD client into |cipd_directory|.""" 47 """Bootstraps CIPD client into |cipd_directory|."""
48 _check_call([ 48 _check_call([
49 sys.executable, 49 sys.executable,
50 os.path.join(ROOT_DIR, 'recipe_modules', 'cipd', 'resources', 50 os.path.join(ROOT_DIR, 'recipe_modules', 'cipd', 'resources',
51 'bootstrap.py'), 51 'bootstrap.py'),
52 '--platform', 'windows-amd64', 52 '--platform', cipd_platform,
53 '--dest-directory', cipd_directory 53 '--dest-directory', cipd_directory
54 ]) 54 ])
55 55
56 56
57 def cipd_install(args, dest_directory, package, version): 57 def cipd_install(args, dest_directory, package, version):
58 """Installs CIPD |package| at |version| into |dest_directory|.""" 58 """Installs CIPD |package| at |version| into |dest_directory|."""
59 manifest_file = tempfile.mktemp() 59 manifest_file = tempfile.mktemp()
60 try: 60 try:
61 with open(manifest_file, 'w') as f: 61 with open(manifest_file, 'w') as f:
62 f.write('%s %s\n' % (package, version)) 62 f.write('%s %s\n' % (package, version))
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 if os.path.relpath(git_directory, ROOT_DIR) not in f.read(): 96 if os.path.relpath(git_directory, ROOT_DIR) not in f.read():
97 return True 97 return True
98 if not os.path.exists(os.path.join( 98 if not os.path.exists(os.path.join(
99 git_directory, 'etc', 'profile.d', 'python.sh')): 99 git_directory, 'etc', 'profile.d', 'python.sh')):
100 return True 100 return True
101 return False 101 return False
102 102
103 103
104 def install_git(args, git_version, git_directory): 104 def install_git(args, git_version, git_directory):
105 """Installs |git_version| into |git_directory|.""" 105 """Installs |git_version| into |git_directory|."""
106 cipd_platform = 'windows-%s' % ('amd64' if args.bits == 64 else '386')
106 if not args.cipd_client: 107 if not args.cipd_client:
107 bootstrap_cipd(ROOT_DIR) 108 bootstrap_cipd(ROOT_DIR, cipd_platform)
108 args.cipd_client = os.path.join(ROOT_DIR, 'cipd') 109 args.cipd_client = os.path.join(ROOT_DIR, 'cipd')
109 temp_dir = tempfile.mkdtemp() 110 temp_dir = tempfile.mkdtemp()
110 try: 111 try:
111 cipd_install(args, 112 cipd_install(args,
112 temp_dir, 113 temp_dir,
113 'infra/depot_tools/git_installer/windows-amd64', 114 'infra/depot_tools/git_installer/%s' % cipd_platform,
114 'v' + git_version.replace('.', '_')) 115 'v' + git_version.replace('.', '_'))
115 116
116 if not os.path.exists(git_directory): 117 if not os.path.exists(git_directory):
117 os.makedirs(git_directory) 118 os.makedirs(git_directory)
118 119
119 # 7-zip has weird expectations for command-line syntax. Pass it as a string 120 # 7-zip has weird expectations for command-line syntax. Pass it as a string
120 # to avoid subprocess module quoting breaking it. Also double-escape 121 # to avoid subprocess module quoting breaking it. Also double-escape
121 # backslashes in paths. 122 # backslashes in paths.
122 _check_call(' '.join([ 123 _check_call(' '.join([
123 os.path.join(temp_dir, 'git-installer.exe'), 124 os.path.join(temp_dir, 'git-installer.exe'),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 # TODO(phajdan.jr): consider replacing the call with python code. 163 # TODO(phajdan.jr): consider replacing the call with python code.
163 _check_call([ 164 _check_call([
164 'xcopy', '/i', '/q', '/d', '/y', 165 'xcopy', '/i', '/q', '/d', '/y',
165 os.path.join(ROOT_DIR, 'man', 'html', '*'), 166 os.path.join(ROOT_DIR, 'man', 'html', '*'),
166 os.path.join(git_directory, 'mingw64', 'share', 'doc', 'git-doc')], 167 os.path.join(git_directory, 'mingw64', 'share', 'doc', 'git-doc')],
167 stdout=DEVNULL) 168 stdout=DEVNULL)
168 169
169 170
170 def main(argv): 171 def main(argv):
171 parser = argparse.ArgumentParser() 172 parser = argparse.ArgumentParser()
173 parser.add_argument('--bits', type=int, choices=(32,64), default=64,
174 help='Bitness of the client to install.')
172 parser.add_argument('--cipd-client', help='Path to CIPD client binary.') 175 parser.add_argument('--cipd-client', help='Path to CIPD client binary.')
173 parser.add_argument('--cipd-cache-directory', 176 parser.add_argument('--cipd-cache-directory',
174 help='Path to CIPD cache directory.') 177 help='Path to CIPD cache directory.')
175 parser.add_argument('--force', action='store_true', 178 parser.add_argument('--force', action='store_true',
176 help='Always re-install git.') 179 help='Always re-install git.')
177 parser.add_argument('--verbose', action='store_true') 180 parser.add_argument('--verbose', action='store_true')
178 args = parser.parse_args(argv) 181 args = parser.parse_args(argv)
179 182
180 if os.environ.get('WIN_TOOLS_FORCE') == '1': 183 if os.environ.get('WIN_TOOLS_FORCE') == '1':
181 args.force = True 184 args.force = True
182 185
183 logging.basicConfig(level=logging.INFO if args.verbose else logging.WARN) 186 logging.basicConfig(level=logging.INFO if args.verbose else logging.WARN)
184 187
185 git_version = get_target_git_version() 188 git_version = get_target_git_version()
186 git_directory = os.path.join(ROOT_DIR, 'git-%s-64_bin' % git_version) 189 git_directory = os.path.join(
190 ROOT_DIR, 'git-%s-%s_bin' % (git_version, args.bits))
187 191
188 clean_up_old_git_installations(git_directory) 192 clean_up_old_git_installations(git_directory)
189 193
190 if need_to_install_git(args, git_directory): 194 if need_to_install_git(args, git_directory):
191 install_git(args, git_version, git_directory) 195 install_git(args, git_version, git_directory)
192 196
193 sync_git_help_files(git_directory) 197 sync_git_help_files(git_directory)
194 198
195 return 0 199 return 0
196 200
197 201
198 if __name__ == '__main__': 202 if __name__ == '__main__':
199 sys.exit(main(sys.argv[1:])) 203 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698