@@ -24,6 +24,9 @@ if [ "$(id -u)" -ne 0 ]; then
24
24
exit 1
25
25
fi
26
26
27
+ echo " Starting installation of Rust (${RUST_VERSION} )"
28
+
29
+
27
30
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
28
31
rm -f /etc/profile.d/00-restore-env.sh
29
32
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() {
95
98
echo " ${variable_name} =${! variable_name} "
96
99
}
97
100
98
- check_nightly_version () {
101
+ check_nightly_version_formatting () {
99
102
local variable_name=$1
100
103
local requested_version=${! variable_name}
101
104
if [ " ${requested_version} " = " none" ]; then return ; fi
@@ -104,7 +107,7 @@ check_nightly_version() {
104
107
105
108
date -d ${version_date} & > /dev/null
106
109
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
108
111
exit 1
109
112
fi
110
113
@@ -173,20 +176,23 @@ chmod g+r+w+s "${RUSTUP_HOME}" "${CARGO_HOME}"
173
176
if [ " ${RUST_VERSION} " = " none" ] || type rustup > /dev/null 2>&1 ; then
174
177
echo " Rust already installed. Skipping..."
175
178
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
177
181
# Find version using soft match
178
182
if ! type git > /dev/null 2>&1 ; then
179
183
apt_get_update_if_needed
180
184
apt-get -y install --no-install-recommends git
181
185
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
184
190
else
185
- check_nightly_version RUST_VERSION
191
+ find_version_from_git_tags RUST_VERSION " https://github.com/rust-lang/rust " " tags/ "
186
192
fi
187
193
default_toolchain_arg=" --default-toolchain ${RUST_VERSION} "
188
194
fi
189
- echo " Installing Rust..."
195
+ echo " Installing Rust (resolved version is ' ${RUST_VERSION} ') ..."
190
196
# Download and verify rustup sha
191
197
mkdir -p /tmp/rustup/target/${download_architecture} -unknown-linux-gnu/release/
192
198
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