Skip to content
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

archive: support dot-slash-prefixed paths for Tar-formats #19530

Open
tgolsson opened this issue Jul 28, 2023 · 6 comments
Open

archive: support dot-slash-prefixed paths for Tar-formats #19530

tgolsson opened this issue Jul 28, 2023 · 6 comments

Comments

@tgolsson
Copy link
Contributor

Is your feature request related to a problem? Please describe.

Some tools (e.g. the Deploy Pages GH Action) prefer and/or require paths that are explicitly relative, with a leading ./ on every path. Pants currently generates archives without this prefix. While not overly complex to manually fix it after packaging, it might be useful to allow this as an option.

Describe the solution you'd like

The ability to specify a path_prefix for tar-like formats.

Describe alternatives you've considered

Manually fixing it seems the most consistent. I was not able to get the right results with relocated_files.

Additional context

  • See above issue link for a clear issue caused by the current format.
  • I can contribute the changes necessary here if this seems like a good change.
@AlexTereshenkov
Copy link
Member

Hey @tgolsson! I am very sorry, I don't follow what kind of prefix you refer to? A file cannot contain /, so I am puzzled by

Pants currently generates archives without this prefix.

I must be missing something, apologies.

@tgolsson
Copy link
Contributor Author

tgolsson commented Jul 31, 2023

Let's imagine this directory:

a-directory/
└── file.foobar
foo.txt
bar.txt

fed into a tar command. I can pass them in two different ways:

tar xf out.tar a-directory/file.foobar foo.txt bar.txt
tar xf out.tar ./a-directory/file.foobar ./foo.txt ./bar.txt

Because tar maintains the full path, those ./ they lead to a slightly different layout in the final archive. Apparently some tools use the ./ for validation, and so it'd be nice if Pants could generate archives on this format as well.

You can find more examples here or here

@AlexTereshenkov
Copy link
Member

AlexTereshenkov commented Aug 2, 2023

Gotcha, now it makes sense to me.

I wonder if there are any other kind of prefixes that one would find useful to apply? As it seems to be a common requirement and there is awareness about this layout, perhaps we shall differentiate between producing a tar with dot-slash and without? So instead of an arbitrary prefix, have a boolean instead (--secure-dot-slash or something like this). But if there are other legit cases for having a variety of prefixes, then perhaps a prefix would be a better option.

@tgolsson
Copy link
Contributor Author

tgolsson commented Aug 2, 2023

I went back and forth on it. I do think that just supporting dot-slash is easier and clearer, as any other prefixing can be achieved with relocated_files.

@AlexTereshenkov
Copy link
Member

Right, so perhaps a new field on the archive target?

@tgolsson
Copy link
Contributor Author

tgolsson commented Aug 2, 2023

Yeah. Something like force_relative_paths: bool maybe?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants