devmatteini / dra

A command line tool to download release assets from GitHub
MIT License
185 stars 8 forks source link

Missing support for various formats (with examples) #205

Closed sandreas closed 3 months ago

sandreas commented 4 months ago

Hey,

thanks for creating this, great tool. I use dra to install my monolithic tools into $HOME/bin/. To do so, I maintain a list of tools in a txt files that are installed automatically.

Reducing my installer script by using dra worked pretty well with the following exceptions:

dra download --install -a aristocratos/btop --output "$HOME/bin/"
# btop-x86_64-linux-musl.tbz is not supported
# reason: tbz is not recognized as tar.bz

dra download --install -a jqlang/jq --output "$HOME/bin/"
# jq-linux-amd64 is not supported
# reason: jq is not distributed as archive, but as raw binary

dra download --install -a jgm/pandoc --output "$HOME/bin/"
# No executable found
# reason: ???

dra download --install -a zellij-org/zellij --output "$HOME/bin/"
# zellij-x86_64-unknown-linux-musl.sha256sum is not supported
# reason: ???

Maybe you could take a look? Thank you.

devmatteini commented 4 months ago

Hey @sandreas! I'm very happy you like dra :smile:

I just published a new release 0.5.4 which fixes some of these problems:

Unfortunately, you will still have issues installing btop, jq and pandoc.

btop & pandoc

If you try the command now, it will work, but it will extract install.sh instead of the actual btop executable.

This is because dra find the first executable in the root directory (with max depth 2). In this case, btop is located at btop-x86_64-linux-musl/btop/bin/btop.

Same issue for pandoc.

jq

This is not supported yet, need some development.


Both of these issues are in my backlog, I just need some time to work on it (not sure when though).

As a workaround you could do something like this:

dra download -a -o btop.tbz aristocratos/btop
tar xjf btop.tbz
mv btop/bin/btop "$HOME/bin"

I will keep this issue open, and update you when these issues will be fixed!

devmatteini commented 4 months ago

I just realized that you can install jq without issues. You don't have to use --install since there's nothing to install.

You just need to download, make executable and move somewhere in $PATH:

dra download -a -o "$HOME/bin/jq" jqlang/jq
chmod +x "$HOME/bin/jq"

I actually do this for various tool in my dotfiles:

This got my thinking that I should add some examples in the README.md with some of these cases

sandreas commented 4 months ago

I just published a new release 0.5.4 which fixes some of these problems:

Awesome, thank you!

This is because dra find the first executable in the root directory (with max depth 2).

Maybe it would be cool to have a flag --install-prefer-binary to skip scripts etc.

I just realized that you can install jq without issues. You don't have to use --install since there's nothing to install. You just need to download, make executable

I'd still prefer using --install to exactly perform this action, because I use a script to walk to a series of projects and if it could all of them the same this would save me a ton of work.

I also would love to have a --from-file parameter, where you can provide a list like this, where comments and empty lines are ignored and a CSV toolname can be prefixed, to tell how the tool is named if the repository is not equal.

# bat - modern cat replacement
sharkdp/bat

# btop - process explorer
aristocratos/btop

# difftastic - better diff
difft;Wilfred/difftastic

# eza - modern ls replacement
eza-community/eza

# fd - find replacement
sharkdp/fd

# fzf - fuzzy finder
junegunn/fzf

# gdu - disk usage analyzer similar to ncdu but faster
dundee/gdu

# jless - json viewer
PaulJuliusMartinez/jless

# jq - json query tool
jqlang/jq

# lazydocker - terminal docker management ui
jesseduffield/lazydocker

# mdtopdf - markdown to pdf converter
# mandolyte/mdtopdf

# pandoc - document conversion tool
jgm/pandoc

# pandoc dependency
typst/typst

# rg - ripgrep, better grep tool
rg;BurntSushi/ripgrep

# rga - ripgrep-all, grep for PDF
rga;phiresky/ripgrep-all

# starship - powerlevel10k replacement
starship/starship

# tone - audio tagger
sandreas/tone

# yazi - terminal file manager
sxyazi/yazi

# zellij - terminal multiplexer
zellij-org/zellij

# zoxide - modern cd replacement
ajeetdsouza/zoxide

Maybe it would be cool to extend this to toml with some extras:

[rga]
id = "phiresky/ripgrep-all"
name = "rga"
description = "ripgrep-all, grep for PDF"
type = "binary" # script, appimage, whatever
path = "/rga"

Thank you for taking the time :-)

sandreas commented 4 months ago

Yet another problem with restic/restic containing a .bz2 file (https://github.com/restic/restic/releases/download/v0.16.5/restic_0.16.5_linux_amd64.bz2)

devmatteini commented 4 months ago

No problem, I'll add .bz2 as well.

I'm working on the issues regarding btop/pandoc and similar archives

sandreas commented 4 months ago

No problem, I'll add .bz2 as well.

restic.bz2 contains one single file restic-latest and it is NOT executable - that may be the problem.

Could the following workflow would be more robust?:

Maybe a (future) enum parameter --install-rules=NamedBinary,Binary,ArchiveNamedBinary,ArchiveBinary,ArchiveExecutable could be used in the future to control the order of lookup rules.

Thanks for putting work in.

devmatteini commented 4 months ago

Thank you for your interest in improving dra. I'll think about your proposal :smile:


I have a working version in the branch install-v2 if you want to try it (See CONTRIBUTING.md)

I changed the rules on how dra choose the executable file:

  1. It finds all executable files (with max depth 3, should be enough for now)
  2. Search for an executable with same name as repository (or the one passed to --install)
  3. If not found and there's only 1 executable, it selects that
  4. Otherwise, you get an error for no executable or too many executables.

In case there are too many executables, you can select which one to install by passing the name to --install <name> option.

It's still very work in progress, things may change in the next days

sandreas commented 4 months ago

Otherwise, you get an error for no executable or too many executables.

This won't work for restic, because the bz2 does neither contain any executable nor a file named restic. I think the ELF lookup is the only way to overcome this... or maybe submitting an issue to the restic team...

devmatteini commented 4 months ago

I have an idea to fix this. I was thinking it was a tar archive compressed with bz2 but it's just a file compressed with bz2.

I can treat this files differently than archives:

  1. Extract compressed file (bz2, xz, gz)
  2. Make that single file executable
  3. Move file to the output directory

This needs some work, but it should be quite easy.

sandreas commented 4 months ago

I have an idea to fix this.

Sounds reasonable... not as robust, but if it is easier to implement, go for it :-) Thanks.

devmatteini commented 4 months ago

Hi @sandreas!

I just pre-released 0.5.5-beta which you can download and try out.

In the CHANGELOG/Release notes, you should be able to find the needed information on how to use the new features.

It's a pre-release because I don't have time to finish everything, but in the meantime I can collect your feedback :smile:

Let me know if it works fine or you encounter some issues!

sandreas commented 4 months ago

Let me know if it works fine or you encounter some issues!

I will test this tomorrow. Thanks.

sandreas commented 4 months ago

So here is my report for 0.5.5-beta:

So everything worked but ripgrep-all and jq (which I think is intented because of providing just a binary)...

Thanks for fixing the most of it so quick.

devmatteini commented 4 months ago

For phiresky/ripgrep-all you can do dra download -a -I rga phiresky/ripgrep-all.

The new option -I allows to select which executable to install when many are available and it can't automatically choose one.

I forgot to include this part in the error message, but I will do before the release.

For jq there's still work to do.

adriangalilea commented 4 months ago

For phiresky/ripgrep-all you can do dra download -a -I rga phiresky/ripgrep-all.

The new option -I allows to select which executable to install when many are available and it can't automatically choose one.

I forgot to include this part in the error message, but I will do before the release.

For jq there's still work to do.

Can it handle cases like yazi, that has 2 binaries?

devmatteini commented 4 months ago

You have to handle it manually. I can see there are two executables:

If you need both, you can do:

dra download -a -i sxyazi/yazi 
# this will install the default executable yazi
dra download -a -I ya sxyazi/yazi
# this will install executable you choose to install
adriangalilea commented 4 months ago

You have to handle it manually. I can see there are two executables:

  • yazi
  • ya

If you need both, you can do:

dra download -a -i sxyazi/yazi 
# this will install the default executable yazi
dra download -a -I ya sxyazi/yazi
# this will install executable you choose to install

You mean I shuld do 2 commands, right? this was my question, if the -I allowed for a ["ya", "yazi"] or something along those lines.

devmatteini commented 4 months ago

Yes two commands. I could make -I accept multiple values...I'll think about it

devmatteini commented 3 months ago

Hi everyone!

Quick update: in the next few days I will do a new release with all the improvements discussed in this issue.

You'll also be able to install binaries like jq.

I need to write documentation, but most work is already done.

devmatteini commented 3 months ago

New release 0.6.0 is out!

If you have any problems, don't hesitate to create a new issue :smile: