bootstrap.sh 20.3 KB
Newer Older
1
#!/bin/sh
Duncan Coutts's avatar
Duncan Coutts committed
2
3
4
5
6
7
8

# A script to bootstrap cabal-install.

# It works by downloading and installing the Cabal, zlib and
# HTTP packages. It then installs cabal-install itself.
# It expects to be run inside the cabal-install directory.

9
10
11
12
# Install settings, you can override these by setting environment vars. E.g. if
# you don't want profiling and dynamic versions of libraries to be installed in
# addition to vanilla, run 'EXTRA_CONFIGURE_OPTS="" ./bootstrap.sh'

13
#VERBOSE
14
15
DEFAULT_CONFIGURE_OPTS="--enable-library-profiling --enable-shared"
EXTRA_CONFIGURE_OPTS=${EXTRA_CONFIGURE_OPTS-$DEFAULT_CONFIGURE_OPTS}
16
17
#EXTRA_BUILD_OPTS
#EXTRA_INSTALL_OPTS
18

tuncer's avatar
tuncer committed
19
20
21
22
die() {
    printf "\nError during cabal-install bootstrap:\n%s\n" "$1" >&2
    exit 2
}
23

24
# programs, you can override these by setting environment vars
25
26
27
GHC="${GHC:-ghc}"
GHC_PKG="${GHC_PKG:-ghc-pkg}"
GHC_VER="$(${GHC} --numeric-version)"
28
HADDOCK=${HADDOCK:-haddock}
29
30
31
32
WGET="${WGET:-wget}"
CURL="${CURL:-curl}"
FETCH="${FETCH:-fetch}"
TAR="${TAR:-tar}"
33
GZIP_PROGRAM="${GZIP_PROGRAM:-gzip}"
34

Mikhail Glushenkov's avatar
Mikhail Glushenkov committed
35
36
37
# The variable SCOPE_OF_INSTALLATION can be set on the command line to
# use/install the libaries needed to build cabal-install to a custom package
# database instead of the user or global package database.
38
#
Mikhail Glushenkov's avatar
Mikhail Glushenkov committed
39
40
41
42
43
44
45
46
47
48
49
# Example:
#
# $ ghc-pkg init /my/package/database
# $ SCOPE_OF_INSTALLATION='--package-db=/my/package/database' ./bootstrap.sh
#
# You can also combine SCOPE_OF_INSTALLATION with PREFIX:
#
# $ ghc-pkg init /my/prefix/packages.conf.d
# $ SCOPE_OF_INSTALLATION='--package-db=/my/prefix/packages.conf.d' \
#   PREFIX=/my/prefix ./bootstrap.sh
#
50
51
52
53
# If you use the --global,--user or --sandbox arguments, this will
# override the SCOPE_OF_INSTALLATION setting and not use the package
# database you pass in the SCOPE_OF_INSTALLATION variable.

54
SCOPE_OF_INSTALLATION="${SCOPE_OF_INSTALLATION:---user}"
55
DEFAULT_PREFIX="${HOME}/.cabal"
56

Oleg Grenrus's avatar
Oleg Grenrus committed
57
TMPDIR=$(mktemp -d -p /tmp -t cabal-XXXXXXX || mktemp -d -t cabal-XXXXXXX)
58
export TMPDIR
Geoff Nixon's avatar
Geoff Nixon committed
59

60
61
# Check for a C compiler, using user-set $CC, if any, first.
for c in $CC gcc clang cc icc; do
tuncer's avatar
tuncer committed
62
  $c --version 1>/dev/null 2>&1 && CC=$c &&
63
  echo "Using $c for C compiler. If this is not what you want, set CC." >&2 &&
64
65
66
67
  break
done

# None found.
68
69
[ -"$CC"- = -""- ] && die 'C compiler not found (or could not be run).
  If a C compiler is installed make sure it is on your PATH, or set $CC.'
70

71
# Find the correct linker/linker-wrapper.
72
LINK="$(for link in collect2 ld; do
tuncer's avatar
tuncer committed
73
74
75
76
77
78
          if [ $($CC -print-prog-name=$link) = $link ]
          then
              continue
          else
              $CC -print-prog-name=$link
          fi
79
        done)"
80

81
82
# Fall back to "ld"... might work.
[ -$LINK- = -""- ] && LINK=ld
83

84
85
86
87
# And finally, see if we can compile and link something.
  echo 'int main(){}' | $CC -xc - -o /dev/null ||
    die "C compiler and linker could not compile a simple test program.
    Please check your toolchain."
88

89
# Warn that were's overriding $LD if set (if you want).
Geoff Nixon's avatar
Geoff Nixon committed
90
[ -"$LD"- != -""- ] && [ -"$LD"- != -"$LINK"- ] &&
91
92
93
94
  echo "Warning: value set in $LD is not the same as C compiler's $LINK." >&2
  echo "Using $LINK instead." >&2

# Set LD, overriding environment if necessary.
95
export LD=$LINK
96
97
98
99

# Check we're in the right directory, etc.
grep "cabal-install" ./cabal-install.cabal > /dev/null 2>&1 ||
  die "The bootstrap.sh script must be run in the cabal-install directory"
100

101
102
103
104
105
106
107
108
109
110
111
112
113
${GHC} --numeric-version > /dev/null 2>&1  ||
  die "${GHC} not found (or could not be run).
       If ghc is installed,  make sure it is on your PATH,
       or set the GHC and GHC_PKG vars."

${GHC_PKG} --version     > /dev/null 2>&1  || die "${GHC_PKG} not found."

GHC_PKG_VER="$(${GHC_PKG} --version | cut -d' ' -f 5)"

[ ${GHC_VER} = ${GHC_PKG_VER} ] ||
  die "Version mismatch between ${GHC} and ${GHC_PKG}.
       If you set the GHC variable then set GHC_PKG too."

114
JOBS="-j1"
115
116
while [ "$#" -gt 0 ]; do
  case "${1}" in
117
    "--user")
118
      SCOPE_OF_INSTALLATION="${1}"
119
120
      shift;;
    "--global")
121
      SCOPE_OF_INSTALLATION="${1}"
122
      DEFAULT_PREFIX="/usr/local"
123
      shift;;
124
125
126
127
128
129
130
131
132
133
    "--sandbox")
      shift
      # check if there is another argument which doesn't start with --
      if [ "$#" -le 0 ] || [ ! -z $(echo "${1}" | grep "^--") ]
      then
          SANDBOX=".cabal-sandbox"
      else
          SANDBOX="${1}"
          shift
      fi;;
134
135
136
    "--no-doc")
      NO_DOCUMENTATION=1
      shift;;
137
138
139
140
141
142
143
144
145
146
147
148
    "-j"|"--jobs")
        shift
        # check if there is another argument which doesn't start with - or --
        if [ "$#" -le 0 ] \
            || [ ! -z $(echo "${1}" | grep "^-") ] \
            || [ ! -z $(echo "${1}" | grep "^--") ]
        then
            JOBS="-j"
        else
            JOBS="-j${1}"
            shift
        fi;;
149
    *)
150
      echo "Unknown argument or option, quitting: ${1}"
151
152
153
      echo "usage: bootstrap.sh [OPTION]"
      echo
      echo "options:"
154
155
      echo "   -j/--jobs       Number of concurrent workers to use (Default: 1)"
      echo "                   -j without an argument will use all available cores"
156
157
      echo "   --user          Install for the local user (default)"
      echo "   --global        Install systemwide (must be run as root)"
Mikhail Glushenkov's avatar
Mikhail Glushenkov committed
158
      echo "   --no-doc        Do not generate documentation for installed"\
159
160
161
162
           "packages"
      echo "   --sandbox       Install to a sandbox in the default location"\
           "(.cabal-sandbox)"
      echo "   --sandbox path  Install to a sandbox located at path"
163
164
165
      exit;;
  esac
done
166

167
# Do not try to use -j with GHC 7.8 or older
168
case $GHC_VER in
169
    7.4*|7.6*|7.8*)
170
171
172
173
174
175
        JOBS=""
        ;;
    *)
        ;;
esac

176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
abspath () { case "$1" in /*)printf "%s\n" "$1";; *)printf "%s\n" "$PWD/$1";;
             esac; }

if [ ! -z "$SANDBOX" ]
then # set up variables for sandbox bootstrap
  # Make the sandbox path absolute since it will be used from
  # different working directories when the dependency packages are
  # installed.
  SANDBOX=$(abspath "$SANDBOX")
  # Get the name of the package database which cabal sandbox would use.
  GHC_ARCH=$(ghc --info |
    sed -n 's/.*"Target platform".*"\([^-]\+\)-[^-]\+-\([^"]\+\)".*/\1-\2/p')
  PACKAGEDB="$SANDBOX/${GHC_ARCH}-ghc-${GHC_VER}-packages.conf.d"
  # Assume that if the directory is already there, it is already a
  # package database. We will get an error immediately below if it
  # isn't. Uses -r to try to be compatible with Solaris, and allow
  # symlinks as well as a normal dir/file.
  [ ! -r "$PACKAGEDB" ] && ghc-pkg init "$PACKAGEDB"
  PREFIX="$SANDBOX"
  SCOPE_OF_INSTALLATION="--package-db=$PACKAGEDB"
  echo Bootstrapping in sandbox at \'$SANDBOX\'.
fi

199
200
201
202
203
204
# Check for haddock unless no documentation should be generated.
if [ ! ${NO_DOCUMENTATION} ]
then
  ${HADDOCK} --version     > /dev/null 2>&1  || die "${HADDOCK} not found."
fi

205
PREFIX=${PREFIX:-${DEFAULT_PREFIX}}
206
207
208

# Versions of the packages to install.
# The version regex says what existing installed versions are ok.
tuncer's avatar
tuncer committed
209
PARSEC_VER="3.1.9";    PARSEC_VER_REGEXP="[3]\.[01]\."
210
                       # >= 3.0 && < 3.2
211
DEEPSEQ_VER="1.4.2.0"; DEEPSEQ_VER_REGEXP="1\.[1-9]\."
212
                       # >= 1.1 && < 2
tuncer's avatar
tuncer committed
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227

case "$GHC_VER" in
    7.4*|7.6*)
        # GHC 7.4 or 7.6
        BINARY_VER="0.8.2.1"
        BINARY_VER_REGEXP="[0]\.[78]\.[0-2]\." # >= 0.7 && < 0.8.3
        ;;
    *)
        # GHC >= 7.8
        BINARY_VER="0.8.3.0"
        BINARY_VER_REGEXP="[0]\.[78]\." # >= 0.7 && < 0.9
        ;;
esac


Mikhail Glushenkov's avatar
Mikhail Glushenkov committed
228
TEXT_VER="1.2.2.1";    TEXT_VER_REGEXP="((1\.[012]\.)|(0\.([2-9]|(1[0-1]))\.))"
tuncer's avatar
tuncer committed
229
                       # >= 0.2 && < 1.3
Mikhail Glushenkov's avatar
Mikhail Glushenkov committed
230
NETWORK_VER="2.6.3.1"; NETWORK_VER_REGEXP="2\.[0-6]\."
tuncer's avatar
tuncer committed
231
                       # >= 2.0 && < 2.7
Mikhail Glushenkov's avatar
Mikhail Glushenkov committed
232
NETWORK_URI_VER="2.6.1.0"; NETWORK_URI_VER_REGEXP="2\.6\."
233
                       # >= 2.6 && < 2.7
Mikhail Glushenkov's avatar
Mikhail Glushenkov committed
234
CABAL_VER="1.25.0.0";  CABAL_VER_REGEXP="1\.25\.[0-9]"
235
                       # >= 1.25 && < 1.26
Mikhail Glushenkov's avatar
Mikhail Glushenkov committed
236
TRANS_VER="0.5.2.0";   TRANS_VER_REGEXP="0\.[45]\."
237
                       # >= 0.2.* && < 0.6
238
239
MTL_VER="2.2.1";       MTL_VER_REGEXP="[2]\."
                       #  >= 2.0 && < 3
240
HTTP_VER="4000.3.3";   HTTP_VER_REGEXP="4000\.(2\.([5-9]|1[0-9]|2[0-9])|3\.?)"
241
                       # >= 4000.2.5 < 4000.4
Mikhail Glushenkov's avatar
Mikhail Glushenkov committed
242
ZLIB_VER="0.6.1.2";    ZLIB_VER_REGEXP="(0\.5\.([3-9]|1[0-9])|0\.6)"
243
                       # >= 0.5.3 && <= 0.7
Mikhail Glushenkov's avatar
Mikhail Glushenkov committed
244
245
TIME_VER="1.7"         TIME_VER_REGEXP="1\.[1-7]\.?"
                       # >= 1.1 && < 1.8
Mikhail Glushenkov's avatar
Mikhail Glushenkov committed
246
247
RANDOM_VER="1.1"       RANDOM_VER_REGEXP="1\.[01]\.?"
                       # >= 1 && < 1.2
248
STM_VER="2.4.4.1";     STM_VER_REGEXP="2\."
249
                       # == 2.*
Mikhail Glushenkov's avatar
Mikhail Glushenkov committed
250
251
ASYNC_VER="2.1.0";     ASYNC_VER_REGEXP="2\."
                       # 2.*
252
253
254
255
OLD_TIME_VER="1.1.0.3"; OLD_TIME_VER_REGEXP="1\.[01]\.?"
                       # >=1.0.0.0 && <1.2
OLD_LOCALE_VER="1.0.0.7"; OLD_LOCALE_VER_REGEXP="1\.0\.?"
                       # >=1.0.0.0 && <1.1
tuncer's avatar
tuncer committed
256
257
BASE16_BYTESTRING_VER="0.1.1.6"; BASE16_BYTESTRING_VER_REGEXP="0\.1"
                       # 0.1.*
258
BASE64_BYTESTRING_VER="1.0.0.1"; BASE64_BYTESTRING_VER_REGEXP="1\."
259
                       # >=1.0
Mikhail Glushenkov's avatar
Mikhail Glushenkov committed
260
CRYPTOHASH_SHA256_VER="0.11.100.1"; CRYPTOHASH_SHA256_VER_REGEXP="0\.11\.?"
261
                       # 0.11.*
Ryan Scott's avatar
Ryan Scott committed
262
263
ECHO_VER="0.1";        ECHO_VER_REGEXP="0\.1\.?"
                       # 0.1.*
264
265
EDIT_DISTANCE_VER="0.2.2.1"; EDIT_DISTANCE_VER_REGEXP="0\.2\.2\.?"
                       # 0.2.2.*
266
ED25519_VER="0.0.5.0"; ED25519_VER_REGEXP="0\.0\.?"
267
                       # 0.0.*
268
HACKAGE_SECURITY_VER="0.5.2.2"; HACKAGE_SECURITY_VER_REGEXP="0\.5\.(2\.[2-9]|[3-9])"
269
                       # >= 0.5.2 && < 0.6
270
BYTESTRING_BUILDER_VER="0.10.8.1.0"; BYTESTRING_BUILDER_VER_REGEXP="0\.10\.?"
271
272
TAR_VER="0.5.0.3";     TAR_VER_REGEXP="0\.5\.([1-9]|1[0-9]|0\.[3-9]|0\.1[0-9])\.?"
                       # >= 0.5.0.3  && < 0.6
tuncer's avatar
tuncer committed
273
274
HASHABLE_VER="1.2.4.0"; HASHABLE_VER_REGEXP="1\."
                       # 1.*
Duncan Coutts's avatar
Duncan Coutts committed
275

nkaretnikov's avatar
nkaretnikov committed
276
HACKAGE_URL="https://hackage.haskell.org/package"
277

278
279
280
# Haddock fails for network-2.5.0.0, and for hackage-security for
# GHC <8, c.f. https://github.com/well-typed/hackage-security/issues/149
NO_DOCS_PACKAGES_VER_REGEXP="network-uri-2\.5\.[0-9]+\.[0-9]+|hackage-security-0\.5\.[0-9]+\.[0-9]+"
281

282
# Cache the list of packages:
283
echo "Checking installed packages for ghc-${GHC_VER}..."
284
285
${GHC_PKG} list --global ${SCOPE_OF_INSTALLATION} > ghc-pkg.list ||
  die "running '${GHC_PKG} list' failed"
286
287
288
289
290

# Will we need to install this package, or is a suitable version installed?
need_pkg () {
  PKG=$1
  VER_MATCH=$2
291
  if egrep " ${PKG}-${VER_MATCH}" ghc-pkg.list > /dev/null 2>&1
292
293
294
295
296
297
  then
    return 1;
  else
    return 0;
  fi
  #Note: we cannot use "! grep" here as Solaris 9 /bin/sh doesn't like it.
298
299
300
301
302
303
304
305
306
}

info_pkg () {
  PKG=$1
  VER=$2
  VER_MATCH=$3

  if need_pkg ${PKG} ${VER_MATCH}
  then
307
    if [ -r "${PKG}-${VER}.tar.gz" ]
308
309
310
311
312
    then
        echo "${PKG}-${VER} will be installed from local tarball."
    else
        echo "${PKG}-${VER} will be downloaded and installed."
    fi
313
314
315
316
317
318
319
320
321
  else
    echo "${PKG} is already installed and the version is ok."
  fi
}

fetch_pkg () {
  PKG=$1
  VER=$2

322
323
  URL_PKG=${HACKAGE_URL}/${PKG}-${VER}/${PKG}-${VER}.tar.gz
  URL_PKGDESC=${HACKAGE_URL}/${PKG}-${VER}/${PKG}.cabal
324
325
  if which ${CURL} > /dev/null
  then
tuncer's avatar
tuncer committed
326
327
    # TODO: switch back to resuming curl command once
    #       https://github.com/haskell/hackage-server/issues/111 is resolved
328
329
330
331
    #${CURL} -L --fail -C - -O ${URL_PKG} || die "Failed to download ${PKG}."
    ${CURL} -L --fail -O ${URL_PKG} || die "Failed to download ${PKG}."
    ${CURL} -L --fail -O ${URL_PKGDESC} \
        || die "Failed to download '${PKG}.cabal'."
332
333
  elif which ${WGET} > /dev/null
  then
334
335
    ${WGET} -c ${URL_PKG} || die "Failed to download ${PKG}."
    ${WGET} -c ${URL_PKGDESC} || die "Failed to download '${PKG}.cabal'."
336
  elif which ${FETCH} > /dev/null
Mikhail Glushenkov's avatar
Mikhail Glushenkov committed
337
    then
338
339
      ${FETCH} ${URL_PKG} || die "Failed to download ${PKG}."
      ${FETCH} ${URL_PKGDESC} || die "Failed to download '${PKG}.cabal'."
340
  else
341
    die "Failed to find a downloader. 'curl', 'wget' or 'fetch' is required."
342
  fi
343
  [ -f "${PKG}-${VER}.tar.gz" ] ||
344
345
346
347
     die "Downloading ${URL_PKG} did not create ${PKG}-${VER}.tar.gz"
  [ -f "${PKG}.cabal" ] ||
     die "Downloading ${URL_PKGDESC} did not create ${PKG}.cabal"
  mv "${PKG}.cabal" "${PKG}.cabal.hackage"
348
349
350
351
352
353
}

unpack_pkg () {
  PKG=$1
  VER=$2

354
  rm -rf "${PKG}-${VER}.tar" "${PKG}-${VER}"
355
  ${GZIP_PROGRAM} -d < "${PKG}-${VER}.tar.gz" | ${TAR} -xf -
356
  [ -d "${PKG}-${VER}" ] || die "Failed to unpack ${PKG}-${VER}.tar.gz"
357
  cp "${PKG}.cabal.hackage" "${PKG}-${VER}/${PKG}.cabal"
358
359
360
361
}

install_pkg () {
  PKG=$1
362
  VER=$2
363

364
365
366
  [ -x Setup ] && ./Setup clean
  [ -f Setup ] && rm Setup

367
  ${GHC} --make ${JOBS} Setup -o Setup -XRank2Types -XFlexibleContexts ||
368
369
    die "Compiling the Setup script failed."

370
  [ -x Setup ] || die "The Setup script does not exist or cannot be run"
371

372
373
374
375
376
  args="${SCOPE_OF_INSTALLATION} --prefix=${PREFIX} --with-compiler=${GHC}"
  args="$args --with-hc-pkg=${GHC_PKG} --with-gcc=${CC} --with-ld=${LD}"
  args="$args ${EXTRA_CONFIGURE_OPTS} ${VERBOSE}"

  ./Setup configure $args || die "Configuring the ${PKG} package failed."
377

378
  ./Setup build ${JOBS} ${EXTRA_BUILD_OPTS} ${VERBOSE} ||
379
     die "Building the ${PKG} package failed."
380

381
382
  if [ ! ${NO_DOCUMENTATION} ]
  then
Mikhail Glushenkov's avatar
Mikhail Glushenkov committed
383
384
    if echo "${PKG}-${VER}" | egrep ${NO_DOCS_PACKAGES_VER_REGEXP} \
        > /dev/null 2>&1
385
386
387
388
389
390
    then
      echo "Skipping documentation for the ${PKG} package."
    else
      ./Setup haddock --with-ghc=${GHC} --with-haddock=${HADDOCK} ${VERBOSE} ||
        die "Documenting the ${PKG} package failed."
    fi
391
  fi
392

393
  ./Setup install ${EXTRA_INSTALL_OPTS} ${VERBOSE} ||
394
     die "Installing the ${PKG} package failed."
395
396
397
398
399
400
401
402
403
404
}

do_pkg () {
  PKG=$1
  VER=$2
  VER_MATCH=$3

  if need_pkg ${PKG} ${VER_MATCH}
  then
    echo
405
    if [ -r "${PKG}-${VER}.tar.gz" ]
406
    then
407
        echo "Using local tarball for ${PKG}-${VER}."
408
409
410
411
    else
        echo "Downloading ${PKG}-${VER}..."
        fetch_pkg ${PKG} ${VER}
    fi
412
413
    unpack_pkg "${PKG}" "${VER}"
    (cd "${PKG}-${VER}" && install_pkg ${PKG} ${VER})
414
415
416
  fi
}

417
418
419
420
421
422
423
424
# If we're bootstrapping from a Git clone, install the local version of Cabal
# instead of downloading one from Hackage.
do_Cabal_pkg () {
    if [ -d "../.git" ]
    then
        if need_pkg "Cabal" ${CABAL_VER_REGEXP}
        then
            echo "Cabal-${CABAL_VER} will be installed from the local Git clone."
425
            (cd ../Cabal && install_pkg ${CABAL_VER} ${CABAL_VER_REGEXP})
426
        else
Mikhail Glushenkov's avatar
Mikhail Glushenkov committed
427
            echo "Cabal is already installed and the version is ok."
428
429
430
431
432
433
434
        fi
    else
        info_pkg "Cabal"        ${CABAL_VER}   ${CABAL_VER_REGEXP}
        do_pkg   "Cabal"        ${CABAL_VER}   ${CABAL_VER_REGEXP}
    fi
}

435
436
437
438
439
440
441
442
443
444
445
446
447
448
# Replicate the flag selection logic for network-uri in the .cabal file.
do_network_uri_pkg () {
  # Refresh installed package list.
  ${GHC_PKG} list --global ${SCOPE_OF_INSTALLATION} > ghc-pkg-stage2.list \
    || die "running '${GHC_PKG} list' failed"

  NETWORK_URI_DUMMY_VER="2.5.0.0"; NETWORK_URI_DUMMY_VER_REGEXP="2\.5\." # < 2.6
  if egrep " network-2\.[6-9]\." ghc-pkg-stage2.list > /dev/null 2>&1
  then
    # Use network >= 2.6 && network-uri >= 2.6
    info_pkg "network-uri" ${NETWORK_URI_VER} ${NETWORK_URI_VER_REGEXP}
    do_pkg   "network-uri" ${NETWORK_URI_VER} ${NETWORK_URI_VER_REGEXP}
  else
    # Use network < 2.6 && network-uri < 2.6
Mikhail Glushenkov's avatar
Mikhail Glushenkov committed
449
450
451
452
    info_pkg "network-uri" ${NETWORK_URI_DUMMY_VER} \
        ${NETWORK_URI_DUMMY_VER_REGEXP}
    do_pkg   "network-uri" ${NETWORK_URI_DUMMY_VER} \
        ${NETWORK_URI_DUMMY_VER_REGEXP}
453
454
455
  fi
}

456
457
458
459
460
461
462
463
464
465
466
# Conditionally install bytestring-builder if bytestring is < 0.10.2.
do_bytestring_builder_pkg () {
  if egrep "bytestring-0\.(9|10\.[0,1])\.?" ghc-pkg-stage2.list > /dev/null 2>&1
  then
      info_pkg "bytestring-builder" ${BYTESTRING_BUILDER_VER} \
               ${BYTESTRING_BUILDER_VER_REGEXP}
      do_pkg   "bytestring-builder" ${BYTESTRING_BUILDER_VER} \
               ${BYTESTRING_BUILDER_VER_REGEXP}
  fi
}

467
468
# Actually do something!

469
info_pkg "deepseq"      ${DEEPSEQ_VER} ${DEEPSEQ_VER_REGEXP}
470
info_pkg "binary"       ${BINARY_VER}  ${BINARY_VER_REGEXP}
471
info_pkg "time"         ${TIME_VER}    ${TIME_VER_REGEXP}
472
473
info_pkg "transformers" ${TRANS_VER}   ${TRANS_VER_REGEXP}
info_pkg "mtl"          ${MTL_VER}     ${MTL_VER_REGEXP}
474
info_pkg "text"         ${TEXT_VER}    ${TEXT_VER_REGEXP}
475
476
info_pkg "parsec"       ${PARSEC_VER}  ${PARSEC_VER_REGEXP}
info_pkg "network"      ${NETWORK_VER} ${NETWORK_VER_REGEXP}
477
info_pkg "old-locale"   ${OLD_LOCALE_VER} ${OLD_LOCALE_VER_REGEXP}
Mikhail Glushenkov's avatar
Mikhail Glushenkov committed
478
info_pkg "old-time"     ${OLD_TIME_VER}   ${OLD_TIME_VER_REGEXP}
479
480
info_pkg "HTTP"         ${HTTP_VER}    ${HTTP_VER_REGEXP}
info_pkg "zlib"         ${ZLIB_VER}    ${ZLIB_VER_REGEXP}
481
info_pkg "random"       ${RANDOM_VER}  ${RANDOM_VER_REGEXP}
482
info_pkg "stm"          ${STM_VER}     ${STM_VER_REGEXP}
Mikhail Glushenkov's avatar
Mikhail Glushenkov committed
483
info_pkg "async"        ${ASYNC_VER}   ${ASYNC_VER_REGEXP}
tuncer's avatar
tuncer committed
484
485
info_pkg "base16-bytestring" ${BASE16_BYTESTRING_VER} \
    ${BASE16_BYTESTRING_VER_REGEXP}
486
487
info_pkg "base64-bytestring" ${BASE64_BYTESTRING_VER} \
    ${BASE64_BYTESTRING_VER_REGEXP}
tuncer's avatar
tuncer committed
488
489
info_pkg "cryptohash-sha256" ${CRYPTOHASH_SHA256_VER} \
    ${CRYPTOHASH_SHA256_VER_REGEXP}
Ryan Scott's avatar
Ryan Scott committed
490
info_pkg "echo"          ${ECHO_VER}          ${ECHO_VER_REGEXP}
491
info_pkg "edit-distance" ${EDIT_DISTANCE_VER} ${EDIT_DISTANCE_VER_REGEXP}
Mikhail Glushenkov's avatar
Mikhail Glushenkov committed
492
493
info_pkg "ed25519"           ${ED25519_VER}          ${ED25519_VER_REGEXP}
info_pkg "tar"               ${TAR_VER}              ${TAR_VER_REGEXP}
494
info_pkg "hashable"          ${HASHABLE_VER}         ${HASHABLE_VER_REGEXP}
Mikhail Glushenkov's avatar
Mikhail Glushenkov committed
495
496
info_pkg "hackage-security"  ${HACKAGE_SECURITY_VER} \
    ${HACKAGE_SECURITY_VER_REGEXP}
497

498
do_pkg   "deepseq"      ${DEEPSEQ_VER} ${DEEPSEQ_VER_REGEXP}
499
do_pkg   "binary"       ${BINARY_VER}  ${BINARY_VER_REGEXP}
500
do_pkg   "time"         ${TIME_VER}    ${TIME_VER_REGEXP}
501
502
503
504

# Install the Cabal library from the local Git clone if possible.
do_Cabal_pkg

505
506
do_pkg   "transformers" ${TRANS_VER}   ${TRANS_VER_REGEXP}
do_pkg   "mtl"          ${MTL_VER}     ${MTL_VER_REGEXP}
507
do_pkg   "text"         ${TEXT_VER}    ${TEXT_VER_REGEXP}
508
do_pkg   "parsec"       ${PARSEC_VER}  ${PARSEC_VER_REGEXP}
509
do_pkg   "network"      ${NETWORK_VER} ${NETWORK_VER_REGEXP}
510
511
512
513

# We conditionally install network-uri, depending on the network version.
do_network_uri_pkg

514
do_pkg   "old-locale"   ${OLD_LOCALE_VER} ${OLD_LOCALE_VER_REGEXP}
Mikhail Glushenkov's avatar
Mikhail Glushenkov committed
515
516
517
518
519
520
do_pkg   "old-time"     ${OLD_TIME_VER}   ${OLD_TIME_VER_REGEXP}
do_pkg   "HTTP"         ${HTTP_VER}       ${HTTP_VER_REGEXP}
do_pkg   "zlib"         ${ZLIB_VER}       ${ZLIB_VER_REGEXP}
do_pkg   "random"       ${RANDOM_VER}     ${RANDOM_VER_REGEXP}
do_pkg   "stm"          ${STM_VER}        ${STM_VER_REGEXP}
do_pkg   "async"        ${ASYNC_VER}      ${ASYNC_VER_REGEXP}
tuncer's avatar
tuncer committed
521
522
do_pkg   "base16-bytestring" ${BASE16_BYTESTRING_VER} \
    ${BASE16_BYTESTRING_VER_REGEXP}
523
524
do_pkg   "base64-bytestring" ${BASE64_BYTESTRING_VER} \
    ${BASE64_BYTESTRING_VER_REGEXP}
tuncer's avatar
tuncer committed
525
526
do_pkg   "cryptohash-sha256" ${CRYPTOHASH_SHA256_VER} \
    ${CRYPTOHASH_SHA256_VER_REGEXP}
Ryan Scott's avatar
Ryan Scott committed
527
do_pkg "echo"          ${ECHO_VER}          ${ECHO_VER_REGEXP}
528
do_pkg "edit-distance" ${EDIT_DISTANCE_VER} ${EDIT_DISTANCE_VER_REGEXP}
Mikhail Glushenkov's avatar
Mikhail Glushenkov committed
529
do_pkg   "ed25519"           ${ED25519_VER}          ${ED25519_VER_REGEXP}
530
531
532
533
534

# We conditionally install bytestring-builder, depending on the bytestring
# version.
do_bytestring_builder_pkg

Mikhail Glushenkov's avatar
Mikhail Glushenkov committed
535
536
537
538
do_pkg   "tar"               ${TAR_VER}              ${TAR_VER_REGEXP}
do_pkg   "hashable"          ${HASHABLE_VER}         ${HASHABLE_VER_REGEXP}
do_pkg   "hackage-security"  ${HACKAGE_SECURITY_VER} \
    ${HACKAGE_SECURITY_VER_REGEXP}
539

540
541
542

install_pkg "cabal-install"

543
544
545
546
547
548
# Use the newly built cabal to turn the prefix/package database into a
# legit cabal sandbox. This works because 'cabal sandbox init' will
# reuse the already existing package database and other files if they
# are in the expected locations.
[ ! -z "$SANDBOX" ] && $SANDBOX/bin/cabal sandbox init --sandbox $SANDBOX

549
550
551
echo
echo "==========================================="
CABAL_BIN="$PREFIX/bin"
552
553
if [ -x "$CABAL_BIN/cabal" ]
then
554
555
556
557
    echo "The 'cabal' program has been installed in $CABAL_BIN/"
    echo "You should either add $CABAL_BIN to your PATH"
    echo "or copy the cabal program to a directory that is on your PATH."
    echo
558
559
560
561
562
    echo "The first thing to do is to get the latest list of packages with:"
    echo "  cabal update"
    echo "This will also create a default config file (if it does not already"
    echo "exist) at $HOME/.cabal/config"
    echo
563
    echo "By default cabal will install programs to $HOME/.cabal/bin"
564
565
    echo "If you do not want to add this directory to your PATH then you can"
    echo "change the setting in the config file, for example you could use:"
566
    echo "symlink-bindir: $HOME/bin"
567
568
else
    echo "Sorry, something went wrong."
569
570
    echo "The 'cabal' executable was not successfully installed into"
    echo "$CABAL_BIN/"
571
fi
Duncan Coutts's avatar
Duncan Coutts committed
572
echo
573
574

rm ghc-pkg.list