-
Notifications
You must be signed in to change notification settings - Fork 217
pkg_files and pkg_tar produce different tarballs. #670
Copy link
Copy link
Closed
Labels
Description
pkg_files(
name = "test-pkg-files-with-attributes",
srcs = [
"//tests:testdata/loremipsum.txt",
],
attributes = pkg_attributes(
group = "1000",
mode = "0440",
user = "0",
),
prefix = "/foo/bar",
)
pkg_tar(
name = "test-pkg-tar-from-pkg-files-with-attributes",
srcs = [
":test-pkg-files-with-attributes",
],
)
pkg_tar(
name = "test-pkg-tar-with-attributes",
srcs = [
"//tests:testdata/loremipsum.txt",
],
owner = "0.1000",
package_dir = "/foo/bar",
)
I would expect both of these to create the same .tar
austin[169160] aschuh-3950x (main) ~/local/rules_pkg/tests/tar
$ tar tvf ../../bazel-bin/tests/tar/test_pkg_tar_with_attributes.tar; tar tvf ../../bazel-bin/tests/tar/test_pkg_tar_from_pkg_files_with_attributes.tar
drwxr-xr-x 0/1000 0 1999-12-31 16:00 foo/
drwxr-xr-x 0/1000 0 1999-12-31 16:00 foo/bar/
-r--r----- 0/1000 543 1999-12-31 16:00 foo/bar/loremipsum.txt
drwxr-xr-x 0/1000 0 1999-12-31 16:00 foo/
drwxr-xr-x 0/1000 0 1999-12-31 16:00 foo/bar/
-r--r----- 0/1000 543 1999-12-31 16:00 foo/bar/loremipsum.txt
But, the sha256 doesn't match.
austin[169202] aschuh-3950x (main) ~/local/rules_pkg/tests/tar
$ sha256sum ../../bazel-bin/tests/tar/test-pkg-tar-with-attributes.tar ../../bazel-bin/tests/tar/test-pkg-tar-from-pkg-files-with-attributes.tar
3567e6a8e5286da1052853fa4b754d57638625a1574aae48ad493152d3e2ef95 ../../bazel-bin/tests/tar/test-pkg-tar-with-attributes.tar
2f031ccaaf413a05f304ebeb3a29281e22de7028ca9b274fec2094f92e5cd20c ../../bazel-bin/tests/tar/test-pkg-tar-from-pkg-files-with-attributes.tar
This isn't purely academic, the difference causes one of them to be installable for us with busybox tar, and the other to not have permissions which work.
austin[169162] aschuh-3950x (main) ~/local/rules_pkg/tests/tar
$ cat inspect_tar.py
#!/usr/bin/python3
import tarfile
import sys
import os
a = tarfile.open(sys.argv[1])
m = a.getmember(sys.argv[2])
print('uid', m.uid)
print('gid', m.gid)
print('uname', repr(m.uname))
print('gname', repr(m.gname))
austin[169198] aschuh-3950x (main) ~/local/rules_pkg/tests/tar
$ ./inspect_tar.py ../../bazel-bin/tests/tar/test-pkg-tar-from-pkg-files-with-attributes.tar foo/bar/loremipsum.txt
uid 0
gid 0
uname '0'
gname '1000'
austin[169199] aschuh-3950x (main) ~/local/rules_pkg/tests/tar
$ ./inspect_tar.py ../../bazel-bin/tests/tar/test-pkg-tar-with-attributes.tar foo/bar/loremipsum.txt
uid 0
gid 1000
uname ''
gname ''
busybox tar is triggering off uid/gid, rather than uname/gname.
Reactions are currently unavailable