From cb501535b38ac40fc3d93aaee13d76eecd4fa6c9 Mon Sep 17 00:00:00 2001 From: Johannes Hoff Date: Sat, 22 Nov 2014 15:49:38 -0800 Subject: [PATCH] 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. --- src/etc/rustup.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/etc/rustup.sh b/src/etc/rustup.sh index 4829e15fb0ff..7b72fe625c4a 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 ]