Commit 2e401be1 authored by recipe-roller's avatar recipe-roller Committed by Commit Bot

Roll recipe dependencies (trivial).

This is an automated CL created by the recipe roller. This CL rolls recipe
changes from upstream projects (e.g. depot_tools) into downstream projects
(e.g. tools/build).


More info is at https://goo.gl/zkKdpD. Use https://goo.gl/noib3a to file a bug
(or complain)

recipe_engine:
  https://crrev.com/51395b1ba1ea684f5e99d2bb03c934f2ac441984 [recipes.cfg] ONLY support jsonpb. (iannucci@chromium.org)

TBR=iannucci@chromium.org

Change-Id: I65893b7f3f9db0209863376e1d2659869842d94d
Recipe-Tryjob-Bypass-Reason: Autoroller
Bugdroid-Send-Email: False
Reviewed-on: https://chromium-review.googlesource.com/458882
Reviewed-by: <recipe-roller@chromium.org>
Commit-Queue: <recipe-roller@chromium.org>
parent 5be3bdd7
......@@ -4,7 +4,7 @@
{
"branch": "master",
"project_id": "recipe_engine",
"revision": "84b34416f3e1b1582cf81ab7ffea34f1e84b1c95",
"revision": "51395b1ba1ea684f5e99d2bb03c934f2ac441984",
"url": "https://chromium.googlesource.com/external/github.com/luci/recipes-py.git"
}
],
......
......@@ -32,15 +32,12 @@ RECIPES_CFG = os.path.join('infra', 'config', 'recipes.cfg')
BOOTSTRAP_VERSION = 1
import argparse
import ast
import json
import logging
import random
import re
import subprocess
import sys
import time
import traceback
import urlparse
from cStringIO import StringIO
......@@ -68,97 +65,22 @@ def parse(repo_root, recipes_cfg_path):
`recipe_modules`)
"""
with open(recipes_cfg_path, 'rU') as fh:
data = fh.read()
if data.lstrip().startswith('{'):
pb = json.loads(data)
engine = next(
(d for d in pb['deps'] if d['project_id'] == 'recipe_engine'), None)
if engine is None:
raise ValueError('could not find recipe_engine dep in %r'
% recipes_cfg_path)
engine_url = engine['url']
engine_revision = engine.get('revision', '')
engine_subpath = engine.get('path_override', '')
recipes_path = pb.get('recipes_path', '')
else:
def get_unique(things):
if len(things) == 1:
return things[0]
elif len(things) == 0:
raise ValueError("Expected to get one thing, but dinna get none.")
else:
logging.warn('Expected to get one thing, but got a bunch: %s\n%s' %
(things, traceback.format_stack()))
return things[0]
protobuf = parse_textpb(StringIO(data))
engine_buf = get_unique([
b for b in protobuf.get('deps', [])
if b.get('project_id') == ['recipe_engine'] ])
engine_url = get_unique(engine_buf['url'])
engine_revision = get_unique(engine_buf.get('revision', ['']))
engine_subpath = (get_unique(engine_buf.get('path_override', ['']))
.replace('/', os.path.sep))
recipes_path = get_unique(protobuf.get('recipes_path', ['']))
pb = json.load(fh)
engine = next(
(d for d in pb['deps'] if d['project_id'] == 'recipe_engine'), None)
if engine is None:
raise ValueError('could not find recipe_engine dep in %r'
% recipes_cfg_path)
engine_url = engine['url']
engine_revision = engine.get('revision', '')
engine_subpath = engine.get('path_override', '')
recipes_path = pb.get('recipes_path', '')
recipes_path = os.path.join(repo_root, recipes_path.replace('/', os.path.sep))
return engine_url, engine_revision, engine_subpath, recipes_path
def parse_textpb(fh):
"""Parse the protobuf text format just well enough to understand recipes.cfg.
We don't use the protobuf library because we want to be as self-contained
as possible in this bootstrap, so it can be simply vendored into a client
repo.
We assume all fields are repeated since we don't have a proto spec to work
with.
Args:
fh: a filehandle containing the text format protobuf.
Returns:
A recursive dictionary of lists.
"""
def parse_atom(field, text):
if text == 'true':
return True
if text == 'false':
return False
# repo_type is an enum. Since it does not have quotes,
# invoking literal_eval would fail.
if field == 'repo_type':
return text
return ast.literal_eval(text)
ret = {}
for line in fh:
line = line.strip()
m = re.match(r'(\w+)\s*:\s*(.*)', line)
if m:
ret.setdefault(m.group(1), []).append(parse_atom(m.group(1), m.group(2)))
continue
m = re.match(r'(\w+)\s*{', line)
if m:
subparse = parse_textpb(fh)
ret.setdefault(m.group(1), []).append(subparse)
continue
if line == '}':
return ret
if line == '':
continue
raise ValueError('Could not understand line: <%s>' % line)
return ret
def _subprocess_call(argv, **kwargs):
logging.info('Running %r', argv)
return subprocess.call(argv, **kwargs)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment