-
Notifications
You must be signed in to change notification settings - Fork 456
pkg: rewrite archive extraction with typed tar capabilities #12917
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
base: main
Are you sure you want to change the base?
Conversation
We rewrite the extraction capabilities for package management, enforcing the invariants we wish to preserve at the type level. The aim is to separate the concerns of finding an appropriate archive binary, checking the capabilities of this binary, creating arguments for this binary and invoking this for extraction. The public API of extraction is still simple, so the typed invariants are more of an internal impelementation detail. A sumamry of the changes are as follows: - Use GADTs to encode which formats each tar implementation supports, preventing invalid combinations at compile time - Detect tar implementation (BSD/GNU/Other) via --version output - Prefer BSD tar over unzip for zip extraction - Check bsdtar before tar to get more capable implementation - Add gtar to binary list for GNU tar on macOS/BSD - Pass explicit -z/-j flags for OpenBSD/busybox tar Signed-off-by: Ali Caglayan <[email protected]>
848c4f5 to
a6eb859
Compare
|
Does this actually solve #12818 ? The scope of that issue has been sharpened to be about ensuring that dev tools are removed if installation fails for any reason, but skimming the diff here, I don't see a fix addressing that. Am I just missing that logic, or should we remove that issues from the list of issues fixed by this PR? |
| | | | | | | ||
| | Gnu | GNU tar (most Linux) | yes | no | | ||
| | | | | | | ||
| | Other | OpenBSD tar, busybox tar | no | no | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shonfeder this is the tar binary on Open BSD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure why your are pointing these out to me, but thanks :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mentioned if this solves #12818. The issue there is about openbsd not invoking tar correctly. Here we are doing the suggested fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The title of that issue is "If dune tools install fails to install a tool it can break a user's environment". It happened that the failure in that case was caused by the tar issue, but that is covered in #10123, which is a separate issue.
See #12818 (comment)
I think your reply here helps clarify that the answer to my question is 'no', it does not close #12818.
| | K_bsd, (`Tar | `Tar_gz | `Tar_bz2 | `Zip) -> [] | ||
| | K_gnu, (`Tar | `Tar_gz | `Tar_bz2) -> [] | ||
| | K_other, `Tar -> [] | ||
| | K_other, `Tar_gz -> [ "-z" ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shonfeder Here is the -z flag for OpenBSD
|
Can you split off some work from this PR? It's a little hard to understand what's a fix and what's just a refactor. It would be good to start with the tests, then the fixes, and then the refactorings. |
I'll do that when I've done some more manual testing. |
We rewrite the extraction capabilities for package management, enforcing the invariants we wish to preserve at the type level. The aim is to separate the concerns of finding an appropriate archive binary, checking the capabilities of this binary, creating arguments for this binary and invoking this for extraction.
The public API of extraction is still simple, so the typed invariants are more of an internal impelementation detail.
A sumamry of the changes are as follows:
taron OpenBSD #10123