aboutsummaryrefslogtreecommitdiff
path: root/src/rust
diff options
context:
space:
mode:
authorJosh Spicer <joshspicer@github.com>2022-07-29 18:38:08 +0300
committerJosh Spicer <joshspicer@github.com>2022-07-29 18:38:08 +0300
commit86eaacb47edefaa8fa36d37eff8b5cccf9d838f4 (patch)
tree14cce439014020be97ca6a80fb88bbd906b26346 /src/rust
parent6191a2e5d5018fbf018ce9b3d9c03b9821d5e26e (diff)
Port changes and set executable bit
-Ports change from: https://github.com/microsoft/vscode-dev-containers/pull/1554 Sets all scripts as executable by default.
Diffstat (limited to 'src/rust')
-rwxr-xr-x[-rw-r--r--]src/rust/install.sh28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/rust/install.sh b/src/rust/install.sh
index be52fd3..3970bb2 100644..100755
--- a/src/rust/install.sh
+++ b/src/rust/install.sh
@@ -94,6 +94,25 @@ find_version_from_git_tags() {
echo "${variable_name}=${!variable_name}"
}
+check_nightly_version_formatting() {
+ local variable_name=$1
+ local requested_version=${!variable_name}
+ if [ "${requested_version}" = "none" ]; then return; fi
+
+ local version_date=$(echo ${requested_version} | sed -e "s/^nightly-//")
+
+ date -d ${version_date} &>/dev/null
+ if [ $? != 0 ]; then
+ echo -e "Invalid ${variable_name} value: ${requested_version}\nNightly version should be in the format nightly-YYYY-MM-DD" >&2
+ exit 1
+ fi
+
+ if [ $(date -d ${version_date} +%s) -ge $(date +%s) ]; then
+ echo -e "Invalid ${variable_name} value: ${requested_version}\nNightly version should not exceed current date" >&2
+ exit 1
+ fi
+}
+
updaterc() {
if [ "${UPDATE_RC}" = "true" ]; then
echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..."
@@ -159,7 +178,14 @@ else
apt_get_update_if_needed
apt-get -y install --no-install-recommends git
fi
- find_version_from_git_tags RUST_VERSION "https://github.com/rust-lang/rust" "tags/"
+
+ echo ${RUST_VERSION} | grep -q "nightly"
+ is_nightly=$?
+ if [ $is_nightly = 0 ]; then
+ check_nightly_version_formatting RUST_VERSION
+ else
+ find_version_from_git_tags RUST_VERSION "https://github.com/rust-lang/rust" "tags/"
+ fi
default_toolchain_arg="--default-toolchain ${RUST_VERSION}"
fi
echo "Installing Rust..."