2020-04-11 19:40:01 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2020-11-27 15:04:00 +00:00
|
|
|
# Main settings:
|
|
|
|
# * BOOTSTRAP_HASKELL_NONINTERACTIVE - any nonzero value for noninteractive installation
|
|
|
|
# * BOOTSTRAP_HASKELL_NO_UPGRADE - any nonzero value to not trigger the upgrade
|
|
|
|
# * GHCUP_USE_XDG_DIRS - any nonzero value to respect The XDG Base Directory Specification
|
|
|
|
# * BOOTSTRAP_HASKELL_VERBOSE - any nonzero value for more verbose installation
|
|
|
|
# * BOOTSTRAP_HASKELL_GHC_VERSION
|
|
|
|
# * BOOTSTRAP_HASKELL_CABAL_VERSION
|
|
|
|
|
2020-11-27 15:06:39 +00:00
|
|
|
# License: LGPL-3.0
|
|
|
|
|
|
|
|
|
2020-04-11 19:40:01 +00:00
|
|
|
# safety subshell to avoid executing anything in case this script is not downloaded properly
|
|
|
|
(
|
|
|
|
|
2021-05-14 21:09:45 +00:00
|
|
|
plat="$(uname -s)"
|
|
|
|
arch=$(uname -m)
|
2021-06-13 22:21:13 +00:00
|
|
|
ghver="0.1.15.2"
|
2021-05-14 21:09:45 +00:00
|
|
|
base_url="https://downloads.haskell.org/~ghcup"
|
|
|
|
|
|
|
|
case "${plat}" in
|
|
|
|
MSYS*|MINGW*)
|
|
|
|
: "${GHCUP_INSTALL_BASE_PREFIX:=/c}"
|
2021-06-08 11:57:01 +00:00
|
|
|
GHCUP_DIR=$(cygpath -u "${GHCUP_INSTALL_BASE_PREFIX}/ghcup")
|
|
|
|
GHCUP_BIN=$(cygpath -u "${GHCUP_INSTALL_BASE_PREFIX}/ghcup/bin")
|
2021-06-07 15:06:44 +00:00
|
|
|
: "${GHCUP_MSYS2:=${GHCUP_DIR}/msys64}"
|
2021-05-14 21:09:45 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
: "${GHCUP_INSTALL_BASE_PREFIX:=$HOME}"
|
|
|
|
export GHCUP_USE_XDG_DIRS
|
2020-07-28 23:43:00 +00:00
|
|
|
|
2021-05-14 21:09:45 +00:00
|
|
|
if [ -n "${GHCUP_USE_XDG_DIRS}" ] ; then
|
|
|
|
GHCUP_DIR=${XDG_DATA_HOME:=$HOME/.local/share}/ghcup
|
|
|
|
GHCUP_BIN=${XDG_BIN_HOME:=$HOME/.local/bin}
|
|
|
|
else
|
|
|
|
GHCUP_DIR=${GHCUP_INSTALL_BASE_PREFIX}/.ghcup
|
|
|
|
GHCUP_BIN=${GHCUP_INSTALL_BASE_PREFIX}/.ghcup/bin
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
2020-07-28 23:43:00 +00:00
|
|
|
|
2020-06-13 21:39:45 +00:00
|
|
|
: "${BOOTSTRAP_HASKELL_GHC_VERSION:=recommended}"
|
|
|
|
: "${BOOTSTRAP_HASKELL_CABAL_VERSION:=recommended}"
|
2020-04-11 19:40:01 +00:00
|
|
|
|
2021-05-14 21:09:45 +00:00
|
|
|
|
2020-04-11 19:40:01 +00:00
|
|
|
die() {
|
|
|
|
(>&2 printf "\\033[0;31m%s\\033[0m\\n" "$1")
|
|
|
|
exit 2
|
|
|
|
}
|
|
|
|
|
2021-05-14 21:09:45 +00:00
|
|
|
warn() {
|
|
|
|
case "${plat}" in
|
|
|
|
MSYS*|MINGW*)
|
|
|
|
echo -e "\\033[0;35m$1\\033[0m"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
printf "\\033[0;35m%s\\033[0m\\n" "$1"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2020-11-27 18:14:43 +00:00
|
|
|
edo() {
|
2020-04-11 19:40:01 +00:00
|
|
|
"$@" || die "\"$*\" failed!"
|
|
|
|
}
|
|
|
|
|
|
|
|
eghcup() {
|
2020-07-21 23:25:12 +00:00
|
|
|
edo _eghcup "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
_eghcup() {
|
2021-05-14 21:09:45 +00:00
|
|
|
if [ -n "${BOOTSTRAP_HASKELL_YAML}" ] ; then
|
|
|
|
args="-s ${BOOTSTRAP_HASKELL_YAML}"
|
|
|
|
fi
|
2020-04-11 19:40:01 +00:00
|
|
|
if [ -z "${BOOTSTRAP_HASKELL_VERBOSE}" ] ; then
|
2021-06-09 13:02:11 +00:00
|
|
|
"${GHCUP_BIN}/ghcup" ${args} "$@"
|
2020-04-11 19:40:01 +00:00
|
|
|
else
|
2021-06-09 13:02:11 +00:00
|
|
|
"${GHCUP_BIN}/ghcup" ${args} --verbose "$@"
|
2020-04-11 19:40:01 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-07-29 19:07:05 +00:00
|
|
|
_done() {
|
2021-05-14 21:09:45 +00:00
|
|
|
case "${plat}" in
|
|
|
|
MSYS*|MINGW*)
|
|
|
|
echo
|
|
|
|
echo "All done!"
|
|
|
|
echo
|
|
|
|
echo "In a new powershell or cmd.exe session, now you can..."
|
|
|
|
echo
|
|
|
|
echo "Start a simple repl via:"
|
|
|
|
echo " ghci"
|
|
|
|
echo
|
|
|
|
echo "Start a new haskell project in the current directory via:"
|
|
|
|
echo " cabal init --interactive"
|
|
|
|
echo
|
|
|
|
echo "Install other GHC versions and tools via:"
|
|
|
|
echo " ghcup list"
|
|
|
|
echo " ghcup install <tool> <version>"
|
|
|
|
echo
|
|
|
|
echo "To install system libraries and update msys2/mingw64,"
|
|
|
|
echo "open the \"Mingw haskell shell\""
|
|
|
|
echo "and the \"Mingw package management docs\""
|
|
|
|
echo "desktop shortcuts."
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo
|
|
|
|
echo "All done!"
|
|
|
|
echo
|
|
|
|
echo "To start a simple repl, run:"
|
|
|
|
echo " ghci"
|
|
|
|
echo
|
|
|
|
echo "To start a new haskell project in the current directory, run:"
|
|
|
|
echo " cabal init --interactive"
|
|
|
|
echo
|
|
|
|
echo "To install other GHC versions and tools, run:"
|
|
|
|
echo " ghcup tui"
|
|
|
|
;;
|
|
|
|
|
|
|
|
esac
|
|
|
|
|
2020-07-29 19:07:05 +00:00
|
|
|
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
2020-04-11 19:40:01 +00:00
|
|
|
download_ghcup() {
|
|
|
|
|
2021-05-14 21:09:45 +00:00
|
|
|
case "${plat}" in
|
2020-04-11 19:40:01 +00:00
|
|
|
"linux"|"Linux")
|
2021-05-14 21:09:45 +00:00
|
|
|
case "${arch}" in
|
2020-04-13 13:22:16 +00:00
|
|
|
x86_64|amd64)
|
2020-07-20 12:47:42 +00:00
|
|
|
# we could be in a 32bit docker container, in which
|
|
|
|
# case uname doesn't give us what we want
|
|
|
|
if [ "$(getconf LONG_BIT)" = "32" ] ; then
|
2021-05-14 21:09:45 +00:00
|
|
|
_url=${base_url}/${ghver}/i386-linux-ghcup-${ghver}
|
2020-07-20 12:47:42 +00:00
|
|
|
elif [ "$(getconf LONG_BIT)" = "64" ] ; then
|
2021-05-14 21:09:45 +00:00
|
|
|
_url=${base_url}/${ghver}/x86_64-linux-ghcup-${ghver}
|
2020-07-20 12:47:42 +00:00
|
|
|
else
|
|
|
|
die "Unknown long bit size: $(getconf LONG_BIT)"
|
|
|
|
fi
|
2020-04-13 13:22:16 +00:00
|
|
|
;;
|
|
|
|
i*86)
|
2021-05-14 21:09:45 +00:00
|
|
|
_url=${base_url}/${ghver}/i386-linux-ghcup-${ghver}
|
2020-04-13 13:22:16 +00:00
|
|
|
;;
|
2021-02-26 14:38:35 +00:00
|
|
|
armv7*)
|
2021-05-14 21:09:45 +00:00
|
|
|
_url=${base_url}/${ghver}/armv7-linux-ghcup-${ghver}
|
2021-02-26 14:38:35 +00:00
|
|
|
;;
|
|
|
|
aarch64|arm64|armv8l)
|
2021-05-14 21:09:45 +00:00
|
|
|
_url=${base_url}/${ghver}/aarch64-linux-ghcup-${ghver}
|
2021-02-26 14:38:35 +00:00
|
|
|
;;
|
2021-05-14 21:09:45 +00:00
|
|
|
*) die "Unknown architecture: ${arch}"
|
2020-04-13 13:22:16 +00:00
|
|
|
;;
|
|
|
|
esac
|
2020-04-11 19:40:01 +00:00
|
|
|
;;
|
|
|
|
"FreeBSD"|"freebsd")
|
2021-05-14 21:09:45 +00:00
|
|
|
case "${arch}" in
|
2020-04-13 13:22:16 +00:00
|
|
|
x86_64|amd64)
|
|
|
|
;;
|
|
|
|
i*86)
|
|
|
|
die "i386 currently not supported!"
|
|
|
|
;;
|
2021-05-14 21:09:45 +00:00
|
|
|
*) die "Unknown architecture: ${arch}"
|
2020-04-13 13:22:16 +00:00
|
|
|
;;
|
|
|
|
esac
|
2021-05-14 21:09:45 +00:00
|
|
|
_url=${base_url}/${ghver}/x86_64-portbld-freebsd-ghcup-${ghver}
|
2020-04-11 19:40:01 +00:00
|
|
|
;;
|
|
|
|
"Darwin"|"darwin")
|
2021-05-14 21:09:45 +00:00
|
|
|
case "${arch}" in
|
2020-04-13 13:22:16 +00:00
|
|
|
x86_64|amd64)
|
2021-06-11 21:57:16 +00:00
|
|
|
_url=${base_url}/${ghver}/x86_64-apple-darwin-ghcup-${ghver}
|
|
|
|
;;
|
|
|
|
aarch64|arm64|armv8l)
|
|
|
|
_url=${base_url}/${ghver}/aarch64-apple-darwin-ghcup-${ghver}
|
2020-04-13 13:22:16 +00:00
|
|
|
;;
|
|
|
|
i*86)
|
|
|
|
die "i386 currently not supported!"
|
|
|
|
;;
|
2021-05-14 21:09:45 +00:00
|
|
|
*) die "Unknown architecture: ${arch}"
|
|
|
|
;;
|
|
|
|
esac
|
2021-06-11 21:57:16 +00:00
|
|
|
;;
|
2021-05-14 21:09:45 +00:00
|
|
|
MSYS*|MINGW*)
|
|
|
|
case "${arch}" in
|
|
|
|
x86_64|amd64)
|
2021-06-11 21:57:16 +00:00
|
|
|
_url=${base_url}/${ghver}/x86_64-mingw64-ghcup-${ghver}.exe
|
2021-05-14 21:09:45 +00:00
|
|
|
;;
|
|
|
|
*) die "Unknown architecture: ${arch}"
|
2020-04-13 13:22:16 +00:00
|
|
|
;;
|
|
|
|
esac
|
2021-05-14 21:09:45 +00:00
|
|
|
;;
|
|
|
|
*) die "Unknown platform: ${plat}"
|
2020-04-11 19:40:01 +00:00
|
|
|
;;
|
|
|
|
esac
|
2021-05-14 21:09:45 +00:00
|
|
|
case "${plat}" in
|
|
|
|
MSYS*|MINGW*)
|
|
|
|
edo curl -Lf "${_url}" > "${GHCUP_BIN}"/ghcup.exe
|
|
|
|
edo chmod +x "${GHCUP_BIN}"/ghcup.exe
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
edo curl -Lf "${_url}" > "${GHCUP_BIN}"/ghcup
|
|
|
|
edo chmod +x "${GHCUP_BIN}"/ghcup
|
|
|
|
;;
|
|
|
|
esac
|
2020-07-21 23:25:12 +00:00
|
|
|
|
2021-07-11 20:06:19 +00:00
|
|
|
edo mkdir -p "${GHCUP_DIR}"
|
|
|
|
|
|
|
|
# we may overwrite this in adjust_bashrc
|
2020-07-28 23:43:00 +00:00
|
|
|
cat <<-EOF > "${GHCUP_DIR}"/env || die "Failed to create env file"
|
|
|
|
export PATH="\$HOME/.cabal/bin:${GHCUP_BIN}:\$PATH"
|
2020-07-21 23:25:12 +00:00
|
|
|
EOF
|
2021-07-11 20:06:19 +00:00
|
|
|
|
2020-07-21 23:25:12 +00:00
|
|
|
# shellcheck disable=SC1090
|
2020-07-28 23:43:00 +00:00
|
|
|
edo . "${GHCUP_DIR}"/env
|
2020-07-21 23:25:12 +00:00
|
|
|
eghcup upgrade
|
2020-04-11 19:40:01 +00:00
|
|
|
}
|
|
|
|
|
2021-07-04 17:12:37 +00:00
|
|
|
adjust_bashrc() {
|
|
|
|
case $SHELL in
|
|
|
|
*/zsh) # login shell is zsh
|
|
|
|
GHCUP_PROFILE_FILE="$HOME/.zshrc"
|
|
|
|
MY_SHELL="zsh" ;;
|
|
|
|
*/bash) # login shell is bash
|
|
|
|
GHCUP_PROFILE_FILE="$HOME/.bashrc"
|
|
|
|
MY_SHELL="bash" ;;
|
|
|
|
*/sh) # login shell is sh, but might be a symlink to bash or zsh
|
|
|
|
if [ -n "${BASH}" ] ; then
|
|
|
|
GHCUP_PROFILE_FILE="$HOME/.bashrc"
|
|
|
|
MY_SHELL="bash"
|
|
|
|
elif [ -n "${ZSH_VERSION}" ] ; then
|
|
|
|
GHCUP_PROFILE_FILE="$HOME/.zshrc"
|
|
|
|
MY_SHELL="zsh"
|
|
|
|
else
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*/fish) # login shell is fish
|
|
|
|
GHCUP_PROFILE_FILE="$HOME/.config/fish/config.fish"
|
|
|
|
MY_SHELL="fish" ;;
|
|
|
|
*) return ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
|
|
warn ""
|
|
|
|
warn "Detected ${MY_SHELL} shell on your system..."
|
2021-07-11 20:06:19 +00:00
|
|
|
warn "Do you want ghcup to automatically add the required PATH variable to \"${GHCUP_PROFILE_FILE}\"?"
|
2021-07-04 17:12:37 +00:00
|
|
|
warn ""
|
2021-07-11 20:06:19 +00:00
|
|
|
warn "[P] Yes, prepend [A] Yes, append [N] No [?] Help (default is \"P\")."
|
2021-07-04 17:12:37 +00:00
|
|
|
warn ""
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
if [ -z "${BOOTSTRAP_HASKELL_NONINTERACTIVE}" ] ; then
|
|
|
|
read -r next_answer </dev/tty
|
|
|
|
else
|
|
|
|
next_answer="yes"
|
|
|
|
fi
|
|
|
|
|
2021-07-11 20:06:19 +00:00
|
|
|
case $next_answer in
|
|
|
|
[Pp]* | "")
|
|
|
|
cat <<-EOF > "${GHCUP_DIR}"/env || die "Failed to create env file"
|
|
|
|
export PATH="\$HOME/.cabal/bin:${GHCUP_BIN}:\$PATH"
|
|
|
|
EOF
|
|
|
|
;;
|
|
|
|
[Aa]*)
|
|
|
|
cat <<-EOF > "${GHCUP_DIR}"/env || die "Failed to create env file"
|
|
|
|
export PATH="\$HOME/.cabal/bin:\$PATH:${GHCUP_BIN}"
|
|
|
|
EOF
|
|
|
|
;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
|
2021-07-04 17:12:37 +00:00
|
|
|
case $next_answer in
|
|
|
|
[Nn]*)
|
|
|
|
return ;;
|
2021-07-11 20:06:19 +00:00
|
|
|
[Pp]* | [Aa]* | "")
|
2021-07-04 17:12:37 +00:00
|
|
|
case $MY_SHELL in
|
|
|
|
"") break ;;
|
|
|
|
fish)
|
2021-07-11 20:06:19 +00:00
|
|
|
mkdir -p "${GHCUP_PROFILE_FILE%/*}"
|
|
|
|
sed -i -e '/# ghcup-env$/ s/^#*/#/' "${GHCUP_PROFILE_FILE}"
|
|
|
|
case $next_answer in
|
|
|
|
[Pp]* | "")
|
|
|
|
echo "set -q GHCUP_INSTALL_BASE_PREFIX[1]; or set GHCUP_INSTALL_BASE_PREFIX \$HOME ; set -gx PATH \$HOME/.cabal/bin $GHCUP_BIN \$PATH # ghcup-env" >> "${GHCUP_PROFILE_FILE}"
|
|
|
|
;;
|
|
|
|
[Aa]*)
|
|
|
|
echo "set -q GHCUP_INSTALL_BASE_PREFIX[1]; or set GHCUP_INSTALL_BASE_PREFIX \$HOME ; set -gx PATH \$HOME/.cabal/bin \$PATH $GHCUP_BIN # ghcup-env" >> "${GHCUP_PROFILE_FILE}"
|
|
|
|
;;
|
|
|
|
esac
|
2021-07-04 17:12:37 +00:00
|
|
|
break ;;
|
|
|
|
bash)
|
|
|
|
sed -i -e '/# ghcup-env$/ s/^#*/#/' "${GHCUP_PROFILE_FILE}"
|
|
|
|
echo "[ -f \"${GHCUP_DIR}/env\" ] && source \"${GHCUP_DIR}/env\" # ghcup-env" >> "${GHCUP_PROFILE_FILE}"
|
|
|
|
case "${plat}" in
|
|
|
|
"Darwin"|"darwin")
|
|
|
|
if ! grep -q "ghcup-env" "${HOME}/.bash_profile" ; then
|
|
|
|
echo "[[ -f ~/.bashrc ]] && source ~/.bashrc # ghcup-env" >> "${HOME}/.bash_profile"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
break ;;
|
|
|
|
|
|
|
|
zsh)
|
|
|
|
sed -i -e '/# ghcup-env$/ s/^#*/#/' "${GHCUP_PROFILE_FILE}"
|
|
|
|
echo "[ -f \"${GHCUP_DIR}/env\" ] && source \"${GHCUP_DIR}/env\" # ghcup-env" >> "${GHCUP_PROFILE_FILE}"
|
|
|
|
break ;;
|
|
|
|
esac
|
|
|
|
warn "OK! ${GHCUP_PROFILE_FILE} has been modified. Restart your terminal for the changes to take effect,"
|
|
|
|
warn "or type \"source ${GHCUP_DIR}/env\" to apply them in your current terminal session."
|
|
|
|
return
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Possible choices are:"
|
|
|
|
echo
|
2021-07-11 20:06:19 +00:00
|
|
|
echo "P - Yes, prepend to PATH, taking precedence (default)"
|
|
|
|
echo "A - Yes, append to PATH"
|
2021-07-04 17:12:37 +00:00
|
|
|
echo "N - No, don't mess with my configuration"
|
|
|
|
echo
|
|
|
|
echo "Please make your choice and press ENTER."
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2020-04-11 19:40:01 +00:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Welcome to Haskell!"
|
|
|
|
echo
|
2020-05-06 20:33:52 +00:00
|
|
|
echo "This script will download and install the following binaries:"
|
2020-07-29 19:07:05 +00:00
|
|
|
echo " * ghcup - The Haskell toolchain installer"
|
2020-05-06 20:33:52 +00:00
|
|
|
echo " * ghc - The Glasgow Haskell Compiler"
|
2021-05-30 13:17:04 +00:00
|
|
|
echo " * cabal - The Cabal build tool for managing Haskell software"
|
|
|
|
echo " * stack - (optional) A cross-platform program for developing Haskell projects"
|
|
|
|
echo " * hls - (optional) A language server for developers to integrate with their editor/IDE"
|
2020-04-11 19:40:01 +00:00
|
|
|
echo
|
2020-07-28 23:43:00 +00:00
|
|
|
if [ -z "${GHCUP_USE_XDG_DIRS}" ] ; then
|
2020-07-29 19:07:05 +00:00
|
|
|
echo "ghcup installs only into the following directory,"
|
|
|
|
echo "which can be removed anytime:"
|
2021-05-14 21:09:45 +00:00
|
|
|
case "${plat}" in
|
|
|
|
MSYS*|MINGW*)
|
|
|
|
echo " $(cygpath -w "$GHCUP_DIR")"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo " $GHCUP_DIR"
|
|
|
|
;;
|
|
|
|
esac
|
2020-07-28 23:43:00 +00:00
|
|
|
else
|
2020-07-29 19:07:05 +00:00
|
|
|
echo "ghcup installs into XDG directories as long as"
|
|
|
|
echo "'GHCUP_USE_XDG_DIRS' is set."
|
2020-07-28 23:43:00 +00:00
|
|
|
fi
|
2020-04-11 19:40:01 +00:00
|
|
|
echo
|
|
|
|
|
|
|
|
if [ -z "${BOOTSTRAP_HASKELL_NONINTERACTIVE}" ] ; then
|
2021-05-14 21:09:45 +00:00
|
|
|
warn "Press ENTER to proceed or ctrl-c to abort."
|
|
|
|
warn "Note that this script can be re-run at any given time."
|
2020-04-11 19:40:01 +00:00
|
|
|
echo
|
|
|
|
# Wait for user input to continue.
|
|
|
|
# shellcheck disable=SC2034
|
|
|
|
read -r answer </dev/tty
|
|
|
|
fi
|
|
|
|
|
2020-07-28 23:43:00 +00:00
|
|
|
edo mkdir -p "${GHCUP_BIN}"
|
2020-04-11 19:40:01 +00:00
|
|
|
|
|
|
|
if command -V "ghcup" >/dev/null 2>&1 ; then
|
|
|
|
if [ -z "${BOOTSTRAP_HASKELL_NO_UPGRADE}" ] ; then
|
2020-07-21 23:25:12 +00:00
|
|
|
_eghcup upgrade || download_ghcup
|
2020-04-11 19:40:01 +00:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
download_ghcup
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
2021-05-14 21:09:45 +00:00
|
|
|
echo "$(if [ -n "${BOOTSTRAP_HASKELL_YAML}" ] ; then ghcup -s "${BOOTSTRAP_HASKELL_YAML}" tool-requirements ; else ghcup tool-requirements ; fi)"
|
2020-04-11 19:40:01 +00:00
|
|
|
echo
|
|
|
|
|
|
|
|
if [ -z "${BOOTSTRAP_HASKELL_NONINTERACTIVE}" ] ; then
|
2021-05-14 21:09:45 +00:00
|
|
|
warn "Press ENTER to proceed or ctrl-c to abort."
|
|
|
|
warn "Installation may take a while."
|
2020-04-11 19:40:01 +00:00
|
|
|
echo
|
|
|
|
|
|
|
|
# Wait for user input to continue.
|
|
|
|
# shellcheck disable=SC2034
|
|
|
|
read -r answer </dev/tty
|
|
|
|
fi
|
|
|
|
|
2020-07-14 17:07:57 +00:00
|
|
|
eghcup --cache install ghc "${BOOTSTRAP_HASKELL_GHC_VERSION}"
|
2020-04-11 19:40:01 +00:00
|
|
|
|
2020-07-14 17:07:57 +00:00
|
|
|
eghcup set ghc "${BOOTSTRAP_HASKELL_GHC_VERSION}"
|
|
|
|
eghcup --cache install cabal "${BOOTSTRAP_HASKELL_CABAL_VERSION}"
|
2020-04-11 19:40:01 +00:00
|
|
|
|
2021-05-14 21:09:45 +00:00
|
|
|
adjust_cabal_config() {
|
2021-06-08 11:57:01 +00:00
|
|
|
edo cabal user-config -a "extra-prog-path: $(cygpath -w "$GHCUP_BIN"), $(cygpath -w "$HOME"/AppData/Roaming/cabal/bin), $(cygpath -w "$GHCUP_MSYS2"/usr/bin), $(cygpath -w "$GHCUP_MSYS2"/mingw64/bin)" -a "extra-include-dirs: $(cygpath -w "$GHCUP_MSYS2"/mingw64/include)" -a "extra-lib-dirs: $(cygpath -w "$GHCUP_MSYS2"/mingw64/lib)" -f init
|
2021-05-14 21:09:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case "${plat}" in
|
|
|
|
MSYS*|MINGW*)
|
|
|
|
if [ -z "${BOOTSTRAP_HASKELL_NONINTERACTIVE}" ] ; then
|
|
|
|
warn "Create an initial cabal.config including relevant msys2 paths (recommended)?"
|
|
|
|
warn "[Y] Yes [N] No [?] Help (default is \"Y\")."
|
|
|
|
echo
|
|
|
|
while true; do
|
|
|
|
read -r mingw_answer </dev/tty
|
|
|
|
|
|
|
|
case $mingw_answer in
|
|
|
|
[Yy]* | "")
|
|
|
|
adjust_cabal_config
|
|
|
|
break ;;
|
|
|
|
[Nn]*)
|
|
|
|
echo "Make sure that your global cabal.config references the correct mingw64 paths (extra-prog-path, extra-include-dirs and extra-lib-dirs)."
|
2021-06-07 15:06:44 +00:00
|
|
|
echo "And set the environment variable GHCUP_MSYS2 to the root path of your msys2 installation."
|
2021-05-14 21:09:45 +00:00
|
|
|
sleep 5
|
|
|
|
break ;;
|
|
|
|
*)
|
|
|
|
echo "Possible choices are:"
|
|
|
|
echo
|
|
|
|
echo "Y - Yes, create a cabal.config with pre-set paths to msys2/mingw64 (default)"
|
|
|
|
echo "N - No, leave the current/default cabal config untouched"
|
|
|
|
echo
|
|
|
|
echo "Please make your choice and press ENTER."
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
else
|
|
|
|
adjust_cabal_config
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
2020-04-11 19:40:01 +00:00
|
|
|
|
2020-09-28 21:48:59 +00:00
|
|
|
|
2021-05-14 21:09:45 +00:00
|
|
|
edo cabal new-update
|
2020-04-11 19:40:01 +00:00
|
|
|
|
2021-07-04 17:12:37 +00:00
|
|
|
|
2020-04-11 19:40:01 +00:00
|
|
|
if [ -z "${BOOTSTRAP_HASKELL_NONINTERACTIVE}" ] ; then
|
2021-05-14 21:09:45 +00:00
|
|
|
warn "Do you want to install haskell-language-server (HLS) now?"
|
|
|
|
warn "HLS is a language-server that provides IDE-like functionality"
|
|
|
|
warn "and can integrate with different editors, such as Vim, Emacs, VS Code, Atom, ..."
|
|
|
|
warn "Also see https://github.com/haskell/haskell-language-server/blob/master/README.md"
|
|
|
|
warn ""
|
|
|
|
warn "[Y] Yes [N] No [?] Help (default is \"N\")."
|
|
|
|
warn ""
|
2020-09-29 08:52:31 +00:00
|
|
|
|
2020-09-29 08:12:03 +00:00
|
|
|
while true; do
|
|
|
|
read -r hls_answer </dev/tty
|
|
|
|
|
|
|
|
case $hls_answer in
|
|
|
|
[Yy]*)
|
2021-07-07 18:08:12 +00:00
|
|
|
_eghcup --cache install hls || warn "HLS installation failed, continuing anyway"
|
2020-09-29 08:12:03 +00:00
|
|
|
break ;;
|
2021-05-14 21:09:45 +00:00
|
|
|
[Nn]* | "")
|
2020-09-29 08:12:03 +00:00
|
|
|
break ;;
|
|
|
|
*)
|
2021-05-14 21:09:45 +00:00
|
|
|
echo "Possible choices are:"
|
|
|
|
echo
|
|
|
|
echo "Y - Yes, install the haskell-langauge-server"
|
|
|
|
echo "N - No, don't install anything more (default)"
|
|
|
|
echo
|
|
|
|
echo "Please make your choice and press ENTER."
|
|
|
|
;;
|
2020-09-29 08:12:03 +00:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2021-05-14 21:09:45 +00:00
|
|
|
warn "Do you want to install stack now?"
|
|
|
|
warn "Stack is a haskell build tool similar to cabal that is used by some projects."
|
|
|
|
warn "Also see https://docs.haskellstack.org/"
|
|
|
|
warn ""
|
|
|
|
warn "[Y] Yes [N] No [?] Help (default is \"N\")."
|
|
|
|
warn ""
|
2021-05-30 13:17:04 +00:00
|
|
|
|
|
|
|
while true; do
|
|
|
|
read -r stack_answer </dev/tty
|
|
|
|
|
|
|
|
case $stack_answer in
|
|
|
|
[Yy]*)
|
2021-07-07 18:08:12 +00:00
|
|
|
_eghcup --cache install stack || warn "Stack installation failed, continuing anyway"
|
2021-05-30 13:17:04 +00:00
|
|
|
break ;;
|
2021-05-14 21:09:45 +00:00
|
|
|
[Nn]* | "")
|
2021-05-30 13:17:04 +00:00
|
|
|
break ;;
|
|
|
|
*)
|
2021-05-14 21:09:45 +00:00
|
|
|
echo "Possible choices are:"
|
|
|
|
echo
|
|
|
|
echo "Y - Yes, install stack"
|
|
|
|
echo "N - No, don't install anything more (default)"
|
|
|
|
echo
|
|
|
|
echo "Please make your choice and press ENTER."
|
|
|
|
;;
|
2021-05-30 13:17:04 +00:00
|
|
|
esac
|
|
|
|
done
|
2021-07-04 17:12:37 +00:00
|
|
|
fi
|
2021-05-30 13:17:04 +00:00
|
|
|
|
2021-07-04 17:12:37 +00:00
|
|
|
# short-circuit script based on platform
|
|
|
|
case "${plat}" in
|
|
|
|
MSYS*|MINGW*)
|
|
|
|
# For windows we always adjust bashrc, since it's inside msys2
|
|
|
|
adjust_bashrc
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
if [ -z "${BOOTSTRAP_HASKELL_NONINTERACTIVE}" ] ; then
|
|
|
|
echo "In order to run ghc and cabal, you need to adjust your PATH variable."
|
|
|
|
echo "You may want to source '$GHCUP_DIR/env' in your shell"
|
|
|
|
echo "configuration to do so (e.g. ~/.bashrc)."
|
2020-04-11 19:40:01 +00:00
|
|
|
|
2021-07-04 17:12:37 +00:00
|
|
|
adjust_bashrc
|
2020-04-11 19:40:01 +00:00
|
|
|
fi
|
|
|
|
;;
|
2021-07-04 17:12:37 +00:00
|
|
|
esac
|
2021-05-14 21:09:45 +00:00
|
|
|
|
|
|
|
_done
|
|
|
|
|
2020-04-11 19:40:01 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# vim: tabstop=4 shiftwidth=4 expandtab
|
|
|
|
|