opam-bootstrap.sh 2.61 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
#!/bin/sh

set -e

# Check that OCamlDuce is not installed
if which ocamlduce >/dev/null; then
    echo "Please uninstall OCamlDuce first, or remove it from your PATH."
    exit 1
fi

11 12 13 14 15 16 17 18 19 20 21 22
echo
echo "=-=-= Download and check tarballs =-=-="
echo

# Look for wget or curl
if which wget >/dev/null; then
    echo "wget was found and will be used"
elif which curl >/dev/null; then
    wget () { curl "$1" > "${1##*/}"; }
    echo "curl was found and will be used"
fi

23 24
export BELENIOS_SYSROOT="${BELENIOS_SYSROOT:-$HOME/.belenios}"
export OPAMROOT="$BELENIOS_SYSROOT/opam"
25

26 27 28
if [ -e "$BELENIOS_SYSROOT" ]; then
    echo "$BELENIOS_SYSROOT already exists."
    echo "Please remove it or set BELENIOS_SYSROOT to a non-existent directory first."
29 30 31
    exit 1
fi

32
mkdir -p "$BELENIOS_SYSROOT/bootstrap/src"
33

34
cd "$BELENIOS_SYSROOT/bootstrap/src"
35 36
wget http://caml.inria.fr/pub/distrib/ocaml-4.01/ocaml-4.01.0.tar.gz
wget http://www.ocamlpro.com/pub/opam-full-1.1.0.tar.gz
37 38

if which sha256sum >/dev/null; then
39 40 41 42
sha256sum --check <<EOF
ea1751deff454f5c738d10d8a0ad135afee0852d391cf95766b726c0faf7cfdb  ocaml-4.01.0.tar.gz
c0ab5e85b6cd26e533a40686e08aea173387d15bead817026f5b08f264642583  opam-full-1.1.0.tar.gz
EOF
43 44 45
else
    echo "WARNING: sha256sum was not found, checking tarballs is impossible!"
fi
46

47 48 49 50
echo
echo "=-=-= Compilation and installation of OCaml =-=-="
echo
cd "$BELENIOS_SYSROOT/bootstrap/src"
51 52
tar -xzf ocaml-4.01.0.tar.gz
cd ocaml-4.01.0
53
./configure -prefix "$BELENIOS_SYSROOT/bootstrap"
54 55 56 57
make world
make opt
make opt.opt
make install
58
export PATH="$BELENIOS_SYSROOT/bootstrap/bin:$PATH"
59

60 61 62 63
echo
echo "=-=-= Compilation and installation of OPAM =-=-="
echo
cd "$BELENIOS_SYSROOT/bootstrap/src"
64 65
tar -xzf opam-full-1.1.0.tar.gz
cd opam-full-1.1.0
66
./configure -prefix "$BELENIOS_SYSROOT/bootstrap"
67 68 69
make
make install

70 71 72
echo
echo "=-=-= Initialization of OPAM root =-=-="
echo
73 74
opam init --no-setup
eval `opam config env`
75 76 77 78

echo
echo "=-=-= Installation of Belenios build-dependencies =-=-="
echo
79 80 81 82 83 84
opam install --yes atdgen zarith cryptokit uuidm calendar eliom csv

echo
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
echo
echo "Belenios build-dependencies have been successfully compiled and installed"
85 86
echo "to $BELENIOS_SYSROOT. The directory"
echo "  $BELENIOS_SYSROOT/bootstrap/src"
87 88 89 90
echo "can be safely removed now."
echo
echo "Next, you need to run the following commands or add them to your ~/.bashrc"
echo "or equivalent:"
91
echo "  export PATH=$BELENIOS_SYSROOT/bootstrap/bin:\$PATH"
92 93 94 95
echo "  export OPAMROOT=$OPAMROOT"
echo "  eval \`opam config env\`"
echo
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
96
echo