replace ctx.actions.run for run_shell (#64)
* replace ctx.actions.run for run_shell
* either sh_binary or ctx.actions.run are not compatible with remote
execution. run_shell is.
* use arguments in container_file_export
diff --git a/skylib/BUILD b/skylib/BUILD
index 882d60e..b28ab12 100644
--- a/skylib/BUILD
+++ b/skylib/BUILD
@@ -16,7 +16,4 @@
package(default_visibility = ["//visibility:public"])
-sh_binary(
- name = "container_file_export",
- srcs = ["container_file_export.sh"],
-)
+exports_files(["container_file_export.sh"])
diff --git a/skylib/container_file_export.bzl b/skylib/container_file_export.bzl
index c23ed53..35e4044 100644
--- a/skylib/container_file_export.bzl
+++ b/skylib/container_file_export.bzl
@@ -15,18 +15,20 @@
def _container_file_export_impl(ctx):
"""Implementation of the container_file_export rule."""
+ input = ctx.file._container_file_export_exec
args = [
+ input.path,
ctx.attr.image,
ctx.attr.src_path,
ctx.outputs.out.path,
]
- ctx.actions.run(
- executable = ctx.executable._container_file_export_exec,
+ # The command may only access files declared in inputs.
+ ctx.actions.run_shell(
arguments = args,
+ inputs = [input],
outputs = [ctx.outputs.out],
- mnemonic = "ContainerCp",
progress_message = "copying %{} out of docker image %{} ...".format(ctx.attr.src_path, ctx.attr.image),
- use_default_shell_env = True,
+ command = "$1 $2 $3 $4",
)
_container_file_export = rule(
@@ -35,9 +37,8 @@
"image": attr.string(mandatory=True),
"src_path": attr.string(mandatory=True),
"_container_file_export_exec": attr.label(
- default=Label("//skylib:container_file_export"),
- cfg="host",
- executable=True,
+ default=Label("//skylib:container_file_export.sh"),
+ single_file=True,
allow_files=True)
},
outputs = {