Skip to content
This repository was archived by the owner on Nov 30, 2023. It is now read-only.

Commit 10bf6f7

Browse files
committed
additional changes for #1554
1 parent 36d6744 commit 10bf6f7

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

script-library/rust-debian.sh

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ if [ "$(id -u)" -ne 0 ]; then
2424
exit 1
2525
fi
2626

27+
echo "Starting installation of Rust (${RUST_VERSION})"
28+
29+
2730
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
2831
rm -f /etc/profile.d/00-restore-env.sh
2932
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh
@@ -95,7 +98,7 @@ find_version_from_git_tags() {
9598
echo "${variable_name}=${!variable_name}"
9699
}
97100

98-
check_nightly_version() {
101+
check_nightly_version_formatting() {
99102
local variable_name=$1
100103
local requested_version=${!variable_name}
101104
if [ "${requested_version}" = "none" ]; then return; fi
@@ -104,7 +107,7 @@ check_nightly_version() {
104107

105108
date -d ${version_date} &>/dev/null
106109
if [ $? != 0 ]; then
107-
echo -e "Invalid ${variable_name} value: ${requested_version}\nNightly version should be in the format nightly-YYYY-MM-DD" >&2
110+
echo -e "Invalid nightly version for ${variable_name} value: ${requested_version}\nNightly version should be in the format nightly-YYYY-MM-DD" >&2
108111
exit 1
109112
fi
110113

@@ -173,20 +176,23 @@ chmod g+r+w+s "${RUSTUP_HOME}" "${CARGO_HOME}"
173176
if [ "${RUST_VERSION}" = "none" ] || type rustup > /dev/null 2>&1; then
174177
echo "Rust already installed. Skipping..."
175178
else
176-
if [ "${RUST_VERSION}" != "latest" ] && [ "${RUST_VERSION}" != "lts" ] && [ "${RUST_VERSION}" != "stable" ] && [ "${RUST_VERSION}" != "nightly" ]; then
179+
# Non-latest version of rust specified.
180+
if [ "${RUST_VERSION}" != "latest" ] && [ "${RUST_VERSION}" != "lts" ] && [ "${RUST_VERSION}" != "stable" ]; then
177181
# Find version using soft match
178182
if ! type git > /dev/null 2>&1; then
179183
apt_get_update_if_needed
180184
apt-get -y install --no-install-recommends git
181185
fi
182-
if [ $(echo ${RUST_VERSION} | grep -q "nightly") ]; then
183-
find_version_from_git_tags RUST_VERSION "https://github.com/rust-lang/rust" "tags/"
186+
echo ${RUST_VERSION} | grep -q "nightly"
187+
is_nightly=$?
188+
if [ $is_nightly = 0 ]; then
189+
check_nightly_version_formatting RUST_VERSION
184190
else
185-
check_nightly_version RUST_VERSION
191+
find_version_from_git_tags RUST_VERSION "https://github.com/rust-lang/rust" "tags/"
186192
fi
187193
default_toolchain_arg="--default-toolchain ${RUST_VERSION}"
188194
fi
189-
echo "Installing Rust..."
195+
echo "Installing Rust (resolved version is '${RUST_VERSION}')..."
190196
# Download and verify rustup sha
191197
mkdir -p /tmp/rustup/target/${download_architecture}-unknown-linux-gnu/release/
192198
curl -sSL --proto '=https' --tlsv1.2 "https://static.rust-lang.org/rustup/dist/${download_architecture}-unknown-linux-gnu/rustup-init" -o /tmp/rustup/target/${download_architecture}-unknown-linux-gnu/release/rustup-init

0 commit comments

Comments
 (0)