about summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/etc/rustup.sh25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/etc/rustup.sh b/src/etc/rustup.sh
index 749d9eaa173..5a34770b88e 100755
--- a/src/etc/rustup.sh
+++ b/src/etc/rustup.sh
@@ -453,16 +453,33 @@ then
     RUST_URL="${RUST_URL}/${CFG_DATE}"
 fi
 
-verify_hash() {
-    remote_sha256="$1"
-    local_file="$2"
-
+download_hash() {
     msg "Downloading ${remote_sha256}"
     remote_sha256=`"${CFG_CURL}" -f "${remote_sha256}"`
+    if [ -n "${CFG_SAVE}" ]; then
+        echo "${remote_sha256}" > "${local_sha_file}"
+    fi
     if [ "$?" -ne 0 ]; then
         rm -Rf "${CFG_TMP_DIR}"
         err "Failed to download ${remote_url}"
     fi
+}
+
+verify_hash() {
+    remote_sha256="$1"
+    local_file="$2"
+    local_sha_file="${local_file}.sha256"
+
+    if [ -n "${CFG_SAVE}" ]; then
+        if [ -f "${local_sha_file}" ]; then
+            msg "Local ${local_sha_file} exists, treating as remote hash"
+            remote_sha256=`cat "${local_sha_file}"`
+        else
+            download_hash
+        fi
+    else
+        download_hash
+    fi
 
     msg "Verifying hash"
     local_sha256=$(calculate_hash "${local_file}")