bazelbuild / bazelbuild/rules_pkg
pkg_tar does *not* include runfiles via an alias
- Dominant language
- Starlark
- Stars
- 253
- Forks
- 221
- Avg merge
- 10h 33m
- Merged PRs (30d)
- 1
Description
Discovered by noticing that adding runfiles resolution library into `data`, does not, in fact, end up adding them to the archive.
The patch below fixes things in my case. You may want to generalize.
```
--- a/pkg/private/pkg_files.bzl
+++ b/pkg/private/pkg_files.bzl
@@ -463,6 +463,23 @@
gid = mapping_context.default_gid,
)
+ if hasattr(runfiles, "root_symlinks"):
+ for rsym in runfiles.root_symlinks.to_list():
+ mapping_context.file_deps.append(depset([rsym.target_file]))
+ d_path = mapping_context.path_mapper(base_file_path + ".runfiles/" + rsym.path)
+ fmode = "0755" if rsym.target_file == the_executable else mapping_context.default_mode
+ _check_dest(mapping_context.content_map, d_path, rsym.target_file, src.label, mapping_context.allow_duplicates_with_different_content)
+ mapping_context.content_map[d_path] = _DestFile(
+ src = rsym.target_file,
+ entry_type = ENTRY_IS_FILE,
+ origin = src.label,
+ mode = fmode,
+ user = mapping_context.default_user,
+ group = mapping_context.default_group,
+ uid = mapping_context.default_uid,
+ gid = mapping_context.default_gid,
+ )
+
# if repo_mapping manifest exists (for e.g. with --enable_bzlmod),
# create _repo_mapping under runfiles directory
repo_mapping_manifest = get_repo_mapping_manifest(src)
```
Contributor guide
Research direction
Start in pkg/private/pkg_files.bzl around the runfiles handling near the repo_mapping manifest logic. Reproduce the pkg_tar case described in the issue, where runfiles resolution is supplied through data via an alias, and inspect the generated archive. Done means the relevant runfiles are included without breaking existing archive behavior.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100