summaryrefslogtreecommitdiffstats
path: root/repo
diff options
context:
space:
mode:
Diffstat (limited to 'repo')
-rwxr-xr-xrepo202
1 files changed, 111 insertions, 91 deletions
diff --git a/repo b/repo
index 602cf0cf..62e6ea51 100755
--- a/repo
+++ b/repo
@@ -2,7 +2,6 @@
2 2
3## repo default configuration 3## repo default configuration
4## 4##
5from __future__ import print_function
6REPO_URL = 'https://gerrit.googlesource.com/git-repo' 5REPO_URL = 'https://gerrit.googlesource.com/git-repo'
7REPO_REV = 'stable' 6REPO_REV = 'stable'
8 7
@@ -21,10 +20,10 @@ REPO_REV = 'stable'
21# limitations under the License. 20# limitations under the License.
22 21
23# increment this whenever we make important changes to this script 22# increment this whenever we make important changes to this script
24VERSION = (1, 19) 23VERSION = (1, 20)
25 24
26# increment this if the MAINTAINER_KEYS block is modified 25# increment this if the MAINTAINER_KEYS block is modified
27KEYRING_VERSION = (1, 1) 26KEYRING_VERSION = (1, 2)
28MAINTAINER_KEYS = """ 27MAINTAINER_KEYS = """
29 28
30 Repo Maintainer <repo@android.kernel.org> 29 Repo Maintainer <repo@android.kernel.org>
@@ -73,32 +72,32 @@ TACbBS+Up3RpfYVfd63c1cDdlru13pQAn3NQy/SN858MkxN+zym86UBgOad2
73-----BEGIN PGP PUBLIC KEY BLOCK----- 72-----BEGIN PGP PUBLIC KEY BLOCK-----
74Version: GnuPG v1.4.11 (GNU/Linux) 73Version: GnuPG v1.4.11 (GNU/Linux)
75 74
76mQENBFBiLPwBCACvISTASOgFXwADw2GYRH2I2z9RvYkYoZ6ThTTNlMXbbYYKO2Wo 75mQENBFHRvc8BCADFg45Xx/y6QDC+T7Y/gGc7vx0ww7qfOwIKlAZ9xG3qKunMxo+S
77a9LQDNW0TbCEekg5UKk0FD13XOdWaqUt4Gtuvq9c43GRSjMO6NXH+0BjcQ8vUtY2 76hPCnzEl3cq+6I1Ww/ndop/HB3N3toPXRCoN8Vs4/Hc7by+SnaLFnacrm+tV5/OgT
78/W4CYUevwdo4nQ1+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bDAAK 93V45+1Nnx/uuCxDbeI4RbHzujnxDiq70AEQEAAYkBHwQYAQIACQUCUdG9zwIbDAAK
95CRAZJpRVM4hxpNfkB/0W/hP5WK/NETXBlWXXW7JPaWO2c5kGwD0lnj5RRmridyo1 94CRBnt+RIaSs4LNVeB/0Y2pZ8I7gAAcEM0Xw8drr4omg2fUoK1J33ozlA/RxeA/lJ
96vbm5PdM91jOsDQYqRu6YOoYBnDnEhB2wL2bPh34HWwwrA+LwB8hlcAV2z1bdwyfl 95I3KnyCDTpXuIeBKPGkdL8uMATC9Z8DnBBajRlftNDVZS3Hz4G09G9QpMojvJkFJV
973R823fReKN3QcvLHzmvZPrF4Rk97M9UIyKS0RtnfTWykRgDWHIsrtQPoNwsXrWoT 96By+01Flw/X+eeN8NpqSuLV4W+AjEO8at/VvgKr1AFvBRdZ7GkpI1o6DgPe7ZqX+1
989LrM2v+1+9mp3vuXnE473/NHxmiWEQH9Ez+O/mOxQ7rSOlqGRiKq/IBZCfioJOtV 97dzQZt3e13W0rVBb/bUgx9iSLoeWP3aq/k+/GRGOR+S6F6BBSl0SQ2EF2+dIywb1x
99fTQeIu/yASZnsLBqr6SJEGwYBoWcyjG++k4fyw8ocOAo4uGDYbxgN7yYfNQ0OH7o 98JuinEP+AwLAUZ1Bsx9ISC0Agpk2VeHXPL3FGhroEmoMvBzO0kTFGyoeT7PR/BfKv
100V6pfUgqKLWa/aK7/N1ZHnPdFLD8Xt0Dmy4BPwrKC 99+H/g3HsL2LOB9uoIm8/5p2TTU5ttYCXMHhQZ81AY
101=O7am 100=AUp4
102-----END PGP PUBLIC KEY BLOCK----- 101-----END PGP PUBLIC KEY BLOCK-----
103""" 102"""
104 103
@@ -108,6 +107,7 @@ repodir = '.repo' # name of repo's private directory
108S_repo = 'repo' # special repo repository 107S_repo = 'repo' # special repo repository
109S_manifests = 'manifests' # special manifest repository 108S_manifests = 'manifests' # special manifest repository
110REPO_MAIN = S_repo + '/main.py' # main script 109REPO_MAIN = S_repo + '/main.py' # main script
110MIN_PYTHON_VERSION = (2, 6) # minimum supported python version
111 111
112 112
113import optparse 113import optparse
@@ -116,19 +116,38 @@ import re
116import stat 116import stat
117import subprocess 117import subprocess
118import sys 118import sys
119try: 119
120 import urllib2 120if sys.version_info[0] == 3:
121except ImportError:
122 # For python3
123 import urllib.request 121 import urllib.request
124 import urllib.error 122 import urllib.error
125else: 123else:
126 # For python2
127 import imp 124 import imp
125 import urllib2
128 urllib = imp.new_module('urllib') 126 urllib = imp.new_module('urllib')
129 urllib.request = urllib2 127 urllib.request = urllib2
130 urllib.error = urllib2 128 urllib.error = urllib2
131 129
130
131def _print(*objects, **kwargs):
132 sep = kwargs.get('sep', ' ')
133 end = kwargs.get('end', '\n')
134 out = kwargs.get('file', sys.stdout)
135 out.write(sep.join(objects) + end)
136
137
138# Python version check
139ver = sys.version_info
140if ver[0] == 3:
141 _print('error: Python 3 support is not fully implemented in repo yet.\n'
142 'Please use Python 2.6 - 2.7 instead.',
143 file=sys.stderr)
144 sys.exit(1)
145if (ver[0], ver[1]) < MIN_PYTHON_VERSION:
146 _print('error: Python version %s unsupported.\n'
147 'Please use Python 2.6 - 2.7 instead.'
148 % sys.version.split(' ')[0], file=sys.stderr)
149 sys.exit(1)
150
132home_dot_repo = os.path.expanduser('~/.repoconfig') 151home_dot_repo = os.path.expanduser('~/.repoconfig')
133gpg_dir = os.path.join(home_dot_repo, 'gnupg') 152gpg_dir = os.path.join(home_dot_repo, 'gnupg')
134 153
@@ -164,7 +183,8 @@ group.add_option('--depth', type='int', default=None,
164 help='create a shallow clone with given depth; see git clone') 183 help='create a shallow clone with given depth; see git clone')
165group.add_option('-g', '--groups', 184group.add_option('-g', '--groups',
166 dest='groups', default='default', 185 dest='groups', default='default',
167 help='restrict manifest projects to ones with a specified group', 186 help='restrict manifest projects to ones with specified '
187 'group(s) [default|all|G1,G2,G3|G4,-G5,-G6]',
168 metavar='GROUP') 188 metavar='GROUP')
169group.add_option('-p', '--platform', 189group.add_option('-p', '--platform',
170 dest='platform', default="auto", 190 dest='platform', default="auto",
@@ -217,15 +237,15 @@ def _Init(args):
217 if branch.startswith('refs/heads/'): 237 if branch.startswith('refs/heads/'):
218 branch = branch[len('refs/heads/'):] 238 branch = branch[len('refs/heads/'):]
219 if branch.startswith('refs/'): 239 if branch.startswith('refs/'):
220 print("fatal: invalid branch name '%s'" % branch, file=sys.stderr) 240 _print("fatal: invalid branch name '%s'" % branch, file=sys.stderr)
221 raise CloneFailure() 241 raise CloneFailure()
222 242
223 if not os.path.isdir(repodir): 243 if not os.path.isdir(repodir):
224 try: 244 try:
225 os.mkdir(repodir) 245 os.mkdir(repodir)
226 except OSError as e: 246 except OSError as e:
227 print('fatal: cannot make %s directory: %s' 247 _print('fatal: cannot make %s directory: %s'
228 % (repodir, e.strerror), file=sys.stderr) 248 % (repodir, e.strerror), file=sys.stderr)
229 # Don't raise CloneFailure; that would delete the 249 # Don't raise CloneFailure; that would delete the
230 # name. Instead exit immediately. 250 # name. Instead exit immediately.
231 # 251 #
@@ -249,8 +269,8 @@ def _Init(args):
249 _Checkout(dst, branch, rev, opt.quiet) 269 _Checkout(dst, branch, rev, opt.quiet)
250 except CloneFailure: 270 except CloneFailure:
251 if opt.quiet: 271 if opt.quiet:
252 print('fatal: repo init failed; run without --quiet to see why', 272 _print('fatal: repo init failed; run without --quiet to see why',
253 file=sys.stderr) 273 file=sys.stderr)
254 raise 274 raise
255 275
256 276
@@ -259,12 +279,12 @@ def _CheckGitVersion():
259 try: 279 try:
260 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) 280 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
261 except OSError as e: 281 except OSError as e:
262 print(file=sys.stderr) 282 _print(file=sys.stderr)
263 print("fatal: '%s' is not available" % GIT, file=sys.stderr) 283 _print("fatal: '%s' is not available" % GIT, file=sys.stderr)
264 print('fatal: %s' % e, file=sys.stderr) 284 _print('fatal: %s' % e, file=sys.stderr)
265 print(file=sys.stderr) 285 _print(file=sys.stderr)
266 print('Please make sure %s is installed and in your path.' % GIT, 286 _print('Please make sure %s is installed and in your path.' % GIT,
267 file=sys.stderr) 287 file=sys.stderr)
268 raise CloneFailure() 288 raise CloneFailure()
269 289
270 ver_str = proc.stdout.read().strip() 290 ver_str = proc.stdout.read().strip()
@@ -272,14 +292,14 @@ def _CheckGitVersion():
272 proc.wait() 292 proc.wait()
273 293
274 if not ver_str.startswith('git version '): 294 if not ver_str.startswith('git version '):
275 print('error: "%s" unsupported' % ver_str, file=sys.stderr) 295 _print('error: "%s" unsupported' % ver_str, file=sys.stderr)
276 raise CloneFailure() 296 raise CloneFailure()
277 297
278 ver_str = ver_str[len('git version '):].strip() 298 ver_str = ver_str[len('git version '):].strip()
279 ver_act = tuple(map(int, ver_str.split('.')[0:3])) 299 ver_act = tuple(map(int, ver_str.split('.')[0:3]))
280 if ver_act < MIN_GIT_VERSION: 300 if ver_act < MIN_GIT_VERSION:
281 need = '.'.join(map(str, MIN_GIT_VERSION)) 301 need = '.'.join(map(str, MIN_GIT_VERSION))
282 print('fatal: git %s or later required' % need, file=sys.stderr) 302 _print('fatal: git %s or later required' % need, file=sys.stderr)
283 raise CloneFailure() 303 raise CloneFailure()
284 304
285 305
@@ -306,16 +326,16 @@ def SetupGnuPG(quiet):
306 try: 326 try:
307 os.mkdir(home_dot_repo) 327 os.mkdir(home_dot_repo)
308 except OSError as e: 328 except OSError as e:
309 print('fatal: cannot make %s directory: %s' 329 _print('fatal: cannot make %s directory: %s'
310 % (home_dot_repo, e.strerror), file=sys.stderr) 330 % (home_dot_repo, e.strerror), file=sys.stderr)
311 sys.exit(1) 331 sys.exit(1)
312 332
313 if not os.path.isdir(gpg_dir): 333 if not os.path.isdir(gpg_dir):
314 try: 334 try:
315 os.mkdir(gpg_dir, stat.S_IRWXU) 335 os.mkdir(gpg_dir, stat.S_IRWXU)
316 except OSError as e: 336 except OSError as e:
317 print('fatal: cannot make %s directory: %s' % (gpg_dir, e.strerror), 337 _print('fatal: cannot make %s directory: %s' % (gpg_dir, e.strerror),
318 file=sys.stderr) 338 file=sys.stderr)
319 sys.exit(1) 339 sys.exit(1)
320 340
321 env = os.environ.copy() 341 env = os.environ.copy()
@@ -328,18 +348,18 @@ def SetupGnuPG(quiet):
328 stdin = subprocess.PIPE) 348 stdin = subprocess.PIPE)
329 except OSError as e: 349 except OSError as e:
330 if not quiet: 350 if not quiet:
331 print('warning: gpg (GnuPG) is not available.', file=sys.stderr) 351 _print('warning: gpg (GnuPG) is not available.', file=sys.stderr)
332 print('warning: Installing it is strongly encouraged.', file=sys.stderr) 352 _print('warning: Installing it is strongly encouraged.', file=sys.stderr)
333 print(file=sys.stderr) 353 _print(file=sys.stderr)
334 return False 354 return False
335 355
336 proc.stdin.write(MAINTAINER_KEYS) 356 proc.stdin.write(MAINTAINER_KEYS)
337 proc.stdin.close() 357 proc.stdin.close()
338 358
339 if proc.wait() != 0: 359 if proc.wait() != 0:
340 print('fatal: registering repo maintainer keys failed', file=sys.stderr) 360 _print('fatal: registering repo maintainer keys failed', file=sys.stderr)
341 sys.exit(1) 361 sys.exit(1)
342 print() 362 _print()
343 363
344 fd = open(os.path.join(home_dot_repo, 'keyring-version'), 'w') 364 fd = open(os.path.join(home_dot_repo, 'keyring-version'), 'w')
345 fd.write('.'.join(map(str, KEYRING_VERSION)) + '\n') 365 fd.write('.'.join(map(str, KEYRING_VERSION)) + '\n')
@@ -381,7 +401,7 @@ def _InitHttp():
381 401
382def _Fetch(url, local, src, quiet): 402def _Fetch(url, local, src, quiet):
383 if not quiet: 403 if not quiet:
384 print('Get %s' % url, file=sys.stderr) 404 _print('Get %s' % url, file=sys.stderr)
385 405
386 cmd = [GIT, 'fetch'] 406 cmd = [GIT, 'fetch']
387 if quiet: 407 if quiet:
@@ -430,16 +450,16 @@ def _DownloadBundle(url, local, quiet):
430 except urllib.error.HTTPError as e: 450 except urllib.error.HTTPError as e:
431 if e.code in [403, 404]: 451 if e.code in [403, 404]:
432 return False 452 return False
433 print('fatal: Cannot get %s' % url, file=sys.stderr) 453 _print('fatal: Cannot get %s' % url, file=sys.stderr)
434 print('fatal: HTTP error %s' % e.code, file=sys.stderr) 454 _print('fatal: HTTP error %s' % e.code, file=sys.stderr)
435 raise CloneFailure() 455 raise CloneFailure()
436 except urllib.error.URLError as e: 456 except urllib.error.URLError as e:
437 print('fatal: Cannot get %s' % url, file=sys.stderr) 457 _print('fatal: Cannot get %s' % url, file=sys.stderr)
438 print('fatal: error %s' % e.reason, file=sys.stderr) 458 _print('fatal: error %s' % e.reason, file=sys.stderr)
439 raise CloneFailure() 459 raise CloneFailure()
440 try: 460 try:
441 if not quiet: 461 if not quiet:
442 print('Get %s' % url, file=sys.stderr) 462 _print('Get %s' % url, file=sys.stderr)
443 while True: 463 while True:
444 buf = r.read(8192) 464 buf = r.read(8192)
445 if buf == '': 465 if buf == '':
@@ -463,23 +483,23 @@ def _Clone(url, local, quiet):
463 try: 483 try:
464 os.mkdir(local) 484 os.mkdir(local)
465 except OSError as e: 485 except OSError as e:
466 print('fatal: cannot make %s directory: %s' % (local, e.strerror), 486 _print('fatal: cannot make %s directory: %s' % (local, e.strerror),
467 file=sys.stderr) 487 file=sys.stderr)
468 raise CloneFailure() 488 raise CloneFailure()
469 489
470 cmd = [GIT, 'init', '--quiet'] 490 cmd = [GIT, 'init', '--quiet']
471 try: 491 try:
472 proc = subprocess.Popen(cmd, cwd = local) 492 proc = subprocess.Popen(cmd, cwd = local)
473 except OSError as e: 493 except OSError as e:
474 print(file=sys.stderr) 494 _print(file=sys.stderr)
475 print("fatal: '%s' is not available" % GIT, file=sys.stderr) 495 _print("fatal: '%s' is not available" % GIT, file=sys.stderr)
476 print('fatal: %s' % e, file=sys.stderr) 496 _print('fatal: %s' % e, file=sys.stderr)
477 print(file=sys.stderr) 497 _print(file=sys.stderr)
478 print('Please make sure %s is installed and in your path.' % GIT, 498 _print('Please make sure %s is installed and in your path.' % GIT,
479 file=sys.stderr) 499 file=sys.stderr)
480 raise CloneFailure() 500 raise CloneFailure()
481 if proc.wait() != 0: 501 if proc.wait() != 0:
482 print('fatal: could not create %s' % local, file=sys.stderr) 502 _print('fatal: could not create %s' % local, file=sys.stderr)
483 raise CloneFailure() 503 raise CloneFailure()
484 504
485 _InitHttp() 505 _InitHttp()
@@ -507,18 +527,18 @@ def _Verify(cwd, branch, quiet):
507 proc.stderr.close() 527 proc.stderr.close()
508 528
509 if proc.wait() != 0 or not cur: 529 if proc.wait() != 0 or not cur:
510 print(file=sys.stderr) 530 _print(file=sys.stderr)
511 print("fatal: branch '%s' has not been signed" % branch, file=sys.stderr) 531 _print("fatal: branch '%s' has not been signed" % branch, file=sys.stderr)
512 raise CloneFailure() 532 raise CloneFailure()
513 533
514 m = re.compile(r'^(.*)-[0-9]{1,}-g[0-9a-f]{1,}$').match(cur) 534 m = re.compile(r'^(.*)-[0-9]{1,}-g[0-9a-f]{1,}$').match(cur)
515 if m: 535 if m:
516 cur = m.group(1) 536 cur = m.group(1)
517 if not quiet: 537 if not quiet:
518 print(file=sys.stderr) 538 _print(file=sys.stderr)
519 print("info: Ignoring branch '%s'; using tagged release '%s'" 539 _print("info: Ignoring branch '%s'; using tagged release '%s'"
520 % (branch, cur), file=sys.stderr) 540 % (branch, cur), file=sys.stderr)
521 print(file=sys.stderr) 541 _print(file=sys.stderr)
522 542
523 env = os.environ.copy() 543 env = os.environ.copy()
524 env['GNUPGHOME'] = gpg_dir.encode() 544 env['GNUPGHOME'] = gpg_dir.encode()
@@ -536,10 +556,10 @@ def _Verify(cwd, branch, quiet):
536 proc.stderr.close() 556 proc.stderr.close()
537 557
538 if proc.wait() != 0: 558 if proc.wait() != 0:
539 print(file=sys.stderr) 559 _print(file=sys.stderr)
540 print(out, file=sys.stderr) 560 _print(out, file=sys.stderr)
541 print(err, file=sys.stderr) 561 _print(err, file=sys.stderr)
542 print(file=sys.stderr) 562 _print(file=sys.stderr)
543 raise CloneFailure() 563 raise CloneFailure()
544 return '%s^0' % cur 564 return '%s^0' % cur
545 565
@@ -606,7 +626,7 @@ def _ParseArguments(args):
606 626
607 627
608def _Usage(): 628def _Usage():
609 print( 629 _print(
610"""usage: repo COMMAND [ARGS] 630"""usage: repo COMMAND [ARGS]
611 631
612repo is not yet installed. Use "repo init" to install it here. 632repo is not yet installed. Use "repo init" to install it here.
@@ -627,23 +647,23 @@ def _Help(args):
627 init_optparse.print_help() 647 init_optparse.print_help()
628 sys.exit(0) 648 sys.exit(0)
629 else: 649 else:
630 print("error: '%s' is not a bootstrap command.\n" 650 _print("error: '%s' is not a bootstrap command.\n"
631 ' For access to online help, install repo ("repo init").' 651 ' For access to online help, install repo ("repo init").'
632 % args[0], file=sys.stderr) 652 % args[0], file=sys.stderr)
633 else: 653 else:
634 _Usage() 654 _Usage()
635 sys.exit(1) 655 sys.exit(1)
636 656
637 657
638def _NotInstalled(): 658def _NotInstalled():
639 print('error: repo is not installed. Use "repo init" to install it here.', 659 _print('error: repo is not installed. Use "repo init" to install it here.',
640 file=sys.stderr) 660 file=sys.stderr)
641 sys.exit(1) 661 sys.exit(1)
642 662
643 663
644def _NoCommands(cmd): 664def _NoCommands(cmd):
645 print("""error: command '%s' requires repo to be installed first. 665 _print("""error: command '%s' requires repo to be installed first.
646 Use "repo init" to install it here.""" % cmd, file=sys.stderr) 666 Use "repo init" to install it here.""" % cmd, file=sys.stderr)
647 sys.exit(1) 667 sys.exit(1)
648 668
649 669
@@ -680,7 +700,7 @@ def _SetDefaultsTo(gitdir):
680 proc.stderr.close() 700 proc.stderr.close()
681 701
682 if proc.wait() != 0: 702 if proc.wait() != 0:
683 print('fatal: %s has no current branch' % gitdir, file=sys.stderr) 703 _print('fatal: %s has no current branch' % gitdir, file=sys.stderr)
684 sys.exit(1) 704 sys.exit(1)
685 705
686 706
@@ -729,8 +749,8 @@ def main(orig_args):
729 try: 749 try:
730 os.execv(sys.executable, me) 750 os.execv(sys.executable, me)
731 except OSError as e: 751 except OSError as e:
732 print("fatal: unable to start %s" % repo_main, file=sys.stderr) 752 _print("fatal: unable to start %s" % repo_main, file=sys.stderr)
733 print("fatal: %s" % e, file=sys.stderr) 753 _print("fatal: %s" % e, file=sys.stderr)
734 sys.exit(148) 754 sys.exit(148)
735 755
736 756