Ticket #196: install.sh

File install.sh, 2.3 kB (added by chrisdornan, 3 years ago)

install.sh

Line 
1#!/bin/sh
2
3die () {
4  echo
5  echo "Error:"
6  echo $1 >&2
7  exit 2
8}
9
10[ -e "scripts/config" ] \
11  || die "Please run ./configure first"
12
13. scripts/config
14. scripts/common.sh
15
16install_pkg () {
17  IDX=$1
18  PKG=$2
19
20  cd "packages/${PKG}" 2> /dev/null \
21    || die "The directory for the component ${PKG} is missing"
22
23  [ -x Setup ] || die "The ${PKG}/Setup script does not exist or cannot be run"
24
25
26  if [ -n "${DESTDIR}" ]; then
27
28      ./Setup copy ${VERBOSE} --destdir=${DESTDIR} \
29        || die "Installing the ${PKG} component failed"
30   
31      ./Setup register ${VERBOSE} --gen-pkg-config="${DESTDIR}/load/${IDX}-${PKG}.conf" \
32        || die "Generating the registration information for the package ${PKG} failed"
33       
34  else
35   
36      ./Setup copy ${VERBOSE} \
37        || die "Installing the ${PKG} component failed"
38   
39      ./Setup register ${VERBOSE} --gen-pkg-config="${PKG}.conf" \
40        || die "Generating the registration information for the package ${PKG} failed"
41       
42      if [ -f ${PKG}.conf ]; then
43        if test "${USER_INSTALL}" = "YES"; then
44          GHC_PKG_DB="--user"
45        else
46          GHC_PKG_DB="--global"
47        fi
48        ${GHC_PKG} update ${GHC_PKG_DB} "${PKG}.conf" \
49          || die "Registering the package ${PKG} failed"
50      fi
51   
52      ./Setup copy ${VERBOSE} \
53        || die "Installing the ${PKG} component failed"
54   
55  fi
56
57
58  cd ../..
59}
60
61if [ -f DESTDIR ]; then
62    DESTDIR=$(cat DESTDIR)
63    mkdir -p ${DESTDIR}/load
64fi
65
66# Actually do something!
67i=000
68for pkg in `cat packages/platform.packages`; do
69  if is_pkg_installed "${pkg}"; then
70    true
71  else
72    echo "Installing ${pkg}..."
73    install_pkg ${i} ${pkg}
74  fi
75  i=$(printf "%03d" $(expr ${i} + 1))
76done
77
78echo
79echo '*******************************************************'
80echo '* Installation completed successfully.            '
81echo '*'
82echo '* Programs installed into:                        '
83echo "*   ${prefix}/bin"
84echo '*'
85echo '* Now do "cabal update" to initialize the package list                          '
86echo '*'
87echo '* Additional packages may be found at http://hackage.haskell.org'
88echo '* or via "cabal list <pattern>"'
89echo '*'
90echo '* Use "cabal install <foo>" to install additional packages'
91echo '*'
92echo '*******************************************************'