-
-
Notifications
You must be signed in to change notification settings - Fork 598
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
Add support for installing binaries #1413
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Just a couple of comments
install.sh
Outdated
local arch=$(uname -sm) | ||
local bin_dir=/usr/local/bin | ||
|
||
# todo: Can make it an optional argument to install script as well, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we do this now? would be really great to have!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, that's something I can add. I had it in the patch but wasn't sure if it is okay to change the interface for the script.
install.sh
Outdated
local binary_url="https://github.com/atuinsh/atuin/releases/download/v17.0.1/$archive_name.tar.gz" | ||
download_dir=$(mktemp -d) | ||
curl -s -L $binary_url | tar -xz -C $download_dir -f - | ||
sudo mkdir -p $bin_dir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to
- Let the user know what's going on (eg tell them we couldn't find anything + will install a binary from releases)
- Tell them where it's being installed, and ask for y/n to go ahead
I don't think we should go putting files in the users filesystem without getting their confirmation that is OK, especially when they'll be getting a sudo
prompt without explanation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. I think I can add logging here, with a prompt.
@ellie, made the suggested changes. |
@ellie did you get a chance to look at it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple more things
install.sh
Outdated
@@ -34,6 +34,8 @@ LATEST_RELEASE=$(curl -L -s -H 'Accept: application/json' https://github.com/atu | |||
# Allow sed; sometimes it's more readable than ${variable//search/replace} | |||
# shellcheck disable=SC2001 | |||
LATEST_VERSION=$(echo "$LATEST_RELEASE" | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/') | |||
# For binary install, use the first argument as the installation directory. | |||
INSTALL_DIRECTORY=${1:-/usr/local/bin} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd really rather we just made this an env var input. That way we don't change the interface at all, but still allow customization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense.
install.sh
Outdated
|
||
local latest_version=$(curl -s https://api.github.com/repos/atuinsh/atuin/releases/latest | grep tag_name | grep -Eo "v[0-9]+\.[0-9]+\.[0-9]+") | ||
local archive_name=atuin-$latest_version-$target | ||
local binary_url="https://github.com/atuinsh/atuin/releases/download/v17.0.1/$archive_name.tar.gz" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hardcodes v17.0.1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made a few updates for the review, shellcheck and a small fix for darwin's stat
utility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ellie , did you get a chance to see the changes?
305b7fe
to
54e34d2
Compare
As noted in a existing TODO, this installs the `atuin` binary directly at `/usr/local/bin` for operating systems that don't have an official method. For example: Raspberry Pi / MacOS (without homebrew). Steps: 1. Get latest release info to find out the version. 2. Get the release archive and extract it to a temporary directory. 3. Move the `atuin` binary to PATH. > This is based on the [installation script](https://github.com/crodjer/sysit/blob/main/scripts/install.sh) > for `sysit` - a small utility I made.
The optional first argument to the installer can specify the install directory other than `/usr/local/bin`.
54e34d2
to
ae871ee
Compare
ae871ee
to
b17811e
Compare
- Don't change installation interface, use `INSTALL_DIR` instead. - Fix all the shellcheck errors. - Remove the hard coded 17.0.1 - Fix `stat` usage for `darwin`
b17811e
to
9442813
Compare
@crodjer looks like the prompt I mentioned in a previous review isn't here?
I really don't want to go installing files on the users system without confirmation. It would be good to tell them what files are going to be downloaded where, and also explain how they can change that. Also - the real fix for Ubuntu is to also build a deb for aarch64 and install with the proper tooling, not to install a binary manually. This should be a last resort. |
For scripting usage (say ansible playbooks), setting ATUIN_NO_PROMPT will ensure no prompt is shown.
8e333ef
to
7982375
Compare
@ellie Yes, I figured we could rely on the
I didn't want an explicit prompt because it'll then affect my scripts. For that, I have added another environment variable: |
Longer term, I think the approach for installing binaries should be one of the following
I am generally quite against automatically installing to known binary paths. This is the job of a package manager, and there are almost certainly many edge cases we have not considered. This can also conflict with existing package managers and other installs, which is not something we want. Especially in the case of /usr/local/bin, I'd rather avoid calling
For this specific case, you should be able to use ansible/saltstack/etc to automate a manual binary install. |
I understand. Lately I haven't been using I discovered https://github.com/cargo-bins/cargo-binstall, so |
As noted in a existing TODO, this installs the
atuin
binary directly at/usr/local/bin
for operating systems that don't have an official method. For example: Raspberry Pi / MacOS (without homebrew).Steps:
atuin
binary to PATH.Also, add support for custom binary installation path. It can be an additional argument to the install command. For instance:
to install the binary in
~/.local/bin