This repository has been archived by the owner on Mar 10, 2023. It is now read-only.
forked from glondu/belenios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
opam-bootstrap.sh
executable file
·114 lines (93 loc) · 3.46 KB
/
opam-bootstrap.sh
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/sh
set -e
BELENIOS_SRC="${BELENIOS_SRC:-$PWD}"
export BELENIOS_SYSROOT="${BELENIOS_SYSROOT:-$HOME/.belenios}"
export OPAMROOT="$BELENIOS_SYSROOT/opam"
export XDG_CACHE_HOME="$BELENIOS_SYSROOT/cache"
if [ -e "$BELENIOS_SYSROOT" ]; then
echo "$BELENIOS_SYSROOT already exists."
echo "Please remove it or set BELENIOS_SYSROOT to a non-existent directory first."
exit 1
fi
mkdir -p "$BELENIOS_SYSROOT"
if [ -z "$BELENIOS_USE_SYSTEM_OPAM" ]; then
# Download and install opam
# Check that Dune is not installed
# cf. https://github.com/ocaml/opam/issues/3987
if command -v dune >/dev/null; then
echo "Please uninstall Dune first, or remove it from your PATH."
exit 1
fi
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
mkdir -p "$BELENIOS_SYSROOT/bootstrap/src"
cd "$BELENIOS_SYSROOT/bootstrap/src"
wget https://github.com/ocaml/opam/releases/download/2.0.7/opam-full-2.0.7.tar.gz
if which sha256sum >/dev/null; then
sha256sum --check <<EOF
9c0dac1094ed624158fff13000cdfa8edbc96798d32b9fab40b0b5330f9490a2 opam-full-2.0.7.tar.gz
EOF
else
echo "WARNING: sha256sum was not found, checking tarballs is impossible!"
fi
export PATH="$BELENIOS_SYSROOT/bootstrap/bin:$PATH"
echo
echo "=-=-= Compilation and installation of OPAM =-=-="
echo
cd "$BELENIOS_SYSROOT/bootstrap/src"
tar -xzf opam-full-2.0.7.tar.gz
cd opam-full-2.0.7
cp $BELENIOS_SRC/ext/opam/bootstrap-ocaml.sh $BELENIOS_SYSROOT/bootstrap/src/opam-full-2.0.7/shell
make cold CONFIGURE_ARGS="--prefix $BELENIOS_SYSROOT/bootstrap"
make cold-install LIBINSTALL_DIR="$BELENIOS_SYSROOT/bootstrap/lib/ocaml"
cat > $BELENIOS_SYSROOT/env.sh <<EOF
PATH="$BELENIOS_SYSROOT/bootstrap/bin:\$PATH"; export PATH;
EOF
fi
echo
echo "=-=-= Generation of env.sh =-=-="
echo
cat >> $BELENIOS_SYSROOT/env.sh <<EOF
OPAMROOT=$OPAMROOT; export OPAMROOT;
XDG_CACHE_HOME=$XDG_CACHE_HOME; export XDG_CACHE_HOME;
eval \$(opam env)
EOF
ln -sf $BELENIOS_SYSROOT/env.sh $BELENIOS_SRC/env.sh
echo
echo "=-=-= Initialization of OPAM root =-=-="
echo
cd "$BELENIOS_SYSROOT"
git clone https://github.com/ocaml/opam-repository.git
cd opam-repository
git reset --hard ea0d9f1d30e13bb1db009b79a39bbe7a95b0217e
opam init $BELENIOS_OPAM_INIT_ARGS --bare --no-setup -k git "$BELENIOS_SYSROOT/opam-repository"
opam switch create 4.11.1 ocaml-base-compiler.4.11.1 --jobs=1
eval $(opam env)
echo
echo "=-=-= Installation of Belenios build-dependencies =-=-="
echo
opam install --yes dune atdgen zarith cryptokit calendar cmdliner sqlite3 csv eliom gettext-camomile
echo
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
echo
echo "Belenios build-dependencies have been successfully compiled and installed"
echo "to $BELENIOS_SYSROOT. The directory"
echo " $BELENIOS_SYSROOT/bootstrap/src"
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:"
echo " source $BELENIOS_SRC/env.sh"
echo "Note that if you use a Bourne-incompatible shell (e.g. tcsh), you'll have"
echo "to adapt env.sh to your shell."
echo
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
echo