Skip to content

Use mktemp for temporary download directory #19227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 29, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/etc/rustup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down