| Index: scripts/slave/recipe_modules/cipd/api.py
|
| diff --git a/scripts/slave/recipe_modules/cipd/api.py b/scripts/slave/recipe_modules/cipd/api.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a3ac8f2f2a144b355e552d4aedc8c277500cde79
|
| --- /dev/null
|
| +++ b/scripts/slave/recipe_modules/cipd/api.py
|
| @@ -0,0 +1,44 @@
|
| +# Copyright 2015 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +from recipe_engine import recipe_api
|
| +
|
| +class CIPDApi(recipe_api.RecipeApi):
|
| + """CIPDApi provides support for CIPD."""
|
| + def __init__(self, *args, **kwargs):
|
| + super(CIPDApi, self).__init__(*args, **kwargs)
|
| + self.bin_path = None
|
| +
|
| + def install_client(self, step_name):
|
| + bin_path = self.m.path['slave_build'].join('cipd')
|
| + script_input = {
|
| + 'platform': self.platform_tag(),
|
| + 'bin_path': bin_path,
|
| + }
|
| +
|
| + self.m.python(
|
| + name=step_name,
|
| + script=self.resource('bootstrap.py'),
|
| + stdin=self.m.json.input(script_input))
|
| +
|
| + # TODO(seanmccullough): clean up older CIPD installations.
|
| +
|
| + def platform_tag(self):
|
| + # TODO(seanmccullough): get the arch from env instead of hardcoding it.
|
| + return "linux-amd64"
|
| +
|
| + def ensure_installed(self, root, pkgs):
|
| + pkg_list = []
|
| + for pkg_name in sorted(pkgs):
|
| + pkg_spec = pkgs[pkg_name]
|
| + pkg_list.append("%s %s" % (pkg_name, pkg_spec['version']))
|
| +
|
| + list_data = self.m.raw_io.input("\n".join(pkg_list))
|
| + bin_path = self.m.path['slave_build'].join('cipd')
|
| + self.m.step(
|
| + "ensure_installed",
|
| + [bin_path.join('cipd'), "ensure",
|
| + "--root", root, "--list", list_data],
|
| + )
|
| +
|
|
|