blob: 1468fad3ed7427c17d960b1ea8ff85eee54ac193 [file] [log] [blame]
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -07001#!/bin/sh
2
3## repo default configuration
4##
Shawn O. Pearce44da16e2011-09-05 14:02:38 -07005REPO_URL='https://code.google.com/p/git-repo/'
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -07006REPO_REV='stable'
7
8# Copyright (C) 2008 Google Inc.
9#
10# Licensed under the Apache License, Version 2.0 (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
13#
14# http://www.apache.org/licenses/LICENSE-2.0
15#
16# Unless required by applicable law or agreed to in writing, software
17# distributed under the License is distributed on an "AS IS" BASIS,
18# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19# See the License for the specific language governing permissions and
20# limitations under the License.
21
22magic='--calling-python-from-/bin/sh--'
Shawn O. Pearce7542d662008-10-21 07:11:36 -070023"""exec" python -E "$0" "$@" """#$magic"
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070024if __name__ == '__main__':
25 import sys
26 if sys.argv[-1] == '#%s' % magic:
27 del sys.argv[-1]
28del magic
29
30# increment this whenever we make important changes to this script
Shawn O. Pearce44da16e2011-09-05 14:02:38 -070031VERSION = (1, 12)
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070032
33# increment this if the MAINTAINER_KEYS block is modified
34KEYRING_VERSION = (1,0)
35MAINTAINER_KEYS = """
36
37 Repo Maintainer <repo@android.kernel.org>
38-----BEGIN PGP PUBLIC KEY BLOCK-----
39Version: GnuPG v1.4.2.2 (GNU/Linux)
40
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
76=CMiZ
77-----END PGP PUBLIC KEY BLOCK-----
78"""
79
80GIT = 'git' # our git command
81MIN_GIT_VERSION = (1, 5, 4) # minimum supported git version
82repodir = '.repo' # name of repo's private directory
83S_repo = 'repo' # special repo reposiory
84S_manifests = 'manifests' # special manifest repository
85REPO_MAIN = S_repo + '/main.py' # main script
86
87
88import optparse
89import os
90import re
91import readline
92import subprocess
93import sys
94
95home_dot_repo = os.path.expanduser('~/.repoconfig')
96gpg_dir = os.path.join(home_dot_repo, 'gnupg')
97
98extra_args = []
99init_optparse = optparse.OptionParser(usage="repo init -u url [options]")
100
101# Logging
102group = init_optparse.add_option_group('Logging options')
103group.add_option('-q', '--quiet',
104 dest="quiet", action="store_true", default=False,
105 help="be quiet")
106
107# Manifest
108group = init_optparse.add_option_group('Manifest options')
109group.add_option('-u', '--manifest-url',
110 dest='manifest_url',
111 help='manifest repository location', metavar='URL')
112group.add_option('-b', '--manifest-branch',
113 dest='manifest_branch',
114 help='manifest branch or revision', metavar='REVISION')
115group.add_option('-m', '--manifest-name',
116 dest='manifest_name',
117 help='initial manifest file', metavar='NAME.xml')
Shawn O. Pearcee284ad12008-11-04 07:37:10 -0800118group.add_option('--mirror',
119 dest='mirror', action='store_true',
120 help='mirror the forrest')
Shawn O. Pearce88443382010-10-08 10:02:09 +0200121group.add_option('--reference',
122 dest='reference',
123 help='location of mirror directory', metavar='DIR')
Doug Anderson49cd59b2011-06-13 21:42:06 -0700124group.add_option('--depth', type='int', default=None,
125 dest='depth',
126 help='create a shallow clone with given depth; see git clone')
127
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700128
129# Tool
Shawn O. Pearcefd89b672009-04-18 11:28:57 -0700130group = init_optparse.add_option_group('repo Version options')
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700131group.add_option('--repo-url',
132 dest='repo_url',
133 help='repo repository location', metavar='URL')
134group.add_option('--repo-branch',
135 dest='repo_branch',
136 help='repo branch or revision', metavar='REVISION')
137group.add_option('--no-repo-verify',
138 dest='no_repo_verify', action='store_true',
139 help='do not verify repo source code')
140
141
142class CloneFailure(Exception):
143 """Indicate the remote clone of repo itself failed.
144 """
145
146
147def _Init(args):
148 """Installs repo by cloning it over the network.
149 """
150 opt, args = init_optparse.parse_args(args)
151 if args or not opt.manifest_url:
152 init_optparse.print_usage()
153 sys.exit(1)
154
155 url = opt.repo_url
156 if not url:
157 url = REPO_URL
158 extra_args.append('--repo-url=%s' % url)
159
160 branch = opt.repo_branch
161 if not branch:
162 branch = REPO_REV
163 extra_args.append('--repo-branch=%s' % branch)
164
165 if branch.startswith('refs/heads/'):
166 branch = branch[len('refs/heads/'):]
167 if branch.startswith('refs/'):
168 print >>sys.stderr, "fatal: invalid branch name '%s'" % branch
169 raise CloneFailure()
170
171 if not os.path.isdir(repodir):
172 try:
173 os.mkdir(repodir)
174 except OSError, e:
175 print >>sys.stderr, \
176 'fatal: cannot make %s directory: %s' % (
177 repodir, e.strerror)
178 # Don't faise CloneFailure; that would delete the
179 # name. Instead exit immediately.
180 #
181 sys.exit(1)
182
183 _CheckGitVersion()
184 try:
185 if _NeedSetupGnuPG():
186 can_verify = _SetupGnuPG(opt.quiet)
187 else:
188 can_verify = True
189
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))
195 _Clone(url, dst, opt.quiet)
196
197 if can_verify and not opt.no_repo_verify:
198 rev = _Verify(dst, branch, opt.quiet)
199 else:
200 rev = 'refs/remotes/origin/%s^0' % branch
201
202 _Checkout(dst, branch, rev, opt.quiet)
203 except CloneFailure:
204 if opt.quiet:
205 print >>sys.stderr, \
206 'fatal: repo init failed; run without --quiet to see why'
207 raise
208
209
210def _CheckGitVersion():
211 cmd = [GIT, '--version']
212 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
213 ver_str = proc.stdout.read().strip()
214 proc.stdout.close()
Shawn O. Pearce16191342008-10-28 08:33:34 -0700215 proc.wait()
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700216
217 if not ver_str.startswith('git version '):
218 print >>sys.stderr, 'error: "%s" unsupported' % ver_str
219 raise CloneFailure()
220
221 ver_str = ver_str[len('git version '):].strip()
222 ver_act = tuple(map(lambda x: int(x), ver_str.split('.')[0:3]))
223 if ver_act < MIN_GIT_VERSION:
224 need = '.'.join(map(lambda x: str(x), MIN_GIT_VERSION))
225 print >>sys.stderr, 'fatal: git %s or later required' % need
226 raise CloneFailure()
227
228
229def _NeedSetupGnuPG():
230 if not os.path.isdir(home_dot_repo):
231 return True
232
233 kv = os.path.join(home_dot_repo, 'keyring-version')
234 if not os.path.exists(kv):
235 return True
236
237 kv = open(kv).read()
238 if not kv:
239 return True
240
241 kv = tuple(map(lambda x: int(x), kv.split('.')))
242 if kv < KEYRING_VERSION:
243 return True
244 return False
245
246
247def _SetupGnuPG(quiet):
248 if not os.path.isdir(home_dot_repo):
249 try:
250 os.mkdir(home_dot_repo)
251 except OSError, e:
252 print >>sys.stderr, \
253 'fatal: cannot make %s directory: %s' % (
254 home_dot_repo, e.strerror)
255 sys.exit(1)
256
257 if not os.path.isdir(gpg_dir):
258 try:
259 os.mkdir(gpg_dir, 0700)
260 except OSError, e:
261 print >>sys.stderr, \
262 'fatal: cannot make %s directory: %s' % (
263 gpg_dir, e.strerror)
264 sys.exit(1)
265
Shawn O. Pearcef18cb762010-12-07 11:41:05 -0800266 env = os.environ.copy()
267 env['GNUPGHOME'] = gpg_dir.encode()
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700268
269 cmd = ['gpg', '--import']
270 try:
271 proc = subprocess.Popen(cmd,
272 env = env,
273 stdin = subprocess.PIPE)
274 except OSError, e:
275 if not quiet:
276 print >>sys.stderr, 'warning: gpg (GnuPG) is not available.'
277 print >>sys.stderr, 'warning: Installing it is strongly encouraged.'
278 print >>sys.stderr
279 return False
280
281 proc.stdin.write(MAINTAINER_KEYS)
282 proc.stdin.close()
283
284 if proc.wait() != 0:
285 print >>sys.stderr, 'fatal: registering repo maintainer keys failed'
286 sys.exit(1)
287 print
288
289 fd = open(os.path.join(home_dot_repo, 'keyring-version'), 'w')
290 fd.write('.'.join(map(lambda x: str(x), KEYRING_VERSION)) + '\n')
291 fd.close()
292 return True
293
294
295def _SetConfig(local, name, value):
296 """Set a git configuration option to the specified value.
297 """
298 cmd = [GIT, 'config', name, value]
299 if subprocess.Popen(cmd, cwd = local).wait() != 0:
300 raise CloneFailure()
301
302
303def _Fetch(local, quiet, *args):
304 cmd = [GIT, 'fetch']
305 if quiet:
306 cmd.append('--quiet')
307 err = subprocess.PIPE
308 else:
309 err = None
310 cmd.extend(args)
311 cmd.append('origin')
312
313 proc = subprocess.Popen(cmd, cwd = local, stderr = err)
314 if err:
315 proc.stderr.read()
316 proc.stderr.close()
317 if proc.wait() != 0:
318 raise CloneFailure()
319
320
321def _Clone(url, local, quiet):
322 """Clones a git repository to a new subdirectory of repodir
323 """
324 try:
325 os.mkdir(local)
326 except OSError, e:
327 print >>sys.stderr, \
328 'fatal: cannot make %s directory: %s' \
329 % (local, e.strerror)
330 raise CloneFailure()
331
332 cmd = [GIT, 'init', '--quiet']
333 try:
334 proc = subprocess.Popen(cmd, cwd = local)
335 except OSError, e:
336 print >>sys.stderr
337 print >>sys.stderr, "fatal: '%s' is not available" % GIT
338 print >>sys.stderr, 'fatal: %s' % e
339 print >>sys.stderr
340 print >>sys.stderr, 'Please make sure %s is installed'\
341 ' and in your path.' % GIT
342 raise CloneFailure()
343 if proc.wait() != 0:
344 print >>sys.stderr, 'fatal: could not create %s' % local
345 raise CloneFailure()
346
347 _SetConfig(local, 'remote.origin.url', url)
348 _SetConfig(local, 'remote.origin.fetch',
349 '+refs/heads/*:refs/remotes/origin/*')
350 _Fetch(local, quiet)
351 _Fetch(local, quiet, '--tags')
352
353
354def _Verify(cwd, branch, quiet):
355 """Verify the branch has been signed by a tag.
356 """
357 cmd = [GIT, 'describe', 'origin/%s' % branch]
358 proc = subprocess.Popen(cmd,
359 stdout=subprocess.PIPE,
360 stderr=subprocess.PIPE,
361 cwd = cwd)
362 cur = proc.stdout.read().strip()
363 proc.stdout.close()
364
365 proc.stderr.read()
366 proc.stderr.close()
367
368 if proc.wait() != 0 or not cur:
369 print >>sys.stderr
370 print >>sys.stderr,\
371 "fatal: branch '%s' has not been signed" \
372 % branch
373 raise CloneFailure()
374
375 m = re.compile(r'^(.*)-[0-9]{1,}-g[0-9a-f]{1,}$').match(cur)
376 if m:
377 cur = m.group(1)
378 if not quiet:
379 print >>sys.stderr
380 print >>sys.stderr, \
381 "info: Ignoring branch '%s'; using tagged release '%s'" \
382 % (branch, cur)
383 print >>sys.stderr
384
Shawn O. Pearcef18cb762010-12-07 11:41:05 -0800385 env = os.environ.copy()
386 env['GNUPGHOME'] = gpg_dir.encode()
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700387
388 cmd = [GIT, 'tag', '-v', cur]
389 proc = subprocess.Popen(cmd,
390 stdout = subprocess.PIPE,
391 stderr = subprocess.PIPE,
392 cwd = cwd,
393 env = env)
394 out = proc.stdout.read()
395 proc.stdout.close()
396
397 err = proc.stderr.read()
398 proc.stderr.close()
399
400 if proc.wait() != 0:
401 print >>sys.stderr
402 print >>sys.stderr, out
403 print >>sys.stderr, err
404 print >>sys.stderr
405 raise CloneFailure()
406 return '%s^0' % cur
407
408
409def _Checkout(cwd, branch, rev, quiet):
410 """Checkout an upstream branch into the repository and track it.
411 """
412 cmd = [GIT, 'update-ref', 'refs/heads/default', rev]
413 if subprocess.Popen(cmd, cwd = cwd).wait() != 0:
414 raise CloneFailure()
415
416 _SetConfig(cwd, 'branch.default.remote', 'origin')
417 _SetConfig(cwd, 'branch.default.merge', 'refs/heads/%s' % branch)
418
419 cmd = [GIT, 'symbolic-ref', 'HEAD', 'refs/heads/default']
420 if subprocess.Popen(cmd, cwd = cwd).wait() != 0:
421 raise CloneFailure()
422
423 cmd = [GIT, 'read-tree', '--reset', '-u']
424 if not quiet:
425 cmd.append('-v')
426 cmd.append('HEAD')
427 if subprocess.Popen(cmd, cwd = cwd).wait() != 0:
428 raise CloneFailure()
429
430
431def _FindRepo():
432 """Look for a repo installation, starting at the current directory.
433 """
434 dir = os.getcwd()
435 repo = None
436
Anthony Newnamdf14a702011-01-09 17:31:57 -0800437 olddir = None
438 while dir != '/' \
439 and dir != olddir \
440 and not repo:
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700441 repo = os.path.join(dir, repodir, REPO_MAIN)
442 if not os.path.isfile(repo):
443 repo = None
Anthony Newnamdf14a702011-01-09 17:31:57 -0800444 olddir = dir
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700445 dir = os.path.dirname(dir)
446 return (repo, os.path.join(dir, repodir))
447
448
449class _Options:
450 help = False
451
452
453def _ParseArguments(args):
454 cmd = None
455 opt = _Options()
456 arg = []
457
458 for i in xrange(0, len(args)):
459 a = args[i]
460 if a == '-h' or a == '--help':
461 opt.help = True
462
463 elif not a.startswith('-'):
464 cmd = a
465 arg = args[i + 1:]
466 break
467 return cmd, opt, arg
468
469
470def _Usage():
471 print >>sys.stderr,\
472"""usage: repo COMMAND [ARGS]
473
474repo is not yet installed. Use "repo init" to install it here.
475
476The most commonly used repo commands are:
477
478 init Install repo in the current working directory
479 help Display detailed help on a command
480
481For access to the full online help, install repo ("repo init").
482"""
483 sys.exit(1)
484
485
486def _Help(args):
487 if args:
488 if args[0] == 'init':
489 init_optparse.print_help()
Trond Norbyed3fd5372011-01-03 11:35:15 +0100490 sys.exit(0)
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700491 else:
492 print >>sys.stderr,\
493 "error: '%s' is not a bootstrap command.\n"\
494 ' For access to online help, install repo ("repo init").'\
495 % args[0]
496 else:
497 _Usage()
498 sys.exit(1)
499
500
501def _NotInstalled():
502 print >>sys.stderr,\
503'error: repo is not installed. Use "repo init" to install it here.'
504 sys.exit(1)
505
506
507def _NoCommands(cmd):
508 print >>sys.stderr,\
509"""error: command '%s' requires repo to be installed first.
510 Use "repo init" to install it here.""" % cmd
511 sys.exit(1)
512
513
514def _RunSelf(wrapper_path):
515 my_dir = os.path.dirname(wrapper_path)
516 my_main = os.path.join(my_dir, 'main.py')
517 my_git = os.path.join(my_dir, '.git')
518
519 if os.path.isfile(my_main) and os.path.isdir(my_git):
Shawn O. Pearcec8a300f2009-05-18 13:19:57 -0700520 for name in ['git_config.py',
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700521 'project.py',
522 'subcmds']:
523 if not os.path.exists(os.path.join(my_dir, name)):
524 return None, None
525 return my_main, my_git
526 return None, None
527
528
529def _SetDefaultsTo(gitdir):
530 global REPO_URL
531 global REPO_REV
532
533 REPO_URL = gitdir
534 proc = subprocess.Popen([GIT,
535 '--git-dir=%s' % gitdir,
536 'symbolic-ref',
537 'HEAD'],
538 stdout = subprocess.PIPE,
539 stderr = subprocess.PIPE)
540 REPO_REV = proc.stdout.read().strip()
541 proc.stdout.close()
542
543 proc.stderr.read()
544 proc.stderr.close()
545
546 if proc.wait() != 0:
547 print >>sys.stderr, 'fatal: %s has no current branch' % gitdir
548 sys.exit(1)
549
550
551def main(orig_args):
552 main, dir = _FindRepo()
553 cmd, opt, args = _ParseArguments(orig_args)
554
555 wrapper_path = os.path.abspath(__file__)
556 my_main, my_git = _RunSelf(wrapper_path)
557
558 if not main:
559 if opt.help:
560 _Usage()
561 if cmd == 'help':
562 _Help(args)
563 if not cmd:
564 _NotInstalled()
565 if cmd == 'init':
566 if my_git:
567 _SetDefaultsTo(my_git)
568 try:
569 _Init(args)
570 except CloneFailure:
571 for root, dirs, files in os.walk(repodir, topdown=False):
572 for name in files:
573 os.remove(os.path.join(root, name))
574 for name in dirs:
575 os.rmdir(os.path.join(root, name))
576 os.rmdir(repodir)
577 sys.exit(1)
578 main, dir = _FindRepo()
579 else:
580 _NoCommands(cmd)
581
582 if my_main:
583 main = my_main
584
585 ver_str = '.'.join(map(lambda x: str(x), VERSION))
586 me = [main,
587 '--repo-dir=%s' % dir,
588 '--wrapper-version=%s' % ver_str,
589 '--wrapper-path=%s' % wrapper_path,
590 '--']
591 me.extend(orig_args)
592 me.extend(extra_args)
593 try:
594 os.execv(main, me)
595 except OSError, e:
596 print >>sys.stderr, "fatal: unable to start %s" % main
597 print >>sys.stderr, "fatal: %s" % e
598 sys.exit(148)
599
600
601if __name__ == '__main__':
602 main(sys.argv[1:])