diff options
Diffstat (limited to 'main.py')
| -rwxr-xr-x | main.py | 32 |
1 files changed, 23 insertions, 9 deletions
| @@ -255,27 +255,41 @@ class _Repo(object): | |||
| 255 | return result | 255 | return result |
| 256 | 256 | ||
| 257 | 257 | ||
| 258 | def _CheckWrapperVersion(ver, repo_path): | 258 | def _CheckWrapperVersion(ver_str, repo_path): |
| 259 | """Verify the repo launcher is new enough for this checkout. | ||
| 260 | |||
| 261 | Args: | ||
| 262 | ver_str: The version string passed from the repo launcher when it ran us. | ||
| 263 | repo_path: The path to the repo launcher that loaded us. | ||
| 264 | """ | ||
| 265 | # Refuse to work with really old wrapper versions. We don't test these, | ||
| 266 | # so might as well require a somewhat recent sane version. | ||
| 267 | # v1.15 of the repo launcher was released in ~Mar 2012. | ||
| 268 | MIN_REPO_VERSION = (1, 15) | ||
| 269 | min_str = '.'.join(str(x) for x in MIN_REPO_VERSION) | ||
| 270 | |||
| 259 | if not repo_path: | 271 | if not repo_path: |
| 260 | repo_path = '~/bin/repo' | 272 | repo_path = '~/bin/repo' |
| 261 | 273 | ||
| 262 | if not ver: | 274 | if not ver_str: |
| 263 | print('no --wrapper-version argument', file=sys.stderr) | 275 | print('no --wrapper-version argument', file=sys.stderr) |
| 264 | sys.exit(1) | 276 | sys.exit(1) |
| 265 | 277 | ||
| 278 | # Pull out the version of the repo launcher we know about to compare. | ||
| 266 | exp = Wrapper().VERSION | 279 | exp = Wrapper().VERSION |
| 267 | ver = tuple(map(int, ver.split('.'))) | 280 | ver = tuple(map(int, ver_str.split('.'))) |
| 268 | if len(ver) == 1: | ||
| 269 | ver = (0, ver[0]) | ||
| 270 | 281 | ||
| 271 | exp_str = '.'.join(map(str, exp)) | 282 | exp_str = '.'.join(map(str, exp)) |
| 272 | if exp[0] > ver[0] or ver < (0, 4): | 283 | if ver < MIN_REPO_VERSION: |
| 273 | print(""" | 284 | print(""" |
| 274 | !!! A new repo command (%5s) is available. !!! | 285 | repo: error: |
| 275 | !!! You must upgrade before you can continue: !!! | 286 | !!! Your version of repo %s is too old. |
| 287 | !!! We need at least version %s. | ||
| 288 | !!! A new repo command (%s) is available. | ||
| 289 | !!! You must upgrade before you can continue: | ||
| 276 | 290 | ||
| 277 | cp %s %s | 291 | cp %s %s |
| 278 | """ % (exp_str, WrapperPath(), repo_path), file=sys.stderr) | 292 | """ % (ver_str, min_str, exp_str, WrapperPath(), repo_path), file=sys.stderr) |
| 279 | sys.exit(1) | 293 | sys.exit(1) |
| 280 | 294 | ||
| 281 | if exp > ver: | 295 | if exp > ver: |
