about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJohannes Hoff <johshoff@gmail.com>2014-11-22 15:49:38 -0800
committerJohannes Hoff <johshoff@gmail.com>2014-11-22 15:49:38 -0800
commitcb501535b38ac40fc3d93aaee13d76eecd4fa6c9 (patch)
tree010e11c050a9ac7f05cea384ebf01ac9e200a66e
parent0d0a29061443852cae070b27d51de7cc69bbf293 (diff)
Use mktemp for temporary download directory
Using the current directory may not always be appropriate, for example in
the case where it will unnecessarily trigger a backup to be made.

The only risk with this change is that systems might not have a mktemp.
I am not aware of such a system, but have not tested on Windows. It is
working on a basic Ubuntu and OS X installation.
-rw-r--r--src/etc/rustup.sh8
1 files changed, 1 insertions, 7 deletions
diff --git a/src/etc/rustup.sh b/src/etc/rustup.sh
index 4829e15fb0f..7b72fe625c4 100644
--- a/src/etc/rustup.sh
+++ b/src/etc/rustup.sh
@@ -392,7 +392,7 @@ PACKAGE_NAME=rust-nightly
 PACKAGE_NAME_AND_TRIPLE="${PACKAGE_NAME}-${HOST_TRIPLE}"
 TARBALL_NAME="${PACKAGE_NAME_AND_TRIPLE}.tar.gz"
 REMOTE_TARBALL="https://static.rust-lang.org/dist/${TARBALL_NAME}"
-TMP_DIR="./rustup-tmp-install"
+TMP_DIR=`mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir'`
 LOCAL_TARBALL="${TMP_DIR}/${TARBALL_NAME}"
 LOCAL_INSTALL_DIR="${TMP_DIR}/${PACKAGE_NAME_AND_TRIPLE}"
 LOCAL_INSTALL_SCRIPT="${LOCAL_INSTALL_DIR}/install.sh"
@@ -405,12 +405,6 @@ CARGO_LOCAL_TARBALL="${TMP_DIR}/${CARGO_TARBALL_NAME}"
 CARGO_LOCAL_INSTALL_DIR="${TMP_DIR}/${CARGO_PACKAGE_NAME_AND_TRIPLE}"
 CARGO_LOCAL_INSTALL_SCRIPT="${CARGO_LOCAL_INSTALL_DIR}/install.sh"
 
-rm -Rf "${TMP_DIR}"
-need_ok "failed to remove temporary installation directory"
-
-mkdir -p "${TMP_DIR}"
-need_ok "failed to create create temporary installation directory"
-
 msg "downloading rust installer"
 "${CFG_CURL}" "${REMOTE_TARBALL}" > "${LOCAL_TARBALL}"
 if [ $? -ne 0 ]