While I can imagine that there might be someone out there who wants to be able to impose a prefix on the files and symlinks in their tarball without also applying it to empty files or directories, that behavior is certainly surprising, and moreover if one needs to put an empty file or directory in a location with the prefix, and you're prefix depends on a file input (as in package_dir_file), you are out of luck.
When a directory is created using
pkg_mkdirs
, it seems thatpkg_tar
does not apply the prefix to it.Application of the prefix happens through
normalize_path
: https://github.com/bazelbuild/rules_pkg/blob/ff60b34e037313927b9067dd883dd82e1fbc211e/pkg/private/tar/build_tar.py#L65-L75 at least for files https://github.com/bazelbuild/rules_pkg/blob/ff60b34e037313927b9067dd883dd82e1fbc211e/pkg/private/tar/build_tar.py#L89 and symlinks https://github.com/bazelbuild/rules_pkg/blob/ff60b34e037313927b9067dd883dd82e1fbc211e/pkg/private/tar/build_tar.py#L178 as well as for tree artifacts (though without using reusing the function) https://github.com/bazelbuild/rules_pkg/blob/ff60b34e037313927b9067dd883dd82e1fbc211e/pkg/private/tar/build_tar.py#L229-L236 however it doesn't happen for empty files https://github.com/bazelbuild/rules_pkg/blob/ff60b34e037313927b9067dd883dd82e1fbc211e/pkg/private/tar/build_tar.py#L106-L139 or directories https://github.com/bazelbuild/rules_pkg/blob/ff60b34e037313927b9067dd883dd82e1fbc211e/pkg/private/tar/build_tar.py#L141-L152While I can imagine that there might be someone out there who wants to be able to impose a prefix on the files and symlinks in their tarball without also applying it to empty files or directories, that behavior is certainly surprising, and moreover if one needs to put an empty file or directory in a location with the prefix, and you're prefix depends on a file input (as in
package_dir_file
), you are out of luck.