Skip to content

Commit 03a1188

Browse files
committed
auto merge of rust-lang#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.
2 parents 6366631 + 0e2b5d9 commit 03a1188

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/etc/rustup.sh

+15-4
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,18 @@ validate_opt() {
229229
done
230230
}
231231

232+
create_tmp_dir() {
233+
local TMP_DIR=./rustup-tmp-install
234+
235+
rm -Rf "${TMP_DIR}"
236+
need_ok "failed to remove temporary installation directory"
237+
238+
mkdir -p "${TMP_DIR}"
239+
need_ok "failed to create create temporary installation directory"
240+
241+
echo $TMP_DIR
242+
}
243+
232244
probe_need CFG_CURL curl
233245
probe_need CFG_TAR tar
234246
probe_need CFG_FILE file
@@ -401,7 +413,9 @@ then
401413
CFG_INSTALL_FLAGS="${CFG_INSTALL_FLAGS} --prefix=${CFG_PREFIX}"
402414
fi
403415

404-
CFG_TMP_DIR="./rustup-tmp-install"
416+
CFG_TMP_DIR=$(mktemp -d 2>/dev/null \
417+
|| mktemp -d -t 'rustup-tmp-install' 2>/dev/null \
418+
|| create_tmp_dir)
405419

406420
RUST_URL="https://static.rust-lang.org/dist"
407421
RUST_PACKAGE_NAME=rust-nightly
@@ -424,9 +438,6 @@ download_package() {
424438

425439
msg "Downloading ${remote_tarball} to ${local_tarball}"
426440

427-
mkdir -p "${CFG_TMP_DIR}"
428-
need_ok "failed to create create download directory"
429-
430441
"${CFG_CURL}" -f -o "${local_tarball}" "${remote_tarball}"
431442
if [ $? -ne 0 ]
432443
then

0 commit comments

Comments
 (0)