The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | ## repo default configuration |
| 4 | ## |
Shawn O. Pearce | 3f61950 | 2012-06-05 07:57:24 -0700 | [diff] [blame] | 5 | REPO_URL='https://gerrit.googlesource.com/git-repo' |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6 | REPO_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 | |
| 22 | magic='--calling-python-from-/bin/sh--' |
Shawn O. Pearce | 7542d66 | 2008-10-21 07:11:36 -0700 | [diff] [blame] | 23 | """exec" python -E "$0" "$@" """#$magic" |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 24 | if __name__ == '__main__': |
| 25 | import sys |
| 26 | if sys.argv[-1] == '#%s' % magic: |
| 27 | del sys.argv[-1] |
| 28 | del magic |
| 29 | |
| 30 | # increment this whenever we make important changes to this script |
Conley Owens | c9129d9 | 2012-10-01 16:12:28 -0700 | [diff] [blame] | 31 | VERSION = (1, 18) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 32 | |
| 33 | # increment this if the MAINTAINER_KEYS block is modified |
Conley Owens | 55e4d46 | 2012-10-01 16:12:28 -0700 | [diff] [blame^] | 34 | KEYRING_VERSION = (1,1) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 35 | MAINTAINER_KEYS = """ |
| 36 | |
| 37 | Repo Maintainer <repo@android.kernel.org> |
| 38 | -----BEGIN PGP PUBLIC KEY BLOCK----- |
| 39 | Version: GnuPG v1.4.2.2 (GNU/Linux) |
| 40 | |
| 41 | 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 |
| 76 | =CMiZ |
| 77 | -----END PGP PUBLIC KEY BLOCK----- |
Conley Owens | 55e4d46 | 2012-10-01 16:12:28 -0700 | [diff] [blame^] | 78 | |
| 79 | Conley Owens <cco3@android.com> |
| 80 | -----BEGIN PGP PUBLIC KEY BLOCK----- |
| 81 | Version: GnuPG v1.4.11 (GNU/Linux) |
| 82 | |
| 83 | mQENBFBiLPwBCACvISTASOgFXwADw2GYRH2I2z9RvYkYoZ6ThTTNlMXbbYYKO2Wo |
| 84 | a9LQDNW0TbCEekg5UKk0FD13XOdWaqUt4Gtuvq9c43GRSjMO6NXH+0BjcQ8vUtY2 |
| 85 | /W4CYUevwdo4nQ1+1zsOCu1XYe/CReXq0fdugv3hgmRmh3sz1soo37Q44W2frxxg |
| 86 | U7Rz3Da4FjgAL0RQ8qndD+LwRHXTY7H7wYM8V/3cYFZV7pSodd75q3MAXYQLf0ZV |
| 87 | QR1XATu5l1QnXrxgHvz7MmDwb1D+jX3YPKnZveaukigQ6hDHdiVcePBiGXmk8LZC |
| 88 | 2jQkdXeF7Su1ZYpr2nnEHLJ6vOLcCpPGb8gDABEBAAG0H0NvbmxleSBPd2VucyA8 |
| 89 | Y2NvM0BhbmRyb2lkLmNvbT6JATgEEwECACIFAlBiLPwCGwMGCwkIBwMCBhUIAgkK |
| 90 | CwQWAgMBAh4BAheAAAoJEBkmlFUziHGkHVkH/2Hks2Cif5i2xPtv2IFZcjL42joU |
| 91 | T7lO5XFqUYS9ZNHpGa/V0eiPt7rHoO16glR83NZtwlrq2cSN89i9HfOhMYV/qLu8 |
| 92 | fLCHcV2muw+yCB5s5bxnI5UkToiNZyBNqFkcOt/Kbj9Hpy68A1kmc6myVEaUYebq |
| 93 | 2Chx/f3xuEthan099t746v1K+/6SvQGDNctHuaMr9cWdxZtHjdRf31SQRc99Phe5 |
| 94 | w+ZGR/ebxNDKRK9mKgZT8wVFHlXerJsRqWIqtx1fsW1UgLgbpcpe2MChm6B5wTu0 |
| 95 | s1ltzox3l4q71FyRRPUJxXyvGkDLZWpK7EpiHSCOYq/KP3HkKeXU3xqHpcG5AQ0E |
| 96 | UGIs/AEIAKzO/7lO9cB6dshmZYo8Vy/b7aGicThE+ChcDSfhvyOXVdEM2GKAjsR+ |
| 97 | rlBWbTFX3It301p2HwZPFEi9nEvJxVlqqBiW0bPmNMkDRR55l2vbWg35wwkg6RyE |
| 98 | Bc5/TQjhXI2w8IvlimoGoUff4t3JmMOnWrnKSvL+5iuRj12p9WmanCHzw3Ee7ztf |
| 99 | /aU/q+FTpr3DLerb6S8xbv86ySgnJT6o5CyL2DCWRtnYQyGVi0ZmLzEouAYiO0hs |
| 100 | z0AAu28Mj+12g2WwePRz6gfM9rHtI37ylYW3oT/9M9mO9ei/Bc/1D7Dz6qNV+0vg |
| 101 | uSVJxM2Bl6GalHPZLhHntFEdIA6EdoUAEQEAAYkBHwQYAQIACQUCUGIs/AIbDAAK |
| 102 | CRAZJpRVM4hxpNfkB/0W/hP5WK/NETXBlWXXW7JPaWO2c5kGwD0lnj5RRmridyo1 |
| 103 | vbm5PdM91jOsDQYqRu6YOoYBnDnEhB2wL2bPh34HWwwrA+LwB8hlcAV2z1bdwyfl |
| 104 | 3R823fReKN3QcvLHzmvZPrF4Rk97M9UIyKS0RtnfTWykRgDWHIsrtQPoNwsXrWoT |
| 105 | 9LrM2v+1+9mp3vuXnE473/NHxmiWEQH9Ez+O/mOxQ7rSOlqGRiKq/IBZCfioJOtV |
| 106 | fTQeIu/yASZnsLBqr6SJEGwYBoWcyjG++k4fyw8ocOAo4uGDYbxgN7yYfNQ0OH7o |
| 107 | V6pfUgqKLWa/aK7/N1ZHnPdFLD8Xt0Dmy4BPwrKC |
| 108 | =O7am |
| 109 | -----END PGP PUBLIC KEY BLOCK----- |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 110 | """ |
| 111 | |
| 112 | GIT = 'git' # our git command |
| 113 | MIN_GIT_VERSION = (1, 5, 4) # minimum supported git version |
| 114 | repodir = '.repo' # name of repo's private directory |
Conley Owens | c9129d9 | 2012-10-01 16:12:28 -0700 | [diff] [blame] | 115 | S_repo = 'repo' # special repo repository |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 116 | S_manifests = 'manifests' # special manifest repository |
| 117 | REPO_MAIN = S_repo + '/main.py' # main script |
| 118 | |
| 119 | |
| 120 | import optparse |
| 121 | import os |
| 122 | import re |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 123 | import subprocess |
| 124 | import sys |
Shawn O. Pearce | f322b9a | 2011-09-19 14:50:58 -0700 | [diff] [blame] | 125 | import urllib2 |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 126 | |
| 127 | home_dot_repo = os.path.expanduser('~/.repoconfig') |
| 128 | gpg_dir = os.path.join(home_dot_repo, 'gnupg') |
| 129 | |
| 130 | extra_args = [] |
| 131 | init_optparse = optparse.OptionParser(usage="repo init -u url [options]") |
| 132 | |
| 133 | # Logging |
| 134 | group = init_optparse.add_option_group('Logging options') |
| 135 | group.add_option('-q', '--quiet', |
| 136 | dest="quiet", action="store_true", default=False, |
| 137 | help="be quiet") |
| 138 | |
| 139 | # Manifest |
| 140 | group = init_optparse.add_option_group('Manifest options') |
| 141 | group.add_option('-u', '--manifest-url', |
| 142 | dest='manifest_url', |
| 143 | help='manifest repository location', metavar='URL') |
| 144 | group.add_option('-b', '--manifest-branch', |
| 145 | dest='manifest_branch', |
| 146 | help='manifest branch or revision', metavar='REVISION') |
| 147 | group.add_option('-m', '--manifest-name', |
| 148 | dest='manifest_name', |
| 149 | help='initial manifest file', metavar='NAME.xml') |
Shawn O. Pearce | e284ad1 | 2008-11-04 07:37:10 -0800 | [diff] [blame] | 150 | group.add_option('--mirror', |
| 151 | dest='mirror', action='store_true', |
| 152 | help='mirror the forrest') |
Shawn O. Pearce | 8844338 | 2010-10-08 10:02:09 +0200 | [diff] [blame] | 153 | group.add_option('--reference', |
| 154 | dest='reference', |
| 155 | help='location of mirror directory', metavar='DIR') |
Doug Anderson | 49cd59b | 2011-06-13 21:42:06 -0700 | [diff] [blame] | 156 | group.add_option('--depth', type='int', default=None, |
| 157 | dest='depth', |
| 158 | help='create a shallow clone with given depth; see git clone') |
Colin Cross | 5acde75 | 2012-03-28 20:15:45 -0700 | [diff] [blame] | 159 | group.add_option('-g', '--groups', |
Conley Owens | 971de8e | 2012-04-16 10:36:08 -0700 | [diff] [blame] | 160 | dest='groups', default='default', |
Colin Cross | 5acde75 | 2012-03-28 20:15:45 -0700 | [diff] [blame] | 161 | help='restrict manifest projects to ones with a specified group', |
| 162 | metavar='GROUP') |
Conley Owens | d21720d | 2012-04-16 11:02:21 -0700 | [diff] [blame] | 163 | group.add_option('-p', '--platform', |
| 164 | dest='platform', default="auto", |
Conley Owens | c9129d9 | 2012-10-01 16:12:28 -0700 | [diff] [blame] | 165 | help='restrict manifest projects to ones with a specified ' |
Conley Owens | d21720d | 2012-04-16 11:02:21 -0700 | [diff] [blame] | 166 | 'platform group [auto|all|none|linux|darwin|...]', |
| 167 | metavar='PLATFORM') |
Doug Anderson | 49cd59b | 2011-06-13 21:42:06 -0700 | [diff] [blame] | 168 | |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 169 | |
| 170 | # Tool |
Shawn O. Pearce | fd89b67 | 2009-04-18 11:28:57 -0700 | [diff] [blame] | 171 | group = init_optparse.add_option_group('repo Version options') |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 172 | group.add_option('--repo-url', |
| 173 | dest='repo_url', |
| 174 | help='repo repository location', metavar='URL') |
| 175 | group.add_option('--repo-branch', |
| 176 | dest='repo_branch', |
| 177 | help='repo branch or revision', metavar='REVISION') |
| 178 | group.add_option('--no-repo-verify', |
| 179 | dest='no_repo_verify', action='store_true', |
| 180 | help='do not verify repo source code') |
| 181 | |
Victor Boivie | 841be34 | 2011-04-05 11:31:10 +0200 | [diff] [blame] | 182 | # Other |
| 183 | group = init_optparse.add_option_group('Other options') |
| 184 | group.add_option('--config-name', |
| 185 | dest='config_name', action="store_true", default=False, |
| 186 | help='Always prompt for name/e-mail') |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 187 | |
| 188 | class CloneFailure(Exception): |
| 189 | """Indicate the remote clone of repo itself failed. |
| 190 | """ |
| 191 | |
| 192 | |
| 193 | def _Init(args): |
| 194 | """Installs repo by cloning it over the network. |
| 195 | """ |
| 196 | opt, args = init_optparse.parse_args(args) |
Xiaodong Xu | ae0a36c | 2012-01-31 11:10:09 +0800 | [diff] [blame] | 197 | if args: |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 198 | init_optparse.print_usage() |
| 199 | sys.exit(1) |
| 200 | |
| 201 | url = opt.repo_url |
| 202 | if not url: |
| 203 | url = REPO_URL |
| 204 | extra_args.append('--repo-url=%s' % url) |
| 205 | |
| 206 | branch = opt.repo_branch |
| 207 | if not branch: |
| 208 | branch = REPO_REV |
| 209 | extra_args.append('--repo-branch=%s' % branch) |
| 210 | |
| 211 | if branch.startswith('refs/heads/'): |
| 212 | branch = branch[len('refs/heads/'):] |
| 213 | if branch.startswith('refs/'): |
| 214 | print >>sys.stderr, "fatal: invalid branch name '%s'" % branch |
| 215 | raise CloneFailure() |
| 216 | |
| 217 | if not os.path.isdir(repodir): |
| 218 | try: |
| 219 | os.mkdir(repodir) |
Sarah Owens | a5be53f | 2012-09-09 15:37:57 -0700 | [diff] [blame] | 220 | except OSError as e: |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 221 | print >>sys.stderr, \ |
| 222 | 'fatal: cannot make %s directory: %s' % ( |
| 223 | repodir, e.strerror) |
| 224 | # Don't faise CloneFailure; that would delete the |
| 225 | # name. Instead exit immediately. |
| 226 | # |
| 227 | sys.exit(1) |
| 228 | |
| 229 | _CheckGitVersion() |
| 230 | try: |
Conley Owens | c9129d9 | 2012-10-01 16:12:28 -0700 | [diff] [blame] | 231 | if NeedSetupGnuPG(): |
| 232 | can_verify = SetupGnuPG(opt.quiet) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 233 | else: |
| 234 | can_verify = True |
| 235 | |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 236 | dst = os.path.abspath(os.path.join(repodir, S_repo)) |
| 237 | _Clone(url, dst, opt.quiet) |
| 238 | |
| 239 | if can_verify and not opt.no_repo_verify: |
| 240 | rev = _Verify(dst, branch, opt.quiet) |
| 241 | else: |
| 242 | rev = 'refs/remotes/origin/%s^0' % branch |
| 243 | |
| 244 | _Checkout(dst, branch, rev, opt.quiet) |
| 245 | except CloneFailure: |
| 246 | if opt.quiet: |
| 247 | print >>sys.stderr, \ |
| 248 | 'fatal: repo init failed; run without --quiet to see why' |
| 249 | raise |
| 250 | |
| 251 | |
| 252 | def _CheckGitVersion(): |
| 253 | cmd = [GIT, '--version'] |
Shawn O. Pearce | 4fd38ec | 2012-06-05 07:55:07 -0700 | [diff] [blame] | 254 | try: |
| 255 | proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) |
Sarah Owens | a5be53f | 2012-09-09 15:37:57 -0700 | [diff] [blame] | 256 | except OSError as e: |
Shawn O. Pearce | 4fd38ec | 2012-06-05 07:55:07 -0700 | [diff] [blame] | 257 | print >>sys.stderr |
| 258 | print >>sys.stderr, "fatal: '%s' is not available" % GIT |
| 259 | print >>sys.stderr, 'fatal: %s' % e |
| 260 | print >>sys.stderr |
| 261 | print >>sys.stderr, 'Please make sure %s is installed'\ |
| 262 | ' and in your path.' % GIT |
| 263 | raise CloneFailure() |
| 264 | |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 265 | ver_str = proc.stdout.read().strip() |
| 266 | proc.stdout.close() |
Shawn O. Pearce | 1619134 | 2008-10-28 08:33:34 -0700 | [diff] [blame] | 267 | proc.wait() |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 268 | |
| 269 | if not ver_str.startswith('git version '): |
| 270 | print >>sys.stderr, 'error: "%s" unsupported' % ver_str |
| 271 | raise CloneFailure() |
| 272 | |
| 273 | ver_str = ver_str[len('git version '):].strip() |
| 274 | ver_act = tuple(map(lambda x: int(x), ver_str.split('.')[0:3])) |
| 275 | if ver_act < MIN_GIT_VERSION: |
| 276 | need = '.'.join(map(lambda x: str(x), MIN_GIT_VERSION)) |
| 277 | print >>sys.stderr, 'fatal: git %s or later required' % need |
| 278 | raise CloneFailure() |
| 279 | |
| 280 | |
Conley Owens | c9129d9 | 2012-10-01 16:12:28 -0700 | [diff] [blame] | 281 | def NeedSetupGnuPG(): |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 282 | if not os.path.isdir(home_dot_repo): |
| 283 | return True |
| 284 | |
| 285 | kv = os.path.join(home_dot_repo, 'keyring-version') |
| 286 | if not os.path.exists(kv): |
| 287 | return True |
| 288 | |
| 289 | kv = open(kv).read() |
| 290 | if not kv: |
| 291 | return True |
| 292 | |
| 293 | kv = tuple(map(lambda x: int(x), kv.split('.'))) |
| 294 | if kv < KEYRING_VERSION: |
| 295 | return True |
| 296 | return False |
| 297 | |
| 298 | |
Conley Owens | c9129d9 | 2012-10-01 16:12:28 -0700 | [diff] [blame] | 299 | def SetupGnuPG(quiet): |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 300 | if not os.path.isdir(home_dot_repo): |
| 301 | try: |
| 302 | os.mkdir(home_dot_repo) |
Sarah Owens | a5be53f | 2012-09-09 15:37:57 -0700 | [diff] [blame] | 303 | except OSError as e: |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 304 | print >>sys.stderr, \ |
| 305 | 'fatal: cannot make %s directory: %s' % ( |
| 306 | home_dot_repo, e.strerror) |
| 307 | sys.exit(1) |
| 308 | |
| 309 | if not os.path.isdir(gpg_dir): |
| 310 | try: |
| 311 | os.mkdir(gpg_dir, 0700) |
Sarah Owens | a5be53f | 2012-09-09 15:37:57 -0700 | [diff] [blame] | 312 | except OSError as e: |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 313 | print >>sys.stderr, \ |
| 314 | 'fatal: cannot make %s directory: %s' % ( |
| 315 | gpg_dir, e.strerror) |
| 316 | sys.exit(1) |
| 317 | |
Shawn O. Pearce | f18cb76 | 2010-12-07 11:41:05 -0800 | [diff] [blame] | 318 | env = os.environ.copy() |
| 319 | env['GNUPGHOME'] = gpg_dir.encode() |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 320 | |
| 321 | cmd = ['gpg', '--import'] |
| 322 | try: |
| 323 | proc = subprocess.Popen(cmd, |
| 324 | env = env, |
| 325 | stdin = subprocess.PIPE) |
Sarah Owens | a5be53f | 2012-09-09 15:37:57 -0700 | [diff] [blame] | 326 | except OSError as e: |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 327 | if not quiet: |
| 328 | print >>sys.stderr, 'warning: gpg (GnuPG) is not available.' |
| 329 | print >>sys.stderr, 'warning: Installing it is strongly encouraged.' |
| 330 | print >>sys.stderr |
| 331 | return False |
| 332 | |
| 333 | proc.stdin.write(MAINTAINER_KEYS) |
| 334 | proc.stdin.close() |
| 335 | |
| 336 | if proc.wait() != 0: |
| 337 | print >>sys.stderr, 'fatal: registering repo maintainer keys failed' |
| 338 | sys.exit(1) |
| 339 | print |
| 340 | |
| 341 | fd = open(os.path.join(home_dot_repo, 'keyring-version'), 'w') |
| 342 | fd.write('.'.join(map(lambda x: str(x), KEYRING_VERSION)) + '\n') |
| 343 | fd.close() |
| 344 | return True |
| 345 | |
| 346 | |
| 347 | def _SetConfig(local, name, value): |
| 348 | """Set a git configuration option to the specified value. |
| 349 | """ |
| 350 | cmd = [GIT, 'config', name, value] |
| 351 | if subprocess.Popen(cmd, cwd = local).wait() != 0: |
| 352 | raise CloneFailure() |
| 353 | |
Shawn O. Pearce | f322b9a | 2011-09-19 14:50:58 -0700 | [diff] [blame] | 354 | |
| 355 | def _InitHttp(): |
| 356 | handlers = [] |
| 357 | |
| 358 | mgr = urllib2.HTTPPasswordMgrWithDefaultRealm() |
| 359 | try: |
| 360 | import netrc |
| 361 | n = netrc.netrc() |
| 362 | for host in n.hosts: |
| 363 | p = n.hosts[host] |
Xiaodong Xu | ae0a36c | 2012-01-31 11:10:09 +0800 | [diff] [blame] | 364 | mgr.add_password(p[1], 'http://%s/' % host, p[0], p[2]) |
| 365 | mgr.add_password(p[1], 'https://%s/' % host, p[0], p[2]) |
Shawn O. Pearce | f322b9a | 2011-09-19 14:50:58 -0700 | [diff] [blame] | 366 | except: |
| 367 | pass |
| 368 | handlers.append(urllib2.HTTPBasicAuthHandler(mgr)) |
Xiaodong Xu | ae0a36c | 2012-01-31 11:10:09 +0800 | [diff] [blame] | 369 | handlers.append(urllib2.HTTPDigestAuthHandler(mgr)) |
Shawn O. Pearce | f322b9a | 2011-09-19 14:50:58 -0700 | [diff] [blame] | 370 | |
| 371 | if 'http_proxy' in os.environ: |
| 372 | url = os.environ['http_proxy'] |
| 373 | handlers.append(urllib2.ProxyHandler({'http': url, 'https': url})) |
| 374 | if 'REPO_CURL_VERBOSE' in os.environ: |
| 375 | handlers.append(urllib2.HTTPHandler(debuglevel=1)) |
| 376 | handlers.append(urllib2.HTTPSHandler(debuglevel=1)) |
| 377 | urllib2.install_opener(urllib2.build_opener(*handlers)) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 378 | |
Shawn O. Pearce | f322b9a | 2011-09-19 14:50:58 -0700 | [diff] [blame] | 379 | def _Fetch(url, local, src, quiet): |
| 380 | if not quiet: |
| 381 | print >>sys.stderr, 'Get %s' % url |
| 382 | |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 383 | cmd = [GIT, 'fetch'] |
| 384 | if quiet: |
| 385 | cmd.append('--quiet') |
| 386 | err = subprocess.PIPE |
| 387 | else: |
| 388 | err = None |
Shawn O. Pearce | f322b9a | 2011-09-19 14:50:58 -0700 | [diff] [blame] | 389 | cmd.append(src) |
| 390 | cmd.append('+refs/heads/*:refs/remotes/origin/*') |
| 391 | cmd.append('refs/tags/*:refs/tags/*') |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 392 | |
| 393 | proc = subprocess.Popen(cmd, cwd = local, stderr = err) |
| 394 | if err: |
| 395 | proc.stderr.read() |
| 396 | proc.stderr.close() |
| 397 | if proc.wait() != 0: |
| 398 | raise CloneFailure() |
| 399 | |
Shawn O. Pearce | f322b9a | 2011-09-19 14:50:58 -0700 | [diff] [blame] | 400 | def _DownloadBundle(url, local, quiet): |
| 401 | if not url.endswith('/'): |
| 402 | url += '/' |
| 403 | url += 'clone.bundle' |
| 404 | |
| 405 | proc = subprocess.Popen( |
| 406 | [GIT, 'config', '--get-regexp', 'url.*.insteadof'], |
| 407 | cwd = local, |
| 408 | stdout = subprocess.PIPE) |
| 409 | for line in proc.stdout: |
| 410 | m = re.compile(r'^url\.(.*)\.insteadof (.*)$').match(line) |
| 411 | if m: |
| 412 | new_url = m.group(1) |
| 413 | old_url = m.group(2) |
| 414 | if url.startswith(old_url): |
| 415 | url = new_url + url[len(old_url):] |
| 416 | break |
| 417 | proc.stdout.close() |
| 418 | proc.wait() |
| 419 | |
| 420 | if not url.startswith('http:') and not url.startswith('https:'): |
| 421 | return False |
| 422 | |
| 423 | dest = open(os.path.join(local, '.git', 'clone.bundle'), 'w+b') |
| 424 | try: |
| 425 | try: |
| 426 | r = urllib2.urlopen(url) |
Sarah Owens | a5be53f | 2012-09-09 15:37:57 -0700 | [diff] [blame] | 427 | except urllib2.HTTPError as e: |
Shawn O. Pearce | f322b9a | 2011-09-19 14:50:58 -0700 | [diff] [blame] | 428 | if e.code == 404: |
| 429 | return False |
| 430 | print >>sys.stderr, 'fatal: Cannot get %s' % url |
| 431 | print >>sys.stderr, 'fatal: HTTP error %s' % e.code |
| 432 | raise CloneFailure() |
Sarah Owens | a5be53f | 2012-09-09 15:37:57 -0700 | [diff] [blame] | 433 | except urllib2.URLError as e: |
Shawn O. Pearce | f322b9a | 2011-09-19 14:50:58 -0700 | [diff] [blame] | 434 | print >>sys.stderr, 'fatal: Cannot get %s' % url |
| 435 | print >>sys.stderr, 'fatal: error %s' % e.reason |
| 436 | raise CloneFailure() |
| 437 | try: |
| 438 | if not quiet: |
| 439 | print >>sys.stderr, 'Get %s' % url |
| 440 | while True: |
| 441 | buf = r.read(8192) |
| 442 | if buf == '': |
| 443 | return True |
| 444 | dest.write(buf) |
| 445 | finally: |
| 446 | r.close() |
| 447 | finally: |
| 448 | dest.close() |
| 449 | |
| 450 | def _ImportBundle(local): |
| 451 | path = os.path.join(local, '.git', 'clone.bundle') |
| 452 | try: |
| 453 | _Fetch(local, local, path, True) |
| 454 | finally: |
| 455 | os.remove(path) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 456 | |
| 457 | def _Clone(url, local, quiet): |
| 458 | """Clones a git repository to a new subdirectory of repodir |
| 459 | """ |
| 460 | try: |
| 461 | os.mkdir(local) |
Sarah Owens | a5be53f | 2012-09-09 15:37:57 -0700 | [diff] [blame] | 462 | except OSError as e: |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 463 | print >>sys.stderr, \ |
| 464 | 'fatal: cannot make %s directory: %s' \ |
| 465 | % (local, e.strerror) |
| 466 | raise CloneFailure() |
| 467 | |
| 468 | cmd = [GIT, 'init', '--quiet'] |
| 469 | try: |
| 470 | proc = subprocess.Popen(cmd, cwd = local) |
Sarah Owens | a5be53f | 2012-09-09 15:37:57 -0700 | [diff] [blame] | 471 | except OSError as e: |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 472 | print >>sys.stderr |
| 473 | print >>sys.stderr, "fatal: '%s' is not available" % GIT |
| 474 | print >>sys.stderr, 'fatal: %s' % e |
| 475 | print >>sys.stderr |
| 476 | print >>sys.stderr, 'Please make sure %s is installed'\ |
| 477 | ' and in your path.' % GIT |
| 478 | raise CloneFailure() |
| 479 | if proc.wait() != 0: |
| 480 | print >>sys.stderr, 'fatal: could not create %s' % local |
| 481 | raise CloneFailure() |
| 482 | |
Shawn O. Pearce | f322b9a | 2011-09-19 14:50:58 -0700 | [diff] [blame] | 483 | _InitHttp() |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 484 | _SetConfig(local, 'remote.origin.url', url) |
| 485 | _SetConfig(local, 'remote.origin.fetch', |
| 486 | '+refs/heads/*:refs/remotes/origin/*') |
Shawn O. Pearce | f322b9a | 2011-09-19 14:50:58 -0700 | [diff] [blame] | 487 | if _DownloadBundle(url, local, quiet): |
| 488 | _ImportBundle(local) |
| 489 | else: |
| 490 | _Fetch(url, local, 'origin', quiet) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 491 | |
| 492 | |
| 493 | def _Verify(cwd, branch, quiet): |
| 494 | """Verify the branch has been signed by a tag. |
| 495 | """ |
| 496 | cmd = [GIT, 'describe', 'origin/%s' % branch] |
| 497 | proc = subprocess.Popen(cmd, |
| 498 | stdout=subprocess.PIPE, |
| 499 | stderr=subprocess.PIPE, |
| 500 | cwd = cwd) |
| 501 | cur = proc.stdout.read().strip() |
| 502 | proc.stdout.close() |
| 503 | |
| 504 | proc.stderr.read() |
| 505 | proc.stderr.close() |
| 506 | |
| 507 | if proc.wait() != 0 or not cur: |
| 508 | print >>sys.stderr |
| 509 | print >>sys.stderr,\ |
| 510 | "fatal: branch '%s' has not been signed" \ |
| 511 | % branch |
| 512 | raise CloneFailure() |
| 513 | |
| 514 | m = re.compile(r'^(.*)-[0-9]{1,}-g[0-9a-f]{1,}$').match(cur) |
| 515 | if m: |
| 516 | cur = m.group(1) |
| 517 | if not quiet: |
| 518 | print >>sys.stderr |
| 519 | print >>sys.stderr, \ |
| 520 | "info: Ignoring branch '%s'; using tagged release '%s'" \ |
| 521 | % (branch, cur) |
| 522 | print >>sys.stderr |
| 523 | |
Shawn O. Pearce | f18cb76 | 2010-12-07 11:41:05 -0800 | [diff] [blame] | 524 | env = os.environ.copy() |
| 525 | env['GNUPGHOME'] = gpg_dir.encode() |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 526 | |
| 527 | cmd = [GIT, 'tag', '-v', cur] |
| 528 | proc = subprocess.Popen(cmd, |
| 529 | stdout = subprocess.PIPE, |
| 530 | stderr = subprocess.PIPE, |
| 531 | cwd = cwd, |
| 532 | env = env) |
| 533 | out = proc.stdout.read() |
| 534 | proc.stdout.close() |
| 535 | |
| 536 | err = proc.stderr.read() |
| 537 | proc.stderr.close() |
| 538 | |
| 539 | if proc.wait() != 0: |
| 540 | print >>sys.stderr |
| 541 | print >>sys.stderr, out |
| 542 | print >>sys.stderr, err |
| 543 | print >>sys.stderr |
| 544 | raise CloneFailure() |
| 545 | return '%s^0' % cur |
| 546 | |
| 547 | |
| 548 | def _Checkout(cwd, branch, rev, quiet): |
| 549 | """Checkout an upstream branch into the repository and track it. |
| 550 | """ |
| 551 | cmd = [GIT, 'update-ref', 'refs/heads/default', rev] |
| 552 | if subprocess.Popen(cmd, cwd = cwd).wait() != 0: |
| 553 | raise CloneFailure() |
| 554 | |
| 555 | _SetConfig(cwd, 'branch.default.remote', 'origin') |
| 556 | _SetConfig(cwd, 'branch.default.merge', 'refs/heads/%s' % branch) |
| 557 | |
| 558 | cmd = [GIT, 'symbolic-ref', 'HEAD', 'refs/heads/default'] |
| 559 | if subprocess.Popen(cmd, cwd = cwd).wait() != 0: |
| 560 | raise CloneFailure() |
| 561 | |
| 562 | cmd = [GIT, 'read-tree', '--reset', '-u'] |
| 563 | if not quiet: |
| 564 | cmd.append('-v') |
| 565 | cmd.append('HEAD') |
| 566 | if subprocess.Popen(cmd, cwd = cwd).wait() != 0: |
| 567 | raise CloneFailure() |
| 568 | |
| 569 | |
| 570 | def _FindRepo(): |
| 571 | """Look for a repo installation, starting at the current directory. |
| 572 | """ |
Mickaël Salaün | 2f6ab7f | 2012-09-30 00:37:55 +0200 | [diff] [blame] | 573 | curdir = os.getcwd() |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 574 | repo = None |
| 575 | |
Anthony Newnam | df14a70 | 2011-01-09 17:31:57 -0800 | [diff] [blame] | 576 | olddir = None |
Mickaël Salaün | 2f6ab7f | 2012-09-30 00:37:55 +0200 | [diff] [blame] | 577 | while curdir != '/' \ |
| 578 | and curdir != olddir \ |
Anthony Newnam | df14a70 | 2011-01-09 17:31:57 -0800 | [diff] [blame] | 579 | and not repo: |
Mickaël Salaün | 2f6ab7f | 2012-09-30 00:37:55 +0200 | [diff] [blame] | 580 | repo = os.path.join(curdir, repodir, REPO_MAIN) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 581 | if not os.path.isfile(repo): |
| 582 | repo = None |
Mickaël Salaün | 2f6ab7f | 2012-09-30 00:37:55 +0200 | [diff] [blame] | 583 | olddir = curdir |
| 584 | curdir = os.path.dirname(curdir) |
| 585 | return (repo, os.path.join(curdir, repodir)) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 586 | |
| 587 | |
| 588 | class _Options: |
| 589 | help = False |
| 590 | |
| 591 | |
| 592 | def _ParseArguments(args): |
| 593 | cmd = None |
| 594 | opt = _Options() |
| 595 | arg = [] |
| 596 | |
| 597 | for i in xrange(0, len(args)): |
| 598 | a = args[i] |
| 599 | if a == '-h' or a == '--help': |
| 600 | opt.help = True |
| 601 | |
| 602 | elif not a.startswith('-'): |
| 603 | cmd = a |
| 604 | arg = args[i + 1:] |
| 605 | break |
| 606 | return cmd, opt, arg |
| 607 | |
| 608 | |
| 609 | def _Usage(): |
| 610 | print >>sys.stderr,\ |
| 611 | """usage: repo COMMAND [ARGS] |
| 612 | |
| 613 | repo is not yet installed. Use "repo init" to install it here. |
| 614 | |
| 615 | The most commonly used repo commands are: |
| 616 | |
| 617 | init Install repo in the current working directory |
| 618 | help Display detailed help on a command |
| 619 | |
| 620 | For access to the full online help, install repo ("repo init"). |
| 621 | """ |
| 622 | sys.exit(1) |
| 623 | |
| 624 | |
| 625 | def _Help(args): |
| 626 | if args: |
| 627 | if args[0] == 'init': |
| 628 | init_optparse.print_help() |
Trond Norbye | d3fd537 | 2011-01-03 11:35:15 +0100 | [diff] [blame] | 629 | sys.exit(0) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 630 | else: |
| 631 | print >>sys.stderr,\ |
| 632 | "error: '%s' is not a bootstrap command.\n"\ |
| 633 | ' For access to online help, install repo ("repo init").'\ |
| 634 | % args[0] |
| 635 | else: |
| 636 | _Usage() |
| 637 | sys.exit(1) |
| 638 | |
| 639 | |
| 640 | def _NotInstalled(): |
| 641 | print >>sys.stderr,\ |
| 642 | 'error: repo is not installed. Use "repo init" to install it here.' |
| 643 | sys.exit(1) |
| 644 | |
| 645 | |
| 646 | def _NoCommands(cmd): |
| 647 | print >>sys.stderr,\ |
| 648 | """error: command '%s' requires repo to be installed first. |
| 649 | Use "repo init" to install it here.""" % cmd |
| 650 | sys.exit(1) |
| 651 | |
| 652 | |
| 653 | def _RunSelf(wrapper_path): |
| 654 | my_dir = os.path.dirname(wrapper_path) |
| 655 | my_main = os.path.join(my_dir, 'main.py') |
| 656 | my_git = os.path.join(my_dir, '.git') |
| 657 | |
| 658 | if os.path.isfile(my_main) and os.path.isdir(my_git): |
Shawn O. Pearce | c8a300f | 2009-05-18 13:19:57 -0700 | [diff] [blame] | 659 | for name in ['git_config.py', |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 660 | 'project.py', |
| 661 | 'subcmds']: |
| 662 | if not os.path.exists(os.path.join(my_dir, name)): |
| 663 | return None, None |
| 664 | return my_main, my_git |
| 665 | return None, None |
| 666 | |
| 667 | |
| 668 | def _SetDefaultsTo(gitdir): |
| 669 | global REPO_URL |
| 670 | global REPO_REV |
| 671 | |
| 672 | REPO_URL = gitdir |
| 673 | proc = subprocess.Popen([GIT, |
| 674 | '--git-dir=%s' % gitdir, |
| 675 | 'symbolic-ref', |
| 676 | 'HEAD'], |
| 677 | stdout = subprocess.PIPE, |
| 678 | stderr = subprocess.PIPE) |
| 679 | REPO_REV = proc.stdout.read().strip() |
| 680 | proc.stdout.close() |
| 681 | |
| 682 | proc.stderr.read() |
| 683 | proc.stderr.close() |
| 684 | |
| 685 | if proc.wait() != 0: |
| 686 | print >>sys.stderr, 'fatal: %s has no current branch' % gitdir |
| 687 | sys.exit(1) |
| 688 | |
| 689 | |
| 690 | def main(orig_args): |
Mickaël Salaün | 2f6ab7f | 2012-09-30 00:37:55 +0200 | [diff] [blame] | 691 | repo_main, rel_repo_dir = _FindRepo() |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 692 | cmd, opt, args = _ParseArguments(orig_args) |
| 693 | |
| 694 | wrapper_path = os.path.abspath(__file__) |
| 695 | my_main, my_git = _RunSelf(wrapper_path) |
| 696 | |
Mickaël Salaün | 2f6ab7f | 2012-09-30 00:37:55 +0200 | [diff] [blame] | 697 | if not repo_main: |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 698 | if opt.help: |
| 699 | _Usage() |
| 700 | if cmd == 'help': |
| 701 | _Help(args) |
| 702 | if not cmd: |
| 703 | _NotInstalled() |
| 704 | if cmd == 'init': |
| 705 | if my_git: |
| 706 | _SetDefaultsTo(my_git) |
| 707 | try: |
| 708 | _Init(args) |
| 709 | except CloneFailure: |
| 710 | for root, dirs, files in os.walk(repodir, topdown=False): |
| 711 | for name in files: |
| 712 | os.remove(os.path.join(root, name)) |
| 713 | for name in dirs: |
| 714 | os.rmdir(os.path.join(root, name)) |
| 715 | os.rmdir(repodir) |
| 716 | sys.exit(1) |
Mickaël Salaün | 2f6ab7f | 2012-09-30 00:37:55 +0200 | [diff] [blame] | 717 | repo_main, rel_repo_dir = _FindRepo() |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 718 | else: |
| 719 | _NoCommands(cmd) |
| 720 | |
| 721 | if my_main: |
Mickaël Salaün | 2f6ab7f | 2012-09-30 00:37:55 +0200 | [diff] [blame] | 722 | repo_main = my_main |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 723 | |
| 724 | ver_str = '.'.join(map(lambda x: str(x), VERSION)) |
Mickaël Salaün | 2f6ab7f | 2012-09-30 00:37:55 +0200 | [diff] [blame] | 725 | me = [repo_main, |
| 726 | '--repo-dir=%s' % rel_repo_dir, |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 727 | '--wrapper-version=%s' % ver_str, |
| 728 | '--wrapper-path=%s' % wrapper_path, |
| 729 | '--'] |
| 730 | me.extend(orig_args) |
| 731 | me.extend(extra_args) |
| 732 | try: |
Mickaël Salaün | 2f6ab7f | 2012-09-30 00:37:55 +0200 | [diff] [blame] | 733 | os.execv(repo_main, me) |
Sarah Owens | a5be53f | 2012-09-09 15:37:57 -0700 | [diff] [blame] | 734 | except OSError as e: |
Mickaël Salaün | 2f6ab7f | 2012-09-30 00:37:55 +0200 | [diff] [blame] | 735 | print >>sys.stderr, "fatal: unable to start %s" % repo_main |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 736 | print >>sys.stderr, "fatal: %s" % e |
| 737 | sys.exit(148) |
| 738 | |
| 739 | |
| 740 | if __name__ == '__main__': |
| 741 | main(sys.argv[1:]) |