about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-01-21 09:13:40 -0800
committerAlex Crichton <alex@alexcrichton.com>2015-01-21 09:13:40 -0800
commit550255d986cd31f4b6086a4a82cb58f4ca7e5f29 (patch)
treea7bf1394d9ecac3b5c2327775305faa71f9fdfc3 /src
parent2e9adab52808bb7eb439a0e3482973e6a9c59c4b (diff)
parent785176b7ccc3f6acdf18496473ec5f2345897067 (diff)
downloadrust-550255d986cd31f4b6086a4a82cb58f4ca7e5f29.tar.gz
rust-550255d986cd31f4b6086a4a82cb58f4ca7e5f29.zip
rollup merge of #21138: mkpankov/master
When combined with '--save' and '--date', it uses previously saved
tarball, making possible to re-install in offline mode.
r?
Diffstat (limited to 'src')
-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}")