Compare commits
1 Commits
issue-177
...
fix-ghcToo
| Author | SHA1 | Date | |
|---|---|---|---|
|
928f4a97de
|
@@ -41,7 +41,7 @@ variables:
|
|||||||
CABAL_DIR: "$CI_PROJECT_DIR/cabal"
|
CABAL_DIR: "$CI_PROJECT_DIR/cabal"
|
||||||
|
|
||||||
.linux:armv7:
|
.linux:armv7:
|
||||||
image: "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb10:$DOCKER_REV"
|
image: "arm32v7/fedora"
|
||||||
tags:
|
tags:
|
||||||
- armv7-linux
|
- armv7-linux
|
||||||
variables:
|
variables:
|
||||||
@@ -50,7 +50,7 @@ variables:
|
|||||||
CABAL_DIR: "$CI_PROJECT_DIR/cabal"
|
CABAL_DIR: "$CI_PROJECT_DIR/cabal"
|
||||||
|
|
||||||
.linux:aarch64:
|
.linux:aarch64:
|
||||||
image: "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb10:$DOCKER_REV"
|
image: "arm64v8/fedora"
|
||||||
tags:
|
tags:
|
||||||
- aarch64-linux
|
- aarch64-linux
|
||||||
variables:
|
variables:
|
||||||
@@ -124,14 +124,14 @@ variables:
|
|||||||
- .test_ghcup_version
|
- .test_ghcup_version
|
||||||
- .linux:armv7
|
- .linux:armv7
|
||||||
before_script:
|
before_script:
|
||||||
- ./.gitlab/before_script/linux/install_deps.sh
|
- ./.gitlab/before_script/linux/install_deps_manual.sh
|
||||||
|
|
||||||
.test_ghcup_version:aarch64:
|
.test_ghcup_version:aarch64:
|
||||||
extends:
|
extends:
|
||||||
- .test_ghcup_version
|
- .test_ghcup_version
|
||||||
- .linux:aarch64
|
- .linux:aarch64
|
||||||
before_script:
|
before_script:
|
||||||
- ./.gitlab/before_script/linux/install_deps.sh
|
- ./.gitlab/before_script/linux/install_deps_manual.sh
|
||||||
|
|
||||||
.test_ghcup_version:darwin:
|
.test_ghcup_version:darwin:
|
||||||
extends:
|
extends:
|
||||||
@@ -374,7 +374,7 @@ release:linux:armv7:
|
|||||||
- .linux:armv7
|
- .linux:armv7
|
||||||
- .release_ghcup
|
- .release_ghcup
|
||||||
before_script:
|
before_script:
|
||||||
- ./.gitlab/before_script/linux/install_deps.sh
|
- ./.gitlab/before_script/linux/install_deps_manual.sh
|
||||||
variables:
|
variables:
|
||||||
ARTIFACT: "armv7-linux-ghcup"
|
ARTIFACT: "armv7-linux-ghcup"
|
||||||
GHC_VERSION: "8.10.4"
|
GHC_VERSION: "8.10.4"
|
||||||
@@ -387,7 +387,7 @@ release:linux:aarch64:
|
|||||||
- .linux:aarch64
|
- .linux:aarch64
|
||||||
- .release_ghcup
|
- .release_ghcup
|
||||||
before_script:
|
before_script:
|
||||||
- ./.gitlab/before_script/linux/install_deps.sh
|
- ./.gitlab/before_script/linux/install_deps_manual.sh
|
||||||
variables:
|
variables:
|
||||||
ARTIFACT: "aarch64-linux-ghcup"
|
ARTIFACT: "aarch64-linux-ghcup"
|
||||||
GHC_VERSION: "8.10.4"
|
GHC_VERSION: "8.10.4"
|
||||||
|
|||||||
@@ -7,60 +7,13 @@ set -eux
|
|||||||
mkdir -p "${TMPDIR}"
|
mkdir -p "${TMPDIR}"
|
||||||
|
|
||||||
sudo apt-get update -y
|
sudo apt-get update -y
|
||||||
sudo apt-get install -y libnuma-dev zlib1g-dev libgmp-dev libgmp10 libssl-dev liblzma-dev libbz2-dev git wget lsb-release software-properties-common gnupg2 apt-transport-https
|
sudo apt-get install -y libnuma-dev zlib1g-dev libgmp-dev libgmp10 libssl-dev liblzma-dev libbz2-dev git wget
|
||||||
|
|
||||||
case "${ARCH}" in
|
curl -sSfL https://downloads.haskell.org/~ghcup/x86_64-linux-ghcup > ./ghcup-bin
|
||||||
ARM*)
|
chmod +x ghcup-bin
|
||||||
case "${ARCH}" in
|
|
||||||
"ARM")
|
|
||||||
ghc_url=https://downloads.haskell.org/~ghc/${GHC_VERSION}/ghc-${GHC_VERSION}-armv7-deb10-linux.tar.xz
|
|
||||||
cabal_url=home.smart-cactus.org/~ben/cabal-install-${CABAL_VERSION}-armv7-linux-bootstrapped.tar.xz
|
|
||||||
;;
|
|
||||||
"ARM64")
|
|
||||||
ghc_url=https://downloads.haskell.org/~ghc/${GHC_VERSION}/ghc-${GHC_VERSION}-aarch64-deb10-linux.tar.xz
|
|
||||||
cabal_url=https://downloads.haskell.org/~cabal/cabal-install-${CABAL_VERSION}/cabal-install-${CABAL_VERSION}-aarch64-ubuntu-18.04.tar.xz
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
exit 1 ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
mkdir -p "${GHCUP_INSTALL_BASE_PREFIX}"/.ghcup/bin
|
./ghcup-bin upgrade -i -f
|
||||||
|
./ghcup-bin install ${GHC_VERSION}
|
||||||
curl -O "${ghc_url}"
|
./ghcup-bin set ${GHC_VERSION}
|
||||||
tar -xf ghc-*.tar.*
|
./ghcup-bin install-cabal ${CABAL_VERSION}
|
||||||
cd ghc-${GHC_VERSION}
|
|
||||||
./configure --prefix="${GHCUP_INSTALL_BASE_PREFIX}"/.ghcup/ghc/${GHC_VERSION}
|
|
||||||
make install
|
|
||||||
for i in "${GHCUP_INSTALL_BASE_PREFIX}"/.ghcup/ghc/${GHC_VERSION}/bin/*-${GHC_VERSION} ; do
|
|
||||||
ln -s "${i}" "${GHCUP_INSTALL_BASE_PREFIX}"/.ghcup/bin/${i##*/}
|
|
||||||
done
|
|
||||||
for x in "${GHCUP_INSTALL_BASE_PREFIX}"/.ghcup/bin/*-${GHC_VERSION} ; do
|
|
||||||
ln -s ${x##*/} ${x%-${GHC_VERSION}}
|
|
||||||
done
|
|
||||||
cd ..
|
|
||||||
rm -rf ghc-${GHC_VERSION} ghc-*.tar.*
|
|
||||||
unset x i
|
|
||||||
|
|
||||||
mkdir cabal-install
|
|
||||||
cd cabal-install
|
|
||||||
curl -O "${cabal_url}"
|
|
||||||
tar -xf cabal-install-*
|
|
||||||
mv cabal "${GHCUP_INSTALL_BASE_PREFIX}"/.ghcup/bin/cabal
|
|
||||||
cd ..
|
|
||||||
rm -rf cabal-install
|
|
||||||
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
url=https://downloads.haskell.org/~ghcup/x86_64-linux-ghcup
|
|
||||||
|
|
||||||
curl -sSfL "${url}" > ./ghcup-bin
|
|
||||||
chmod +x ghcup-bin
|
|
||||||
|
|
||||||
./ghcup-bin upgrade -i -f
|
|
||||||
./ghcup-bin install ${GHC_VERSION}
|
|
||||||
./ghcup-bin set ${GHC_VERSION}
|
|
||||||
./ghcup-bin install-cabal ${CABAL_VERSION}
|
|
||||||
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
|
|||||||
64
.gitlab/before_script/linux/install_deps_manual.sh
Executable file
64
.gitlab/before_script/linux/install_deps_manual.sh
Executable file
@@ -0,0 +1,64 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
. "$( cd "$(dirname "$0")" ; pwd -P )/../../ghcup_env"
|
||||||
|
|
||||||
|
mkdir -p "${TMPDIR}"
|
||||||
|
|
||||||
|
ednf() {
|
||||||
|
case "${ARCH}" in
|
||||||
|
"ARM")
|
||||||
|
sudo dnf -y --forcearch armv7hl "$@"
|
||||||
|
;;
|
||||||
|
"ARM64")
|
||||||
|
sudo dnf -y --forcearch aarch64 "$@"
|
||||||
|
;;
|
||||||
|
*) exit 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
ednf update
|
||||||
|
ednf install gcc gcc-c++ gmp gmp-devel make ncurses ncurses-devel xz xz-devel perl zlib zlib-devel openssl-devel openssl-libs openssl libffi libffi-devel lbzip2 lbzip2-utils bzip2-devel
|
||||||
|
if [ "${ARCH}" = "ARM64" ] ; then
|
||||||
|
ednf install numactl numactl-libs numactl-devel
|
||||||
|
fi
|
||||||
|
ednf install bash wget curl git tar
|
||||||
|
ednf install llvm9.0 llvm9.0-devel llvm9.0-libs llvm9.0-static
|
||||||
|
|
||||||
|
case "${ARCH}" in
|
||||||
|
"ARM")
|
||||||
|
ghc_url=https://downloads.haskell.org/~ghc/${GHC_VERSION}/ghc-${GHC_VERSION}-armv7-deb10-linux.tar.xz
|
||||||
|
cabal_url=home.smart-cactus.org/~ben/cabal-install-${CABAL_VERSION}-armv7-linux-bootstrapped.tar.xz
|
||||||
|
;;
|
||||||
|
"ARM64")
|
||||||
|
ghc_url=https://downloads.haskell.org/~ghc/${GHC_VERSION}/ghc-${GHC_VERSION}-aarch64-deb10-linux.tar.xz
|
||||||
|
cabal_url=https://downloads.haskell.org/~cabal/cabal-install-${CABAL_VERSION}/cabal-install-${CABAL_VERSION}-aarch64-ubuntu-18.04.tar.xz
|
||||||
|
;;
|
||||||
|
*) exit 1 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
mkdir -p "${GHCUP_INSTALL_BASE_PREFIX}"/.ghcup/bin
|
||||||
|
|
||||||
|
curl -O "${ghc_url}"
|
||||||
|
tar -xf ghc-*.tar.*
|
||||||
|
cd ghc-${GHC_VERSION}
|
||||||
|
./configure --prefix="${GHCUP_INSTALL_BASE_PREFIX}"/.ghcup/ghc/${GHC_VERSION}
|
||||||
|
make install
|
||||||
|
for i in "${GHCUP_INSTALL_BASE_PREFIX}"/.ghcup/ghc/${GHC_VERSION}/bin/*-${GHC_VERSION} ; do
|
||||||
|
ln -s "${i}" "${GHCUP_INSTALL_BASE_PREFIX}"/.ghcup/bin/${i##*/}
|
||||||
|
done
|
||||||
|
for x in "${GHCUP_INSTALL_BASE_PREFIX}"/.ghcup/bin/*-${GHC_VERSION} ; do
|
||||||
|
ln -s ${x##*/} ${x%-${GHC_VERSION}}
|
||||||
|
done
|
||||||
|
cd ..
|
||||||
|
rm -rf ghc-${GHC_VERSION} ghc-*.tar.*
|
||||||
|
unset x i
|
||||||
|
|
||||||
|
mkdir cabal-install
|
||||||
|
cd cabal-install
|
||||||
|
curl -O "${cabal_url}"
|
||||||
|
tar -xf cabal-install-*
|
||||||
|
mv cabal "${GHCUP_INSTALL_BASE_PREFIX}"/.ghcup/bin/cabal
|
||||||
|
cd ..
|
||||||
|
rm -rf cabal-install
|
||||||
@@ -4,6 +4,6 @@ if [ "${OS}" = "WINDOWS" ] ; then
|
|||||||
export TMPDIR="$CI_PROJECT_DIR/tmp"
|
export TMPDIR="$CI_PROJECT_DIR/tmp"
|
||||||
else
|
else
|
||||||
export GHCUP_INSTALL_BASE_PREFIX="$CI_PROJECT_DIR"
|
export GHCUP_INSTALL_BASE_PREFIX="$CI_PROJECT_DIR"
|
||||||
export PATH="$CI_PROJECT_DIR/.ghcup/bin:$CI_PROJECT_DIR/.local/bin:/opt/llvm/bin:$PATH"
|
export PATH="$CI_PROJECT_DIR/.ghcup/bin:$CI_PROJECT_DIR/.local/bin:$PATH"
|
||||||
export TMPDIR="$CI_PROJECT_DIR/tmp"
|
export TMPDIR="$CI_PROJECT_DIR/tmp"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -84,10 +84,8 @@ ghcup-gen check -f ghcup-${JSON_VERSION}.yaml
|
|||||||
eghcup --numeric-version
|
eghcup --numeric-version
|
||||||
|
|
||||||
eghcup install ${GHC_VERSION}
|
eghcup install ${GHC_VERSION}
|
||||||
[ `$(eghcup whereis ghc ${GHC_VERSION}) --numeric-version` = "${GHC_VERSION}" ]
|
|
||||||
eghcup set ${GHC_VERSION}
|
eghcup set ${GHC_VERSION}
|
||||||
eghcup install-cabal ${CABAL_VERSION}
|
eghcup install-cabal ${CABAL_VERSION}
|
||||||
[ `$(eghcup whereis cabal ${CABAL_VERSION}) --numeric-version` = "${CABAL_VERSION}" ]
|
|
||||||
|
|
||||||
cabal --version
|
cabal --version
|
||||||
|
|
||||||
@@ -127,10 +125,10 @@ else
|
|||||||
|
|
||||||
if [ "${OS}" = "DARWIN" ] ; then
|
if [ "${OS}" = "DARWIN" ] ; then
|
||||||
eghcup install hls
|
eghcup install hls
|
||||||
$(eghcup whereis hls) --version
|
haskell-language-server-wrapper --version
|
||||||
|
|
||||||
eghcup install stack
|
eghcup install stack
|
||||||
$(eghcup whereis stack) --version
|
stack --version
|
||||||
elif [ "${OS}" = "LINUX" ] ; then
|
elif [ "${OS}" = "LINUX" ] ; then
|
||||||
if [ "${ARCH}" = "64" ] ; then
|
if [ "${ARCH}" = "64" ] ; then
|
||||||
eghcup install hls
|
eghcup install hls
|
||||||
|
|||||||
@@ -69,7 +69,3 @@ yaml files: `ghcup-<yaml-ver>.yaml`.
|
|||||||
Most of the `Version` parameters to functions had to be replaced with
|
Most of the `Version` parameters to functions had to be replaced with
|
||||||
that and ensured the logic is consistent for cross and non-cross
|
that and ensured the logic is consistent for cross and non-cross
|
||||||
installs.
|
installs.
|
||||||
2. This refactor added windows support wrt [#130](https://gitlab.haskell.org/haskell/ghcup-hs/-/issues/130).
|
|
||||||
The major changes here were switching `hpath` library out for `filepath`/`directory` (sadly) and
|
|
||||||
introducing a non-unix way of handling processes via the `process` library. It also introduced considerable
|
|
||||||
amounts of CPP wrt file handling, installation etc.
|
|
||||||
|
|||||||
@@ -100,7 +100,6 @@ data Command
|
|||||||
| Rm (Either RmCommand RmOptions)
|
| Rm (Either RmCommand RmOptions)
|
||||||
| DInfo
|
| DInfo
|
||||||
| Compile CompileCommand
|
| Compile CompileCommand
|
||||||
| Whereis WhereisOptions WhereisCommand
|
|
||||||
| Upgrade UpgradeOpts Bool
|
| Upgrade UpgradeOpts Bool
|
||||||
| ToolRequirements
|
| ToolRequirements
|
||||||
| ChangeLog ChangeLogOptions
|
| ChangeLog ChangeLogOptions
|
||||||
@@ -191,13 +190,6 @@ data ChangeLogOptions = ChangeLogOptions
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
data WhereisCommand = WhereisTool Tool (Maybe ToolVersion)
|
|
||||||
|
|
||||||
data WhereisOptions = WhereisOptions {
|
|
||||||
directory :: Bool
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
-- https://github.com/pcapriotti/optparse-applicative/issues/148
|
-- https://github.com/pcapriotti/optparse-applicative/issues/148
|
||||||
|
|
||||||
-- | A switch that can be enabled using --foo and disabled using --no-foo.
|
-- | A switch that can be enabled using --foo and disabled using --no-foo.
|
||||||
@@ -343,17 +335,6 @@ com =
|
|||||||
<$> info (compileP <**> helper)
|
<$> info (compileP <**> helper)
|
||||||
(progDesc "Compile a tool from source")
|
(progDesc "Compile a tool from source")
|
||||||
)
|
)
|
||||||
<> command
|
|
||||||
"whereis"
|
|
||||||
(info
|
|
||||||
( (Whereis
|
|
||||||
<$> (WhereisOptions <$> switch (short 'd' <> long "directory" <> help "return directory of the binary instead of the binary location"))
|
|
||||||
<*> whereisP
|
|
||||||
) <**> helper
|
|
||||||
)
|
|
||||||
(progDesc "Find a tools location"
|
|
||||||
<> footerDoc ( Just $ text whereisFooter ))
|
|
||||||
)
|
|
||||||
<> commandGroup "Main commands:"
|
<> commandGroup "Main commands:"
|
||||||
)
|
)
|
||||||
<|> subparser
|
<|> subparser
|
||||||
@@ -421,23 +402,6 @@ com =
|
|||||||
By default returns the URI of the ChangeLog of the latest GHC release.
|
By default returns the URI of the ChangeLog of the latest GHC release.
|
||||||
Pass '-o' to automatically open via xdg-open.|]
|
Pass '-o' to automatically open via xdg-open.|]
|
||||||
|
|
||||||
whereisFooter :: String
|
|
||||||
whereisFooter = [s|Discussion:
|
|
||||||
Finds the location of a tool. For GHC, this is the ghc binary, that
|
|
||||||
usually resides in a self-contained "~/.ghcup/ghc/<ghcver>" directory.
|
|
||||||
For cabal/stack/hls this the binary usually at "~/.ghcup/bin/<tool>-<ver>".
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
# outputs ~/.ghcup/ghc/8.10.5/bin/ghc.exe
|
|
||||||
ghcup whereis ghc 8.10.5
|
|
||||||
# outputs ~/.ghcup/ghc/8.10.5/bin/
|
|
||||||
ghcup whereis --directory ghc 8.10.5
|
|
||||||
# outputs ~/.ghcup/bin/cabal-3.4.0.0
|
|
||||||
ghcup whereis cabal 3.4.0.0
|
|
||||||
# outputs ~/.ghcup/bin/
|
|
||||||
ghcup whereis --directory cabal 3.4.0.0|]
|
|
||||||
|
|
||||||
|
|
||||||
installCabalFooter :: String
|
installCabalFooter :: String
|
||||||
installCabalFooter = [s|Discussion:
|
installCabalFooter = [s|Discussion:
|
||||||
Installs the specified cabal-install version (or a recommended default one)
|
Installs the specified cabal-install version (or a recommended default one)
|
||||||
@@ -742,86 +706,6 @@ Examples:
|
|||||||
ghcup compile ghc -j 4 -v 8.4.2 -b 8.2.2 -x armv7-unknown-linux-gnueabihf --config $(pwd)/build.mk -- --enable-unregisterised|]
|
ghcup compile ghc -j 4 -v 8.4.2 -b 8.2.2 -x armv7-unknown-linux-gnueabihf --config $(pwd)/build.mk -- --enable-unregisterised|]
|
||||||
|
|
||||||
|
|
||||||
whereisP :: Parser WhereisCommand
|
|
||||||
whereisP = subparser
|
|
||||||
( command
|
|
||||||
"ghc"
|
|
||||||
(WhereisTool GHC <$> info
|
|
||||||
( optional (toolVersionArgument Nothing (Just GHC)) <**> helper )
|
|
||||||
( progDesc "Get GHC location"
|
|
||||||
<> footerDoc (Just $ text whereisGHCFooter ))
|
|
||||||
)
|
|
||||||
<>
|
|
||||||
command
|
|
||||||
"cabal"
|
|
||||||
(WhereisTool Cabal <$> info
|
|
||||||
( optional (toolVersionArgument Nothing (Just Cabal)) <**> helper )
|
|
||||||
( progDesc "Get cabal location"
|
|
||||||
<> footerDoc (Just $ text whereisCabalFooter ))
|
|
||||||
)
|
|
||||||
<>
|
|
||||||
command
|
|
||||||
"hls"
|
|
||||||
(WhereisTool HLS <$> info
|
|
||||||
( optional (toolVersionArgument Nothing (Just HLS)) <**> helper )
|
|
||||||
( progDesc "Get HLS location"
|
|
||||||
<> footerDoc (Just $ text whereisHLSFooter ))
|
|
||||||
)
|
|
||||||
<>
|
|
||||||
command
|
|
||||||
"stack"
|
|
||||||
(WhereisTool Stack <$> info
|
|
||||||
( optional (toolVersionArgument Nothing (Just Stack)) <**> helper )
|
|
||||||
( progDesc "Get stack location"
|
|
||||||
<> footerDoc (Just $ text whereisStackFooter ))
|
|
||||||
)
|
|
||||||
<>
|
|
||||||
command
|
|
||||||
"ghcup"
|
|
||||||
(WhereisTool GHCup <$> info ( (pure Nothing) <**> helper ) ( progDesc "Get ghcup location" ))
|
|
||||||
)
|
|
||||||
where
|
|
||||||
whereisGHCFooter = [s|Discussion:
|
|
||||||
Finds the location of a GHC executable, which usually resides in
|
|
||||||
a self-contained "~/.ghcup/ghc/<ghcver>" directory.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
# outputs ~/.ghcup/ghc/8.10.5/bin/ghc.exe
|
|
||||||
ghcup whereis ghc 8.10.5
|
|
||||||
# outputs ~/.ghcup/ghc/8.10.5/bin/
|
|
||||||
ghcup whereis --directory ghc 8.10.5 |]
|
|
||||||
|
|
||||||
whereisCabalFooter = [s|Discussion:
|
|
||||||
Finds the location of a Cabal executable, which usually resides in
|
|
||||||
"~/.ghcup/bin/".
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
# outputs ~/.ghcup/bin/cabal-3.4.0.0
|
|
||||||
ghcup whereis cabal 3.4.0.0
|
|
||||||
# outputs ~/.ghcup/bin
|
|
||||||
ghcup whereis --directory cabal 3.4.0.0|]
|
|
||||||
|
|
||||||
whereisHLSFooter = [s|Discussion:
|
|
||||||
Finds the location of a HLS executable, which usually resides in
|
|
||||||
"~/.ghcup/bin/".
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
# outputs ~/.ghcup/bin/haskell-language-server-wrapper-1.2.0
|
|
||||||
ghcup whereis hls 1.2.0
|
|
||||||
# outputs ~/.ghcup/bin/
|
|
||||||
ghcup whereis --directory hls 1.2.0|]
|
|
||||||
|
|
||||||
whereisStackFooter = [s|Discussion:
|
|
||||||
Finds the location of a stack executable, which usually resides in
|
|
||||||
"~/.ghcup/bin/".
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
# outputs ~/.ghcup/bin/stack-2.7.1
|
|
||||||
ghcup whereis stack 2.7.1
|
|
||||||
# outputs ~/.ghcup/bin/
|
|
||||||
ghcup whereis --directory stack 2.7.1|]
|
|
||||||
|
|
||||||
|
|
||||||
ghcCompileOpts :: Parser GHCCompileOptions
|
ghcCompileOpts :: Parser GHCCompileOptions
|
||||||
ghcCompileOpts =
|
ghcCompileOpts =
|
||||||
GHCCompileOptions
|
GHCCompileOptions
|
||||||
@@ -1381,17 +1265,6 @@ Report bugs at <https://gitlab.haskell.org/haskell/ghcup-hs/issues>|]
|
|||||||
#endif
|
#endif
|
||||||
]
|
]
|
||||||
|
|
||||||
let
|
|
||||||
runWhereIs =
|
|
||||||
runLogger
|
|
||||||
. flip runReaderT appstate
|
|
||||||
. runE
|
|
||||||
@'[ NotInstalled
|
|
||||||
, NoToolVersionSet
|
|
||||||
, NextVerNotFound
|
|
||||||
, TagNotFound
|
|
||||||
]
|
|
||||||
|
|
||||||
let runUpgrade =
|
let runUpgrade =
|
||||||
runLogger
|
runLogger
|
||||||
. flip runReaderT appstate
|
. flip runReaderT appstate
|
||||||
@@ -1755,22 +1628,6 @@ Make sure to clean up #{tmpdir} afterwards.|])
|
|||||||
runLogger $ $(logError) $ T.pack $ prettyShow e
|
runLogger $ $(logError) $ T.pack $ prettyShow e
|
||||||
pure $ ExitFailure 9
|
pure $ ExitFailure 9
|
||||||
|
|
||||||
Whereis WhereisOptions{..} (WhereisTool tool whereVer) ->
|
|
||||||
runWhereIs (do
|
|
||||||
(v, _) <- liftE $ fromVersion whereVer tool
|
|
||||||
loc <- liftE $ whereIsTool tool v
|
|
||||||
if directory
|
|
||||||
then pure $ takeDirectory loc
|
|
||||||
else pure loc
|
|
||||||
)
|
|
||||||
>>= \case
|
|
||||||
VRight r -> do
|
|
||||||
putStr r
|
|
||||||
pure ExitSuccess
|
|
||||||
VLeft e -> do
|
|
||||||
runLogger $ $(logError) $ T.pack $ prettyShow e
|
|
||||||
pure $ ExitFailure 30
|
|
||||||
|
|
||||||
Upgrade uOpts force -> do
|
Upgrade uOpts force -> do
|
||||||
target <- case uOpts of
|
target <- case uOpts of
|
||||||
UpgradeInplace -> Just <$> liftIO getExecutablePath
|
UpgradeInplace -> Just <$> liftIO getExecutablePath
|
||||||
|
|||||||
@@ -5,12 +5,8 @@
|
|||||||
# * BOOTSTRAP_HASKELL_NO_UPGRADE - any nonzero value to not trigger the upgrade
|
# * 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
|
# * 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_VERBOSE - any nonzero value for more verbose installation
|
||||||
# * BOOTSTRAP_HASKELL_GHC_VERSION - the ghc version to install
|
# * BOOTSTRAP_HASKELL_GHC_VERSION
|
||||||
# * BOOTSTRAP_HASKELL_CABAL_VERSION - the cabal version to install
|
# * BOOTSTRAP_HASKELL_CABAL_VERSION
|
||||||
# * BOOTSTRAP_HASKELL_INSTALL_STACK - whether to install latest stack
|
|
||||||
# * BOOTSTRAP_HASKELL_INSTALL_HLS - whether to install latest hls
|
|
||||||
# * BOOTSTRAP_HASKELL_ADJUST_BASHRC - whether to adjust PATH in bashrc (prepend)
|
|
||||||
# * BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG - whether to adjust mingw paths in cabal.config on windows
|
|
||||||
|
|
||||||
# License: LGPL-3.0
|
# License: LGPL-3.0
|
||||||
|
|
||||||
@@ -23,8 +19,6 @@ arch=$(uname -m)
|
|||||||
ghver="0.1.15.2"
|
ghver="0.1.15.2"
|
||||||
base_url="https://downloads.haskell.org/~ghcup"
|
base_url="https://downloads.haskell.org/~ghcup"
|
||||||
|
|
||||||
export GHCUP_SKIP_UPDATE_CHECK=yes
|
|
||||||
|
|
||||||
case "${plat}" in
|
case "${plat}" in
|
||||||
MSYS*|MINGW*)
|
MSYS*|MINGW*)
|
||||||
: "${GHCUP_INSTALL_BASE_PREFIX:=/c}"
|
: "${GHCUP_INSTALL_BASE_PREFIX:=/c}"
|
||||||
@@ -66,28 +60,6 @@ warn() {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
yellow() {
|
|
||||||
case "${plat}" in
|
|
||||||
MSYS*|MINGW*)
|
|
||||||
echo -e "\\033[0;33m$1\\033[0m"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
printf "\\033[0;33m%s\\033[0m\\n" "$1"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
green() {
|
|
||||||
case "${plat}" in
|
|
||||||
MSYS*|MINGW*)
|
|
||||||
echo -e "\\033[0;32m$1\\033[0m"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
printf "\\033[0;32m%s\\033[0m\\n" "$1"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
edo() {
|
edo() {
|
||||||
"$@" || die "\"$*\" failed!"
|
"$@" || die "\"$*\" failed!"
|
||||||
}
|
}
|
||||||
@@ -108,42 +80,40 @@ _eghcup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_done() {
|
_done() {
|
||||||
echo
|
|
||||||
echo "==============================================================================="
|
|
||||||
case "${plat}" in
|
case "${plat}" in
|
||||||
MSYS*|MINGW*)
|
MSYS*|MINGW*)
|
||||||
green
|
echo
|
||||||
green "All done!"
|
echo "All done!"
|
||||||
green
|
echo
|
||||||
green "In a new powershell or cmd.exe session, now you can..."
|
echo "In a new powershell or cmd.exe session, now you can..."
|
||||||
green
|
echo
|
||||||
green "Start a simple repl via:"
|
echo "Start a simple repl via:"
|
||||||
green " ghci"
|
echo " ghci"
|
||||||
green
|
echo
|
||||||
green "Start a new haskell project in the current directory via:"
|
echo "Start a new haskell project in the current directory via:"
|
||||||
green " cabal init --interactive"
|
echo " cabal init --interactive"
|
||||||
green
|
echo
|
||||||
green "Install other GHC versions and tools via:"
|
echo "Install other GHC versions and tools via:"
|
||||||
green " ghcup list"
|
echo " ghcup list"
|
||||||
green " ghcup install <tool> <version>"
|
echo " ghcup install <tool> <version>"
|
||||||
green
|
echo
|
||||||
green "To install system libraries and update msys2/mingw64,"
|
echo "To install system libraries and update msys2/mingw64,"
|
||||||
green "open the \"Mingw haskell shell\""
|
echo "open the \"Mingw haskell shell\""
|
||||||
green "and the \"Mingw package management docs\""
|
echo "and the \"Mingw package management docs\""
|
||||||
green "desktop shortcuts."
|
echo "desktop shortcuts."
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
green
|
echo
|
||||||
green "All done!"
|
echo "All done!"
|
||||||
green
|
echo
|
||||||
green "To start a simple repl, run:"
|
echo "To start a simple repl, run:"
|
||||||
green " ghci"
|
echo " ghci"
|
||||||
green
|
echo
|
||||||
green "To start a new haskell project in the current directory, run:"
|
echo "To start a new haskell project in the current directory, run:"
|
||||||
green " cabal init --interactive"
|
echo " cabal init --interactive"
|
||||||
green
|
echo
|
||||||
green "To install other GHC versions and tools, run:"
|
echo "To install other GHC versions and tools, run:"
|
||||||
green " ghcup tui"
|
echo " ghcup tui"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
@@ -231,21 +201,16 @@ download_ghcup() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
edo mkdir -p "${GHCUP_DIR}"
|
edo mkdir -p "${GHCUP_DIR}"
|
||||||
|
|
||||||
# we may overwrite this in adjust_bashrc
|
|
||||||
cat <<-EOF > "${GHCUP_DIR}"/env || die "Failed to create env file"
|
cat <<-EOF > "${GHCUP_DIR}"/env || die "Failed to create env file"
|
||||||
export PATH="\$HOME/.cabal/bin:${GHCUP_BIN}:\$PATH"
|
export PATH="\$HOME/.cabal/bin:${GHCUP_BIN}:\$PATH"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# shellcheck disable=SC1090
|
# shellcheck disable=SC1090
|
||||||
edo . "${GHCUP_DIR}"/env
|
edo . "${GHCUP_DIR}"/env
|
||||||
eghcup upgrade
|
eghcup upgrade
|
||||||
}
|
}
|
||||||
|
|
||||||
# Figures out the users login shell and sets
|
adjust_bashrc() {
|
||||||
# GHCUP_PROFILE_FILE and MY_SHELL variables.
|
|
||||||
find_shell() {
|
|
||||||
case $SHELL in
|
case $SHELL in
|
||||||
*/zsh) # login shell is zsh
|
*/zsh) # login shell is zsh
|
||||||
GHCUP_PROFILE_FILE="$HOME/.zshrc"
|
GHCUP_PROFILE_FILE="$HOME/.zshrc"
|
||||||
@@ -269,259 +234,66 @@ find_shell() {
|
|||||||
MY_SHELL="fish" ;;
|
MY_SHELL="fish" ;;
|
||||||
*) return ;;
|
*) return ;;
|
||||||
esac
|
esac
|
||||||
}
|
|
||||||
|
|
||||||
# Ask user if they want to adjust the bashrc.
|
|
||||||
ask_bashrc() {
|
warn ""
|
||||||
if [ -n "${BOOTSTRAP_HASKELL_ADJUST_BASHRC}" ] ; then
|
warn "Detected ${MY_SHELL} shell on your system..."
|
||||||
return 1
|
warn "If you want ghcup to automatically add the required PATH variable to \"${GHCUP_PROFILE_FILE}\""
|
||||||
fi
|
warn ""
|
||||||
|
warn "[Y] Yes [N] No [?] Help (default is \"Y\")."
|
||||||
|
warn ""
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
if [ -z "${BOOTSTRAP_HASKELL_NONINTERACTIVE}" ] ; then
|
if [ -z "${BOOTSTRAP_HASKELL_NONINTERACTIVE}" ] ; then
|
||||||
echo "-------------------------------------------------------------------------------"
|
read -r next_answer </dev/tty
|
||||||
|
|
||||||
warn ""
|
|
||||||
warn "Detected ${MY_SHELL} shell on your system..."
|
|
||||||
warn "Do you want ghcup to automatically add the required PATH variable to \"${GHCUP_PROFILE_FILE}\"?"
|
|
||||||
warn ""
|
|
||||||
warn "[P] Yes, prepend [A] Yes, append [N] No [?] Help (default is \"P\")."
|
|
||||||
warn ""
|
|
||||||
|
|
||||||
read -r bashrc_answer </dev/tty
|
|
||||||
else
|
else
|
||||||
return 1
|
next_answer="yes"
|
||||||
fi
|
fi
|
||||||
case $bashrc_answer in
|
|
||||||
[Pp]* | "")
|
case $next_answer in
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
[Aa]*)
|
|
||||||
return 2
|
|
||||||
;;
|
|
||||||
[Nn]*)
|
[Nn]*)
|
||||||
return 0;;
|
return ;;
|
||||||
|
[Yy]* | "")
|
||||||
|
case $MY_SHELL in
|
||||||
|
"") break ;;
|
||||||
|
fish)
|
||||||
|
mkdir -p "${GHCUP_PROFILE_FILE%/*}"
|
||||||
|
sed -i -e '/# ghcup-env$/ s/^#*/#/' "${GHCUP_PROFILE_FILE}"
|
||||||
|
echo "set -q GHCUP_INSTALL_BASE_PREFIX[1]; or set GHCUP_INSTALL_BASE_PREFIX \$HOME ; test -f $GHCUP_DIR/env ; and set -gx PATH \$HOME/.cabal/bin $GHCUP_BIN \$PATH # ghcup-env" >> "${GHCUP_PROFILE_FILE}"
|
||||||
|
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 "Possible choices are:"
|
||||||
echo
|
echo
|
||||||
echo "P - Yes, prepend to PATH, taking precedence (default)"
|
echo "Y - Yes, update my \"${GHCUP_PROFILE_FILE}\" (default)"
|
||||||
echo "A - Yes, append to PATH"
|
|
||||||
echo "N - No, don't mess with my configuration"
|
echo "N - No, don't mess with my configuration"
|
||||||
echo
|
echo
|
||||||
echo "Please make your choice and press ENTER."
|
echo "Please make your choice and press ENTER."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
unset bashrc_answer
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Needs 'find_shell' to be called beforehand.
|
|
||||||
adjust_bashrc() {
|
|
||||||
case $1 in
|
|
||||||
1)
|
|
||||||
cat <<-EOF > "${GHCUP_DIR}"/env || die "Failed to create env file"
|
|
||||||
export PATH="\$HOME/.cabal/bin:${GHCUP_BIN}:\$PATH"
|
|
||||||
EOF
|
|
||||||
;;
|
|
||||||
2)
|
|
||||||
cat <<-EOF > "${GHCUP_DIR}"/env || die "Failed to create env file"
|
|
||||||
export PATH="\$HOME/.cabal/bin:\$PATH:${GHCUP_BIN}"
|
|
||||||
EOF
|
|
||||||
;;
|
|
||||||
*) ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
case $1 in
|
|
||||||
1 | 2)
|
|
||||||
case $MY_SHELL in
|
|
||||||
"") break ;;
|
|
||||||
fish)
|
|
||||||
mkdir -p "${GHCUP_PROFILE_FILE%/*}"
|
|
||||||
sed -i -e '/# ghcup-env$/ s/^#*/#/' "${GHCUP_PROFILE_FILE}"
|
|
||||||
case $1 in
|
|
||||||
1)
|
|
||||||
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}"
|
|
||||||
;;
|
|
||||||
2)
|
|
||||||
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
|
|
||||||
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
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
adjust_cabal_config() {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
ask_cabal_config_init() {
|
|
||||||
case "${plat}" in
|
|
||||||
MSYS*|MINGW*)
|
|
||||||
if [ -n "${BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG}" ] ; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "${BOOTSTRAP_HASKELL_NONINTERACTIVE}" ] ; then
|
|
||||||
echo "-------------------------------------------------------------------------------"
|
|
||||||
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]* | "")
|
|
||||||
return 1 ;;
|
|
||||||
[Nn]*)
|
|
||||||
return 0 ;;
|
|
||||||
*)
|
|
||||||
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
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
unset mingw_answer
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
do_cabal_config_init() {
|
|
||||||
case "${plat}" in
|
|
||||||
MSYS*|MINGW*)
|
|
||||||
case $1 in
|
|
||||||
1)
|
|
||||||
adjust_cabal_config
|
|
||||||
;;
|
|
||||||
0)
|
|
||||||
echo "Make sure that your global cabal.config references the correct mingw64 paths (extra-prog-path, extra-include-dirs and extra-lib-dirs)."
|
|
||||||
echo "And set the environment variable GHCUP_MSYS2 to the root path of your msys2 installation."
|
|
||||||
sleep 5
|
|
||||||
return ;;
|
|
||||||
*) ;;
|
|
||||||
esac
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
ask_hls() {
|
|
||||||
if [ -n "${BOOTSTRAP_HASKELL_INSTALL_HLS}" ] ; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "${BOOTSTRAP_HASKELL_NONINTERACTIVE}" ] ; then
|
|
||||||
echo "-------------------------------------------------------------------------------"
|
|
||||||
|
|
||||||
warn "Do you want to install haskell-language-server (HLS)?"
|
|
||||||
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 ""
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
read -r hls_answer </dev/tty
|
|
||||||
|
|
||||||
case $hls_answer in
|
|
||||||
[Yy]*)
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
[Nn]* | "")
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
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."
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
else
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
unset hls_answer
|
|
||||||
}
|
|
||||||
|
|
||||||
ask_stack() {
|
|
||||||
if [ -n "${BOOTSTRAP_HASKELL_INSTALL_STACK}" ] ; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "${BOOTSTRAP_HASKELL_NONINTERACTIVE}" ] ; then
|
|
||||||
echo "-------------------------------------------------------------------------------"
|
|
||||||
|
|
||||||
warn "Do you want to install stack?"
|
|
||||||
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 ""
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
read -r stack_answer </dev/tty
|
|
||||||
|
|
||||||
case $stack_answer in
|
|
||||||
[Yy]*)
|
|
||||||
return 1 ;;
|
|
||||||
[Nn]* | "")
|
|
||||||
return 0 ;;
|
|
||||||
*)
|
|
||||||
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."
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
else
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
unset stack_answer
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
find_shell
|
|
||||||
|
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "Welcome to Haskell!"
|
echo "Welcome to Haskell!"
|
||||||
@@ -553,20 +325,12 @@ echo
|
|||||||
if [ -z "${BOOTSTRAP_HASKELL_NONINTERACTIVE}" ] ; then
|
if [ -z "${BOOTSTRAP_HASKELL_NONINTERACTIVE}" ] ; then
|
||||||
warn "Press ENTER to proceed or ctrl-c to abort."
|
warn "Press ENTER to proceed or ctrl-c to abort."
|
||||||
warn "Note that this script can be re-run at any given time."
|
warn "Note that this script can be re-run at any given time."
|
||||||
|
echo
|
||||||
# Wait for user input to continue.
|
# Wait for user input to continue.
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
read -r answer </dev/tty
|
read -r answer </dev/tty
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ask_bashrc
|
|
||||||
ask_bashrc_answer=$?
|
|
||||||
ask_cabal_config_init
|
|
||||||
ask_cabal_config_init_answer=$?
|
|
||||||
ask_hls
|
|
||||||
ask_hls_answer=$?
|
|
||||||
ask_stack
|
|
||||||
ask_stack_answer=$?
|
|
||||||
|
|
||||||
edo mkdir -p "${GHCUP_BIN}"
|
edo mkdir -p "${GHCUP_BIN}"
|
||||||
|
|
||||||
if command -V "ghcup" >/dev/null 2>&1 ; then
|
if command -V "ghcup" >/dev/null 2>&1 ; then
|
||||||
@@ -596,52 +360,118 @@ eghcup --cache install ghc "${BOOTSTRAP_HASKELL_GHC_VERSION}"
|
|||||||
eghcup set ghc "${BOOTSTRAP_HASKELL_GHC_VERSION}"
|
eghcup set ghc "${BOOTSTRAP_HASKELL_GHC_VERSION}"
|
||||||
eghcup --cache install cabal "${BOOTSTRAP_HASKELL_CABAL_VERSION}"
|
eghcup --cache install cabal "${BOOTSTRAP_HASKELL_CABAL_VERSION}"
|
||||||
|
|
||||||
do_cabal_config_init $ask_cabal_config_init_answer
|
adjust_cabal_config() {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
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)."
|
||||||
|
echo "And set the environment variable GHCUP_MSYS2 to the root path of your msys2 installation."
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
edo cabal new-update
|
edo cabal new-update
|
||||||
|
|
||||||
case $ask_hls_answer in
|
|
||||||
1)
|
|
||||||
_eghcup --cache install hls || warn "HLS installation failed, continuing anyway"
|
|
||||||
;;
|
|
||||||
*) ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
case $ask_stack_answer in
|
if [ -z "${BOOTSTRAP_HASKELL_NONINTERACTIVE}" ] ; then
|
||||||
1)
|
warn "Do you want to install haskell-language-server (HLS) now?"
|
||||||
_eghcup --cache install stack || warn "Stack installation failed, continuing anyway"
|
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"
|
||||||
esac
|
warn ""
|
||||||
|
warn "[Y] Yes [N] No [?] Help (default is \"N\")."
|
||||||
|
warn ""
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
read -r hls_answer </dev/tty
|
||||||
|
|
||||||
|
case $hls_answer in
|
||||||
|
[Yy]*)
|
||||||
|
eghcup --cache install hls || warn "HLS installation failed, continuing anyway"
|
||||||
|
break ;;
|
||||||
|
[Nn]* | "")
|
||||||
|
break ;;
|
||||||
|
*)
|
||||||
|
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."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
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 ""
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
read -r stack_answer </dev/tty
|
||||||
|
|
||||||
|
case $stack_answer in
|
||||||
|
[Yy]*)
|
||||||
|
eghcup --cache install stack || warn "Stack installation failed, continuing anyway"
|
||||||
|
break ;;
|
||||||
|
[Nn]* | "")
|
||||||
|
break ;;
|
||||||
|
*)
|
||||||
|
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."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
# short-circuit script based on platform
|
# short-circuit script based on platform
|
||||||
case "${plat}" in
|
case "${plat}" in
|
||||||
MSYS*|MINGW*)
|
MSYS*|MINGW*)
|
||||||
# For windows we always adjust bashrc, since it's inside msys2
|
# For windows we always adjust bashrc, since it's inside msys2
|
||||||
adjust_bashrc $adjust_bashrc_answer
|
adjust_bashrc
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
if [ -z "${BOOTSTRAP_HASKELL_NONINTERACTIVE}" ] ; then
|
if [ -z "${BOOTSTRAP_HASKELL_NONINTERACTIVE}" ] ; then
|
||||||
case $ask_bashrc_answer in
|
echo "In order to run ghc and cabal, you need to adjust your PATH variable."
|
||||||
1 | 2)
|
echo "You may want to source '$GHCUP_DIR/env' in your shell"
|
||||||
echo
|
echo "configuration to do so (e.g. ~/.bashrc)."
|
||||||
echo "==============================================================================="
|
|
||||||
echo
|
adjust_bashrc
|
||||||
yellow "In order to run ghc and cabal, start a new shell or"
|
|
||||||
yellow "run 'source $GHCUP_DIR/env' in your current shell session."
|
|
||||||
adjust_bashrc $adjust_bashrc_answer
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo
|
|
||||||
echo "==============================================================================="
|
|
||||||
echo
|
|
||||||
yellow "In order to run ghc and cabal, you need to adjust your PATH variable."
|
|
||||||
yellow "You may want to source '$GHCUP_DIR/env' in your shell"
|
|
||||||
yellow "configuration to do so (e.g. ~/.bashrc)."
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@@ -26,13 +26,7 @@ param (
|
|||||||
# Specify the bootstrap url (default: 'https://www.haskell.org/ghcup/sh/bootstrap-haskell')
|
# Specify the bootstrap url (default: 'https://www.haskell.org/ghcup/sh/bootstrap-haskell')
|
||||||
[string]$BootstrapUrl,
|
[string]$BootstrapUrl,
|
||||||
# Run the final bootstrap script via 'bash' instead of a full newly spawned msys2 shell
|
# Run the final bootstrap script via 'bash' instead of a full newly spawned msys2 shell
|
||||||
[switch]$InBash,
|
[switch]$InBash
|
||||||
# Whether to install stack as well
|
|
||||||
[switch]$InstallStack,
|
|
||||||
# Whether to install hls as well
|
|
||||||
[switch]$InstallHLS,
|
|
||||||
# Skip adjusting cabal.config with mingw paths
|
|
||||||
[switch]$NoAdjustCabalConfig
|
|
||||||
)
|
)
|
||||||
|
|
||||||
$Silent = !$Interactive
|
$Silent = !$Interactive
|
||||||
@@ -184,7 +178,6 @@ if ($GhcupBasePrefixEnv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# ask for base install prefix
|
|
||||||
if ($Silent -and !($InstallDir)) {
|
if ($Silent -and !($InstallDir)) {
|
||||||
$GhcupBasePrefix = $defaultGhcupBasePrefix
|
$GhcupBasePrefix = $defaultGhcupBasePrefix
|
||||||
} elseif ($InstallDir) {
|
} elseif ($InstallDir) {
|
||||||
@@ -232,7 +225,6 @@ $GhcupMsys2 = [System.Environment]::GetEnvironmentVariable('GHCUP_MSYS2', 'user'
|
|||||||
|
|
||||||
Print-Msg -msg 'Preparing for GHCup installation...'
|
Print-Msg -msg 'Preparing for GHCup installation...'
|
||||||
|
|
||||||
# ask what to do in case ghcup is already installed
|
|
||||||
if (Test-Path -LiteralPath ('{0}' -f $GhcupDir)) {
|
if (Test-Path -LiteralPath ('{0}' -f $GhcupDir)) {
|
||||||
Print-Msg -msg ('GHCup already installed at ''{0}''...' -f $GhcupDir)
|
Print-Msg -msg ('GHCup already installed at ''{0}''...' -f $GhcupDir)
|
||||||
if ($Overwrite) {
|
if ($Overwrite) {
|
||||||
@@ -262,75 +254,8 @@ if (Test-Path -LiteralPath ('{0}' -f $GhcupDir)) {
|
|||||||
$null = New-Item -Path ('{0}' -f $GhcupDir) -ItemType 'directory' -ErrorAction SilentlyContinue
|
$null = New-Item -Path ('{0}' -f $GhcupDir) -ItemType 'directory' -ErrorAction SilentlyContinue
|
||||||
$null = New-Item -Path ('{0}' -f $GhcupDir) -Name 'bin' -ItemType 'directory' -ErrorAction SilentlyContinue
|
$null = New-Item -Path ('{0}' -f $GhcupDir) -Name 'bin' -ItemType 'directory' -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
# ask for cabal dir destination
|
|
||||||
if ($CabalDir) {
|
|
||||||
$CabDirEnv = $CabalDir
|
|
||||||
if (!($CabDirEnv)) {
|
|
||||||
Print-Msg -color Red -msg "No directory specified!"
|
|
||||||
Exit 1
|
|
||||||
} elseif (!(Split-Path -IsAbsolute -Path "$CabDirEnv")) {
|
|
||||||
Print-Msg -color Red -msg "Invalid/Non-absolute Path specified"
|
|
||||||
Exit 1
|
|
||||||
}
|
|
||||||
} elseif (!($Silent)) {
|
|
||||||
while ($true) {
|
|
||||||
|
|
||||||
$defaultCabalDir = ('{0}\cabal' -f $GhcupBasePrefix)
|
|
||||||
Print-Msg -color Magenta -msg ('Specify Cabal directory (this is where haskell packages end up). Press enter to accept the default [{0}]:' -f $defaultCabalDir)
|
|
||||||
$CabalDirPrompt = Read-Host
|
|
||||||
$CabDirEnv = ($defaultCabalDir,$CabalDirPrompt)[[bool]$CabalDirPrompt]
|
|
||||||
|
|
||||||
if (!($CabDirEnv)) {
|
|
||||||
Print-Msg -color Red -msg "No directory specified!"
|
|
||||||
} elseif (!(Split-Path -IsAbsolute -Path "$CabDirEnv")) {
|
|
||||||
Print-Msg -color Red -msg "Invalid/Non-absolute Path specified"
|
|
||||||
} else {
|
|
||||||
Break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$CabDirEnv = ('{0}\cabal' -f $GhcupBasePrefix)
|
|
||||||
}
|
|
||||||
|
|
||||||
# ask whether to install HLS
|
|
||||||
if (!($InstallHLS)) {
|
|
||||||
if (!($Silent)) {
|
|
||||||
$HLSdecision = $Host.UI.PromptForChoice('Install HLS'
|
|
||||||
, 'Do you want to install the haskell-language-server (HLS) for development purposes as well?'
|
|
||||||
, [System.Management.Automation.Host.ChoiceDescription[]] @('&Yes'
|
|
||||||
'&No'
|
|
||||||
'&Abort'), 1)
|
|
||||||
|
|
||||||
if ($HLSdecision -eq 0) {
|
|
||||||
$InstallHLS = $true
|
|
||||||
} elseif ($HLSdecision -eq 2) {
|
|
||||||
Exit 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# ask whether to install stack
|
|
||||||
if (!($InstallStack)) {
|
|
||||||
if (!($Silent)) {
|
|
||||||
$StackDecision = $Host.UI.PromptForChoice('Install stack'
|
|
||||||
, 'Do you want to install stack as well?'
|
|
||||||
, [System.Management.Automation.Host.ChoiceDescription[]] @('&Yes'
|
|
||||||
'&No'
|
|
||||||
'&Abort'), 1)
|
|
||||||
|
|
||||||
if ($StackDecision -eq 0) {
|
|
||||||
$InstallStack = $true
|
|
||||||
} elseif ($StackDecision -eq 2) {
|
|
||||||
Exit 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Print-Msg -msg 'Starting installation in 5 seconds, this may take a while...'
|
|
||||||
Start-Sleep -s 5
|
|
||||||
|
|
||||||
# mingw foo
|
|
||||||
Print-Msg -msg 'First checking for Msys2...'
|
Print-Msg -msg 'First checking for Msys2...'
|
||||||
|
|
||||||
if (!(Test-Path -Path ('{0}' -f $MsysDir))) {
|
if (!(Test-Path -Path ('{0}' -f $MsysDir))) {
|
||||||
if ($Silent) {
|
if ($Silent) {
|
||||||
$msys2Decision = 0
|
$msys2Decision = 0
|
||||||
@@ -417,7 +342,34 @@ Create-Shortcut -SourceExe 'https://www.msys2.org/docs/package-management' -Argu
|
|||||||
Print-Msg -msg ('Adding {0}\bin to Users Path...' -f $GhcupDir)
|
Print-Msg -msg ('Adding {0}\bin to Users Path...' -f $GhcupDir)
|
||||||
Add-EnvPath -Path ('{0}\bin' -f ([System.IO.Path]::GetFullPath("$GhcupDir"))) -Container 'User'
|
Add-EnvPath -Path ('{0}\bin' -f ([System.IO.Path]::GetFullPath("$GhcupDir"))) -Container 'User'
|
||||||
|
|
||||||
|
if ($CabalDir) {
|
||||||
|
$CabDirEnv = $CabalDir
|
||||||
|
if (!($CabDirEnv)) {
|
||||||
|
Print-Msg -color Red -msg "No directory specified!"
|
||||||
|
Exit 1
|
||||||
|
} elseif (!(Split-Path -IsAbsolute -Path "$CabDirEnv")) {
|
||||||
|
Print-Msg -color Red -msg "Invalid/Non-absolute Path specified"
|
||||||
|
Exit 1
|
||||||
|
}
|
||||||
|
} elseif (!($Silent)) {
|
||||||
|
while ($true) {
|
||||||
|
|
||||||
|
$defaultCabalDir = ('{0}\cabal' -f $GhcupBasePrefix)
|
||||||
|
Print-Msg -color Magenta -msg ('Specify Cabal directory (this is where haskell packages end up). Press enter to accept the default [{0}]:' -f $defaultCabalDir)
|
||||||
|
$CabalDirPrompt = Read-Host
|
||||||
|
$CabDirEnv = ($defaultCabalDir,$CabalDirPrompt)[[bool]$CabalDirPrompt]
|
||||||
|
|
||||||
|
if (!($CabDirEnv)) {
|
||||||
|
Print-Msg -color Red -msg "No directory specified!"
|
||||||
|
} elseif (!(Split-Path -IsAbsolute -Path "$CabDirEnv")) {
|
||||||
|
Print-Msg -color Red -msg "Invalid/Non-absolute Path specified"
|
||||||
|
} else {
|
||||||
|
Break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$CabDirEnv = ('{0}\cabal' -f $GhcupBasePrefix)
|
||||||
|
}
|
||||||
|
|
||||||
$CabalDirFull = [System.IO.Path]::GetFullPath("$CabDirEnv")
|
$CabalDirFull = [System.IO.Path]::GetFullPath("$CabDirEnv")
|
||||||
Print-Msg -msg ('Setting CABAL_DIR to ''{0}''' -f $CabalDirFull)
|
Print-Msg -msg ('Setting CABAL_DIR to ''{0}''' -f $CabalDirFull)
|
||||||
@@ -427,25 +379,16 @@ Print-Msg -msg 'Starting GHCup installer...'
|
|||||||
|
|
||||||
$Msys2Shell = ('{0}\msys2_shell.cmd' -f $MsysDir)
|
$Msys2Shell = ('{0}\msys2_shell.cmd' -f $MsysDir)
|
||||||
|
|
||||||
# The bootstrap script is always silent, since we ask relevant questions here
|
if ($Silent) {
|
||||||
$SilentExport = 'export BOOTSTRAP_HASKELL_NONINTERACTIVE=1 ;'
|
$SilentExport = 'export BOOTSTRAP_HASKELL_NONINTERACTIVE=1 ;'
|
||||||
|
} else {
|
||||||
if ($InstallStack) {
|
$SilentExport = ''
|
||||||
$StackInstallExport = 'export BOOTSTRAP_HASKELL_INSTALL_STACK=1 ;'
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($InstallHLS) {
|
|
||||||
$HLSInstallExport = 'export BOOTSTRAP_HASKELL_INSTALL_HLS=1 ;'
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!($NoAdjustCabalConfig)) {
|
|
||||||
$AdjustCabalConfigExport = 'export BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG=1 ;'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((Get-Process -ID $PID).ProcessName.StartsWith("bootstrap-haskell") -Or $InBash) {
|
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} [ -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)
|
||||||
} else {
|
} 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} [ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -477,5 +420,3 @@ if ((Get-Process -ID $PID).ProcessName.StartsWith("bootstrap-haskell") -Or $InBa
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2060,8 +2060,8 @@ ghcupDownloads:
|
|||||||
A_ARM64:
|
A_ARM64:
|
||||||
Linux_UnknownLinux:
|
Linux_UnknownLinux:
|
||||||
unknown_versioning:
|
unknown_versioning:
|
||||||
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.2/aarch64-linux-ghcup-0.1.15.2-r1
|
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.2/aarch64-linux-ghcup-0.1.15.2
|
||||||
dlHash: d853372440f3d43babbb868fad399811241760f2233829c92403fcbea8c547ec
|
dlHash: d91b7a5416f292f2cf813824eb419f76ad9976d258cee3581123cb6eb01db9a7
|
||||||
Darwin:
|
Darwin:
|
||||||
unknown_versioning:
|
unknown_versioning:
|
||||||
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.2/aarch64-apple-darwin-ghcup-0.1.15.2
|
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.2/aarch64-apple-darwin-ghcup-0.1.15.2
|
||||||
@@ -2069,8 +2069,8 @@ ghcupDownloads:
|
|||||||
A_ARM:
|
A_ARM:
|
||||||
Linux_UnknownLinux:
|
Linux_UnknownLinux:
|
||||||
unknown_versioning:
|
unknown_versioning:
|
||||||
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.2/armv7-linux-ghcup-0.1.15.2-r1
|
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.2/armv7-linux-ghcup-0.1.15.2
|
||||||
dlHash: f8add9b39e1f7d0f03904dc69a8683259972a4472432c1ade27d918c39a4a874
|
dlHash: 03a4af5ed895ada1dd21f4cc3f64dc9078a5bf4268313021d004c04bea7f9c2e
|
||||||
HLS:
|
HLS:
|
||||||
1.1.0:
|
1.1.0:
|
||||||
viTags: []
|
viTags: []
|
||||||
@@ -2120,17 +2120,8 @@ ghcupDownloads:
|
|||||||
- old
|
- old
|
||||||
viChangeLog: https://github.com/commercialhaskell/stack/blob/master/ChangeLog.md#v251
|
viChangeLog: https://github.com/commercialhaskell/stack/blob/master/ChangeLog.md#v251
|
||||||
viPostInstall: &stack-post |
|
viPostInstall: &stack-post |
|
||||||
Stack manages GHC versions internally by default. In order to make it use ghcup installed
|
Stack manages GHC versions internally by default. In order to make it use ghcup installed GHC versions have a look at the options 'system-ghc', 'compiler-check' and 'compiler': https://docs.haskellstack.org/en/stable/yaml_configuration/#system-ghc
|
||||||
GHC versions you can run the following commands:
|
Additionally, you should upgrade stack only through ghcup.
|
||||||
stack config set install-ghc false --global
|
|
||||||
stack config set system-ghc true --global
|
|
||||||
|
|
||||||
On windows, you may find the following config options useful too:
|
|
||||||
skip-msys, extra-path, extra-include-dirs, extra-lib-dirs
|
|
||||||
|
|
||||||
Also check out: https://docs.haskellstack.org/en/stable/yaml_configuration
|
|
||||||
|
|
||||||
!!! Additionally, you should upgrade stack only through ghcup and not use 'stack upgrade' !!!
|
|
||||||
viArch:
|
viArch:
|
||||||
A_64:
|
A_64:
|
||||||
Linux_UnknownLinux:
|
Linux_UnknownLinux:
|
||||||
|
|||||||
46
lib/GHCup.hs
46
lib/GHCup.hs
@@ -1880,49 +1880,3 @@ postGHCInstall ver@GHCTargetVersion {..} = do
|
|||||||
$ getMajorMinorV _tvVersion
|
$ getMajorMinorV _tvVersion
|
||||||
forM_ v' $ \(mj, mi) -> lift (getGHCForMajor mj mi _tvTarget)
|
forM_ v' $ \(mj, mi) -> lift (getGHCForMajor mj mi _tvTarget)
|
||||||
>>= mapM_ (\v -> liftE $ setGHC v SetGHC_XY)
|
>>= mapM_ (\v -> liftE $ setGHC v SetGHC_XY)
|
||||||
|
|
||||||
|
|
||||||
-- | Reports the binary location of a given tool:
|
|
||||||
--
|
|
||||||
-- * for GHC, this reports: @~\/.ghcup\/ghc\/\<ver\>\/bin\/ghc@
|
|
||||||
-- * for cabal, this reports @~\/.ghcup\/bin\/cabal-\<ver\>@
|
|
||||||
-- * for hls, this reports @~\/.ghcup\/bin\/haskell-language-server-wrapper-\<ver\>@
|
|
||||||
-- * for stack, this reports @~\/.ghcup\/bin\/stack-\<ver\>@
|
|
||||||
-- * for ghcup, this reports the location of the currently running executable
|
|
||||||
whereIsTool :: ( MonadReader AppState m
|
|
||||||
, MonadLogger m
|
|
||||||
, MonadThrow m
|
|
||||||
, MonadFail m
|
|
||||||
, MonadIO m
|
|
||||||
, MonadCatch m
|
|
||||||
, MonadMask m
|
|
||||||
, MonadUnliftIO m
|
|
||||||
)
|
|
||||||
=> Tool
|
|
||||||
-> GHCTargetVersion
|
|
||||||
-> Excepts '[NotInstalled] m FilePath
|
|
||||||
whereIsTool tool ver@GHCTargetVersion {..} = do
|
|
||||||
AppState { dirs } <- lift ask
|
|
||||||
|
|
||||||
case tool of
|
|
||||||
GHC -> do
|
|
||||||
whenM (lift $ fmap not $ ghcInstalled ver)
|
|
||||||
$ throwE (NotInstalled GHC ver)
|
|
||||||
bdir <- lift $ ghcupGHCDir ver
|
|
||||||
pure (bdir </> "bin" </> "ghc" <> exeExt)
|
|
||||||
Cabal -> do
|
|
||||||
whenM (lift $ fmap not $ cabalInstalled _tvVersion)
|
|
||||||
$ throwE (NotInstalled Cabal (GHCTargetVersion Nothing _tvVersion))
|
|
||||||
pure (binDir dirs </> "cabal-" <> T.unpack (prettyVer _tvVersion) <> exeExt)
|
|
||||||
HLS -> do
|
|
||||||
whenM (lift $ fmap not $ hlsInstalled _tvVersion)
|
|
||||||
$ throwE (NotInstalled HLS (GHCTargetVersion Nothing _tvVersion))
|
|
||||||
pure (binDir dirs </> "haskell-language-server-wrapper-" <> T.unpack (prettyVer _tvVersion) <> exeExt)
|
|
||||||
|
|
||||||
Stack -> do
|
|
||||||
whenM (lift $ fmap not $ stackInstalled _tvVersion)
|
|
||||||
$ throwE (NotInstalled Stack (GHCTargetVersion Nothing _tvVersion))
|
|
||||||
pure (binDir dirs </> "stack-" <> T.unpack (prettyVer _tvVersion) <> exeExt)
|
|
||||||
GHCup -> do
|
|
||||||
currentRunningExecPath <- liftIO getExecutablePath
|
|
||||||
liftIO $ canonicalizePath currentRunningExecPath
|
|
||||||
|
|||||||
@@ -765,49 +765,22 @@ ghcToolFiles ver = do
|
|||||||
whenM (fmap not $ liftIO $ doesDirectoryExist ghcdir)
|
whenM (fmap not $ liftIO $ doesDirectoryExist ghcdir)
|
||||||
(throwE (NotInstalled GHC ver))
|
(throwE (NotInstalled GHC ver))
|
||||||
|
|
||||||
files <- liftIO $ listDirectory bindir
|
files <- liftIO (listDirectory bindir >>= filterM (doesFileExist . (bindir </>)))
|
||||||
-- figure out the <ver> suffix, because this might not be `Version` for
|
pure (getUniqueTools . groupToolFiles . fmap (dropSuffix exeExt) $ files)
|
||||||
-- alpha/rc releases, but x.y.a.somedate.
|
|
||||||
|
|
||||||
ghcIsHadrian <- liftIO $ isHadrian bindir
|
|
||||||
onlyUnversioned <- case ghcIsHadrian of
|
|
||||||
Right () -> pure id
|
|
||||||
Left (fmap (dropSuffix exeExt) -> [ghc, ghc_ver])
|
|
||||||
| (Just symver) <- stripPrefix (ghc <> "-") ghc_ver
|
|
||||||
, not (null symver) -> pure $ filter (\x -> not $ symver `isInfixOf` x)
|
|
||||||
_ -> fail "Fatal: Could not find internal GHC version"
|
|
||||||
|
|
||||||
pure $ onlyUnversioned $ fmap (dropSuffix exeExt) files
|
|
||||||
where
|
where
|
||||||
isNotAnyInfix xs t = foldr (\a b -> not (a `isInfixOf` t) && b) True xs
|
|
||||||
-- GHC is moving some builds to Hadrian for bindists,
|
|
||||||
-- which doesn't create versioned binaries.
|
|
||||||
-- https://gitlab.haskell.org/haskell/ghcup-hs/issues/31
|
|
||||||
isHadrian :: FilePath -- ^ ghcbin path
|
|
||||||
-> IO (Either [String] ()) -- ^ Right for Hadrian
|
|
||||||
isHadrian dir = do
|
|
||||||
-- Non-hadrian has e.g. ["ghc", "ghc-8.10.4"]
|
|
||||||
-- which also requires us to discover the internal version
|
|
||||||
-- to filter the correct tool files.
|
|
||||||
-- We can't use the symlink on windows, so we fall back to some
|
|
||||||
-- more complicated logic.
|
|
||||||
fs <- fmap
|
|
||||||
-- regex over-matches
|
|
||||||
(filter (isNotAnyInfix ["haddock", "ghc-pkg", "ghci"]))
|
|
||||||
$ liftIO $ findFiles
|
|
||||||
dir
|
|
||||||
(makeRegexOpts compExtended
|
|
||||||
execBlank
|
|
||||||
-- for cross, this won't be "ghc", but e.g.
|
|
||||||
-- "armv7-unknown-linux-gnueabihf-ghc"
|
|
||||||
([s|^([a-zA-Z0-9_-]*[a-zA-Z0-9_]-)?ghc.*$|] :: ByteString)
|
|
||||||
)
|
|
||||||
if | length fs == 1 -> pure $ Right () -- hadrian
|
|
||||||
| length fs == 2 -> pure $ Left
|
|
||||||
(sortOn length fs) -- legacy make, result should
|
|
||||||
-- be ["ghc", "ghc-8.10.4"]
|
|
||||||
| otherwise -> fail "isHadrian failed!"
|
|
||||||
|
|
||||||
|
groupToolFiles :: [FilePath] -> [[(FilePath, String)]]
|
||||||
|
groupToolFiles = groupBy (\(a, _) (b, _) -> a == b) . fmap (splitOnPVP "-")
|
||||||
|
|
||||||
|
getUniqueTools :: [[(FilePath, String)]] -> [String]
|
||||||
|
getUniqueTools = filter (isNotAnyInfix blackListedTools) . nub . fmap fst . filter ((== "") . snd) . concat
|
||||||
|
|
||||||
|
blackListedTools :: [String]
|
||||||
|
blackListedTools = ["haddock-ghc"]
|
||||||
|
|
||||||
|
isNotAnyInfix :: [String] -> String -> Bool
|
||||||
|
isNotAnyInfix xs t = foldr (\a b -> not (a `isInfixOf` t) && b) True xs
|
||||||
|
|
||||||
|
|
||||||
-- | This file, when residing in @~\/.ghcup\/ghc\/\<ver\>\/@ signals that
|
-- | This file, when residing in @~\/.ghcup\/ghc\/\<ver\>\/@ signals that
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import GHCup.Utils.String.QQ
|
|||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Control.Monad.IO.Class
|
import Control.Monad.IO.Class
|
||||||
import Control.Monad.Logger
|
import Control.Monad.Logger
|
||||||
import Data.Char ( ord )
|
|
||||||
import Prelude hiding ( appendFile )
|
import Prelude hiding ( appendFile )
|
||||||
import System.Console.Pretty
|
import System.Console.Pretty
|
||||||
import System.FilePath
|
import System.FilePath
|
||||||
@@ -44,33 +43,20 @@ myLoggerT LoggerConfig {..} loggingt = runLoggingT loggingt mylogger
|
|||||||
mylogger :: Loc -> LogSource -> LogLevel -> LogStr -> IO ()
|
mylogger :: Loc -> LogSource -> LogLevel -> LogStr -> IO ()
|
||||||
mylogger _ _ level str' = do
|
mylogger _ _ level str' = do
|
||||||
-- color output
|
-- color output
|
||||||
let style' = case level of
|
|
||||||
LevelDebug -> style Bold . color Blue
|
|
||||||
LevelInfo -> style Bold . color Green
|
|
||||||
LevelWarn -> style Bold . color Yellow
|
|
||||||
LevelError -> style Bold . color Red
|
|
||||||
LevelOther _ -> id
|
|
||||||
let l = case level of
|
let l = case level of
|
||||||
LevelDebug -> toLogStr (style' "[ Debug ]")
|
LevelDebug -> toLogStr (style Bold $ color Blue "[ Debug ]")
|
||||||
LevelInfo -> toLogStr (style' "[ Info ]")
|
LevelInfo -> toLogStr (style Bold $ color Green "[ Info ]")
|
||||||
LevelWarn -> toLogStr (style' "[ Warn ]")
|
LevelWarn -> toLogStr (style Bold $ color Yellow "[ Warn ]")
|
||||||
LevelError -> toLogStr (style' "[ Error ]")
|
LevelError -> toLogStr (style Bold $ color Red "[ Error ]")
|
||||||
LevelOther t -> toLogStr "[ " <> toLogStr t <> toLogStr " ]"
|
LevelOther t -> toLogStr "[ " <> toLogStr t <> toLogStr " ]"
|
||||||
let strs = fmap toLogStr . B.split (fromIntegral $ ord '\n') . fromLogStr $ str'
|
let out = fromLogStr (l <> toLogStr " " <> str' <> toLogStr "\n")
|
||||||
let out = case strs of
|
|
||||||
[] -> B.empty
|
|
||||||
(x:xs) -> fromLogStr
|
|
||||||
. foldr (\a b -> a <> toLogStr "\n" <> b) mempty
|
|
||||||
. ((l <> toLogStr " " <> x) :)
|
|
||||||
. fmap (\line' -> toLogStr (style' "[ ... ] ") <> line' )
|
|
||||||
$ xs
|
|
||||||
|
|
||||||
when (lcPrintDebug || (not lcPrintDebug && (level /= LevelDebug)))
|
when (lcPrintDebug || (not lcPrintDebug && (level /= LevelDebug)))
|
||||||
$ colorOutter out
|
$ colorOutter out
|
||||||
|
|
||||||
-- raw output
|
-- raw output
|
||||||
let lr = case level of
|
let lr = case level of
|
||||||
LevelDebug -> toLogStr "Debug:"
|
LevelDebug -> toLogStr "Debug: "
|
||||||
LevelInfo -> toLogStr "Info:"
|
LevelInfo -> toLogStr "Info:"
|
||||||
LevelWarn -> toLogStr "Warn:"
|
LevelWarn -> toLogStr "Warn:"
|
||||||
LevelError -> toLogStr "Error:"
|
LevelError -> toLogStr "Error:"
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import Control.Monad.IO.Class
|
|||||||
import Control.Monad.Trans.Class ( lift )
|
import Control.Monad.Trans.Class ( lift )
|
||||||
import Data.Bifunctor
|
import Data.Bifunctor
|
||||||
import Data.ByteString ( ByteString )
|
import Data.ByteString ( ByteString )
|
||||||
import Data.List ( nub )
|
import Data.List ( nub, intercalate )
|
||||||
import Data.Foldable
|
import Data.Foldable
|
||||||
import Data.String
|
import Data.String
|
||||||
import Data.Text ( Text )
|
import Data.Text ( Text )
|
||||||
@@ -47,6 +47,7 @@ import GHC.IO.Exception
|
|||||||
import qualified Data.ByteString as B
|
import qualified Data.ByteString as B
|
||||||
import qualified Data.ByteString.Lazy as L
|
import qualified Data.ByteString.Lazy as L
|
||||||
import qualified Data.Strict.Maybe as S
|
import qualified Data.Strict.Maybe as S
|
||||||
|
import qualified Data.List.Split as Split
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import qualified Data.Text.Encoding as E
|
import qualified Data.Text.Encoding as E
|
||||||
import qualified Data.Text.Encoding.Error as E
|
import qualified Data.Text.Encoding.Error as E
|
||||||
@@ -425,3 +426,19 @@ isNewLine w
|
|||||||
| w == _lf = True
|
| w == _lf = True
|
||||||
| w == _cr = True
|
| w == _cr = True
|
||||||
| otherwise = False
|
| otherwise = False
|
||||||
|
|
||||||
|
|
||||||
|
-- | Split on a PVP suffix.
|
||||||
|
--
|
||||||
|
-- >>> splitOnPVP "-" "ghc-iserv-dyn-9.3.20210706" == ("ghc-iserv-dyn", "9.3.20210706")
|
||||||
|
-- >>> splitOnPVP "-" "ghc-iserv-dyn" == ("ghc-iserv-dyn", "")
|
||||||
|
splitOnPVP :: String -> String -> (String, String)
|
||||||
|
splitOnPVP c s = case Split.splitOn c s of
|
||||||
|
[] -> def
|
||||||
|
[_] -> def
|
||||||
|
xs
|
||||||
|
| let l = last xs
|
||||||
|
, (Right _) <- pvp (T.pack l) -> (intercalate c (init xs), l)
|
||||||
|
| otherwise -> def
|
||||||
|
where
|
||||||
|
def = (s, "")
|
||||||
|
|||||||
Reference in New Issue
Block a user