zdharma-continuum / zinit

🌻 Flexible and fast ZSH plugin manager
MIT License
2.9k stars 125 forks source link

Support 'unar' instead of requiring various unpackers (e.g. xz) #73

Open docwhat opened 2 years ago

docwhat commented 2 years ago

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

I'm frustrated when something requires an unpacker, such as xz.

Describe the solution you'd like

Recognize and support unar for unpacking archives.

Bonus points for adding a Zinit pack/annex (not sure which would be applicable here).

Describe alternatives you've considered

You gotta help us, Doc. We've tried nothin' and we're all out of ideas.

alichtman commented 2 years ago

Can you show me something that requires an unpacker?

docwhat commented 2 years ago

Note my has'xz' that I just added to prevent it borking the install and requiring a zi delete.

zinit wait lucid for \
  from'gh-r' \
  as'program' \
  has'xz' \
  mv'shellcheck* -> shellcheck' \
  pick'shellcheck/shellcheck' \
  @koalaman/shellcheck
pschmitt commented 2 years ago

I can see this within zinit's core.

If there's $fancy_archive_extractor, then use it.

ziextract should be relatively easy to patch: https://github.com/zdharma-continuum/zinit/blob/5df5fb6b4673939b3f23d579a132fc7b701e09a4/zinit-install.zsh#L1526-L1827

What I don't like about that idea though is that while you mention unar, there's a ton of alternatives. What $fancy_archive_extractor should we support?

borking the install and requiring a zi delete.

What exactly do you mean by that?

alichtman commented 2 years ago

If we support installing packages from GH Releases, we must support decompressing them. I think it's reasonable to add support like this.

This is essentially what unar does, to the best of my knowledge. We can reimplement it, or just declare unar as a dependency.

pschmitt commented 2 years ago

If we support installing packages from GH Releases, we must support decompressing them. I think it's reasonable to add support like this.

That is supported already. I've literally linked to the implementation above :) zinit can already extract archives. This issue is about whether ziextract should try unpacking with unar before falling back to the individual tar, unzip, unrar etc commands.

alichtman commented 2 years ago

Hah, right. I see that now. Ignore my comment above. I was thinking we only supported shell scripts and executables.

I don't use this feature, so I'm not super knowledgeable about it.

vladdoster commented 1 year ago

@docwhat,

Can this be closed?

docwhat commented 1 year ago

What I don't like about that idea though is that while you mention unar, there's a ton of alternatives. What $fancy_archive_extractor should we support?

It's true. There are a lot.

zi could just fetch unar (or some other unpacker) for its own use instead of depending on the system's unpacker.

borking the install and requiring a zi delete.

What exactly do you mean by that?

I don't remember exactly anymore.

I think I had unar but didn't have xz. The unpack failed, and zi didn't know since there was a directory present.

Fixing it required figuring out what happened, installing xz, and deleting the package so it could reinstall.

docwhat commented 1 year ago

This issue is about whether ziextract should try unpacking with unar before falling back to the individual tar, unzip, unrar etc commands.

At least, unar should be tried. I had unar available but didn't have xz.

docwhat commented 1 year ago

Can this be closed?

I'd prefer if unar was added to ziextract.

vladdoster commented 1 year ago

@docwhat,

I, too, have been on systems or in containers that do not have xz (xz-utils on Ubuntu), file, or unzip.

The most portable solution is to try using python3 modules (e.g., lzma, zip, etc.) and fallback to install programs. I think Python3 will solve most issues of missing archive tools.

Thoughts?

vladdoster commented 1 year ago

I just stumbled upon this rust utility you might like.

https://github.com/ouch-org/ouch