mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
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
This commit is contained in:
@@ -25,6 +25,12 @@ vm_image(
|
||||
These images can be built manually by executing the target. The output on
|
||||
`stdout` will be the image id (in the current project).
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
$ bazel build :ubuntu
|
||||
```
|
||||
|
||||
Images are always named per the hash of all the hermetic input scripts. This
|
||||
allows images to be memoized quickly and easily.
|
||||
|
||||
|
||||
+6
-5
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user