Skip to content
This repository was archived by the owner on Dec 29, 2025. It is now read-only.

Commit fd7ad6a

Browse files
committed
Implement strip_components
1 parent 76fe7ae commit fd7ad6a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

file/rules.bzl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,17 @@ def _untar_impl(ctx):
5050
actions = ctx.actions
5151
name = ctx.attr.name
5252
src = ctx.file.src
53+
strip_components = ctx.attr.strip_components
5354

5455
dir = actions.declare_directory(name)
5556

5657
args = actions.args()
5758
args.add(src)
5859
args.add(dir.path)
60+
args.add(str(strip_components))
5961
actions.run_shell(
6062
arguments = [args],
61-
command = 'mkdir -p "$2" && tar xf "$1" -C "$2"',
63+
command = 'mkdir -p "$2" && tar xf "$1" -C "$2" --strip-components "$3"',
6264
inputs = [src],
6365
outputs = [dir],
6466
)
@@ -73,6 +75,7 @@ untar = rule(
7375
allow_single_file = True,
7476
mandatory = True,
7577
),
78+
"strip_components": attr.int(),
7679
},
7780
doc = "Create directory from tar archive",
7881
implementation = _untar_impl,

0 commit comments

Comments
 (0)