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

Side by Side Diff: repo

Issue 8540026: Update version of repo. Most importantly this takes repo from (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Created 9 years, 1 month 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 | Annotate | Revision Log
« 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 #!/bin/sh 1 #!/bin/sh
2 2
3 ## repo default configuration 3 ## repo default configuration
4 ## 4 ##
5 REPO_URL='http://git.chromium.org/external/repo.git' 5 REPO_URL='https://code.google.com/p/git-repo/'
6 REPO_REV='stable' 6 REPO_REV='stable'
7 7
8 # Copyright (C) 2008 Google Inc. 8 # Copyright (C) 2008 Google Inc.
9 # 9 #
10 # Licensed under the Apache License, Version 2.0 (the "License"); 10 # Licensed under the Apache License, Version 2.0 (the "License");
11 # you may not use this file except in compliance with the License. 11 # you may not use this file except in compliance with the License.
12 # You may obtain a copy of the License at 12 # You may obtain a copy of the License at
13 # 13 #
14 # http://www.apache.org/licenses/LICENSE-2.0 14 # http://www.apache.org/licenses/LICENSE-2.0
15 # 15 #
16 # Unless required by applicable law or agreed to in writing, software 16 # Unless required by applicable law or agreed to in writing, software
17 # distributed under the License is distributed on an "AS IS" BASIS, 17 # distributed under the License is distributed on an "AS IS" BASIS,
18 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 # See the License for the specific language governing permissions and 19 # See the License for the specific language governing permissions and
20 # limitations under the License. 20 # limitations under the License.
21 21
22 magic='--calling-python-from-/bin/sh--' 22 magic='--calling-python-from-/bin/sh--'
23 """exec" python -E "$0" "$@" """#$magic" 23 """exec" python -E "$0" "$@" """#$magic"
24 if __name__ == '__main__': 24 if __name__ == '__main__':
25 import sys 25 import sys
26 if sys.argv[-1] == '#%s' % magic: 26 if sys.argv[-1] == '#%s' % magic:
27 del sys.argv[-1] 27 del sys.argv[-1]
28 del magic 28 del magic
29 29
30 # increment this whenever we make important changes to this script 30 # increment this whenever we make important changes to this script
31 VERSION = (1, 11) 31 VERSION = (1, 13)
32 32
33 # increment this if the MAINTAINER_KEYS block is modified 33 # increment this if the MAINTAINER_KEYS block is modified
34 KEYRING_VERSION = (1,0) 34 KEYRING_VERSION = (1,0)
35 MAINTAINER_KEYS = """ 35 MAINTAINER_KEYS = """
36 36
37 Repo Maintainer <repo@android.kernel.org> 37 Repo Maintainer <repo@android.kernel.org>
38 -----BEGIN PGP PUBLIC KEY BLOCK----- 38 -----BEGIN PGP PUBLIC KEY BLOCK-----
39 Version: GnuPG v1.4.2.2 (GNU/Linux) 39 Version: GnuPG v1.4.2.2 (GNU/Linux)
40 40
41 mQGiBEj3ugERBACrLJh/ZPyVSKeClMuznFIrsQ+hpNnmJGw1a9GXKYKk8qHPhAZf 41 mQGiBEj3ugERBACrLJh/ZPyVSKeClMuznFIrsQ+hpNnmJGw1a9GXKYKk8qHPhAZf
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 S_manifests = 'manifests' # special manifest repository 84 S_manifests = 'manifests' # special manifest repository
85 REPO_MAIN = S_repo + '/main.py' # main script 85 REPO_MAIN = S_repo + '/main.py' # main script
86 86
87 87
88 import optparse 88 import optparse
89 import os 89 import os
90 import re 90 import re
91 import readline 91 import readline
92 import subprocess 92 import subprocess
93 import sys 93 import sys
94 import urllib2
94 95
95 home_dot_repo = os.path.expanduser('~/.repoconfig') 96 home_dot_repo = os.path.expanduser('~/.repoconfig')
96 gpg_dir = os.path.join(home_dot_repo, 'gnupg') 97 gpg_dir = os.path.join(home_dot_repo, 'gnupg')
97 98
98 extra_args = [] 99 extra_args = []
99 init_optparse = optparse.OptionParser(usage="repo init -u url [options]") 100 init_optparse = optparse.OptionParser(usage="repo init -u url [options]")
100 101
101 # Logging 102 # Logging
102 group = init_optparse.add_option_group('Logging options') 103 group = init_optparse.add_option_group('Logging options')
103 group.add_option('-q', '--quiet', 104 group.add_option('-q', '--quiet',
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 # 181 #
181 sys.exit(1) 182 sys.exit(1)
182 183
183 _CheckGitVersion() 184 _CheckGitVersion()
184 try: 185 try:
185 if _NeedSetupGnuPG(): 186 if _NeedSetupGnuPG():
186 can_verify = _SetupGnuPG(opt.quiet) 187 can_verify = _SetupGnuPG(opt.quiet)
187 else: 188 else:
188 can_verify = True 189 can_verify = True
189 190
190 if not opt.quiet:
191 print >>sys.stderr, 'Getting repo ...'
192 print >>sys.stderr, ' from %s' % url
193
194 dst = os.path.abspath(os.path.join(repodir, S_repo)) 191 dst = os.path.abspath(os.path.join(repodir, S_repo))
195 _Clone(url, dst, opt.quiet) 192 _Clone(url, dst, opt.quiet)
196 193
197 if can_verify and not opt.no_repo_verify: 194 if can_verify and not opt.no_repo_verify:
198 rev = _Verify(dst, branch, opt.quiet) 195 rev = _Verify(dst, branch, opt.quiet)
199 else: 196 else:
200 rev = 'refs/remotes/origin/%s^0' % branch 197 rev = 'refs/remotes/origin/%s^0' % branch
201 198
202 _Checkout(dst, branch, rev, opt.quiet) 199 _Checkout(dst, branch, rev, opt.quiet)
203 except CloneFailure: 200 except CloneFailure:
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 290
294 291
295 def _SetConfig(local, name, value): 292 def _SetConfig(local, name, value):
296 """Set a git configuration option to the specified value. 293 """Set a git configuration option to the specified value.
297 """ 294 """
298 cmd = [GIT, 'config', name, value] 295 cmd = [GIT, 'config', name, value]
299 if subprocess.Popen(cmd, cwd = local).wait() != 0: 296 if subprocess.Popen(cmd, cwd = local).wait() != 0:
300 raise CloneFailure() 297 raise CloneFailure()
301 298
302 299
303 def _Fetch(local, quiet, *args): 300 def _InitHttp():
301 handlers = []
302
303 mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
304 try:
305 import netrc
306 n = netrc.netrc()
307 for host in n.hosts:
308 p = n.hosts[host]
309 mgr.add_password(None, 'http://%s/' % host, p[0], p[2])
310 mgr.add_password(None, 'https://%s/' % host, p[0], p[2])
311 except:
312 pass
313 handlers.append(urllib2.HTTPBasicAuthHandler(mgr))
314
315 if 'http_proxy' in os.environ:
316 url = os.environ['http_proxy']
317 handlers.append(urllib2.ProxyHandler({'http': url, 'https': url}))
318 if 'REPO_CURL_VERBOSE' in os.environ:
319 handlers.append(urllib2.HTTPHandler(debuglevel=1))
320 handlers.append(urllib2.HTTPSHandler(debuglevel=1))
321 urllib2.install_opener(urllib2.build_opener(*handlers))
322
323 def _Fetch(url, local, src, quiet):
324 if not quiet:
325 print >>sys.stderr, 'Get %s' % url
326
304 cmd = [GIT, 'fetch'] 327 cmd = [GIT, 'fetch']
305 if quiet: 328 if quiet:
306 cmd.append('--quiet') 329 cmd.append('--quiet')
307 err = subprocess.PIPE 330 err = subprocess.PIPE
308 else: 331 else:
309 err = None 332 err = None
310 cmd.extend(args) 333 cmd.append(src)
311 cmd.append('origin') 334 cmd.append('+refs/heads/*:refs/remotes/origin/*')
335 cmd.append('refs/tags/*:refs/tags/*')
312 336
313 proc = subprocess.Popen(cmd, cwd = local, stderr = err) 337 proc = subprocess.Popen(cmd, cwd = local, stderr = err)
314 if err: 338 if err:
315 proc.stderr.read() 339 proc.stderr.read()
316 proc.stderr.close() 340 proc.stderr.close()
317 if proc.wait() != 0: 341 if proc.wait() != 0:
318 raise CloneFailure() 342 raise CloneFailure()
319 343
344 def _DownloadBundle(url, local, quiet):
345 if not url.endswith('/'):
346 url += '/'
347 url += 'clone.bundle'
348
349 proc = subprocess.Popen(
350 [GIT, 'config', '--get-regexp', 'url.*.insteadof'],
351 cwd = local,
352 stdout = subprocess.PIPE)
353 for line in proc.stdout:
354 m = re.compile(r'^url\.(.*)\.insteadof (.*)$').match(line)
355 if m:
356 new_url = m.group(1)
357 old_url = m.group(2)
358 if url.startswith(old_url):
359 url = new_url + url[len(old_url):]
360 break
361 proc.stdout.close()
362 proc.wait()
363
364 if not url.startswith('http:') and not url.startswith('https:'):
365 return False
366
367 dest = open(os.path.join(local, '.git', 'clone.bundle'), 'w+b')
368 try:
369 try:
370 r = urllib2.urlopen(url)
371 except urllib2.HTTPError, e:
372 if e.code == 404:
373 return False
374 print >>sys.stderr, 'fatal: Cannot get %s' % url
375 print >>sys.stderr, 'fatal: HTTP error %s' % e.code
376 raise CloneFailure()
377 except urllib2.URLError, e:
378 print >>sys.stderr, 'fatal: Cannot get %s' % url
379 print >>sys.stderr, 'fatal: error %s' % e.reason
380 raise CloneFailure()
381 try:
382 if not quiet:
383 print >>sys.stderr, 'Get %s' % url
384 while True:
385 buf = r.read(8192)
386 if buf == '':
387 return True
388 dest.write(buf)
389 finally:
390 r.close()
391 finally:
392 dest.close()
393
394 def _ImportBundle(local):
395 path = os.path.join(local, '.git', 'clone.bundle')
396 try:
397 _Fetch(local, local, path, True)
398 finally:
399 os.remove(path)
320 400
321 def _Clone(url, local, quiet): 401 def _Clone(url, local, quiet):
322 """Clones a git repository to a new subdirectory of repodir 402 """Clones a git repository to a new subdirectory of repodir
323 """ 403 """
324 try: 404 try:
325 os.mkdir(local) 405 os.mkdir(local)
326 except OSError, e: 406 except OSError, e:
327 print >>sys.stderr, \ 407 print >>sys.stderr, \
328 'fatal: cannot make %s directory: %s' \ 408 'fatal: cannot make %s directory: %s' \
329 % (local, e.strerror) 409 % (local, e.strerror)
330 raise CloneFailure() 410 raise CloneFailure()
331 411
332 cmd = [GIT, 'init', '--quiet'] 412 cmd = [GIT, 'init', '--quiet']
333 try: 413 try:
334 proc = subprocess.Popen(cmd, cwd = local) 414 proc = subprocess.Popen(cmd, cwd = local)
335 except OSError, e: 415 except OSError, e:
336 print >>sys.stderr 416 print >>sys.stderr
337 print >>sys.stderr, "fatal: '%s' is not available" % GIT 417 print >>sys.stderr, "fatal: '%s' is not available" % GIT
338 print >>sys.stderr, 'fatal: %s' % e 418 print >>sys.stderr, 'fatal: %s' % e
339 print >>sys.stderr 419 print >>sys.stderr
340 print >>sys.stderr, 'Please make sure %s is installed'\ 420 print >>sys.stderr, 'Please make sure %s is installed'\
341 ' and in your path.' % GIT 421 ' and in your path.' % GIT
342 raise CloneFailure() 422 raise CloneFailure()
343 if proc.wait() != 0: 423 if proc.wait() != 0:
344 print >>sys.stderr, 'fatal: could not create %s' % local 424 print >>sys.stderr, 'fatal: could not create %s' % local
345 raise CloneFailure() 425 raise CloneFailure()
346 426
427 _InitHttp()
347 _SetConfig(local, 'remote.origin.url', url) 428 _SetConfig(local, 'remote.origin.url', url)
348 _SetConfig(local, 'remote.origin.fetch', 429 _SetConfig(local, 'remote.origin.fetch',
349 '+refs/heads/*:refs/remotes/origin/*') 430 '+refs/heads/*:refs/remotes/origin/*')
350 _Fetch(local, quiet) 431 if _DownloadBundle(url, local, quiet):
351 _Fetch(local, quiet, '--tags') 432 _ImportBundle(local)
433 else:
434 _Fetch(url, local, 'origin', quiet)
352 435
353 436
354 def _Verify(cwd, branch, quiet): 437 def _Verify(cwd, branch, quiet):
355 """Verify the branch has been signed by a tag. 438 """Verify the branch has been signed by a tag.
356 """ 439 """
357 cmd = [GIT, 'describe', 'origin/%s' % branch] 440 cmd = [GIT, 'describe', 'origin/%s' % branch]
358 proc = subprocess.Popen(cmd, 441 proc = subprocess.Popen(cmd,
359 stdout=subprocess.PIPE, 442 stdout=subprocess.PIPE,
360 stderr=subprocess.PIPE, 443 stderr=subprocess.PIPE,
361 cwd = cwd) 444 cwd = cwd)
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 try: 676 try:
594 os.execv(main, me) 677 os.execv(main, me)
595 except OSError, e: 678 except OSError, e:
596 print >>sys.stderr, "fatal: unable to start %s" % main 679 print >>sys.stderr, "fatal: unable to start %s" % main
597 print >>sys.stderr, "fatal: %s" % e 680 print >>sys.stderr, "fatal: %s" % e
598 sys.exit(148) 681 sys.exit(148)
599 682
600 683
601 if __name__ == '__main__': 684 if __name__ == '__main__':
602 main(sys.argv[1:]) 685 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