OLD | NEW |
1 #!/bin/sh | 1 #!/bin/sh |
2 | 2 |
3 ## repo default configuration | 3 ## repo default configuration |
4 ## | 4 ## |
5 REPO_URL='http://android.git.kernel.org/tools/repo.git' | 5 REPO_URL='git://android.git.kernel.org/tools/repo.git' |
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, 9) | 31 VERSION = (1, 10) |
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 group.add_option('-b', '--manifest-branch', | 116 group.add_option('-b', '--manifest-branch', |
117 dest='manifest_branch', | 117 dest='manifest_branch', |
118 help='manifest branch or revision', metavar='REVISION') | 118 help='manifest branch or revision', metavar='REVISION') |
119 group.add_option('-m', '--manifest-name', | 119 group.add_option('-m', '--manifest-name', |
120 dest='manifest_name', | 120 dest='manifest_name', |
121 help='initial manifest file (deprecated)', | 121 help='initial manifest file (deprecated)', |
122 metavar='NAME.xml') | 122 metavar='NAME.xml') |
123 group.add_option('--mirror', | 123 group.add_option('--mirror', |
124 dest='mirror', action='store_true', | 124 dest='mirror', action='store_true', |
125 help='mirror the forrest') | 125 help='mirror the forrest') |
| 126 group.add_option('--reference', |
| 127 dest='reference', |
| 128 help='location of mirror directory', metavar='DIR') |
126 | 129 |
127 # Tool | 130 # Tool |
128 group = init_optparse.add_option_group('repo Version options') | 131 group = init_optparse.add_option_group('repo Version options') |
129 group.add_option('--repo-url', | 132 group.add_option('--repo-url', |
130 dest='repo_url', | 133 dest='repo_url', |
131 help='repo repository location', metavar='URL') | 134 help='repo repository location', metavar='URL') |
132 group.add_option('--repo-branch', | 135 group.add_option('--repo-branch', |
133 dest='repo_branch', | 136 dest='repo_branch', |
134 help='repo branch or revision', metavar='REVISION') | 137 help='repo branch or revision', metavar='REVISION') |
135 group.add_option('--no-repo-verify', | 138 group.add_option('--no-repo-verify', |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 | 257 |
255 if not os.path.isdir(gpg_dir): | 258 if not os.path.isdir(gpg_dir): |
256 try: | 259 try: |
257 os.mkdir(gpg_dir, 0700) | 260 os.mkdir(gpg_dir, 0700) |
258 except OSError, e: | 261 except OSError, e: |
259 print >>sys.stderr, \ | 262 print >>sys.stderr, \ |
260 'fatal: cannot make %s directory: %s' % ( | 263 'fatal: cannot make %s directory: %s' % ( |
261 gpg_dir, e.strerror) | 264 gpg_dir, e.strerror) |
262 sys.exit(1) | 265 sys.exit(1) |
263 | 266 |
264 env = dict(os.environ) | 267 env = os.environ.copy() |
265 env['GNUPGHOME'] = gpg_dir | 268 env['GNUPGHOME'] = gpg_dir.encode() |
266 | 269 |
267 cmd = ['gpg', '--import'] | 270 cmd = ['gpg', '--import'] |
268 try: | 271 try: |
269 proc = subprocess.Popen(cmd, | 272 proc = subprocess.Popen(cmd, |
270 env = env, | 273 env = env, |
271 stdin = subprocess.PIPE) | 274 stdin = subprocess.PIPE) |
272 except OSError, e: | 275 except OSError, e: |
273 if not quiet: | 276 if not quiet: |
274 print >>sys.stderr, 'warning: gpg (GnuPG) is not available.' | 277 print >>sys.stderr, 'warning: gpg (GnuPG) is not available.' |
275 print >>sys.stderr, 'warning: Installing it is strongly encouraged.' | 278 print >>sys.stderr, 'warning: Installing it is strongly encouraged.' |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 m = re.compile(r'^(.*)-[0-9]{1,}-g[0-9a-f]{1,}$').match(cur) | 376 m = re.compile(r'^(.*)-[0-9]{1,}-g[0-9a-f]{1,}$').match(cur) |
374 if m: | 377 if m: |
375 cur = m.group(1) | 378 cur = m.group(1) |
376 if not quiet: | 379 if not quiet: |
377 print >>sys.stderr | 380 print >>sys.stderr |
378 print >>sys.stderr, \ | 381 print >>sys.stderr, \ |
379 "info: Ignoring branch '%s'; using tagged release '%s'" \ | 382 "info: Ignoring branch '%s'; using tagged release '%s'" \ |
380 % (branch, cur) | 383 % (branch, cur) |
381 print >>sys.stderr | 384 print >>sys.stderr |
382 | 385 |
383 env = dict(os.environ) | 386 env = os.environ.copy() |
384 env['GNUPGHOME'] = gpg_dir | 387 env['GNUPGHOME'] = gpg_dir.encode() |
385 | 388 |
386 cmd = [GIT, 'tag', '-v', cur] | 389 cmd = [GIT, 'tag', '-v', cur] |
387 proc = subprocess.Popen(cmd, | 390 proc = subprocess.Popen(cmd, |
388 stdout = subprocess.PIPE, | 391 stdout = subprocess.PIPE, |
389 stderr = subprocess.PIPE, | 392 stderr = subprocess.PIPE, |
390 cwd = cwd, | 393 cwd = cwd, |
391 env = env) | 394 env = env) |
392 out = proc.stdout.read() | 395 out = proc.stdout.read() |
393 proc.stdout.close() | 396 proc.stdout.close() |
394 | 397 |
(...skipping 30 matching lines...) Expand all Loading... |
425 if subprocess.Popen(cmd, cwd = cwd).wait() != 0: | 428 if subprocess.Popen(cmd, cwd = cwd).wait() != 0: |
426 raise CloneFailure() | 429 raise CloneFailure() |
427 | 430 |
428 | 431 |
429 def _FindRepo(): | 432 def _FindRepo(): |
430 """Look for a repo installation, starting at the current directory. | 433 """Look for a repo installation, starting at the current directory. |
431 """ | 434 """ |
432 dir = os.getcwd() | 435 dir = os.getcwd() |
433 repo = None | 436 repo = None |
434 | 437 |
435 while dir != '/' and not repo: | 438 olddir = None |
| 439 while dir != '/' \ |
| 440 and dir != olddir \ |
| 441 and not repo: |
436 repo = os.path.join(dir, repodir, REPO_MAIN) | 442 repo = os.path.join(dir, repodir, REPO_MAIN) |
437 if not os.path.isfile(repo): | 443 if not os.path.isfile(repo): |
438 repo = None | 444 repo = None |
| 445 olddir = dir |
439 dir = os.path.dirname(dir) | 446 dir = os.path.dirname(dir) |
440 return (repo, os.path.join(dir, repodir)) | 447 return (repo, os.path.join(dir, repodir)) |
441 | 448 |
442 | 449 |
443 class _Options: | 450 class _Options: |
444 help = False | 451 help = False |
445 | 452 |
446 | 453 |
447 def _ParseArguments(args): | 454 def _ParseArguments(args): |
448 cmd = None | 455 cmd = None |
(...skipping 25 matching lines...) Expand all Loading... |
474 | 481 |
475 For access to the full online help, install repo ("repo init"). | 482 For access to the full online help, install repo ("repo init"). |
476 """ | 483 """ |
477 sys.exit(1) | 484 sys.exit(1) |
478 | 485 |
479 | 486 |
480 def _Help(args): | 487 def _Help(args): |
481 if args: | 488 if args: |
482 if args[0] == 'init': | 489 if args[0] == 'init': |
483 init_optparse.print_help() | 490 init_optparse.print_help() |
| 491 sys.exit(0) |
484 else: | 492 else: |
485 print >>sys.stderr,\ | 493 print >>sys.stderr,\ |
486 "error: '%s' is not a bootstrap command.\n"\ | 494 "error: '%s' is not a bootstrap command.\n"\ |
487 ' For access to online help, install repo ("repo init").'\ | 495 ' For access to online help, install repo ("repo init").'\ |
488 % args[0] | 496 % args[0] |
489 else: | 497 else: |
490 _Usage() | 498 _Usage() |
491 sys.exit(1) | 499 sys.exit(1) |
492 | 500 |
493 | 501 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 os.execv(main, me) | 595 os.execv(main, me) |
588 except OSError, e: | 596 except OSError, e: |
589 print >>sys.stderr, "fatal: unable to start %s" % main | 597 print >>sys.stderr, "fatal: unable to start %s" % main |
590 print >>sys.stderr, "fatal: %s" % e | 598 print >>sys.stderr, "fatal: %s" % e |
591 sys.exit(148) | 599 sys.exit(148) |
592 | 600 |
593 | 601 |
594 if __name__ == '__main__': | 602 if __name__ == '__main__': |
595 main(sys.argv[1:]) | 603 main(sys.argv[1:]) |
596 | 604 |
OLD | NEW |