forked from jfut/ganeti-rpm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-ghc
executable file
·77 lines (68 loc) · 2.41 KB
/
setup-ghc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
#
# Setup GHC environment to build Ganeti
set -euo pipefail
SCRIPT_DIR=$(dirname $(readlink -f $0))
CACHE_DIR="${SCRIPT_DIR}/cache"
GHC_PREFIX="${HOME}/local"
if [[ ${EUID:-${UID}} = 0 ]]; then
GHC_PREFIX="/usr/local"
fi
# Setup cache directory
if [[ ! -d "${CACHE_DIR}" ]]; then
mkdir -p "${CACHE_DIR}"
fi
# Install dependencies
echo "# Install dependencies for GHC"
if [[ -f /usr/bin/dnf ]]; then
# el8 or later
sudo dnf -y install libcurl-devel pcre-devel zlib-devel gmp-devel ncurses-compat-libs
else
sudo yum -y install libcurl-devel pcre-devel zlib-devel gmp-devel
fi
TMP_DIR=$(mktemp -d "${HOME}/tmp.XXXXXXXXXX")
# Install ghc
# Ubuntu 20.04.01 LTS + initial: 8.6.5
# Ubuntu 20.04.01 LTS + apt upgrade: 8.8.1
#
# NG: GHC_VERSION=8.8.4
# Error:
# + cabal install cryptonite -f -use_target_attributes
# cabal: Error: Could not find module: AutoConf with any suffix:
# ["gc","chs","hsc","x","y","ly","cpphs","hs","lhs","hsig","lhsig"]. If the
# module is autogenerated it should be added to 'autogen-modules'.
GHC_VERSION=8.6.5
echo "# Install GHC version ${GHC_VERSION}"
if ! type ghc > /dev/null 2>&1; then
GHC_BINARY_PACKAGE="ghc-${GHC_VERSION}-x86_64-centos7-linux.tar.xz"
if [[ ! -f "${CACHE_DIR}/${GHC_BINARY_PACKAGE}" ]]; then
curl -L "https://downloads.haskell.org/~ghc/${GHC_VERSION}/{${GHC_BINARY_PACKAGE}}" -o "${CACHE_DIR}/#1"
fi
cp -a "${CACHE_DIR}/${GHC_BINARY_PACKAGE}" "${TMP_DIR}/"
pushd "${TMP_DIR}"
tar xf "${GHC_BINARY_PACKAGE}"
cd "ghc-${GHC_VERSION}"
./configure --prefix="${GHC_PREFIX}"
make install
popd
fi
# Install cabal-install
echo "# Install cabal-install"
if ! type cabal > /dev/null 2>&1; then
# Cabal-3.0.1.0 -> 3.0.0.0
CABAL_VERSION=$(ghc-pkg list Cabal | grep Cabal- | head -1 | egrep -o "\-[0-9].[0-9]" | cut -d'-' -f 2).0.0
echo "- Install Cabal version ${CABAL_VERSION}"
CABAL_BINARY_PACKAGE="cabal-install-${CABAL_VERSION}-x86_64-unknown-linux.tar.gz"
if [[ ! -f "${CACHE_DIR}/${CABAL_BINARY_PACKAGE}" ]]; then
curl -L "https://downloads.haskell.org/~cabal/cabal-install-${CABAL_VERSION}/{${CABAL_BINARY_PACKAGE}}" -o "${CACHE_DIR}/#1"
fi
cp -a "${CACHE_DIR}/${CABAL_BINARY_PACKAGE}" "${TMP_DIR}/"
pushd "${TMP_DIR}"
tar xf "${CABAL_BINARY_PACKAGE}"
rm -f cabal.sig
mkdir -p "${GHC_PREFIX}/bin"
mv cabal "${GHC_PREFIX}/bin/"
echo "- Cabal update"
cabal update
popd
fi