akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 2 | |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 3 | # repo default configuration |
| 4 | # |
| 5 | import os |
| 6 | REPO_URL = os.environ.get('REPO_URL', None) |
| 7 | if not REPO_URL: |
| 8 | REPO_URL = 'https://chromium.googlesource.com/external/repo' |
| 9 | REPO_REV = 'stable' |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 10 | |
| 11 | # Copyright (C) 2008 Google Inc. |
| 12 | # |
| 13 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 14 | # you may not use this file except in compliance with the License. |
| 15 | # You may obtain a copy of the License at |
| 16 | # |
| 17 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 18 | # |
| 19 | # Unless required by applicable law or agreed to in writing, software |
| 20 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 21 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 22 | # See the License for the specific language governing permissions and |
| 23 | # limitations under the License. |
| 24 | |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 25 | # increment this whenever we make important changes to this script |
Don Garrett | 24f2cc0 | 2018-12-18 18:07:17 +0000 | [diff] [blame] | 26 | VERSION = (1, 24) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 27 | |
| 28 | # increment this if the MAINTAINER_KEYS block is modified |
vapier | 7475196 | 2016-09-14 16:08:34 -0700 | [diff] [blame] | 29 | KEYRING_VERSION = (1, 5) |
Don Garrett | 24f2cc0 | 2018-12-18 18:07:17 +0000 | [diff] [blame] | 30 | |
| 31 | # Each individual key entry is created by using: |
| 32 | # gpg --armor --export keyid |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 33 | MAINTAINER_KEYS = """ |
| 34 | |
| 35 | Repo Maintainer <repo@android.kernel.org> |
| 36 | -----BEGIN PGP PUBLIC KEY BLOCK----- |
| 37 | Version: GnuPG v1.4.2.2 (GNU/Linux) |
| 38 | |
| 39 | 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 |
| 74 | =CMiZ |
| 75 | -----END PGP PUBLIC KEY BLOCK----- |
ferringb@google.com | 8db6c88 | 2012-12-25 17:02:37 +0000 | [diff] [blame] | 76 | |
| 77 | Conley Owens <cco3@android.com> |
| 78 | -----BEGIN PGP PUBLIC KEY BLOCK----- |
| 79 | Version: GnuPG v1.4.11 (GNU/Linux) |
| 80 | |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 81 | mQENBFHRvc8BCADFg45Xx/y6QDC+T7Y/gGc7vx0ww7qfOwIKlAZ9xG3qKunMxo+S |
| 82 | hPCnzEl3cq+6I1Ww/ndop/HB3N3toPXRCoN8Vs4/Hc7by+SnaLFnacrm+tV5/OgT |
| 83 | V37Lzt8lhay1Kl+YfpFwHYYpIEBLFV9knyfRXS/428W2qhdzYfvB15/AasRmwmor |
| 84 | py4NIzSs8UD/SPr1ihqNCdZM76+MQyN5HMYXW/ALZXUFG0pwluHFA7hrfPG74i8C |
| 85 | zMiP7qvMWIl/r/jtzHioH1dRKgbod+LZsrDJ8mBaqsZaDmNJMhss9g76XvfMyLra |
| 86 | 9DI9/iFuBpGzeqBv0hwOGQspLRrEoyTeR6n1ABEBAAG0H0NvbmxleSBPd2VucyA8 |
| 87 | Y2NvM0BhbmRyb2lkLmNvbT6JATgEEwECACIFAlHRvc8CGwMGCwkIBwMCBhUIAgkK |
| 88 | CwQWAgMBAh4BAheAAAoJEGe35EhpKzgsP6AIAJKJmNtn4l7hkYHKHFSo3egb6RjQ |
| 89 | zEIP3MFTcu8HFX1kF1ZFbrp7xqurLaE53kEkKuAAvjJDAgI8mcZHP1JyplubqjQA |
| 90 | xvv84gK+OGP3Xk+QK1ZjUQSbjOpjEiSZpRhWcHci3dgOUH4blJfByHw25hlgHowd |
| 91 | a/2PrNKZVcJ92YienaxxGjcXEUcd0uYEG2+rwllQigFcnMFDhr9B71MfalRHjFKE |
| 92 | fmdoypqLrri61YBc59P88Rw2/WUpTQjgNubSqa3A2+CKdaRyaRw+2fdF4TdR0h8W |
| 93 | zbg+lbaPtJHsV+3mJC7fq26MiJDRJa5ZztpMn8su20gbLgi2ShBOaHAYDDi5AQ0E |
| 94 | UdG9zwEIAMoOBq+QLNozAhxOOl5GL3StTStGRgPRXINfmViTsihrqGCWBBUfXlUE |
| 95 | OytC0mYcrDUQev/8ToVoyqw+iGSwDkcSXkrEUCKFtHV/GECWtk1keyHgR10YKI1R |
| 96 | mquSXoubWGqPeG1PAI74XWaRx8UrL8uCXUtmD8Q5J7mDjKR5NpxaXrwlA0bKsf2E |
| 97 | Gp9tu1kKauuToZhWHMRMqYSOGikQJwWSFYKT1KdNcOXLQF6+bfoJ6sjVYdwfmNQL |
| 98 | Ixn8QVhoTDedcqClSWB17VDEFDFa7MmqXZz2qtM3X1R/MUMHqPtegQzBGNhRdnI2 |
| 99 | V45+1Nnx/uuCxDbeI4RbHzujnxDiq70AEQEAAYkBHwQYAQIACQUCUdG9zwIbDAAK |
| 100 | CRBnt+RIaSs4LNVeB/0Y2pZ8I7gAAcEM0Xw8drr4omg2fUoK1J33ozlA/RxeA/lJ |
| 101 | I3KnyCDTpXuIeBKPGkdL8uMATC9Z8DnBBajRlftNDVZS3Hz4G09G9QpMojvJkFJV |
| 102 | By+01Flw/X+eeN8NpqSuLV4W+AjEO8at/VvgKr1AFvBRdZ7GkpI1o6DgPe7ZqX+1 |
| 103 | dzQZt3e13W0rVBb/bUgx9iSLoeWP3aq/k+/GRGOR+S6F6BBSl0SQ2EF2+dIywb1x |
| 104 | JuinEP+AwLAUZ1Bsx9ISC0Agpk2VeHXPL3FGhroEmoMvBzO0kTFGyoeT7PR/BfKv |
| 105 | +H/g3HsL2LOB9uoIm8/5p2TTU5ttYCXMHhQZ81AY |
| 106 | =AUp4 |
ferringb@google.com | 8db6c88 | 2012-12-25 17:02:37 +0000 | [diff] [blame] | 107 | -----END PGP PUBLIC KEY BLOCK----- |
szager@chromium.org | 538283f | 2013-08-13 21:37:50 +0000 | [diff] [blame] | 108 | |
| 109 | Stefan Zager <szager@chromium.org> |
| 110 | -----BEGIN PGP PUBLIC KEY BLOCK----- |
| 111 | Version: GnuPG v1.4.11 (GNU/Linux) |
| 112 | |
| 113 | mQINBFIJOcgBEADwZIq4GRGoO1RJFKlrtVK501cwT5H+Acbizc9N5RxTkFmqxDjb |
| 114 | 9ApUaPW6S1b8+nrzE9P1Ri5erfzipuStfaZ/Wl3mP1JjKulibddmgnPOEbAJ673k |
| 115 | Vj85RUO4rt2oZAHnZN3D3gFJzVY8JVlZ47Enj9fTqzcW78FVsPCpIT9P2LpTLWeE |
| 116 | jX9Cjxeimy6VvyJstIcDLYhlpUN5UWen79L4LFAkHf3luLuU4W3p9NriqUsy5UG2 |
| 117 | 8vO6QdhKrCr5wsjDFFeVnpMtjlSeZJAWH+XhFFibMX1xP5R9BTuJfzw3kOVKvcE0 |
| 118 | e9ClxgoulepXPv2xnDkqO3pG2gQVzl8LA+Aol8/IXfa7KP5FBkxK/g1cDuDtXRk4 |
| 119 | YLpLaLYeeKEhhOHLpsKYkK2DXTIcN+56UnTLGolummpZnCM8UUSZxQgbkFgk4YJL |
| 120 | Elip0hgLZzqEl5h9vjmnQp89AZIHKcgNmzn+szLTOR9x24joaLyQ534x8OSC8lmu |
| 121 | tJv2tQjDOVGWVwvY4gOTpyxCWMwur6WOiMk/TPWdiVRFWAGrAHwf0/CTBEqNhosh |
| 122 | sVXfPeMADBA0PorDbJ6kwcOkLUTGf8CT7OG1R9TuKPEmSjK7BYu/pT4DXitaRCiv |
| 123 | uPVlwbVFpLFr0/jwaKJVMLUjL5MaYwzjJqI2c4RdROZhpMhkn4LvCMmFSQARAQAB |
| 124 | tCJTdGVmYW4gWmFnZXIgPHN6YWdlckBjaHJvbWl1bS5vcmc+iQI4BBMBAgAiBQJS |
| 125 | CTnIAhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRDcuoHPGCdZNU0UD/9y |
| 126 | 0zwwOJH2UGPAzZ0YVzr7p0HtKedoxuFvPkdQxlBIaUOueMzFRmNQu3GI9irAu3MQ |
| 127 | Jkip8/gi7dnLVmJyS/zWARBaRGwSVd1++87XDjw8n7l181p7394X0Agq/heri599 |
| 128 | YheHXkxXKVMPqByWNEPHu4eDbxeJTaDIjcKC2pzKQkm6HbWgW4wA9gCh1TRki8FP |
| 129 | LMv1Fu/dr13STCR9P2evsTRZ+ZSJhTSboHNHeEAJGiGZQAsN94oht7647lYj+AyR |
| 130 | ThzyHDMXXiDr8jPJIkyRilY+y82bCOatOfPoCkce3VI+LRUGJ19hJY01m4RRneIE |
| 131 | 55l7fXR3zggcsONjV5b+oLcGQPGgX9w64BJ7khT7Wb9+kuyrdJBIBzJsaACFEbri |
| 132 | pPi02FS/HahYpLC3J66REAeNyofgVXau6WQsHrHMGsBTL9aAr0nrCrkF4Nyyc2Jd |
| 133 | do6nYuljuUhORqbEECmmBM2eBtkL6Ac92D6WMBIwBOC5tCNHO2YFIvi8Y8EuE8sc |
| 134 | 1zB5U5Ai4SIu2icRAhzAhCRaUq02cMWuELKH6Vuh9nzgEefFWty6vPbKEyZLu19D |
| 135 | B80aqP1cTN88FjtKQ/eTF29TUB6AefUeBS17e2e3WUMy4nc8tduuOFYfiHP40ScP |
| 136 | wOoatwfzpiTIPGbocUEPL+pS0O/Xy8SINxFMCud3zA== |
| 137 | =Vd2S |
| 138 | -----END PGP PUBLIC KEY BLOCK----- |
szager@chromium.org | 33c182b | 2014-09-08 17:50:45 +0000 | [diff] [blame] | 139 | |
| 140 | David James <davidjames@google.com> |
| 141 | -----BEGIN PGP PUBLIC KEY BLOCK----- |
| 142 | Version: GnuPG v1 |
| 143 | |
| 144 | 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 |
| 190 | IM4= |
| 191 | =6VNc |
| 192 | -----END PGP PUBLIC KEY BLOCK----- |
vapier | 7475196 | 2016-09-14 16:08:34 -0700 | [diff] [blame] | 193 | |
| 194 | Mike Frysinger <vapier@chromium.org> |
| 195 | -----BEGIN PGP PUBLIC KEY BLOCK----- |
| 196 | Version: GnuPG v1 |
| 197 | |
| 198 | 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 |
| 233 | =i88c |
| 234 | -----END PGP PUBLIC KEY BLOCK----- |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 235 | """ |
| 236 | |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 237 | GIT = 'git' # our git command |
| 238 | MIN_GIT_VERSION = (1, 7, 2) # minimum supported git version |
| 239 | repodir = '.repo' # name of repo's private directory |
| 240 | S_repo = 'repo' # special repo repository |
| 241 | S_manifests = 'manifests' # special manifest repository |
| 242 | REPO_MAIN = S_repo + '/main.py' # main script |
| 243 | MIN_PYTHON_VERSION = (2, 6) # minimum supported python version |
| 244 | GITC_CONFIG_FILE = '/gitc/.config' |
| 245 | GITC_FS_ROOT_DIR = '/gitc/manifest-rw/' |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 246 | |
| 247 | |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 248 | import errno |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 249 | import optparse |
Don Garrett | 24f2cc0 | 2018-12-18 18:07:17 +0000 | [diff] [blame] | 250 | import platform |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 251 | import re |
vapier | 7475196 | 2016-09-14 16:08:34 -0700 | [diff] [blame] | 252 | import shutil |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 253 | import stat |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 254 | import subprocess |
| 255 | import sys |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 256 | |
| 257 | if sys.version_info[0] == 3: |
| 258 | import urllib.request |
| 259 | import urllib.error |
| 260 | else: |
| 261 | import imp |
| 262 | import urllib2 |
| 263 | urllib = imp.new_module('urllib') |
| 264 | urllib.request = urllib2 |
| 265 | urllib.error = urllib2 |
| 266 | |
| 267 | |
| 268 | def _print(*objects, **kwargs): |
| 269 | sep = kwargs.get('sep', ' ') |
| 270 | end = kwargs.get('end', '\n') |
| 271 | out = kwargs.get('file', sys.stdout) |
| 272 | out.write(sep.join(objects) + end) |
| 273 | |
| 274 | |
| 275 | # Python version check |
| 276 | ver = sys.version_info |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 277 | if (ver[0], ver[1]) < MIN_PYTHON_VERSION: |
| 278 | _print('error: Python version %s unsupported.\n' |
| 279 | 'Please use Python 2.6 - 2.7 instead.' |
| 280 | % sys.version.split(' ')[0], file=sys.stderr) |
| 281 | sys.exit(1) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 282 | |
vapier | 7475196 | 2016-09-14 16:08:34 -0700 | [diff] [blame] | 283 | home_dot_repo = os.path.expanduser('~/.repoconfig') |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 284 | gpg_dir = os.path.join(home_dot_repo, 'gnupg') |
| 285 | |
| 286 | extra_args = [] |
| 287 | init_optparse = optparse.OptionParser(usage="repo init -u url [options]") |
| 288 | |
| 289 | # Logging |
| 290 | group = init_optparse.add_option_group('Logging options') |
| 291 | group.add_option('-q', '--quiet', |
| 292 | dest="quiet", action="store_true", default=False, |
| 293 | help="be quiet") |
| 294 | |
| 295 | # Manifest |
| 296 | group = init_optparse.add_option_group('Manifest options') |
| 297 | group.add_option('-u', '--manifest-url', |
| 298 | dest='manifest_url', |
| 299 | help='manifest repository location', metavar='URL') |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 300 | group.add_option('-b', '--manifest-branch', |
| 301 | dest='manifest_branch', |
| 302 | help='manifest branch or revision', metavar='REVISION') |
| 303 | group.add_option('-m', '--manifest-name', |
| 304 | dest='manifest_name', |
maruel@chromium.org | b25b69b | 2011-06-16 17:41:05 +0000 | [diff] [blame] | 305 | help='initial manifest file', metavar='NAME.xml') |
Don Garrett | 24f2cc0 | 2018-12-18 18:07:17 +0000 | [diff] [blame] | 306 | group.add_option('-c', '--current-branch', |
| 307 | dest='current_branch_only', action='store_true', |
| 308 | help='fetch only current manifest branch from server') |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 309 | group.add_option('--mirror', |
| 310 | dest='mirror', action='store_true', |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 311 | help='create a replica of the remote repositories ' |
| 312 | 'rather than a client working directory') |
msb@chromium.org | 2c64b71 | 2011-01-11 22:57:47 +0000 | [diff] [blame] | 313 | group.add_option('--reference', |
| 314 | dest='reference', |
| 315 | help='location of mirror directory', metavar='DIR') |
maruel@chromium.org | b25b69b | 2011-06-16 17:41:05 +0000 | [diff] [blame] | 316 | group.add_option('--depth', type='int', default=None, |
| 317 | dest='depth', |
| 318 | help='create a shallow clone with given depth; see git clone') |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 319 | group.add_option('--archive', |
| 320 | dest='archive', action='store_true', |
| 321 | help='checkout an archive instead of a git repository for ' |
| 322 | 'each project. See git archive.') |
Don Garrett | 24f2cc0 | 2018-12-18 18:07:17 +0000 | [diff] [blame] | 323 | group.add_option('--submodules', |
| 324 | dest='submodules', action='store_true', |
| 325 | help='sync any submodules associated with the manifest repo') |
ferringb@google.com | 79245bf | 2012-06-14 21:22:01 +0000 | [diff] [blame] | 326 | group.add_option('-g', '--groups', |
| 327 | dest='groups', default='default', |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 328 | help='restrict manifest projects to ones with specified ' |
| 329 | 'group(s) [default|all|G1,G2,G3|G4,-G5,-G6]', |
ferringb@google.com | 79245bf | 2012-06-14 21:22:01 +0000 | [diff] [blame] | 330 | metavar='GROUP') |
| 331 | group.add_option('-p', '--platform', |
| 332 | dest='platform', default="auto", |
ferringb@google.com | 8db6c88 | 2012-12-25 17:02:37 +0000 | [diff] [blame] | 333 | help='restrict manifest projects to ones with a specified ' |
ferringb@google.com | 79245bf | 2012-06-14 21:22:01 +0000 | [diff] [blame] | 334 | 'platform group [auto|all|none|linux|darwin|...]', |
| 335 | metavar='PLATFORM') |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 336 | group.add_option('--no-clone-bundle', |
| 337 | dest='no_clone_bundle', action='store_true', |
| 338 | help='disable use of /clone.bundle on HTTP/HTTPS') |
Don Garrett | 24f2cc0 | 2018-12-18 18:07:17 +0000 | [diff] [blame] | 339 | group.add_option('--no-tags', |
| 340 | dest='no_tags', action='store_true', |
| 341 | help="don't fetch tags in the manifest") |
maruel@chromium.org | b25b69b | 2011-06-16 17:41:05 +0000 | [diff] [blame] | 342 | |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 343 | |
| 344 | # Tool |
| 345 | group = init_optparse.add_option_group('repo Version options') |
| 346 | group.add_option('--repo-url', |
| 347 | dest='repo_url', |
| 348 | help='repo repository location', metavar='URL') |
| 349 | group.add_option('--repo-branch', |
| 350 | dest='repo_branch', |
| 351 | help='repo branch or revision', metavar='REVISION') |
| 352 | group.add_option('--no-repo-verify', |
| 353 | dest='no_repo_verify', action='store_true', |
| 354 | help='do not verify repo source code') |
| 355 | |
ferringb@google.com | 79245bf | 2012-06-14 21:22:01 +0000 | [diff] [blame] | 356 | # Other |
| 357 | group = init_optparse.add_option_group('Other options') |
| 358 | group.add_option('--config-name', |
| 359 | dest='config_name', action="store_true", default=False, |
| 360 | help='Always prompt for name/e-mail') |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 361 | |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 362 | |
| 363 | def _GitcInitOptions(init_optparse_arg): |
| 364 | init_optparse_arg.set_usage("repo gitc-init -u url -c client [options]") |
| 365 | g = init_optparse_arg.add_option_group('GITC options') |
| 366 | g.add_option('-f', '--manifest-file', |
| 367 | dest='manifest_file', |
| 368 | help='Optional manifest file to use for this GITC client.') |
| 369 | g.add_option('-c', '--gitc-client', |
| 370 | dest='gitc_client', |
| 371 | help='The name of the gitc_client instance to create or modify.') |
| 372 | |
| 373 | _gitc_manifest_dir = None |
| 374 | |
| 375 | |
| 376 | def get_gitc_manifest_dir(): |
| 377 | global _gitc_manifest_dir |
| 378 | if _gitc_manifest_dir is None: |
| 379 | _gitc_manifest_dir = '' |
| 380 | try: |
| 381 | with open(GITC_CONFIG_FILE, 'r') as gitc_config: |
| 382 | for line in gitc_config: |
| 383 | match = re.match('gitc_dir=(?P<gitc_manifest_dir>.*)', line) |
| 384 | if match: |
| 385 | _gitc_manifest_dir = match.group('gitc_manifest_dir') |
| 386 | except IOError: |
| 387 | pass |
| 388 | return _gitc_manifest_dir |
| 389 | |
| 390 | |
| 391 | def gitc_parse_clientdir(gitc_fs_path): |
| 392 | """Parse a path in the GITC FS and return its client name. |
| 393 | |
| 394 | @param gitc_fs_path: A subdirectory path within the GITC_FS_ROOT_DIR. |
| 395 | |
| 396 | @returns: The GITC client name |
| 397 | """ |
| 398 | if gitc_fs_path == GITC_FS_ROOT_DIR: |
| 399 | return None |
| 400 | if not gitc_fs_path.startswith(GITC_FS_ROOT_DIR): |
| 401 | manifest_dir = get_gitc_manifest_dir() |
| 402 | if manifest_dir == '': |
| 403 | return None |
| 404 | if manifest_dir[-1] != '/': |
| 405 | manifest_dir += '/' |
| 406 | if gitc_fs_path == manifest_dir: |
| 407 | return None |
| 408 | if not gitc_fs_path.startswith(manifest_dir): |
| 409 | return None |
| 410 | return gitc_fs_path.split(manifest_dir)[1].split('/')[0] |
| 411 | return gitc_fs_path.split(GITC_FS_ROOT_DIR)[1].split('/')[0] |
| 412 | |
| 413 | |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 414 | class CloneFailure(Exception): |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 415 | |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 416 | """Indicate the remote clone of repo itself failed. |
| 417 | """ |
| 418 | |
| 419 | |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 420 | def _Init(args, gitc_init=False): |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 421 | """Installs repo by cloning it over the network. |
| 422 | """ |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 423 | if gitc_init: |
| 424 | _GitcInitOptions(init_optparse) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 425 | opt, args = init_optparse.parse_args(args) |
ferringb@google.com | 79245bf | 2012-06-14 21:22:01 +0000 | [diff] [blame] | 426 | if args: |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 427 | init_optparse.print_usage() |
| 428 | sys.exit(1) |
| 429 | |
| 430 | url = opt.repo_url |
| 431 | if not url: |
| 432 | url = REPO_URL |
| 433 | extra_args.append('--repo-url=%s' % url) |
| 434 | |
| 435 | branch = opt.repo_branch |
| 436 | if not branch: |
| 437 | branch = REPO_REV |
| 438 | extra_args.append('--repo-branch=%s' % branch) |
| 439 | |
| 440 | if branch.startswith('refs/heads/'): |
| 441 | branch = branch[len('refs/heads/'):] |
| 442 | if branch.startswith('refs/'): |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 443 | _print("fatal: invalid branch name '%s'" % branch, file=sys.stderr) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 444 | raise CloneFailure() |
| 445 | |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 446 | try: |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 447 | if gitc_init: |
| 448 | gitc_manifest_dir = get_gitc_manifest_dir() |
| 449 | if not gitc_manifest_dir: |
| 450 | _print('fatal: GITC filesystem is not available. Exiting...', |
| 451 | file=sys.stderr) |
| 452 | sys.exit(1) |
| 453 | gitc_client = opt.gitc_client |
| 454 | if not gitc_client: |
| 455 | gitc_client = gitc_parse_clientdir(os.getcwd()) |
| 456 | if not gitc_client: |
| 457 | _print('fatal: GITC client (-c) is required.', file=sys.stderr) |
| 458 | sys.exit(1) |
| 459 | client_dir = os.path.join(gitc_manifest_dir, gitc_client) |
| 460 | if not os.path.exists(client_dir): |
| 461 | os.makedirs(client_dir) |
| 462 | os.chdir(client_dir) |
| 463 | if os.path.exists(repodir): |
| 464 | # This GITC Client has already initialized repo so continue. |
| 465 | return |
| 466 | |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 467 | os.mkdir(repodir) |
| 468 | except OSError as e: |
| 469 | if e.errno != errno.EEXIST: |
| 470 | _print('fatal: cannot make %s directory: %s' |
| 471 | % (repodir, e.strerror), file=sys.stderr) |
| 472 | # Don't raise CloneFailure; that would delete the |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 473 | # name. Instead exit immediately. |
| 474 | # |
| 475 | sys.exit(1) |
| 476 | |
| 477 | _CheckGitVersion() |
| 478 | try: |
ferringb@google.com | 8db6c88 | 2012-12-25 17:02:37 +0000 | [diff] [blame] | 479 | if NeedSetupGnuPG(): |
| 480 | can_verify = SetupGnuPG(opt.quiet) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 481 | else: |
| 482 | can_verify = True |
| 483 | |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 484 | dst = os.path.abspath(os.path.join(repodir, S_repo)) |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 485 | _Clone(url, dst, opt.quiet, not opt.no_clone_bundle) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 486 | |
Don Garrett | 24f2cc0 | 2018-12-18 18:07:17 +0000 | [diff] [blame] | 487 | if not os.path.isfile('%s/repo' % dst): |
| 488 | _print("warning: '%s' does not look like a git-repo repository, is " |
| 489 | "REPO_URL set correctly?" % url, file=sys.stderr) |
| 490 | |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 491 | if can_verify and not opt.no_repo_verify: |
| 492 | rev = _Verify(dst, branch, opt.quiet) |
| 493 | else: |
| 494 | rev = 'refs/remotes/origin/%s^0' % branch |
| 495 | |
| 496 | _Checkout(dst, branch, rev, opt.quiet) |
| 497 | except CloneFailure: |
| 498 | if opt.quiet: |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 499 | _print('fatal: repo init failed; run without --quiet to see why', |
| 500 | file=sys.stderr) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 501 | raise |
| 502 | |
| 503 | |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 504 | def ParseGitVersion(ver_str): |
| 505 | if not ver_str.startswith('git version '): |
| 506 | return None |
| 507 | |
| 508 | num_ver_str = ver_str[len('git version '):].strip().split('-')[0] |
| 509 | to_tuple = [] |
| 510 | for num_str in num_ver_str.split('.')[:3]: |
| 511 | if num_str.isdigit(): |
| 512 | to_tuple.append(int(num_str)) |
| 513 | else: |
| 514 | to_tuple.append(0) |
| 515 | return tuple(to_tuple) |
| 516 | |
| 517 | |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 518 | def _CheckGitVersion(): |
| 519 | cmd = [GIT, '--version'] |
ferringb@google.com | 79245bf | 2012-06-14 21:22:01 +0000 | [diff] [blame] | 520 | try: |
| 521 | proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) |
ferringb@google.com | 8db6c88 | 2012-12-25 17:02:37 +0000 | [diff] [blame] | 522 | except OSError as e: |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 523 | _print(file=sys.stderr) |
| 524 | _print("fatal: '%s' is not available" % GIT, file=sys.stderr) |
| 525 | _print('fatal: %s' % e, file=sys.stderr) |
| 526 | _print(file=sys.stderr) |
| 527 | _print('Please make sure %s is installed and in your path.' % GIT, |
| 528 | file=sys.stderr) |
ferringb@google.com | 79245bf | 2012-06-14 21:22:01 +0000 | [diff] [blame] | 529 | raise CloneFailure() |
| 530 | |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 531 | ver_str = proc.stdout.read().strip() |
| 532 | proc.stdout.close() |
| 533 | proc.wait() |
| 534 | |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 535 | ver_act = ParseGitVersion(ver_str) |
| 536 | if ver_act is None: |
| 537 | _print('error: "%s" unsupported' % ver_str, file=sys.stderr) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 538 | raise CloneFailure() |
| 539 | |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 540 | if ver_act < MIN_GIT_VERSION: |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 541 | need = '.'.join(map(str, MIN_GIT_VERSION)) |
| 542 | _print('fatal: git %s or later required' % need, file=sys.stderr) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 543 | raise CloneFailure() |
| 544 | |
| 545 | |
ferringb@google.com | 8db6c88 | 2012-12-25 17:02:37 +0000 | [diff] [blame] | 546 | def NeedSetupGnuPG(): |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 547 | if not os.path.isdir(home_dot_repo): |
| 548 | return True |
| 549 | |
| 550 | kv = os.path.join(home_dot_repo, 'keyring-version') |
| 551 | if not os.path.exists(kv): |
| 552 | return True |
| 553 | |
| 554 | kv = open(kv).read() |
| 555 | if not kv: |
| 556 | return True |
| 557 | |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 558 | kv = tuple(map(int, kv.split('.'))) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 559 | if kv < KEYRING_VERSION: |
| 560 | return True |
| 561 | return False |
| 562 | |
| 563 | |
ferringb@google.com | 8db6c88 | 2012-12-25 17:02:37 +0000 | [diff] [blame] | 564 | def SetupGnuPG(quiet): |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 565 | try: |
| 566 | os.mkdir(home_dot_repo) |
| 567 | except OSError as e: |
| 568 | if e.errno != errno.EEXIST: |
| 569 | _print('fatal: cannot make %s directory: %s' |
| 570 | % (home_dot_repo, e.strerror), file=sys.stderr) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 571 | sys.exit(1) |
| 572 | |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 573 | try: |
| 574 | os.mkdir(gpg_dir, stat.S_IRWXU) |
| 575 | except OSError as e: |
| 576 | if e.errno != errno.EEXIST: |
| 577 | _print('fatal: cannot make %s directory: %s' % (gpg_dir, e.strerror), |
| 578 | file=sys.stderr) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 579 | sys.exit(1) |
| 580 | |
msb@chromium.org | 2c64b71 | 2011-01-11 22:57:47 +0000 | [diff] [blame] | 581 | env = os.environ.copy() |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 582 | try: |
| 583 | env['GNUPGHOME'] = gpg_dir |
| 584 | except UnicodeEncodeError: |
| 585 | env['GNUPGHOME'] = gpg_dir.encode() |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 586 | |
| 587 | cmd = ['gpg', '--import'] |
| 588 | try: |
| 589 | proc = subprocess.Popen(cmd, |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 590 | env=env, |
| 591 | stdin=subprocess.PIPE) |
ferringb@google.com | 8db6c88 | 2012-12-25 17:02:37 +0000 | [diff] [blame] | 592 | except OSError as e: |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 593 | if not quiet: |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 594 | _print('warning: gpg (GnuPG) is not available.', file=sys.stderr) |
| 595 | _print('warning: Installing it is strongly encouraged.', file=sys.stderr) |
| 596 | _print(file=sys.stderr) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 597 | return False |
| 598 | |
| 599 | proc.stdin.write(MAINTAINER_KEYS) |
| 600 | proc.stdin.close() |
| 601 | |
| 602 | if proc.wait() != 0: |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 603 | _print('fatal: registering repo maintainer keys failed', file=sys.stderr) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 604 | sys.exit(1) |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 605 | _print() |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 606 | |
| 607 | fd = open(os.path.join(home_dot_repo, 'keyring-version'), 'w') |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 608 | fd.write('.'.join(map(str, KEYRING_VERSION)) + '\n') |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 609 | fd.close() |
| 610 | return True |
| 611 | |
| 612 | |
| 613 | def _SetConfig(local, name, value): |
| 614 | """Set a git configuration option to the specified value. |
| 615 | """ |
| 616 | cmd = [GIT, 'config', name, value] |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 617 | if subprocess.Popen(cmd, cwd=local).wait() != 0: |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 618 | raise CloneFailure() |
| 619 | |
| 620 | |
jeffbailey@chromium.org | ad39056 | 2011-11-12 00:37:07 +0000 | [diff] [blame] | 621 | def _InitHttp(): |
| 622 | handlers = [] |
| 623 | |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 624 | mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm() |
jeffbailey@chromium.org | ad39056 | 2011-11-12 00:37:07 +0000 | [diff] [blame] | 625 | try: |
| 626 | import netrc |
| 627 | n = netrc.netrc() |
| 628 | for host in n.hosts: |
| 629 | p = n.hosts[host] |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 630 | mgr.add_password(p[1], 'http://%s/' % host, p[0], p[2]) |
ferringb@google.com | 79245bf | 2012-06-14 21:22:01 +0000 | [diff] [blame] | 631 | mgr.add_password(p[1], 'https://%s/' % host, p[0], p[2]) |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 632 | except: # pylint: disable=bare-except |
jeffbailey@chromium.org | ad39056 | 2011-11-12 00:37:07 +0000 | [diff] [blame] | 633 | pass |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 634 | handlers.append(urllib.request.HTTPBasicAuthHandler(mgr)) |
| 635 | handlers.append(urllib.request.HTTPDigestAuthHandler(mgr)) |
jeffbailey@chromium.org | ad39056 | 2011-11-12 00:37:07 +0000 | [diff] [blame] | 636 | |
| 637 | if 'http_proxy' in os.environ: |
| 638 | url = os.environ['http_proxy'] |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 639 | handlers.append(urllib.request.ProxyHandler({'http': url, 'https': url})) |
jeffbailey@chromium.org | ad39056 | 2011-11-12 00:37:07 +0000 | [diff] [blame] | 640 | if 'REPO_CURL_VERBOSE' in os.environ: |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 641 | handlers.append(urllib.request.HTTPHandler(debuglevel=1)) |
| 642 | handlers.append(urllib.request.HTTPSHandler(debuglevel=1)) |
| 643 | urllib.request.install_opener(urllib.request.build_opener(*handlers)) |
jeffbailey@chromium.org | ad39056 | 2011-11-12 00:37:07 +0000 | [diff] [blame] | 644 | |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 645 | |
jeffbailey@chromium.org | ad39056 | 2011-11-12 00:37:07 +0000 | [diff] [blame] | 646 | def _Fetch(url, local, src, quiet): |
| 647 | if not quiet: |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 648 | _print('Get %s' % url, file=sys.stderr) |
jeffbailey@chromium.org | ad39056 | 2011-11-12 00:37:07 +0000 | [diff] [blame] | 649 | |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 650 | cmd = [GIT, 'fetch'] |
| 651 | if quiet: |
| 652 | cmd.append('--quiet') |
| 653 | err = subprocess.PIPE |
| 654 | else: |
| 655 | err = None |
jeffbailey@chromium.org | ad39056 | 2011-11-12 00:37:07 +0000 | [diff] [blame] | 656 | cmd.append(src) |
| 657 | cmd.append('+refs/heads/*:refs/remotes/origin/*') |
| 658 | cmd.append('refs/tags/*:refs/tags/*') |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 659 | |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 660 | proc = subprocess.Popen(cmd, cwd=local, stderr=err) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 661 | if err: |
| 662 | proc.stderr.read() |
| 663 | proc.stderr.close() |
| 664 | if proc.wait() != 0: |
| 665 | raise CloneFailure() |
| 666 | |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 667 | |
jeffbailey@chromium.org | ad39056 | 2011-11-12 00:37:07 +0000 | [diff] [blame] | 668 | def _DownloadBundle(url, local, quiet): |
| 669 | if not url.endswith('/'): |
| 670 | url += '/' |
| 671 | url += 'clone.bundle' |
| 672 | |
| 673 | proc = subprocess.Popen( |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 674 | [GIT, 'config', '--get-regexp', 'url.*.insteadof'], |
| 675 | cwd=local, |
| 676 | stdout=subprocess.PIPE) |
jeffbailey@chromium.org | ad39056 | 2011-11-12 00:37:07 +0000 | [diff] [blame] | 677 | for line in proc.stdout: |
| 678 | m = re.compile(r'^url\.(.*)\.insteadof (.*)$').match(line) |
| 679 | if m: |
| 680 | new_url = m.group(1) |
| 681 | old_url = m.group(2) |
| 682 | if url.startswith(old_url): |
| 683 | url = new_url + url[len(old_url):] |
| 684 | break |
| 685 | proc.stdout.close() |
| 686 | proc.wait() |
| 687 | |
| 688 | if not url.startswith('http:') and not url.startswith('https:'): |
| 689 | return False |
| 690 | |
| 691 | dest = open(os.path.join(local, '.git', 'clone.bundle'), 'w+b') |
| 692 | try: |
| 693 | try: |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 694 | r = urllib.request.urlopen(url) |
| 695 | except urllib.error.HTTPError as e: |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 696 | if e.code in [401, 403, 404, 501]: |
jeffbailey@chromium.org | ad39056 | 2011-11-12 00:37:07 +0000 | [diff] [blame] | 697 | return False |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 698 | _print('fatal: Cannot get %s' % url, file=sys.stderr) |
| 699 | _print('fatal: HTTP error %s' % e.code, file=sys.stderr) |
jeffbailey@chromium.org | ad39056 | 2011-11-12 00:37:07 +0000 | [diff] [blame] | 700 | raise CloneFailure() |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 701 | except urllib.error.URLError as e: |
| 702 | _print('fatal: Cannot get %s' % url, file=sys.stderr) |
| 703 | _print('fatal: error %s' % e.reason, file=sys.stderr) |
jeffbailey@chromium.org | ad39056 | 2011-11-12 00:37:07 +0000 | [diff] [blame] | 704 | raise CloneFailure() |
| 705 | try: |
| 706 | if not quiet: |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 707 | _print('Get %s' % url, file=sys.stderr) |
jeffbailey@chromium.org | ad39056 | 2011-11-12 00:37:07 +0000 | [diff] [blame] | 708 | while True: |
| 709 | buf = r.read(8192) |
| 710 | if buf == '': |
| 711 | return True |
| 712 | dest.write(buf) |
| 713 | finally: |
| 714 | r.close() |
| 715 | finally: |
| 716 | dest.close() |
| 717 | |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 718 | |
jeffbailey@chromium.org | ad39056 | 2011-11-12 00:37:07 +0000 | [diff] [blame] | 719 | def _ImportBundle(local): |
| 720 | path = os.path.join(local, '.git', 'clone.bundle') |
| 721 | try: |
| 722 | _Fetch(local, local, path, True) |
| 723 | finally: |
| 724 | os.remove(path) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 725 | |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 726 | |
| 727 | def _Clone(url, local, quiet, clone_bundle): |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 728 | """Clones a git repository to a new subdirectory of repodir |
| 729 | """ |
| 730 | try: |
| 731 | os.mkdir(local) |
ferringb@google.com | 8db6c88 | 2012-12-25 17:02:37 +0000 | [diff] [blame] | 732 | except OSError as e: |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 733 | _print('fatal: cannot make %s directory: %s' % (local, e.strerror), |
| 734 | file=sys.stderr) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 735 | raise CloneFailure() |
| 736 | |
| 737 | cmd = [GIT, 'init', '--quiet'] |
| 738 | try: |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 739 | proc = subprocess.Popen(cmd, cwd=local) |
ferringb@google.com | 8db6c88 | 2012-12-25 17:02:37 +0000 | [diff] [blame] | 740 | except OSError as e: |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 741 | _print(file=sys.stderr) |
| 742 | _print("fatal: '%s' is not available" % GIT, file=sys.stderr) |
| 743 | _print('fatal: %s' % e, file=sys.stderr) |
| 744 | _print(file=sys.stderr) |
| 745 | _print('Please make sure %s is installed and in your path.' % GIT, |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 746 | file=sys.stderr) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 747 | raise CloneFailure() |
| 748 | if proc.wait() != 0: |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 749 | _print('fatal: could not create %s' % local, file=sys.stderr) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 750 | raise CloneFailure() |
| 751 | |
jeffbailey@chromium.org | ad39056 | 2011-11-12 00:37:07 +0000 | [diff] [blame] | 752 | _InitHttp() |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 753 | _SetConfig(local, 'remote.origin.url', url) |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 754 | _SetConfig(local, |
| 755 | 'remote.origin.fetch', |
| 756 | '+refs/heads/*:refs/remotes/origin/*') |
| 757 | if clone_bundle and _DownloadBundle(url, local, quiet): |
jeffbailey@chromium.org | ad39056 | 2011-11-12 00:37:07 +0000 | [diff] [blame] | 758 | _ImportBundle(local) |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 759 | _Fetch(url, local, 'origin', quiet) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 760 | |
| 761 | |
| 762 | def _Verify(cwd, branch, quiet): |
| 763 | """Verify the branch has been signed by a tag. |
| 764 | """ |
| 765 | cmd = [GIT, 'describe', 'origin/%s' % branch] |
| 766 | proc = subprocess.Popen(cmd, |
| 767 | stdout=subprocess.PIPE, |
| 768 | stderr=subprocess.PIPE, |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 769 | cwd=cwd) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 770 | cur = proc.stdout.read().strip() |
| 771 | proc.stdout.close() |
| 772 | |
| 773 | proc.stderr.read() |
| 774 | proc.stderr.close() |
| 775 | |
| 776 | if proc.wait() != 0 or not cur: |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 777 | _print(file=sys.stderr) |
| 778 | _print("fatal: branch '%s' has not been signed" % branch, file=sys.stderr) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 779 | raise CloneFailure() |
| 780 | |
| 781 | m = re.compile(r'^(.*)-[0-9]{1,}-g[0-9a-f]{1,}$').match(cur) |
| 782 | if m: |
| 783 | cur = m.group(1) |
| 784 | if not quiet: |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 785 | _print(file=sys.stderr) |
| 786 | _print("info: Ignoring branch '%s'; using tagged release '%s'" |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 787 | % (branch, cur), file=sys.stderr) |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 788 | _print(file=sys.stderr) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 789 | |
msb@chromium.org | 2c64b71 | 2011-01-11 22:57:47 +0000 | [diff] [blame] | 790 | env = os.environ.copy() |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 791 | try: |
| 792 | env['GNUPGHOME'] = gpg_dir |
| 793 | except UnicodeEncodeError: |
| 794 | env['GNUPGHOME'] = gpg_dir.encode() |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 795 | |
| 796 | cmd = [GIT, 'tag', '-v', cur] |
| 797 | proc = subprocess.Popen(cmd, |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 798 | stdout=subprocess.PIPE, |
| 799 | stderr=subprocess.PIPE, |
| 800 | cwd=cwd, |
| 801 | env=env) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 802 | out = proc.stdout.read() |
| 803 | proc.stdout.close() |
| 804 | |
| 805 | err = proc.stderr.read() |
| 806 | proc.stderr.close() |
| 807 | |
| 808 | if proc.wait() != 0: |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 809 | _print(file=sys.stderr) |
| 810 | _print(out, file=sys.stderr) |
| 811 | _print(err, file=sys.stderr) |
| 812 | _print(file=sys.stderr) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 813 | raise CloneFailure() |
| 814 | return '%s^0' % cur |
| 815 | |
| 816 | |
| 817 | def _Checkout(cwd, branch, rev, quiet): |
| 818 | """Checkout an upstream branch into the repository and track it. |
| 819 | """ |
| 820 | cmd = [GIT, 'update-ref', 'refs/heads/default', rev] |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 821 | if subprocess.Popen(cmd, cwd=cwd).wait() != 0: |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 822 | raise CloneFailure() |
| 823 | |
| 824 | _SetConfig(cwd, 'branch.default.remote', 'origin') |
| 825 | _SetConfig(cwd, 'branch.default.merge', 'refs/heads/%s' % branch) |
| 826 | |
| 827 | cmd = [GIT, 'symbolic-ref', 'HEAD', 'refs/heads/default'] |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 828 | if subprocess.Popen(cmd, cwd=cwd).wait() != 0: |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 829 | raise CloneFailure() |
| 830 | |
| 831 | cmd = [GIT, 'read-tree', '--reset', '-u'] |
| 832 | if not quiet: |
| 833 | cmd.append('-v') |
| 834 | cmd.append('HEAD') |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 835 | if subprocess.Popen(cmd, cwd=cwd).wait() != 0: |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 836 | raise CloneFailure() |
| 837 | |
| 838 | |
| 839 | def _FindRepo(): |
| 840 | """Look for a repo installation, starting at the current directory. |
| 841 | """ |
ferringb@google.com | 8db6c88 | 2012-12-25 17:02:37 +0000 | [diff] [blame] | 842 | curdir = os.getcwd() |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 843 | repo = None |
| 844 | |
msb@chromium.org | 2c64b71 | 2011-01-11 22:57:47 +0000 | [diff] [blame] | 845 | olddir = None |
ferringb@google.com | 8db6c88 | 2012-12-25 17:02:37 +0000 | [diff] [blame] | 846 | while curdir != '/' \ |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 847 | and curdir != olddir \ |
| 848 | and not repo: |
ferringb@google.com | 8db6c88 | 2012-12-25 17:02:37 +0000 | [diff] [blame] | 849 | repo = os.path.join(curdir, repodir, REPO_MAIN) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 850 | if not os.path.isfile(repo): |
| 851 | repo = None |
ferringb@google.com | 8db6c88 | 2012-12-25 17:02:37 +0000 | [diff] [blame] | 852 | olddir = curdir |
| 853 | curdir = os.path.dirname(curdir) |
| 854 | return (repo, os.path.join(curdir, repodir)) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 855 | |
| 856 | |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 857 | class _Options(object): |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 858 | help = False |
| 859 | |
| 860 | |
| 861 | def _ParseArguments(args): |
| 862 | cmd = None |
| 863 | opt = _Options() |
| 864 | arg = [] |
| 865 | |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 866 | for i in range(len(args)): |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 867 | a = args[i] |
| 868 | if a == '-h' or a == '--help': |
| 869 | opt.help = True |
| 870 | |
| 871 | elif not a.startswith('-'): |
| 872 | cmd = a |
| 873 | arg = args[i + 1:] |
| 874 | break |
| 875 | return cmd, opt, arg |
| 876 | |
| 877 | |
| 878 | def _Usage(): |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 879 | gitc_usage = "" |
| 880 | if get_gitc_manifest_dir(): |
| 881 | gitc_usage = " gitc-init Initialize a GITC Client.\n" |
| 882 | |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 883 | _print( |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 884 | """usage: repo COMMAND [ARGS] |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 885 | |
| 886 | repo is not yet installed. Use "repo init" to install it here. |
| 887 | |
| 888 | The most commonly used repo commands are: |
| 889 | |
| 890 | init Install repo in the current working directory |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 891 | """ + gitc_usage + |
| 892 | """ help Display detailed help on a command |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 893 | |
| 894 | For access to the full online help, install repo ("repo init"). |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 895 | """, file=sys.stderr) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 896 | sys.exit(1) |
| 897 | |
| 898 | |
| 899 | def _Help(args): |
| 900 | if args: |
| 901 | if args[0] == 'init': |
| 902 | init_optparse.print_help() |
msb@chromium.org | 2c64b71 | 2011-01-11 22:57:47 +0000 | [diff] [blame] | 903 | sys.exit(0) |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 904 | elif args[0] == 'gitc-init': |
| 905 | _GitcInitOptions(init_optparse) |
| 906 | init_optparse.print_help() |
| 907 | sys.exit(0) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 908 | else: |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 909 | _print("error: '%s' is not a bootstrap command.\n" |
| 910 | ' For access to online help, install repo ("repo init").' |
| 911 | % args[0], file=sys.stderr) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 912 | else: |
| 913 | _Usage() |
| 914 | sys.exit(1) |
| 915 | |
| 916 | |
| 917 | def _NotInstalled(): |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 918 | _print('error: repo is not installed. Use "repo init" to install it here.', |
| 919 | file=sys.stderr) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 920 | sys.exit(1) |
| 921 | |
| 922 | |
| 923 | def _NoCommands(cmd): |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 924 | _print("""error: command '%s' requires repo to be installed first. |
| 925 | Use "repo init" to install it here.""" % cmd, file=sys.stderr) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 926 | sys.exit(1) |
| 927 | |
| 928 | |
| 929 | def _RunSelf(wrapper_path): |
| 930 | my_dir = os.path.dirname(wrapper_path) |
| 931 | my_main = os.path.join(my_dir, 'main.py') |
| 932 | my_git = os.path.join(my_dir, '.git') |
| 933 | |
| 934 | if os.path.isfile(my_main) and os.path.isdir(my_git): |
| 935 | for name in ['git_config.py', |
| 936 | 'project.py', |
| 937 | 'subcmds']: |
| 938 | if not os.path.exists(os.path.join(my_dir, name)): |
| 939 | return None, None |
| 940 | return my_main, my_git |
| 941 | return None, None |
| 942 | |
| 943 | |
| 944 | def _SetDefaultsTo(gitdir): |
| 945 | global REPO_URL |
| 946 | global REPO_REV |
| 947 | |
| 948 | REPO_URL = gitdir |
| 949 | proc = subprocess.Popen([GIT, |
| 950 | '--git-dir=%s' % gitdir, |
| 951 | 'symbolic-ref', |
| 952 | 'HEAD'], |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 953 | stdout=subprocess.PIPE, |
| 954 | stderr=subprocess.PIPE) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 955 | REPO_REV = proc.stdout.read().strip() |
| 956 | proc.stdout.close() |
| 957 | |
| 958 | proc.stderr.read() |
| 959 | proc.stderr.close() |
| 960 | |
| 961 | if proc.wait() != 0: |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 962 | _print('fatal: %s has no current branch' % gitdir, file=sys.stderr) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 963 | sys.exit(1) |
| 964 | |
| 965 | |
| 966 | def main(orig_args): |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 967 | cmd, opt, args = _ParseArguments(orig_args) |
| 968 | |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 969 | repo_main, rel_repo_dir = None, None |
| 970 | # Don't use the local repo copy, make sure to switch to the gitc client first. |
| 971 | if cmd != 'gitc-init': |
| 972 | repo_main, rel_repo_dir = _FindRepo() |
| 973 | |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 974 | wrapper_path = os.path.abspath(__file__) |
| 975 | my_main, my_git = _RunSelf(wrapper_path) |
| 976 | |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 977 | cwd = os.getcwd() |
| 978 | if get_gitc_manifest_dir() and cwd.startswith(get_gitc_manifest_dir()): |
| 979 | _print('error: repo cannot be used in the GITC local manifest directory.' |
| 980 | '\nIf you want to work on this GITC client please rerun this ' |
| 981 | 'command from the corresponding client under /gitc/', |
| 982 | file=sys.stderr) |
| 983 | sys.exit(1) |
ferringb@google.com | 8db6c88 | 2012-12-25 17:02:37 +0000 | [diff] [blame] | 984 | if not repo_main: |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 985 | if opt.help: |
| 986 | _Usage() |
| 987 | if cmd == 'help': |
| 988 | _Help(args) |
| 989 | if not cmd: |
| 990 | _NotInstalled() |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 991 | if cmd == 'init' or cmd == 'gitc-init': |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 992 | if my_git: |
| 993 | _SetDefaultsTo(my_git) |
| 994 | try: |
vapier | ae39f56 | 2016-10-10 19:08:17 -0700 | [diff] [blame] | 995 | _Init(args, gitc_init=(cmd == 'gitc-init')) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 996 | except CloneFailure: |
Don Garrett | 24f2cc0 | 2018-12-18 18:07:17 +0000 | [diff] [blame] | 997 | path = os.path.join(repodir, S_repo) |
| 998 | _print("fatal: cloning the git-repo repository failed, will remove " |
| 999 | "'%s' " % path, file=sys.stderr) |
| 1000 | shutil.rmtree(path, ignore_errors=True) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 1001 | sys.exit(1) |
ferringb@google.com | 8db6c88 | 2012-12-25 17:02:37 +0000 | [diff] [blame] | 1002 | repo_main, rel_repo_dir = _FindRepo() |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 1003 | else: |
| 1004 | _NoCommands(cmd) |
| 1005 | |
| 1006 | if my_main: |
ferringb@google.com | 8db6c88 | 2012-12-25 17:02:37 +0000 | [diff] [blame] | 1007 | repo_main = my_main |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 1008 | |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 1009 | ver_str = '.'.join(map(str, VERSION)) |
| 1010 | me = [sys.executable, repo_main, |
ferringb@google.com | 8db6c88 | 2012-12-25 17:02:37 +0000 | [diff] [blame] | 1011 | '--repo-dir=%s' % rel_repo_dir, |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 1012 | '--wrapper-version=%s' % ver_str, |
| 1013 | '--wrapper-path=%s' % wrapper_path, |
| 1014 | '--'] |
| 1015 | me.extend(orig_args) |
| 1016 | me.extend(extra_args) |
| 1017 | try: |
Don Garrett | 24f2cc0 | 2018-12-18 18:07:17 +0000 | [diff] [blame] | 1018 | if platform.system() == "Windows": |
| 1019 | sys.exit(subprocess.call(me)) |
| 1020 | else: |
| 1021 | os.execv(sys.executable, me) |
ferringb@google.com | 8db6c88 | 2012-12-25 17:02:37 +0000 | [diff] [blame] | 1022 | except OSError as e: |
akeshet@google.com | 3bdfbeb | 2014-02-06 04:52:54 +0000 | [diff] [blame] | 1023 | _print("fatal: unable to start %s" % repo_main, file=sys.stderr) |
| 1024 | _print("fatal: %s" % e, file=sys.stderr) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 1025 | sys.exit(148) |
| 1026 | |
| 1027 | |
| 1028 | if __name__ == '__main__': |
vapier | 7475196 | 2016-09-14 16:08:34 -0700 | [diff] [blame] | 1029 | if ver[0] == 3: |
| 1030 | _print('warning: Python 3 support is currently experimental. YMMV.\n' |
| 1031 | 'Please use Python 2.6 - 2.7 instead.', |
| 1032 | file=sys.stderr) |
msb@chromium.org | 38b04f8 | 2010-07-13 23:03:34 +0000 | [diff] [blame] | 1033 | main(sys.argv[1:]) |