bazelbuild / rules_pkg

Bazel rules for creating packages of many types (zip, tar, deb, rpm, ...)
Apache License 2.0
216 stars 171 forks source link

pkg_tar: package_dir_file is not applied to pkg_mkdirs entries #758

Closed adam-azarchs closed 10 months ago

adam-azarchs commented 10 months ago

When a directory is created using pkg_mkdirs, it seems that pkg_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-L152

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.