From 264d84be6855e5b2383ee53d2a8b6829fa1e95f9 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 4 Nov 2019 21:43:48 +0000 Subject: [PATCH] provide temporary directory name prefix only for Darwin --- ghcup | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/ghcup b/ghcup index 2d1f759..405da2f 100755 --- a/ghcup +++ b/ghcup @@ -1020,6 +1020,20 @@ download_to_stdout() { edo ${DOWNLOADER} ${DOWNLOADER_STDOUT_OPTS} "$1" 2> /dev/null } +# @FUNCTION: mktempdir +# @DESCRIPTION: +# Makes a temporary directory, placing the path in $tmp_dir. +mktempdir() { + if test "${mydistro}" = "darwin"; then + debug_message "mktemp -d -t ghcup" + tmp_dir=$(mktemp -d -t ghcup) + else + debug_message "mktemp -d" + tmp_dir=$(mktemp -d) + fi + [ -z "${tmp_dir}" ] && die "Failed to create temporary directory" +} + # @FUNCTION: unpack # @USAGE: # @DESCRIPTION: @@ -1414,8 +1428,7 @@ install_ghc() { first_install=false fi - tmp_dir=$(mktemp -d -t ghcup.XXXXXXXX) - [ -z "${tmp_dir}" ] && die "Failed to create temporary directory" + mktempdir ( if ${CACHING} ; then if [ ! -f "${CACHE_LOCATION}/${download_tarball_name}" ] ; then @@ -1554,7 +1567,8 @@ upgrade() { status_message "Updating ${SCRIPT}" ( - edo cd "$(mktemp -d -t ghcup.XXXXXXXX)" + mktempdir + edo cd "${tmp_dir}" download "${SCRIPT_UPDATE_URL}" edo chmod +x ghcup edo mv -f ghcup "${target_location}"/ghcup @@ -1679,8 +1693,7 @@ install_cabal() { edo mkdir -p "${inst_location}" - tmp_dir=$(mktemp -d -t ghcup.XXXXXXXX) - [ -z "${tmp_dir}" ] && die "Failed to create temporary directory" + mktempdir ( if ${CACHING} ; then if [ ! -f "${CACHE_LOCATION}/${download_tarball_name}" ] ; then @@ -1741,8 +1754,7 @@ compile_ghc() { fi status_message "Compiling GHC for version ${myghcver} from source" - tmp_dir=$(mktemp -d -t ghcup.XXXXXXXX) - [ -z "${tmp_dir}" ] && die "Failed to create temporary directory" + mktempdir ( if ${CACHING} ; then if [ ! -f "${CACHE_LOCATION}/${download_tarball_name}" ] ; then @@ -2015,9 +2027,6 @@ print_system_reqs() { unset mydistro reqs_url } - - - ####################### #--[ Sanity checks ]--# #######################