Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 from recipe_engine import recipe_api | |
| 6 | |
| 7 class CIPDApi(recipe_api.RecipeApi): | |
| 8 """CIPDApi provides support for CIPD.""" | |
| 9 NATIVE = "native" | |
|
Vadim Sh.
2015/06/29 21:00:46
nit: remove it unless it's used for real
seanmccullough
2015/06/30 17:39:39
Done.
| |
| 10 | |
| 11 def install_client(self, | |
| 12 step_name, | |
| 13 # TODO: get the arch from env instead of hardcoding it. | |
| 14 package='infra/tools/cipd', | |
| 15 version='9579504cec0336688292f5b0b68c3ed4e288e273'): | |
|
Vadim Sh.
2015/06/29 21:00:46
I prefer versions to be expressed as a dict, e.g.
seanmccullough
2015/06/30 17:39:39
Done.
| |
| 16 self.bin_path = ("cipd_%s" % version) | |
|
Vadim Sh.
2015/06/29 21:00:46
nit: () is unnecessary
Also use self.m.path to co
seanmccullough
2015/06/30 17:39:39
Done.
| |
| 17 print ("should install cipd at %s" % self.bin_path) | |
|
Vadim Sh.
2015/06/29 21:00:46
print is not allowed in recipes.
seanmccullough
2015/06/30 17:39:39
Done.
| |
| 18 package = "%s/%s" % (package, self.platform_tag(self.NATIVE)) | |
| 19 script_input = { | |
| 20 'package': package, | |
| 21 'version': version, | |
| 22 } | |
| 23 | |
| 24 self.m.python( | |
| 25 name=step_name, | |
| 26 script=self.resource('bootstrap.py'), | |
| 27 stdin=self.m.json.input(script_input)) | |
| 28 | |
| 29 # TODO: clean up older CIPD installations. | |
| 30 return self.bin_path | |
| 31 | |
| 32 def platform_tag(self, style): | |
| 33 return "linux-amd64" | |
| 34 | |
| 35 def ensure_installed(self, root): | |
| 36 pkg_list = [] | |
| 37 for pkg_name in self.c.packages: | |
|
Vadim Sh.
2015/06/29 21:00:46
sorted(self.c.packages), for reproducibility
seanmccullough
2015/06/30 17:39:38
Done.
| |
| 38 pkg_spec = self.c.packages[pkg_name] | |
| 39 pkg_list.append(("%s %s" % (pkg_name, pkg_spec['version']))) | |
|
Vadim Sh.
2015/06/29 21:00:46
() is not required
seanmccullough
2015/06/30 17:39:39
Done.
| |
| 40 | |
| 41 print "*** pkg list: ***" | |
| 42 print "\n".join(pkg_list) | |
| 43 | |
| 44 self.m.file.write("write_test", "pkg_list.txt", "\n".join(pkg_list)) | |
|
Vadim Sh.
2015/06/29 21:00:46
this is unnecessary, use raw_io module instead (se
seanmccullough
2015/06/30 17:39:38
Done.
| |
| 45 | |
| 46 script_input = { | |
| 47 'list': "pkg_list.txt", | |
| 48 'root': root, | |
| 49 } | |
| 50 self.m.python( | |
| 51 name="ensure_installed", | |
| 52 script=self.resource('ensure.py'), | |
|
Vadim Sh.
2015/06/29 21:00:46
what is the purpose to ensure.py? Why not
self.m.
seanmccullough
2015/06/30 17:39:38
Done.
| |
| 53 stdin=self.m.json.input(script_input)) | |
| 54 | |
| 55 print("package: %s/%s", pkg_name, pkg_spec['version']) | |
| 56 | |
| 57 | |
| OLD | NEW |