Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined behavior when pkg_tar.srcs comes from external repository #131

Closed
ghost opened this issue Jan 24, 2020 · 0 comments · Fixed by #132
Closed

undefined behavior when pkg_tar.srcs comes from external repository #131

ghost opened this issue Jan 24, 2020 · 0 comments · Fixed by #132

Comments

@ghost
Copy link

ghost commented Jan 24, 2020

pkg_tar maps files based on each file's short_path attribute. If a file package/file.txt belongs to an external repository, extrepo, short_path evaluates to ../extrepo/package/file.txt. pkg_tar with strip_prefix="." then creates archives with invalid ../ pathname elements:

$ tar -tf test-tar-strip_prefix-dot.tar
./
./etc/
./etc/nsswitch.conf
tar: Removing leading `./..' from member names
./../
tar: Removing leading `./../' from member names
./../bazel_tools/
./../bazel_tools/tools/
./../bazel_tools/tools/python/
./../bazel_tools/tools/python/runfiles/
./../bazel_tools/tools/python/runfiles/runfiles.py
aiuto pushed a commit that referenced this issue Feb 28, 2020
Avoid use of [`File.short_path`][1] when mapping filenames, because when
creating archives from files imported from external repositories we'll create
archive members with leading `./../` prefixes.  Instead, we'll stick to stripping
to leading `File.root.path` (if present) from `File.path`, resulting in archive
members like `external/repo/package/file.txt`.

[1]: https://docs.bazel.build/versions/master/skylark/lib/File.html#short_path

Resolves #131.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

0 participants