Skip to content

Commit

Permalink
rustup: Don't attempt to download SHA if it exists
Browse files Browse the repository at this point in the history
This way installer can work fully in offline mode.

Put pre-downloaded files
(rust-nightly-x86_64-unknown-linux-gnu.tar.gz and
 rust-nightly-x86_64-unknown-linux-gnu.tar.gz.sha256)
into the $HOME/.rustup/YYYY-MM-DD directory
as it would be done by script itself.

Specify --save and --date=YYYY-MM-DD when running.
Files will be picked up and used to install in offline mode.
  • Loading branch information
mkpankov committed Jan 16, 2015
1 parent d52398e commit 785176b
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/etc/rustup.sh
Expand Up @@ -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}")
Expand Down

0 comments on commit 785176b

Please sign in to comment.