Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Missing support for various formats (with examples) #205

Closed
sandreas opened this issue Jul 19, 2024 · 20 comments
Closed

Missing support for various formats (with examples) #205

sandreas opened this issue Jul 19, 2024 · 20 comments

Comments

@sandreas
Copy link

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
Copy link
Owner

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

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

  • tbz is now supported
  • you can download+install zellij, now assets like sha256sum are ignored

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
Copy link
Owner

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
Copy link
Author

sandreas commented Jul 20, 2024

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
Copy link
Author

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
Copy link
Owner

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

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

@sandreas
Copy link
Author

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?:

  • Download the matching (latest) release for given arch
  • Check, if the downloaded file already is a binary (e.g. jq - ELF) and not an archive
    • Yes? make executable and --install to destination
  • No? Check the (mime)type of the downloaded file
    • Extract supported (mime) types instead of extension based extraction
    • Look for a binary (ELF), which contains the name of the gh project (e.g. btop) first
      • Yes? make executable and install
    • Look for other binaries (ELF)
      • Yes? make executable and install
    • Look for other executable files (script etc)
      • Yes? install
  • Unsupported archive or nothing found?
    • Show install error

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
Copy link
Owner

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


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
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

I have an idea to fix this.

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

@devmatteini
Copy link
Owner

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 😄

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

@sandreas
Copy link
Author

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

I will test this tomorrow. Thanks.

@sandreas
Copy link
Author

sandreas commented Jul 26, 2024

So here is my report for 0.5.5-beta:

  • aristocratos/btop
  • jqlang/jq
  • restic/restic
  • phiresky/ripgrep-all # Error: Many executable candidates found, you must select one
  • jgm/pandoc

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
Copy link
Owner

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
Copy link

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
Copy link
Owner

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

@adriangalilea
Copy link

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
Copy link
Owner

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

@devmatteini
Copy link
Owner

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
Copy link
Owner

New release 0.6.0 is out!

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants