You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

43 lines
1.1 KiB

  1. #!/bin/sh
  2. set -eu
  3. SCRIPT_DIR="$(CDPATH="" cd -- "$(dirname -- "$0")" && pwd -P)"
  4. cd "${SCRIPT_DIR}"
  5. # install ghcup
  6. if ! [ -e "${SCRIPT_DIR}"/.ghcup/bin/ghcup ] ; then
  7. mkdir -p "${SCRIPT_DIR}"/.ghcup/bin
  8. curl --proto '=https' --tlsv1.2 -sSf https://gitlab.haskell.org/haskell/ghcup/raw/master/ghcup > "${SCRIPT_DIR}"/.ghcup/bin/ghcup
  9. chmod +x "${SCRIPT_DIR}"/.ghcup/bin/ghcup
  10. fi
  11. # set up environment
  12. export PATH="${SCRIPT_DIR}/.ghcup/bin:$PATH"
  13. export GHCUP_INSTALL_BASE_PREFIX="${SCRIPT_DIR}"
  14. # get ghc version from cabal.project
  15. ghc_ver=$(grep with-compiler cabal.project | awk '{print $2}' | sed 's/ghc-//')
  16. # install ghc
  17. if ! ghcup list -t ghc -c installed -r | grep -q "${ghc_ver}" ; then
  18. ghcup install "${ghc_ver}"
  19. fi
  20. # install cabal-install
  21. if [ -z "$(ghcup list -t cabal-install -c installed -r)" ] ; then
  22. ghcup install-cabal
  23. fi
  24. [ -e "${SCRIPT_DIR}"/bin ] || mkdir "${SCRIPT_DIR}"/bin
  25. # install binary
  26. cabal v2-install \
  27. --installdir="${SCRIPT_DIR}"/bin \
  28. --install-method=copy \
  29. --overwrite-policy=always
  30. echo "Binary installed in: ${SCRIPT_DIR}/bin"