Skip to content

Commit 4a0f40b

Browse files
committed
---
yaml --- r: 162783 b: refs/heads/try c: bd8dac8 h: refs/heads/master i: 162781: f6b614a 162779: 0c1f384 162775: f3b2a0b 162767: e3abfef 162751: e8ee127 v: v3
1 parent 58c3ffa commit 4a0f40b

File tree

2 files changed

+29
-19
lines changed

2 files changed

+29
-19
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 9146a919b616e39e528e4d7100d16eef52f1f852
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cafe2966770ff377aad6dd9fd808e68055587c58
5-
refs/heads/try: 8ca8e6fa4d3a7dc1a40e958cfa4ca62096bfa509
5+
refs/heads/try: bd8dac8f758fc76ff3c4553e187eba627728cf71
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/etc/rustup.sh

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -455,27 +455,37 @@ install_package() {
455455
fi
456456
}
457457

458-
rm -Rf "${CFG_TMP_DIR}"
459-
need_ok "failed to remove temporary installation directory"
458+
# It's possible that curl could be interrupted partway though downloading
459+
# `rustup.sh`, truncating the file. This could be especially bad if we were in
460+
# the middle of a line that would run "rm -rf ". To protect against this, we
461+
# wrap up the `rustup.sh` destructive functionality in this helper function,
462+
# which we call as the last thing we do. This means we will not do anything
463+
# unless we have the entire file downloaded.
464+
install_packages() {
465+
rm -Rf "${CFG_TMP_DIR}"
466+
need_ok "failed to remove temporary installation directory"
460467

461-
mkdir -p "${CFG_TMP_DIR}"
462-
need_ok "failed to create create temporary installation directory"
463-
464-
download_and_extract_package \
465-
"${RUST_URL}" \
466-
"${RUST_TARBALL_NAME}"
468+
mkdir -p "${CFG_TMP_DIR}"
469+
need_ok "failed to create create temporary installation directory"
467470

468-
if [ -z "${CFG_DISABLE_CARGO}" ]; then
469471
download_and_extract_package \
470-
"${CARGO_URL}" \
471-
"${CARGO_TARBALL_NAME}"
472-
fi
472+
"${RUST_URL}" \
473+
"${RUST_TARBALL_NAME}"
473474

474-
install_package "${RUST_LOCAL_INSTALL_SCRIPT}"
475+
if [ -z "${CFG_DISABLE_CARGO}" ]; then
476+
download_and_extract_package \
477+
"${CARGO_URL}" \
478+
"${CARGO_TARBALL_NAME}"
479+
fi
475480

476-
if [ -z "${CFG_DISABLE_CARGO}" ]; then
477-
install_package "${CARGO_LOCAL_INSTALL_SCRIPT}"
478-
fi
481+
install_package "${RUST_LOCAL_INSTALL_SCRIPT}"
482+
483+
if [ -z "${CFG_DISABLE_CARGO}" ]; then
484+
install_package "${CARGO_LOCAL_INSTALL_SCRIPT}"
485+
fi
486+
487+
rm -Rf "${CFG_TMP_DIR}"
488+
need_ok "couldn't rm temporary installation directory"
489+
}
479490

480-
rm -Rf "${CFG_TMP_DIR}"
481-
need_ok "couldn't rm temporary installation directory"
491+
install_packages

0 commit comments

Comments
 (0)