diff options
author | Ting-Yu Wang <anivia@google.com> | 2020-07-15 12:15:11 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-07-15 12:20:23 -0700 |
commit | 1d11c403787b360140dd08be3a25c5689a89c7a0 (patch) | |
tree | 5936788ddd87803fce65954ddfe40de94a1b423e /tools/vm/defs.bzl | |
parent | 8939fae0af9dc8e1cdf2553339fee35b684fc828 (diff) |
Fix errors not getting caught when building vm image.
`set -e` does not catch errors in bash command substituions like
`echo $(bad cmd)` so bazel thinks it succeeded and cached the result.
PiperOrigin-RevId: 321412327
Diffstat (limited to 'tools/vm/defs.bzl')
-rw-r--r-- | tools/vm/defs.bzl | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/tools/vm/defs.bzl b/tools/vm/defs.bzl index 0f67cfa92..9af5ad3b4 100644 --- a/tools/vm/defs.bzl +++ b/tools/vm/defs.bzl @@ -60,11 +60,12 @@ def _vm_image_impl(ctx): # Run the builder to generate our output. echo = ctx.actions.declare_file(ctx.label.name) resolved_inputs, argv, runfiles_manifests = ctx.resolve_command( - command = "echo -ne \"#!/bin/bash\\nset -e\\nimage=$(%s)\\necho ${image}\\n\" > %s && chmod 0755 %s" % ( - ctx.files.builder[0].path, - echo.path, - echo.path, - ), + command = "\n".join([ + "set -e", + "image=$(%s)" % ctx.files.builder[0].path, + "echo -ne \"#!/bin/bash\\necho ${image}\\n\" > %s" % echo.path, + "chmod 0755 %s" % echo.path, + ]), tools = [ctx.attr.builder], ) ctx.actions.run_shell( |