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

unpack_strategy: allow unpacking .crate (as a gzipped tar) #16951

Merged
merged 1 commit into from Mar 27, 2024

Conversation

cho-m
Copy link
Member

@cho-m cho-m commented Mar 26, 2024

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

Related to discussion in Homebrew/homebrew-core#166955 (comment)

Will need Homebrew/homebrew-core#167208 first to avoid breaking corresponding formula builds

@@ -13,6 +13,7 @@ module UnpackStrategy

def self.strategies
@strategies ||= [
Crate, # Needs to be before Tar
Copy link
Member Author

@cho-m cho-m Mar 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to think about this a bit more as Crate needs to be detected before Tar, but we don't want reverse also too for UnpackStrategy.from_magic(...).

Options:

  • May need to add explicit check on extension inside Crate.can_extract?.
  • Could just allow .crate extension inside Tar instead. Simplest change as it only adds extra string to unpack_strategy/tar.rb.

Copy link
Member

@Bo98 Bo98 Mar 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Could just allow .crate extension inside Tar instead. Simplest change as it only adds extra string to unpack_strategy/tar.rb.

If .crate is just a renamed .tar.gz then it makes sense to do this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If .crate is just a renamed .tar.gz then it makes sense to do this.

Currently it is though there is no documentation guaranteeing it. Assuming Rust doesn't switch to some obscure/specialized format, shouldn't be too difficult to maintain.

https://github.com/rust-lang/cargo/blob/0.78.0/src/cargo/ops/cargo_package.rs#L689-L694

Copy link
Member

@carlocab carlocab Mar 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently it is though there is no documentation guaranteeing it.

I think we can assume it is for now and then deal with it if/when things break.

Perhaps leave a comment mentioning that we make an assumption based on undocumented behaviour of cargo.

Copy link
Member

@Bo98 Bo98 Mar 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While it is an implementation detail, realistically a change to the format would likely break older cargo versions without branching off the API to download it.

And if it did break in-place, we would still have to adjust anyway if it was a separate strategy.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can assume it is for now and then deal with it if/when things break.

Agreed 👍🏻

Signed-off-by: Michael Cho <michael@michaelcho.dev>
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me, thanks again @cho-m!

@cho-m cho-m marked this pull request as ready for review March 27, 2024 12:48
@cho-m
Copy link
Member Author

cho-m commented Mar 27, 2024

May still need Homebrew/homebrew-core#167208 beforehand for existing usage.

And then need to follow up to drop the nounzip and remove system "tar", ... during install.

@cho-m cho-m merged commit 4fa7264 into Homebrew:master Mar 27, 2024
25 checks passed
@cho-m cho-m deleted the unpack-crate branch March 27, 2024 22:00
@github-actions github-actions bot added the outdated PR was locked due to age label Apr 27, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants