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

Unified 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, 6 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 side-by-side diff with in-line comments
Download patch
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..60a3bd940c9556e29552c51169972b0fb5eab784
--- /dev/null
+++ b/scripts/slave/recipe_modules/cipd/api.py
@@ -0,0 +1,54 @@
+# 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."""
+ CLIENT_VERSIONS = {
+ 'linux-amd64': '9579504cec0336688292f5b0b68c3ed4e288e273',
+ }
+
+ def __init__(self, *args, **kwargs):
+ super(CIPDApi, self).__init__(*args, **kwargs)
+ self.bin_path = None
+
+ def install_client(self, step_name):
+ 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.
+ 'cipd_%s' % self.CLIENT_VERSIONS[self.platform_tag()])
+ package = "infra/tools/cipd/%s" % self.platform_tag()
+ script_input = {
+ 'package': package,
+ 'version': self.CLIENT_VERSIONS[self.platform_tag()],
+ 'bin_path': self.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))
+ if self.bin_path is None:
+ raise self.m.step.StepFailure(
+ "install_client wasn't called prior to ensure_installed")
+
+ self.m.step(
+ "ensure_installed",
+ [self.bin_path.join('cipd'), "ensure",
+ "--root", root, "--list", list_data],
+ )
+

Powered by Google App Engine
This is Rietveld 408576698