zinit icon indicating copy to clipboard operation
zinit copied to clipboard

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

Open docwhat opened this issue 2 years ago • 12 comments

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.

docwhat avatar Nov 18 '21 03:11 docwhat

Can you show me something that requires an unpacker?

alichtman avatar Nov 18 '21 03:11 alichtman

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

docwhat avatar Nov 18 '21 03:11 docwhat

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?

pschmitt avatar Nov 18 '21 06:11 pschmitt

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.

alichtman avatar Nov 18 '21 07:11 alichtman

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.

pschmitt avatar Nov 18 '21 08:11 pschmitt

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.

alichtman avatar Nov 18 '21 08:11 alichtman

@docwhat,

Can this be closed?

vladdoster avatar Apr 08 '23 22:04 vladdoster

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 avatar Apr 13 '23 14:04 docwhat

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 avatar Apr 13 '23 14:04 docwhat

Can this be closed?

I'd prefer if unar was added to ziextract.

docwhat avatar Apr 13 '23 14:04 docwhat

@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 avatar Apr 16 '23 05:04 vladdoster

I just stumbled upon this rust utility you might like.

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

vladdoster avatar Apr 16 '23 12:04 vladdoster