Problem description
When using --directory (self.directory) with TarFile, the following segment produces non-normalized path components:
# pkg/private/tar/build_tar.py
# This prevents a potential problem for users with both a prefix_dir and
# symlinks that also repeat the prefix_dir. The old behavior was that we
# would get just the symlink path. Now we are prefixing with the prefix,
# so you get the file in the wrong place.
# We silently de-dup that. If people come up with a real use case for
# the /a/b/a/b/rest... output we can start an issue and come up with a
# solution at that time.
if self.directory and not dest.startswith(self.directory):
dest = self.directory + dest
We are using --directory, and so I was seeing paths like this:
runtime/_main/../_main~ps~av_pip_attrs_3_10/pypi__attrs/attr/__init__.pyi
runtime/_main/../_main~ps~av_pip_attrs_3_10/pypi__attrs/attr/_cmp.pyi
runtime/_main/../_main~ps~av_pip_attrs_3_10/pypi__attrs/attr/_typing_compat.pyi
runtime/_main/../_main~ps~av_pip_attrs_3_10/pypi__attrs/attr/_version_info.pyi
runtime/_main/../_main~ps~av_pip_attrs_3_10/pypi__attrs/attr/converters.pyi
runtime/_main/../_main~ps~av_pip_attrs_3_10/pypi__attrs/attr/exceptions.pyi
runtime/_main/../_main~ps~av_pip_attrs_3_10/pypi__attrs/attr/filters.pyi
runtime/_main/../_main~ps~av_pip_attrs_3_10/pypi__attrs/attr/py.typed
runtime/_main/../_main~ps~av_pip_attrs_3_10/pypi__attrs/attr/setters.pyi
...
Note that these collapse into runtime/_main~ps~av_pip_attrs_3_10/pypi__attrs/....
This may normally not be a problem, but becomes an issue when piping the tar file into mksquashfs:
Parallel mksquashfs: Using 32 processors
Creating 4.0 filesystem on bazel-out/k8-fastbuild/<redacted>.squashfs, block size 131072.
[=======================| ] 1911/15662 12%
FATAL ERROR: Error: Tar pathname can't have '.' or '..' in it
What to do
Call the existing normpath() on the concatenated path.
Problem description
When using
--directory(self.directory) withTarFile, the following segment produces non-normalized path components:We are using
--directory, and so I was seeing paths like this:Note that these collapse into
runtime/_main~ps~av_pip_attrs_3_10/pypi__attrs/....This may normally not be a problem, but becomes an issue when piping the
tarfile intomksquashfs:What to do
Call the existing
normpath()on the concatenated path.