about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-12-29 05:22:26 +0000
committerbors <bors@rust-lang.org>2014-12-29 05:22:26 +0000
commit03a1188cf35b3765d8eb718d3b757c5a5d7e9497 (patch)
tree90e951cc66379c7bc44ac601f96fe398b02991c9
parent63666317214788329e0b7680929b09823f127d83 (diff)
parent0e2b5d99af9a32ce535286fc166b5818cd213e74 (diff)
downloadrust-03a1188cf35b3765d8eb718d3b757c5a5d7e9497.tar.gz
rust-03a1188cf35b3765d8eb718d3b757c5a5d7e9497.zip
auto merge of #19227 : johshoff/rust/master, r=brson
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.
-rwxr-xr-xsrc/etc/rustup.sh19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/etc/rustup.sh b/src/etc/rustup.sh
index 528002f4ade..85e15e36327 100755
--- a/src/etc/rustup.sh
+++ b/src/etc/rustup.sh
@@ -229,6 +229,18 @@ validate_opt() {
     done
 }
 
+create_tmp_dir() {
+    local TMP_DIR=./rustup-tmp-install
+
+    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"
+
+    echo $TMP_DIR
+}
+
 probe_need CFG_CURL  curl
 probe_need CFG_TAR   tar
 probe_need CFG_FILE  file
@@ -401,7 +413,9 @@ then
     CFG_INSTALL_FLAGS="${CFG_INSTALL_FLAGS} --prefix=${CFG_PREFIX}"
 fi
 
-CFG_TMP_DIR="./rustup-tmp-install"
+CFG_TMP_DIR=$(mktemp -d 2>/dev/null \
+           || mktemp -d -t 'rustup-tmp-install' 2>/dev/null \
+           || create_tmp_dir)
 
 RUST_URL="https://static.rust-lang.org/dist"
 RUST_PACKAGE_NAME=rust-nightly
@@ -424,9 +438,6 @@ download_package() {
 
     msg "Downloading ${remote_tarball} to ${local_tarball}"
 
-    mkdir -p "${CFG_TMP_DIR}"
-    need_ok "failed to create create download directory"
-
     "${CFG_CURL}" -f -o "${local_tarball}" "${remote_tarball}"
     if [ $? -ne 0 ]
     then