diff --git a/src/haskell/install.sh b/src/haskell/install.sh index 11189ef8c..092db1fff 100644 --- a/src/haskell/install.sh +++ b/src/haskell/install.sh @@ -1,13 +1,13 @@ #!/usr/bin/env bash GHC_VERSION="${GHCVERSION:-"latest"}" -CABAL_VERSION="${CABALVERSION:-"latest"}" -INCLUDE_STACK="${INSTALLSTACK:-"true"}" -ADJUST_BASHRC="${ADJUSTBASH:-"true"}" +CABAL_VERSION="${CABALVERSION:-"latest"}" +INCLUDE_STACK="${INSTALLSTACK:-"true"}" +ADJUST_BASHRC="${ADJUSTBASH:-"true"}" INSTALL_STACK_GHCUP_HOOK="${INSTALLSTACKGHCUPHOOK:-"true"}" -# Clean up +# Clean up rm -rf /var/lib/apt/lists/* if [ "$(id -u)" -ne 0 ]; then @@ -17,7 +17,7 @@ fi # Checks if packages are installed and installs them if not check_packages() { - if ! dpkg -s "$@" > /dev/null 2>&1; then + if ! dpkg -s "$@" >/dev/null 2>&1; then if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then echo "Running apt-get update..." apt-get update -y @@ -30,27 +30,34 @@ check_packages curl build-essential libffi-dev libffi8ubuntu1 libgmp-dev libgmp1 export BOOTSTRAP_HASKELL_NONINTERACTIVE=1 export GHCUP_USE_XDG_DIRS=1 -export BOOTSTRAP_HASKELL_GHC_VERSION="${GHC_VERSION}" +export BOOTSTRAP_HASKELL_GHC_VERSION="${GHC_VERSION}" export BOOTSTRAP_HASKELL_CABAL_VERSION="${CABAL_VERSION}" export BOOTSTRAP_HASKELL_DOWNLOADER="curl" -if [[ "${INCLUDE_STACK}" = "false" ]] ; then +if [[ "${INCLUDE_STACK}" = "false" ]]; then export BOOTSTRAP_HASKELL_INSTALL_NO_STACK="true" fi -if [[ "${ADJUST_BASH}" = "true" ]] ; then +if [[ "${ADJUST_BASH}" = "true" ]]; then export BOOTSTRAP_HASKELL_ADJUST_BASHRC="true" fi -if [[ "${INSTALL_STACK_GHCUP_HOOK}" = "false" ]] ; then +if [[ "${INSTALL_STACK_GHCUP_HOOK}" = "false" ]]; then export BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK="true" fi +# The installation script is designed to be run by the non-root user +# The files need to be in the remote user's ~/ home directory +ROOT_HOME="${HOME}" +export HOME="${_REMOTE_USER_HOME}" + curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | $SHELL +export HOME="${ROOT_HOME}" +chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "${_REMOTE_USER_HOME}" # without restarting the shell, ghci location would not be resolved from the updated PATH exec $SHELL -# Clean up +# Clean up rm -rf /var/lib/apt/lists/* -echo "Done!" \ No newline at end of file +echo "Done!"