Closed illicitonion closed 1 year ago
I've had the exact same issue and was on my way writing a report as well. I noticed that the behaviour is correct in pkg_zip
but not in pkg_tar
. Building on your example, adding
pkg_zip(
name = "zip",
srcs = [":dir"],
strip_prefix = "dir-dir",
)
and modifying make_directory by
command = "mkdir -p $1/subdir && touch $1/subdir/file_in_subdir && touch $1/file_in_root",
building (bazel build //...
) results in files with the following structure:
$ tar tvf bazel-bin/tar.tar
-r-xr-xr-x 0/0 0 2000-01-01 01:00 ./file_in_root
drwxr-xr-x 0/0 0 2000-01-01 01:00 subdir/
drwxr-xr-x 0/0 0 2000-01-01 01:00 ./subdir/
-r-xr-xr-x 0/0 0 2000-01-01 01:00 ./subdir/file_in_subdir
$ zipinfo bazel-bin/zip.zip
Archive: bazel-bin/zip.zip
Zip file size: 412 bytes, number of entries: 4
drwxr-xr-x 2.0 unx 0 b- stor 80-Jan-01 00:00 /
?r-xr-xr-x 2.0 unx 0 b- defN 80-Jan-01 00:00 file_in_root
drwxr-xr-x 2.0 unx 0 b- stor 80-Jan-01 00:00 subdir/
?r-xr-xr-x 2.0 unx 0 b- defN 80-Jan-01 00:00 subdir/file_in_subdir
4 files, 0 bytes uncompressed, 4 bytes compressed: 0.0%
I would have expected them to be equal and consider the zip-one to be correct. Running cd bazel-bin
, tar cvf dir-dir.tar dir-dir/
and tar tvf dir-dir.tar
also gives the structure I would expect:
dr-xr-xr-x ersko/ersko 0 2023-02-20 10:01 dir-dir/
-r-xr-xr-x ersko/ersko 0 2023-02-20 10:01 dir-dir/file_in_root
dr-xr-xr-x ersko/ersko 0 2023-02-20 10:01 dir-dir/subdir/
-r-xr-xr-x ersko/ersko 0 2023-02-20 10:01 dir-dir/subdir/file_in_subdir
Are you sure you would expect ./subdir/
and ./subdir/file
and not subdir/
and subdir/file
@illicitonion? My understanding is that the .
directory is not supposed to be there.
Are you sure you would expect
./subdir/
and./subdir/file
and notsubdir/
andsubdir/file
@illicitonion? My understanding is that the.
directory is not supposed to be there.
That's a good point, yeah, I don't expect the .
prefix
For this BUILD.bazel file making a tar of a directory artifact:
With this simple directory-creating rule:
I expect to see just
./subdir/
and./subdir/file
in the tar, but instead have bothsubdir/
and./subdir
as well as./subdir/file
: