Skip to content
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

feat(installer): install shuttle binary #1890

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Please file an issue if you encounter any problems!
New-Item -ItemType Directory -Force "$TempDir\cargo-shuttle"
tar.exe -xzf "$TempDir\cargo-shuttle.tar.gz" -C "$TempDir\cargo-shuttle"
Move-Item -Force "$TempDir\cargo-shuttle\cargo-shuttle-x86_64-pc-windows-msvc-$LatestRelease\cargo-shuttle.exe" "$CargoHome\bin\cargo-shuttle.exe"
Move-Item -Force "$TempDir\cargo-shuttle\cargo-shuttle-x86_64-pc-windows-msvc-$LatestRelease\shuttle.exe" "$CargoHome\bin\shuttle.exe"
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$TempDir\cargo-shuttle.tar.gz", "$TempDir\cargo-shuttle"
Write-Host "Installed cargo-shuttle, try running ``cargo shuttle --help``" -ForegroundColor Green
return
Expand Down
26 changes: 14 additions & 12 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
set -euo pipefail

cat <<EOF
_ _ _ _
___| |__ _ _| |_| |_| | ___
_ _ _ _
___| |__ _ _| |_| |_| | ___
/ __| '_ \\| | | | __| __| |/ _ \\
\__ \\ | | | |_| | |_| |_| | __/
|___/_| |_|\\__,_|\\__|\\__|_|\\___|

https://www.shuttle.rs
https://github.com/shuttle-hq/shuttle

Expand Down Expand Up @@ -49,10 +49,10 @@ _install_linux() {
;;
"ubuntu" | "ubuntuwsl" | "debian" | "linuxmint" | "parrot" | "kali" | "elementary" | "pop")
# TODO: distribute .deb packages via `cargo-deb` and install them here
_install_unsupported
_install_default
;;
*)
_install_unsupported
_install_default
;;
esac
}
Expand All @@ -63,7 +63,7 @@ _install_arch_linux() {
pacman_version=$(sudo pacman -Si cargo-shuttle | sed -n 's/^Version *: \(.*\)/\1/p')
if [[ "${pacman_version}" != "${LATEST_VERSION#v}"* ]]; then
echo "cargo-shuttle is not updated in the repos, ping @orhun!!!"
_install_unsupported
_install_default
else
echo "Installing with pacman"
sudo pacman -S --noconfirm cargo-shuttle
Expand All @@ -84,7 +84,7 @@ _install_alpine_linux() {
echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" | tee -a /etc/apk/repositories
apk update
else
_install_unsupported
_install_default
return 0
fi
fi
Expand All @@ -95,7 +95,7 @@ _install_alpine_linux() {
apk_version=$(apk version cargo-shuttle | awk 'NR==2{print $3}')
if [[ "${apk_version}" != "${LATEST_VERSION#v}"* ]]; then
echo "cargo-shuttle is not updated in the testing repository, ping @orhun!!!"
_install_unsupported
_install_default
else
echo "cargo-shuttle is already up to date."
fi
Expand All @@ -108,7 +108,7 @@ _install_alpine_linux() {

# TODO: package cargo-shuttle for Homebrew
_install_mac() {
_install_unsupported
_install_default
}

_install_binary() {
Expand All @@ -126,6 +126,8 @@ _install_binary() {
tar -xzf "cargo-shuttle-$LATEST_VERSION-$target.tar.gz"
echo "Installing to $HOME/.cargo/bin/cargo-shuttle"
mv "cargo-shuttle-$target-$LATEST_VERSION/cargo-shuttle" "$HOME/.cargo/bin/"
echo "Installing to $HOME/.cargo/bin/shuttle"
mv "cargo-shuttle-$target-$LATEST_VERSION/shuttle" "$HOME/.cargo/bin/"
popd >/dev/null || exit 1
if [[ ":$PATH:" != *":$HOME/.cargo/bin:"* ]]; then
echo "Add $HOME/.cargo/bin to PATH to run cargo-shuttle"
Expand All @@ -151,7 +153,7 @@ _install_with_cargo() {
cargo install --locked cargo-shuttle
}

_install_unsupported() {
_install_default() {
echo "Installing with package manager is not supported"

if command -v cargo-binstall &>/dev/null; then
Expand All @@ -166,7 +168,7 @@ _install_unsupported() {
else
echo "rustup was found, but cargo wasn't. Something is up with your install"
exit 1
fi
fi
fi

while true; do
Expand Down Expand Up @@ -205,7 +207,7 @@ fi
case "$OSTYPE" in
linux*) _install_linux ;;
darwin*) _install_mac ;;
*) _install_unsupported ;;
*) _install_default ;;
esac

cat <<EOF
Expand Down