bazelbuild / bazelbuild/rules_pkg

pkg_tar strips user/groups from inputs when using pkg_files

Open
#424 2 comments 0 reactions 0 assignees View on GitHub
P3
Dominant language
Starlark
Stars
253
Forks
221
Avg merge
10h 33m
Merged PRs (30d)
1

Description

pkg_attributes supports user and group, which are both strings. Per #370, numerical IDs are not supported yet.

The `build_tar.py` file sets `numeric = True` when adding a `tar` to a package [1]. As numeric user/groups cannot be set, this means that any user/group set by `pkg_files` is stripped out again if you combine tar files, which is commonly done.

[1]: https://github.com/bazelbuild/rules_pkg/blob/main/pkg/private/build_tar.py#L164

Minimal reproduction:
```
genrule(
name = "foo",
outs = ["foo_file"],
cmd = "echo 1 > $@",
)

pkg_files(
name = "foo_files",
srcs = [":foo"],
attributes = pkg_attributes(
group = "1000",
user = "1000",
),
)

pkg_tar(
name = "foo_tar",
srcs = [":foo_files"],
)

pkg_tar(
name = "bar_tar",
deps = [":foo_tar"],
)
```

```
$ tar tvf bazel-bin/bar_tar.tar
drwxr-xr-x 0/0 0 2000-01-01 00:00 ./
-rw-r--r-- 0/0 2 2000-01-01 00:00 ./foo_file
$ tar tvf bazel-bin/foo_tar.tar
drwxr-xr-x 1000/1000 0 2000-01-01 00:00 ./
-rw-r--r-- 1000/1000 2 2000-01-01 00:00 ./foo_file
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.