Merge remote-tracking branch 'origin/merge-requests/124'

This commit is contained in:
Julian Ospald 2019-11-13 11:11:43 +08:00
commit 28c8c44574
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28

29
ghcup
View File

@ -1020,6 +1020,20 @@ download_to_stdout() {
edo ${DOWNLOADER} ${DOWNLOADER_STDOUT_OPTS} "$1" 2> /dev/null 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 # @FUNCTION: unpack
# @USAGE: <tarball> # @USAGE: <tarball>
# @DESCRIPTION: # @DESCRIPTION:
@ -1414,8 +1428,7 @@ install_ghc() {
first_install=false first_install=false
fi fi
tmp_dir=$(mktemp -d) mktempdir
[ -z "${tmp_dir}" ] && die "Failed to create temporary directory"
( (
if ${CACHING} ; then if ${CACHING} ; then
if [ ! -f "${CACHE_LOCATION}/${download_tarball_name}" ] ; then if [ ! -f "${CACHE_LOCATION}/${download_tarball_name}" ] ; then
@ -1554,7 +1567,8 @@ upgrade() {
status_message "Updating ${SCRIPT}" status_message "Updating ${SCRIPT}"
( (
edo cd "$(mktemp -d)" mktempdir
edo cd "${tmp_dir}"
download "${SCRIPT_UPDATE_URL}" download "${SCRIPT_UPDATE_URL}"
edo chmod +x ghcup edo chmod +x ghcup
edo mv -f ghcup "${target_location}"/ghcup edo mv -f ghcup "${target_location}"/ghcup
@ -1679,8 +1693,7 @@ install_cabal() {
edo mkdir -p "${inst_location}" edo mkdir -p "${inst_location}"
tmp_dir=$(mktemp -d) mktempdir
[ -z "${tmp_dir}" ] && die "Failed to create temporary directory"
( (
if ${CACHING} ; then if ${CACHING} ; then
if [ ! -f "${CACHE_LOCATION}/${download_tarball_name}" ] ; then if [ ! -f "${CACHE_LOCATION}/${download_tarball_name}" ] ; then
@ -1741,8 +1754,7 @@ compile_ghc() {
fi fi
status_message "Compiling GHC for version ${myghcver} from source" status_message "Compiling GHC for version ${myghcver} from source"
tmp_dir=$(mktemp -d) mktempdir
[ -z "${tmp_dir}" ] && die "Failed to create temporary directory"
( (
if ${CACHING} ; then if ${CACHING} ; then
if [ ! -f "${CACHE_LOCATION}/${download_tarball_name}" ] ; then if [ ! -f "${CACHE_LOCATION}/${download_tarball_name}" ] ; then
@ -2015,9 +2027,6 @@ print_system_reqs() {
unset mydistro reqs_url unset mydistro reqs_url
} }
####################### #######################
#--[ Sanity checks ]--# #--[ Sanity checks ]--#
####################### #######################