Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: scripts/slave/recipe_modules/cipd/api.py

Issue 1193813004: cipd recipe_module (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: remove unused imports, pass bin_path in as a data param Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 CLIENT_VERSIONS = {
10 'linux-amd64': '9579504cec0336688292f5b0b68c3ed4e288e273',
11 }
12
13 def __init__(self, *args, **kwargs):
14 super(CIPDApi, self).__init__(*args, **kwargs)
15 self.bin_path = None
16
17 def install_client(self, step_name):
18 self.bin_path = self.m.path['slave_build'].join(
Vadim Sh. 2015/07/01 00:10:57 actually, bin_path doesn't have to depend on versi
seanmccullough 2015/07/01 00:50:19 Done.
19 'cipd_%s' % self.CLIENT_VERSIONS[self.platform_tag()])
20 package = "infra/tools/cipd/%s" % self.platform_tag()
21 script_input = {
22 'package': package,
23 'version': self.CLIENT_VERSIONS[self.platform_tag()],
24 'bin_path': self.bin_path,
25 }
26
27 self.m.python(
28 name=step_name,
29 script=self.resource('bootstrap.py'),
30 stdin=self.m.json.input(script_input))
31
32 # TODO(seanmccullough): clean up older CIPD installations.
33
34 def platform_tag(self):
35 # TODO(seanmccullough): get the arch from env instead of hardcoding it.
36 return "linux-amd64"
37
38 def ensure_installed(self, root, pkgs):
39 pkg_list = []
40 for pkg_name in sorted(pkgs):
41 pkg_spec = pkgs[pkg_name]
42 pkg_list.append("%s %s" % (pkg_name, pkg_spec['version']))
43
44 list_data = self.m.raw_io.input("\n".join(pkg_list))
45 if self.bin_path is None:
46 raise self.m.step.StepFailure(
47 "install_client wasn't called prior to ensure_installed")
48
49 self.m.step(
50 "ensure_installed",
51 [self.bin_path.join('cipd'), "ensure",
52 "--root", root, "--list", list_data],
53 )
54
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698