opam-bootstrap.sh 2.66 KB
Newer Older
1 2 3 4
#!/bin/sh

set -e

Stephane Glondu's avatar
Stephane Glondu committed
5 6
BELENIOS_SRC="${BELENIOS_SRC:-$PWD}"

7 8 9 10 11 12
# 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

13 14 15 16 17 18 19 20 21 22 23 24
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

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

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

34
mkdir -p "$BELENIOS_SYSROOT/bootstrap/src"
35

36
cd "$BELENIOS_SYSROOT/bootstrap/src"
37
wget https://github.com/ocaml/opam/releases/download/2.0.0/opam-full-2.0.0.tar.gz
38 39

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

47
export PATH="$BELENIOS_SYSROOT/bootstrap/bin:$PATH"
48

49 50 51 52
echo
echo "=-=-= Compilation and installation of OPAM =-=-="
echo
cd "$BELENIOS_SYSROOT/bootstrap/src"
53 54 55 56
tar -xzf opam-full-2.0.0.tar.gz
cd opam-full-2.0.0
make cold CONFIGURE_ARGS="--prefix $BELENIOS_SYSROOT/bootstrap"
make cold-install LIBINSTALL_DIR="$BELENIOS_SYSROOT/bootstrap/lib/ocaml"
57

Stephane Glondu's avatar
Stephane Glondu committed
58 59 60 61 62 63
echo
echo "=-=-= Generation of env.sh =-=-="
echo
cat > $BELENIOS_SRC/env.sh <<EOF
PATH="$BELENIOS_SYSROOT/bootstrap/bin:\$PATH"; export PATH;
OPAMROOT=$OPAMROOT; export OPAMROOT;
64
eval \$(opam env)
Stephane Glondu's avatar
Stephane Glondu committed
65 66
EOF

67 68 69
echo
echo "=-=-= Initialization of OPAM root =-=-="
echo
70 71 72
opam init --bare --no-setup
opam switch create 4.06.1
eval $(opam env)
73 74 75 76

echo
echo "=-=-= Installation of Belenios build-dependencies =-=-="
echo
77
opam install --yes dune=1.6.3 atdgen zarith cryptokit uuidm calendar cmdliner sqlite3 ssl=0.5.7 js_of_ocaml=3.3.0 eliom=6.3.0 csv
78 79 80 81 82

echo
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
echo
echo "Belenios build-dependencies have been successfully compiled and installed"
83 84
echo "to $BELENIOS_SYSROOT. The directory"
echo "  $BELENIOS_SYSROOT/bootstrap/src"
85 86 87 88
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:"
Stephane Glondu's avatar
Stephane Glondu committed
89
echo "  source $BELENIOS_SRC/env.sh"
90 91
echo "Note that if you use a Bourne-incompatible shell (e.g. tcsh), you'll have"
echo "to adapt env.sh to your shell."
92 93
echo
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
94
echo