-
Notifications
You must be signed in to change notification settings - Fork 182
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
question about file ordering in pkg_tar #828
Comments
The intended behavior is that files are sorted by final location path rather than ordered by Your example of using We could make an FR for treating srcs in order via another attribute. There might even be someone willing to build it. It should not be that hard, but it does require some strict definition about the corner cases. There are several potential ones around auto-creating directories for something early in srcs when an explicit create with an owner and perms happens later. We could start with it failing hard if that happens. You could work around it by pre-creating them with |
Note that I do double taring (just because I was to lazy to use genrule or assume external files are around), I think it's therefore correct that the final result contains tars. In anycase I would consider to invest some time to build that feature (putting srcs in order). Would you have some ideas on how to name the attribute? I could draft a PR. |
FWIW, you are going to have to fight with the rest of the ecosystem on that. Many projects use |
Ah good point about buildifier. We use that as well. Hmm I'll have to think more about this. |
So I wonder if we should add an pkg_tar(
name = "test-tar-ordered",
srcs = [
"//tests:testdata/config",
"//tests:testdata/hello.txt",
"//tests:testdata/loremipsum.txt",
],
srcs_ordered = {
"1": "//tests:testdata/hello.txt",
"2": "//tests:testdata/loremipsum.txt",
"3": "//tests:testdata/config",
},
) The semantics would be that the keys determine the order of the values. And the values need to match the srcs attribute (this would be checked). I'm not 100% how to integrate this in the |
Please no. Unless you want to write an extensive specification for how the two will merge and how they are sorted. E.g. what is the output order of "1", "11", "2"? Obviously unchanged, because then you can insert a new thing in the middle of an existing list. Right? Oh, someone expects it strict numeric, so they try "1", "1.5", "2" and then all the code assuming ints breaks. Sorting is very easy, yet very hard do do in a way that seems right to everyone. |
Fair enough. I see that's problematic. I wonder how we could approach this that is buildifier friendly and not weird in some other way. |
Ah actually adding a pkg_tar(
name = "test-tar-ordered",
srcs = [
# do not sort
"//tests:testdata/hello.txt",
"//tests:testdata/loremipsum.txt",
"//tests:testdata/config",
],
emit_srcs_in_list_order = True,
) Sorry I wasn't aware that it was that easy to disable the buildifier sorting, that's why I proposed the weird dict approach 🙈 |
Yup. |
I'm wondering about the file order in
pkg_tar
. When I create a normal tar file via the linux command line the order of files in the tar is like specified on the command line:However if I do something similar with rules_pkg this doesn't apply:
Is there any way to make this ordered the same as the srcs are specified?
One workaround I found is to pack a and b into an extra tar and then specify via deps:
however this seems a bit cumbersome.
I assume the order gets lost here when we assign to the map
rules_pkg/pkg/private/pkg_files.bzl
Line 493 in 61132fe
?
is that the expected/desired behavior?
The text was updated successfully, but these errors were encountered: