Repository navigation
Expand file tree
/
Copy pathrust-install
More file actions
executable file
·54 lines (48 loc) · 1.71 KB
/
Copy pathrust-install
File metadata and controls
executable file
·54 lines (48 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh
################################################################################
#
# rust-install
#
# Install/Update Rust for current user. This also works as a version manager.
# If version is not specified, the latest version will be installed.
#
# Homepage: https://rust-lang.org/
#
# Usage:
# rust-install [<version>]
#
# Example:
# rust-install
# rust-install 1.71.0
# rust-install v1.71.0
#
# MIT License.
# Copyright (C) 2025 Nguyen Nhat Tung.
#
################################################################################
set -ex
# Application info
GITHUB_OWNER="rust-lang"
GITHUB_REPO="rust"
PROGRAM_ID="rust"
# Shared library
CTXDIR="$(cd "$(dirname "$0")" && pwd)"
. "${CTXDIR}/shared/install-common.sh"
# Prepare environment
normalize_install_version "${1:-stable}"
init_install_env "${PROGRAM_ID}" "${INSTALL_VERSION}"
# Download and install binaries
BIN_URI_AMD64="https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init"
BIN_URI_ARM64="https://static.rust-lang.org/rustup/dist/aarch64-unknown-linux-gnu/rustup-init"
BIN_TMP_FILE="${TEMP_ROOT}/rustup-init"
download_uri_per_arch "${BIN_URI_AMD64}" "${BIN_URI_ARM64}" "${BIN_TMP_FILE}"
make_executable "${BIN_TMP_FILE}"
ARCH="$(uname -m)"
if [ "${ARCH}" = "x86_64" ] || [ "${ARCH}" = "amd64" ]; then
/tmp/rustup-init --default-toolchain "${INSTALL_VERSION}" --default-host "x86_64-unknown-linux-gnu" --profile "minimal"
elif [ "${ARCH}" = "aarch64" ] || [ "${ARCH}" = "arm64" ]; then
/tmp/rustup-init --default-toolchain "${INSTALL_VERSION}" --default-host "aarch64-unknown-linux-gnu" --profile "minimal"
else
/tmp/rustup-init --default-toolchain "${INSTALL_VERSION}" --profile "minimal"
fi
remove_item ${BIN_TMP_FILE}