Created
March 4, 2025 18:03
-
-
Save Nejat/300ec561eb8e02d017ea6698fcdb6ff2 to your computer and use it in GitHub Desktop.
lets you install archived versions of rustup for any supported target
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
if [[ $1 =~ "-help|-h" ]]; then | |
echo | |
echo "usage: ./install-rustup [version] [target]" | |
echo | |
exit | |
fi | |
if [[ -f rustup-init ]]; then | |
echo | |
./rustup-init --version || { echo "problem" } | |
echo | |
echo "setup file already exists, remove it first if you want another version" | |
echo | |
exit 1 | |
fi | |
local version=${1:-'1.27.1'} | |
local target=${2:-'aarch64-apple-darwin'} | |
echo | |
echo "downloading rustup v${version} for target: ${target}" | |
echo | |
curl --proto '=https' --tlsv1.2 -sSf https://static.rust-lang.org/rustup/archive/$version/$target/rustup-init > rustup-init | |
chmod 744 rustup-init | |
local check_version=$(./rustup-init --version) || { echo "problem with rustup-init v${version}"; exit 1; } | |
if [[ ! $check_version =~ "$version" ]]; then | |
echo "requested $version does not match downloaded version; $check_version" | |
echo | |
exit 1 | |
fi | |
echo "installing rustup v${version} for target: ${target}" | |
echo | |
read -q "choice?Continue (y/N) ? " | |
case "$choice" in | |
y|Y ) ;; | |
n|N ) exit;; | |
esac | |
./rustup-init || { echo "problem installing rustup v${version}"; exit 1; } | |
rm rustup-init |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment