From e5947f3490df66267ceef55a65739f942afe5dcc Mon Sep 17 00:00:00 2001 From: Julian Ospald <hasufell@posteo.de> Date: Mon, 30 Aug 2021 11:18:11 +0200 Subject: [PATCH] Add BOOTSTRAP_HASKELL_MINIMAL wrt #222 --- bootstrap-haskell | 37 ++++++++++++++++++++++++++++--------- bootstrap-haskell.ps1 | 12 +++++++++--- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/bootstrap-haskell b/bootstrap-haskell index 0a89e660..2d51d9af 100755 --- a/bootstrap-haskell +++ b/bootstrap-haskell @@ -3,6 +3,7 @@ # Main settings: # * BOOTSTRAP_HASKELL_NONINTERACTIVE - any nonzero value for noninteractive installation # * BOOTSTRAP_HASKELL_NO_UPGRADE - any nonzero value to not trigger the upgrade +# * BOOTSTRAP_HASKELL_MINIMAL - any nonzero value to only install ghcup # * 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 - the ghc version to install @@ -591,10 +592,12 @@ ask_bashrc ask_bashrc_answer=$? ask_cabal_config_init ask_cabal_config_init_answer=$? -ask_hls -ask_hls_answer=$? -ask_stack -ask_stack_answer=$? +if [ -z "${BOOTSTRAP_HASKELL_MINIMAL}" ] ; then + ask_hls + ask_hls_answer=$? + ask_stack + ask_stack_answer=$? +fi edo mkdir -p "${GHCUP_BIN}" @@ -620,14 +623,30 @@ if [ -z "${BOOTSTRAP_HASKELL_NONINTERACTIVE}" ] ; then read -r answer </dev/tty fi -eghcup --cache install ghc "${BOOTSTRAP_HASKELL_GHC_VERSION}" +if [ -z "${BOOTSTRAP_HASKELL_MINIMAL}" ] ; then + eghcup --cache install ghc "${BOOTSTRAP_HASKELL_GHC_VERSION}" -eghcup set ghc "${BOOTSTRAP_HASKELL_GHC_VERSION}" -eghcup --cache install cabal "${BOOTSTRAP_HASKELL_CABAL_VERSION}" + eghcup set ghc "${BOOTSTRAP_HASKELL_GHC_VERSION}" + eghcup --cache install cabal "${BOOTSTRAP_HASKELL_CABAL_VERSION}" -do_cabal_config_init $ask_cabal_config_init_answer + do_cabal_config_init $ask_cabal_config_init_answer -edo cabal new-update + edo cabal new-update +else # don't install ghc and cabal + case "${plat}" in + MSYS*|MINGW*) + # need to bootstrap cabal to initialize config on windows + # we'll remove it afterwards + tmp_dir="$(mktemp -d)" + eghcup --cache install cabal -i "${tmp_dir}" "${BOOTSTRAP_HASKELL_CABAL_VERSION}" + PATH="${tmp_dir}:$PATH" do_cabal_config_init $ask_cabal_config_init_answer + rm "${tmp_dir}/cabal" + unset tmp_dir + ;; + *) + ;; + esac +fi case $ask_hls_answer in 1) diff --git a/bootstrap-haskell.ps1 b/bootstrap-haskell.ps1 index b9671dae..c81cfd8c 100644 --- a/bootstrap-haskell.ps1 +++ b/bootstrap-haskell.ps1 @@ -32,7 +32,9 @@ param ( # Whether to install hls as well [switch]$InstallHLS, # Skip adjusting cabal.config with mingw paths - [switch]$NoAdjustCabalConfig + [switch]$NoAdjustCabalConfig, + # Do minimal installation of ghcup and msys2 only + [switch]$Minimal ) $Silent = !$Interactive @@ -529,10 +531,14 @@ if (!($NoAdjustCabalConfig)) { $AdjustCabalConfigExport = 'export BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG=1 ;' } +if ($Minimal) { + $MinimalExport = 'export BOOTSTRAP_HASKELL_MINIMAL=1 ;' +} + if ((Get-Process -ID $PID).ProcessName.StartsWith("bootstrap-haskell") -Or $InBash) { - Exec "$Bash" '-lc' ('{4} {6} {7} {8} [ -n ''{1}'' ] && export GHCUP_MSYS2=$(cygpath -m ''{1}'') ; [ -n ''{2}'' ] && export GHCUP_INSTALL_BASE_PREFIX=$(cygpath -m ''{2}/'') ; export PATH=$(cygpath -u ''{3}/bin''):$PATH ; export CABAL_DIR=''{5}'' ; [[ ''{0}'' = https* ]] && curl --proto ''=https'' --tlsv1.2 -sSf {0} | bash || cat $(cygpath -m ''{0}'') | bash' -f $BootstrapUrl, $MsysDir, $GhcupBasePrefix, $GhcupDir, $SilentExport, $CabalDirFull, $StackInstallExport, $HLSInstallExport, $AdjustCabalConfigExport) + Exec "$Bash" '-lc' ('{4} {6} {7} {8} {9} [ -n ''{1}'' ] && export GHCUP_MSYS2=$(cygpath -m ''{1}'') ; [ -n ''{2}'' ] && export GHCUP_INSTALL_BASE_PREFIX=$(cygpath -m ''{2}/'') ; export PATH=$(cygpath -u ''{3}/bin''):$PATH ; export CABAL_DIR=''{5}'' ; [[ ''{0}'' = https* ]] && curl --proto ''=https'' --tlsv1.2 -sSf {0} | bash || cat $(cygpath -m ''{0}'') | bash' -f $BootstrapUrl, $MsysDir, $GhcupBasePrefix, $GhcupDir, $SilentExport, $CabalDirFull, $StackInstallExport, $HLSInstallExport, $AdjustCabalConfigExport, $MinimalExport) } else { - Exec "$Msys2Shell" '-mingw64' '-mintty' '-c' ('{4} {6} {7} {8} [ -n ''{1}'' ] && export GHCUP_MSYS2=$(cygpath -m ''{1}'') ; [ -n ''{2}'' ] && export GHCUP_INSTALL_BASE_PREFIX=$(cygpath -m ''{2}/'') ; export PATH=$(cygpath -u ''{3}/bin''):$PATH ; export CABAL_DIR=''{5}'' ; trap ''echo Press any key to exit && read -n 1 && exit'' 2 ; [[ ''{0}'' = https* ]] && curl --proto ''=https'' --tlsv1.2 -sSf {0} | bash || cat $(cygpath -m ''{0}'') | bash ; echo ''Press any key to exit'' && read -n 1' -f $BootstrapUrl, $MsysDir, $GhcupBasePrefix, $GhcupDir, $SilentExport, $CabalDirFull, $StackInstallExport, $HLSInstallExport, $AdjustCabalConfigExport) + Exec "$Msys2Shell" '-mingw64' '-mintty' '-c' ('{4} {6} {7} {8} {9} [ -n ''{1}'' ] && export GHCUP_MSYS2=$(cygpath -m ''{1}'') ; [ -n ''{2}'' ] && export GHCUP_INSTALL_BASE_PREFIX=$(cygpath -m ''{2}/'') ; export PATH=$(cygpath -u ''{3}/bin''):$PATH ; export CABAL_DIR=''{5}'' ; trap ''echo Press any key to exit && read -n 1 && exit'' 2 ; [[ ''{0}'' = https* ]] && curl --proto ''=https'' --tlsv1.2 -sSf {0} | bash || cat $(cygpath -m ''{0}'') | bash ; echo ''Press any key to exit'' && read -n 1' -f $BootstrapUrl, $MsysDir, $GhcupBasePrefix, $GhcupDir, $SilentExport, $CabalDirFull, $StackInstallExport, $HLSInstallExport, $AdjustCabalConfigExport, $MinimalExport) } -- GitLab