From cb501535b38ac40fc3d93aaee13d76eecd4fa6c9 Mon Sep 17 00:00:00 2001 From: Johannes Hoff Date: Sat, 22 Nov 2014 15:49:38 -0800 Subject: [PATCH 1/4] 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 4829e15fb0ffa..7b72fe625c4a8 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 ] From 8f827d33cab1be648120fc8ac34651d9cc079b5e Mon Sep 17 00:00:00 2001 From: Johannes Hoff Date: Thu, 27 Nov 2014 11:15:49 -0800 Subject: [PATCH 2/4] Fall back to hard coded download directory If mktemp fails, fall back to a hard coded directory, per @nodakai's feedback. --- src/etc/rustup.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/etc/rustup.sh b/src/etc/rustup.sh index 7b72fe625c4a8..234699f49eb62 100644 --- 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 CFG_SRC_DIR="$(cd $(dirname $0) && pwd)/" @@ -392,7 +404,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=`mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir'` +TMP_DIR=`mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir' 2>/dev/null` || TMP_DIR=$(create_tmp_dir) LOCAL_TARBALL="${TMP_DIR}/${TARBALL_NAME}" LOCAL_INSTALL_DIR="${TMP_DIR}/${PACKAGE_NAME_AND_TRIPLE}" LOCAL_INSTALL_SCRIPT="${LOCAL_INSTALL_DIR}/install.sh" From ee72c57bc9081327fcc37f4ecf4bb378969e577f Mon Sep 17 00:00:00 2001 From: Johannes Hoff Date: Wed, 24 Dec 2014 13:25:28 +0100 Subject: [PATCH 3/4] Better temporary directory name --- src/etc/rustup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/etc/rustup.sh b/src/etc/rustup.sh index 35ff1199b5266..697afacf8983f 100755 --- a/src/etc/rustup.sh +++ b/src/etc/rustup.sh @@ -413,7 +413,7 @@ then CFG_INSTALL_FLAGS="${CFG_INSTALL_FLAGS} --prefix=${CFG_PREFIX}" fi -CFG_TMP_DIR=`mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir' 2>/dev/null` || CFG_TMP_DIR=$(create_tmp_dir) +CFG_TMP_DIR=`mktemp -d 2>/dev/null || mktemp -d -t 'rustup-tmp-install' 2>/dev/null` || CFG_TMP_DIR=$(create_tmp_dir) RUST_URL="https://static.rust-lang.org/dist" RUST_PACKAGE_NAME=rust-nightly From 0e2b5d99af9a32ce535286fc166b5818cd213e74 Mon Sep 17 00:00:00 2001 From: Johannes Hoff Date: Sun, 28 Dec 2014 12:59:19 +0100 Subject: [PATCH 4/4] Split overly long line --- src/etc/rustup.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/etc/rustup.sh b/src/etc/rustup.sh index 697afacf8983f..85e15e363271b 100755 --- a/src/etc/rustup.sh +++ b/src/etc/rustup.sh @@ -413,7 +413,9 @@ then CFG_INSTALL_FLAGS="${CFG_INSTALL_FLAGS} --prefix=${CFG_PREFIX}" fi -CFG_TMP_DIR=`mktemp -d 2>/dev/null || mktemp -d -t 'rustup-tmp-install' 2>/dev/null` || CFG_TMP_DIR=$(create_tmp_dir) +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