package: allow setting tar_strip_components #19090
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
in build.zig.zon.
That allows us to unpack tars which don't have leading root folder. Like
examples from #17779.
Trying to fetch
https://chromium.googlesource.com/chromium/tools/depot_tools.git/+archive/refs/heads/main.tar.gzwith default settings results in error. That archive has files in the root:
stripping one folder (default) results in empty files names.
Setting tar_strip_components = 0 in build.zig.zon enables fetching such
archives.
I'm not a fan of adding endless configuration options. Without configuration we can try with strip_components = 1 and if that fail with strip_components = 0, but I can imagine case where first will pass but right is the second. For example if we tar some source without root but it has inside just single src folder and we don't wont that src folder stripped.
In practice tar_strip_components will have only two values 1 (default) or 0. So it is only needed to set it to 0 in rare cases. Instead of int it could be some bool switch tar_dont_strip... But I keep it like this because shell tar has it same way.
Fixes #17779