Skip to content

Commit

Permalink
ensure_gn_version.py: reinstall if tool is missing
Browse files Browse the repository at this point in the history
It's pretty easy to wedge things currently if you do:
  rm buildtools/linux64/gn

ensure_gn_version.py then gets stuck in a crashing loop where it
tries to run the tool with --version but it always fails w/ENOENT.
So improve the logic to redownload things when they're missing.

Change-Id: Id19c1fdbf9b1ed69930f5a6e3f192e1879ce8d62
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1697947
Auto-Submit: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676659}
  • Loading branch information
vapier authored and Commit Bot committed Jul 12, 2019
1 parent df3602c commit ade2398
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions buildtools/ensure_gn_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from __future__ import print_function

import argparse
import errno
import io
import os
import re
Expand Down Expand Up @@ -67,14 +68,22 @@ def main():
except subprocess.CalledProcessError as e:
print('`%s` returned %d:\n%s' % (cmd_str, e.returncode, e.output))
return 1
except OSError as e:
if e.errno != errno.ENOENT:
print('`%s` failed:\n%s' % (cmd_str, e))
return 1

# The tool doesn't exist, so redownload it.
out = ''
except Exception as e:
print('`%s` failed:\n%s' % (cmd_str, e))
return 1

current_revision = re.findall(r'\((.*)\)', out)[0]
if desired_revision.startswith(current_revision):
# We're on the right version, so we're done.
return 0
if out:
current_revision = re.findall(r'\((.*)\)', out)[0]
if desired_revision.startswith(current_revision):
# We're on the right version, so we're done.
return 0

print("`%s` returned '%s', which wasn't what we were expecting."
% (cmd_str, out.strip()))
Expand Down

0 comments on commit ade2398

Please sign in to comment.