repo 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. #!/bin/sh
  2. ## repo default configuration
  3. ##
  4. REPO_URL='git://android.git.kernel.org/tools/repo.git'
  5. REPO_REV='stable'
  6. # Copyright (C) 2008 Google Inc.
  7. #
  8. # Licensed under the Apache License, Version 2.0 (the "License");
  9. # you may not use this file except in compliance with the License.
  10. # You may obtain a copy of the License at
  11. #
  12. # http://www.apache.org/licenses/LICENSE-2.0
  13. #
  14. # Unless required by applicable law or agreed to in writing, software
  15. # distributed under the License is distributed on an "AS IS" BASIS,
  16. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. # See the License for the specific language governing permissions and
  18. # limitations under the License.
  19. magic='--calling-python-from-/bin/sh--'
  20. """exec" python -E "$0" "$@" """#$magic"
  21. if __name__ == '__main__':
  22. import sys
  23. if sys.argv[-1] == '#%s' % magic:
  24. del sys.argv[-1]
  25. del magic
  26. # increment this whenever we make important changes to this script
  27. VERSION = (1, 9)
  28. # increment this if the MAINTAINER_KEYS block is modified
  29. KEYRING_VERSION = (1,0)
  30. MAINTAINER_KEYS = """
  31. Repo Maintainer <repo@android.kernel.org>
  32. -----BEGIN PGP PUBLIC KEY BLOCK-----
  33. Version: GnuPG v1.4.2.2 (GNU/Linux)
  34. mQGiBEj3ugERBACrLJh/ZPyVSKeClMuznFIrsQ+hpNnmJGw1a9GXKYKk8qHPhAZf
  35. WKtrBqAVMNRLhL85oSlekRz98u41H5si5zcuv+IXJDF5MJYcB8f22wAy15lUqPWi
  36. VCkk1l8qqLiuW0fo+ZkPY5qOgrvc0HW1SmdH649uNwqCbcKb6CxaTxzhOwCgj3AP
  37. xI1WfzLqdJjsm1Nq98L0cLcD/iNsILCuw44PRds3J75YP0pze7YF/6WFMB6QSFGu
  38. aUX1FsTTztKNXGms8i5b2l1B8JaLRWq/jOnZzyl1zrUJhkc0JgyZW5oNLGyWGhKD
  39. Fxp5YpHuIuMImopWEMFIRQNrvlg+YVK8t3FpdI1RY0LYqha8pPzANhEYgSfoVzOb
  40. fbfbA/4ioOrxy8ifSoga7ITyZMA+XbW8bx33WXutO9N7SPKS/AK2JpasSEVLZcON
  41. ae5hvAEGVXKxVPDjJBmIc2cOe7kOKSi3OxLzBqrjS2rnjiP4o0ekhZIe4+ocwVOg
  42. e0PLlH5avCqihGRhpoqDRsmpzSHzJIxtoeb+GgGEX8KkUsVAhbQpUmVwbyBNYWlu
  43. dGFpbmVyIDxyZXBvQGFuZHJvaWQua2VybmVsLm9yZz6IYAQTEQIAIAUCSPe6AQIb
  44. AwYLCQgHAwIEFQIIAwQWAgMBAh4BAheAAAoJEBZTDV6SD1xl1GEAn0x/OKQpy7qI
  45. 6G73NJviU0IUMtftAKCFMUhGb/0bZvQ8Rm3QCUpWHyEIu7kEDQRI97ogEBAA2wI6
  46. 5fs9y/rMwD6dkD/vK9v4C9mOn1IL5JCPYMJBVSci+9ED4ChzYvfq7wOcj9qIvaE0
  47. GwCt2ar7Q56me5J+byhSb32Rqsw/r3Vo5cZMH80N4cjesGuSXOGyEWTe4HYoxnHv
  48. gF4EKI2LK7xfTUcxMtlyn52sUpkfKsCpUhFvdmbAiJE+jCkQZr1Z8u2KphV79Ou+
  49. P1N5IXY/XWOlq48Qf4MWCYlJFrB07xjUjLKMPDNDnm58L5byDrP/eHysKexpbakL
  50. xCmYyfT6DV1SWLblpd2hie0sL3YejdtuBMYMS2rI7Yxb8kGuqkz+9l1qhwJtei94
  51. 5MaretDy/d/JH/pRYkRf7L+ke7dpzrP+aJmcz9P1e6gq4NJsWejaALVASBiioqNf
  52. QmtqSVzF1wkR5avZkFHuYvj6V/t1RrOZTXxkSk18KFMJRBZrdHFCWbc5qrVxUB6e
  53. N5pja0NFIUCigLBV1c6I2DwiuboMNh18VtJJh+nwWeez/RueN4ig59gRTtkcc0PR
  54. 35tX2DR8+xCCFVW/NcJ4PSePYzCuuLvp1vEDHnj41R52Fz51hgddT4rBsp0nL+5I
  55. socSOIIezw8T9vVzMY4ArCKFAVu2IVyBcahTfBS8q5EM63mONU6UVJEozfGljiMw
  56. xuQ7JwKcw0AUEKTKG7aBgBaTAgT8TOevpvlw91cAAwUP/jRkyVi/0WAb0qlEaq/S
  57. ouWxX1faR+vU3b+Y2/DGjtXQMzG0qpetaTHC/AxxHpgt/dCkWI6ljYDnxgPLwG0a
  58. Oasm94BjZc6vZwf1opFZUKsjOAAxRxNZyjUJKe4UZVuMTk6zo27Nt3LMnc0FO47v
  59. FcOjRyquvgNOS818irVHUf12waDx8gszKxQTTtFxU5/ePB2jZmhP6oXSe4K/LG5T
  60. +WBRPDrHiGPhCzJRzm9BP0lTnGCAj3o9W90STZa65RK7IaYpC8TB35JTBEbrrNCp
  61. w6lzd74LnNEp5eMlKDnXzUAgAH0yzCQeMl7t33QCdYx2hRs2wtTQSjGfAiNmj/WW
  62. Vl5Jn+2jCDnRLenKHwVRFsBX2e0BiRWt/i9Y8fjorLCXVj4z+7yW6DawdLkJorEo
  63. p3v5ILwfC7hVx4jHSnOgZ65L9s8EQdVr1ckN9243yta7rNgwfcqb60ILMFF1BRk/
  64. 0V7wCL+68UwwiQDvyMOQuqkysKLSDCLb7BFcyA7j6KG+5hpsREstFX2wK1yKeraz
  65. 5xGrFy8tfAaeBMIQ17gvFSp/suc9DYO0ICK2BISzq+F+ZiAKsjMYOBNdH/h0zobQ
  66. HTHs37+/QLMomGEGKZMWi0dShU2J5mNRQu3Hhxl3hHDVbt5CeJBb26aQcQrFz69W
  67. zE3GNvmJosh6leayjtI9P2A6iEkEGBECAAkFAkj3uiACGwwACgkQFlMNXpIPXGWp
  68. TACbBS+Up3RpfYVfd63c1cDdlru13pQAn3NQy/SN858MkxN+zym86UBgOad2
  69. =CMiZ
  70. -----END PGP PUBLIC KEY BLOCK-----
  71. """
  72. GIT = 'git' # our git command
  73. MIN_GIT_VERSION = (1, 5, 4) # minimum supported git version
  74. repodir = '.repo' # name of repo's private directory
  75. S_repo = 'repo' # special repo reposiory
  76. S_manifests = 'manifests' # special manifest repository
  77. REPO_MAIN = S_repo + '/main.py' # main script
  78. import optparse
  79. import os
  80. import re
  81. import readline
  82. import subprocess
  83. import sys
  84. home_dot_repo = os.path.expanduser('~/.repoconfig')
  85. gpg_dir = os.path.join(home_dot_repo, 'gnupg')
  86. extra_args = []
  87. init_optparse = optparse.OptionParser(usage="repo init -u url [options]")
  88. # Logging
  89. group = init_optparse.add_option_group('Logging options')
  90. group.add_option('-q', '--quiet',
  91. dest="quiet", action="store_true", default=False,
  92. help="be quiet")
  93. # Manifest
  94. group = init_optparse.add_option_group('Manifest options')
  95. group.add_option('-u', '--manifest-url',
  96. dest='manifest_url',
  97. help='manifest repository location', metavar='URL')
  98. group.add_option('-o', '--origin',
  99. dest='manifest_origin',
  100. help="use REMOTE instead of 'origin' to track upstream",
  101. metavar='REMOTE')
  102. group.add_option('-b', '--manifest-branch',
  103. dest='manifest_branch',
  104. help='manifest branch or revision', metavar='REVISION')
  105. group.add_option('-m', '--manifest-name',
  106. dest='manifest_name',
  107. help='initial manifest file (deprecated)',
  108. metavar='NAME.xml')
  109. group.add_option('--mirror',
  110. dest='mirror', action='store_true',
  111. help='mirror the forrest')
  112. # Tool
  113. group = init_optparse.add_option_group('repo Version options')
  114. group.add_option('--repo-url',
  115. dest='repo_url',
  116. help='repo repository location', metavar='URL')
  117. group.add_option('--repo-branch',
  118. dest='repo_branch',
  119. help='repo branch or revision', metavar='REVISION')
  120. group.add_option('--no-repo-verify',
  121. dest='no_repo_verify', action='store_true',
  122. help='do not verify repo source code')
  123. class CloneFailure(Exception):
  124. """Indicate the remote clone of repo itself failed.
  125. """
  126. def _Init(args):
  127. """Installs repo by cloning it over the network.
  128. """
  129. opt, args = init_optparse.parse_args(args)
  130. if args or not opt.manifest_url:
  131. init_optparse.print_usage()
  132. sys.exit(1)
  133. url = opt.repo_url
  134. if not url:
  135. url = REPO_URL
  136. extra_args.append('--repo-url=%s' % url)
  137. branch = opt.repo_branch
  138. if not branch:
  139. branch = REPO_REV
  140. extra_args.append('--repo-branch=%s' % branch)
  141. if branch.startswith('refs/heads/'):
  142. branch = branch[len('refs/heads/'):]
  143. if branch.startswith('refs/'):
  144. print >>sys.stderr, "fatal: invalid branch name '%s'" % branch
  145. raise CloneFailure()
  146. if not os.path.isdir(repodir):
  147. try:
  148. os.mkdir(repodir)
  149. except OSError, e:
  150. print >>sys.stderr, \
  151. 'fatal: cannot make %s directory: %s' % (
  152. repodir, e.strerror)
  153. # Don't faise CloneFailure; that would delete the
  154. # name. Instead exit immediately.
  155. #
  156. sys.exit(1)
  157. _CheckGitVersion()
  158. try:
  159. if _NeedSetupGnuPG():
  160. can_verify = _SetupGnuPG(opt.quiet)
  161. else:
  162. can_verify = True
  163. if not opt.quiet:
  164. print >>sys.stderr, 'Getting repo ...'
  165. print >>sys.stderr, ' from %s' % url
  166. dst = os.path.abspath(os.path.join(repodir, S_repo))
  167. _Clone(url, dst, opt.quiet)
  168. if can_verify and not opt.no_repo_verify:
  169. rev = _Verify(dst, branch, opt.quiet)
  170. else:
  171. rev = 'refs/remotes/origin/%s^0' % branch
  172. _Checkout(dst, branch, rev, opt.quiet)
  173. except CloneFailure:
  174. if opt.quiet:
  175. print >>sys.stderr, \
  176. 'fatal: repo init failed; run without --quiet to see why'
  177. raise
  178. def _CheckGitVersion():
  179. cmd = [GIT, '--version']
  180. proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
  181. ver_str = proc.stdout.read().strip()
  182. proc.stdout.close()
  183. proc.wait()
  184. if not ver_str.startswith('git version '):
  185. print >>sys.stderr, 'error: "%s" unsupported' % ver_str
  186. raise CloneFailure()
  187. ver_str = ver_str[len('git version '):].strip()
  188. ver_act = tuple(map(lambda x: int(x), ver_str.split('.')[0:3]))
  189. if ver_act < MIN_GIT_VERSION:
  190. need = '.'.join(map(lambda x: str(x), MIN_GIT_VERSION))
  191. print >>sys.stderr, 'fatal: git %s or later required' % need
  192. raise CloneFailure()
  193. def _NeedSetupGnuPG():
  194. if not os.path.isdir(home_dot_repo):
  195. return True
  196. kv = os.path.join(home_dot_repo, 'keyring-version')
  197. if not os.path.exists(kv):
  198. return True
  199. kv = open(kv).read()
  200. if not kv:
  201. return True
  202. kv = tuple(map(lambda x: int(x), kv.split('.')))
  203. if kv < KEYRING_VERSION:
  204. return True
  205. return False
  206. def _SetupGnuPG(quiet):
  207. if not os.path.isdir(home_dot_repo):
  208. try:
  209. os.mkdir(home_dot_repo)
  210. except OSError, e:
  211. print >>sys.stderr, \
  212. 'fatal: cannot make %s directory: %s' % (
  213. home_dot_repo, e.strerror)
  214. sys.exit(1)
  215. if not os.path.isdir(gpg_dir):
  216. try:
  217. os.mkdir(gpg_dir, 0700)
  218. except OSError, e:
  219. print >>sys.stderr, \
  220. 'fatal: cannot make %s directory: %s' % (
  221. gpg_dir, e.strerror)
  222. sys.exit(1)
  223. env = dict(os.environ)
  224. env['GNUPGHOME'] = gpg_dir
  225. cmd = ['gpg', '--import']
  226. try:
  227. proc = subprocess.Popen(cmd,
  228. env = env,
  229. stdin = subprocess.PIPE)
  230. except OSError, e:
  231. if not quiet:
  232. print >>sys.stderr, 'warning: gpg (GnuPG) is not available.'
  233. print >>sys.stderr, 'warning: Installing it is strongly encouraged.'
  234. print >>sys.stderr
  235. return False
  236. proc.stdin.write(MAINTAINER_KEYS)
  237. proc.stdin.close()
  238. if proc.wait() != 0:
  239. print >>sys.stderr, 'fatal: registering repo maintainer keys failed'
  240. sys.exit(1)
  241. print
  242. fd = open(os.path.join(home_dot_repo, 'keyring-version'), 'w')
  243. fd.write('.'.join(map(lambda x: str(x), KEYRING_VERSION)) + '\n')
  244. fd.close()
  245. return True
  246. def _SetConfig(local, name, value):
  247. """Set a git configuration option to the specified value.
  248. """
  249. cmd = [GIT, 'config', name, value]
  250. if subprocess.Popen(cmd, cwd = local).wait() != 0:
  251. raise CloneFailure()
  252. def _Fetch(local, quiet, *args):
  253. cmd = [GIT, 'fetch']
  254. if quiet:
  255. cmd.append('--quiet')
  256. err = subprocess.PIPE
  257. else:
  258. err = None
  259. cmd.extend(args)
  260. cmd.append('origin')
  261. proc = subprocess.Popen(cmd, cwd = local, stderr = err)
  262. if err:
  263. proc.stderr.read()
  264. proc.stderr.close()
  265. if proc.wait() != 0:
  266. raise CloneFailure()
  267. def _Clone(url, local, quiet):
  268. """Clones a git repository to a new subdirectory of repodir
  269. """
  270. try:
  271. os.mkdir(local)
  272. except OSError, e:
  273. print >>sys.stderr, \
  274. 'fatal: cannot make %s directory: %s' \
  275. % (local, e.strerror)
  276. raise CloneFailure()
  277. cmd = [GIT, 'init', '--quiet']
  278. try:
  279. proc = subprocess.Popen(cmd, cwd = local)
  280. except OSError, e:
  281. print >>sys.stderr
  282. print >>sys.stderr, "fatal: '%s' is not available" % GIT
  283. print >>sys.stderr, 'fatal: %s' % e
  284. print >>sys.stderr
  285. print >>sys.stderr, 'Please make sure %s is installed'\
  286. ' and in your path.' % GIT
  287. raise CloneFailure()
  288. if proc.wait() != 0:
  289. print >>sys.stderr, 'fatal: could not create %s' % local
  290. raise CloneFailure()
  291. _SetConfig(local, 'remote.origin.url', url)
  292. _SetConfig(local, 'remote.origin.fetch',
  293. '+refs/heads/*:refs/remotes/origin/*')
  294. _Fetch(local, quiet)
  295. _Fetch(local, quiet, '--tags')
  296. def _Verify(cwd, branch, quiet):
  297. """Verify the branch has been signed by a tag.
  298. """
  299. cmd = [GIT, 'describe', 'origin/%s' % branch]
  300. proc = subprocess.Popen(cmd,
  301. stdout=subprocess.PIPE,
  302. stderr=subprocess.PIPE,
  303. cwd = cwd)
  304. cur = proc.stdout.read().strip()
  305. proc.stdout.close()
  306. proc.stderr.read()
  307. proc.stderr.close()
  308. if proc.wait() != 0 or not cur:
  309. print >>sys.stderr
  310. print >>sys.stderr,\
  311. "fatal: branch '%s' has not been signed" \
  312. % branch
  313. raise CloneFailure()
  314. m = re.compile(r'^(.*)-[0-9]{1,}-g[0-9a-f]{1,}$').match(cur)
  315. if m:
  316. cur = m.group(1)
  317. if not quiet:
  318. print >>sys.stderr
  319. print >>sys.stderr, \
  320. "info: Ignoring branch '%s'; using tagged release '%s'" \
  321. % (branch, cur)
  322. print >>sys.stderr
  323. env = dict(os.environ)
  324. env['GNUPGHOME'] = gpg_dir
  325. cmd = [GIT, 'tag', '-v', cur]
  326. proc = subprocess.Popen(cmd,
  327. stdout = subprocess.PIPE,
  328. stderr = subprocess.PIPE,
  329. cwd = cwd,
  330. env = env)
  331. out = proc.stdout.read()
  332. proc.stdout.close()
  333. err = proc.stderr.read()
  334. proc.stderr.close()
  335. if proc.wait() != 0:
  336. print >>sys.stderr
  337. print >>sys.stderr, out
  338. print >>sys.stderr, err
  339. print >>sys.stderr
  340. raise CloneFailure()
  341. return '%s^0' % cur
  342. def _Checkout(cwd, branch, rev, quiet):
  343. """Checkout an upstream branch into the repository and track it.
  344. """
  345. cmd = [GIT, 'update-ref', 'refs/heads/default', rev]
  346. if subprocess.Popen(cmd, cwd = cwd).wait() != 0:
  347. raise CloneFailure()
  348. _SetConfig(cwd, 'branch.default.remote', 'origin')
  349. _SetConfig(cwd, 'branch.default.merge', 'refs/heads/%s' % branch)
  350. cmd = [GIT, 'symbolic-ref', 'HEAD', 'refs/heads/default']
  351. if subprocess.Popen(cmd, cwd = cwd).wait() != 0:
  352. raise CloneFailure()
  353. cmd = [GIT, 'read-tree', '--reset', '-u']
  354. if not quiet:
  355. cmd.append('-v')
  356. cmd.append('HEAD')
  357. if subprocess.Popen(cmd, cwd = cwd).wait() != 0:
  358. raise CloneFailure()
  359. def _FindRepo():
  360. """Look for a repo installation, starting at the current directory.
  361. """
  362. dir = os.getcwd()
  363. repo = None
  364. olddir = None
  365. while dir != '/' \
  366. and dir != olddir \
  367. and not repo:
  368. repo = os.path.join(dir, repodir, REPO_MAIN)
  369. if not os.path.isfile(repo):
  370. repo = None
  371. olddir = dir
  372. dir = os.path.dirname(dir)
  373. return (repo, os.path.join(dir, repodir))
  374. class _Options:
  375. help = False
  376. def _ParseArguments(args):
  377. cmd = None
  378. opt = _Options()
  379. arg = []
  380. for i in xrange(0, len(args)):
  381. a = args[i]
  382. if a == '-h' or a == '--help':
  383. opt.help = True
  384. elif not a.startswith('-'):
  385. cmd = a
  386. arg = args[i + 1:]
  387. break
  388. return cmd, opt, arg
  389. def _Usage():
  390. print >>sys.stderr,\
  391. """usage: repo COMMAND [ARGS]
  392. repo is not yet installed. Use "repo init" to install it here.
  393. The most commonly used repo commands are:
  394. init Install repo in the current working directory
  395. help Display detailed help on a command
  396. For access to the full online help, install repo ("repo init").
  397. """
  398. sys.exit(1)
  399. def _Help(args):
  400. if args:
  401. if args[0] == 'init':
  402. init_optparse.print_help()
  403. else:
  404. print >>sys.stderr,\
  405. "error: '%s' is not a bootstrap command.\n"\
  406. ' For access to online help, install repo ("repo init").'\
  407. % args[0]
  408. else:
  409. _Usage()
  410. sys.exit(1)
  411. def _NotInstalled():
  412. print >>sys.stderr,\
  413. 'error: repo is not installed. Use "repo init" to install it here.'
  414. sys.exit(1)
  415. def _NoCommands(cmd):
  416. print >>sys.stderr,\
  417. """error: command '%s' requires repo to be installed first.
  418. Use "repo init" to install it here.""" % cmd
  419. sys.exit(1)
  420. def _RunSelf(wrapper_path):
  421. my_dir = os.path.dirname(wrapper_path)
  422. my_main = os.path.join(my_dir, 'main.py')
  423. my_git = os.path.join(my_dir, '.git')
  424. if os.path.isfile(my_main) and os.path.isdir(my_git):
  425. for name in ['git_config.py',
  426. 'project.py',
  427. 'subcmds']:
  428. if not os.path.exists(os.path.join(my_dir, name)):
  429. return None, None
  430. return my_main, my_git
  431. return None, None
  432. def _SetDefaultsTo(gitdir):
  433. global REPO_URL
  434. global REPO_REV
  435. REPO_URL = gitdir
  436. proc = subprocess.Popen([GIT,
  437. '--git-dir=%s' % gitdir,
  438. 'symbolic-ref',
  439. 'HEAD'],
  440. stdout = subprocess.PIPE,
  441. stderr = subprocess.PIPE)
  442. REPO_REV = proc.stdout.read().strip()
  443. proc.stdout.close()
  444. proc.stderr.read()
  445. proc.stderr.close()
  446. if proc.wait() != 0:
  447. print >>sys.stderr, 'fatal: %s has no current branch' % gitdir
  448. sys.exit(1)
  449. def main(orig_args):
  450. main, dir = _FindRepo()
  451. cmd, opt, args = _ParseArguments(orig_args)
  452. wrapper_path = os.path.abspath(__file__)
  453. my_main, my_git = _RunSelf(wrapper_path)
  454. if not main:
  455. if opt.help:
  456. _Usage()
  457. if cmd == 'help':
  458. _Help(args)
  459. if not cmd:
  460. _NotInstalled()
  461. if cmd == 'init':
  462. if my_git:
  463. _SetDefaultsTo(my_git)
  464. try:
  465. _Init(args)
  466. except CloneFailure:
  467. for root, dirs, files in os.walk(repodir, topdown=False):
  468. for name in files:
  469. os.remove(os.path.join(root, name))
  470. for name in dirs:
  471. os.rmdir(os.path.join(root, name))
  472. os.rmdir(repodir)
  473. sys.exit(1)
  474. main, dir = _FindRepo()
  475. else:
  476. _NoCommands(cmd)
  477. if my_main:
  478. main = my_main
  479. ver_str = '.'.join(map(lambda x: str(x), VERSION))
  480. me = [main,
  481. '--repo-dir=%s' % dir,
  482. '--wrapper-version=%s' % ver_str,
  483. '--wrapper-path=%s' % wrapper_path,
  484. '--']
  485. me.extend(orig_args)
  486. me.extend(extra_args)
  487. try:
  488. os.execv(main, me)
  489. except OSError, e:
  490. print >>sys.stderr, "fatal: unable to start %s" % main
  491. print >>sys.stderr, "fatal: %s" % e
  492. sys.exit(148)
  493. if __name__ == '__main__':
  494. main(sys.argv[1:])