-
Notifications
You must be signed in to change notification settings - Fork 10
/
.travis-ocaml.sh
327 lines (289 loc) · 11.2 KB
/
.travis-ocaml.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
## basic OCaml and opam installation
full_apt_version () {
package=$1
version=$2
case "${version}" in
latest) echo -n "${package}" ;;
*) echo -n "${package}="
apt-cache show "$package" \
| sed -n "s/^Version: \(${version}\)/\1/p" \
| head -1
esac
}
set -uex
if [ "$TRAVIS_OS_NAME" = freebsd -a "${OPAM_VERSION+x}" = x ]; then
echo OPAM_VERSION not permitted for FreeBSD targets
exit 1
fi
OCAML_VERSION=${OCAML_VERSION:-latest}
SYS_OCAML_VERSION=4.05
# Default opam is the latest release of opam 2
OPAM_VERSION=${OPAM_VERSION:-2}
OPAM_INIT=${OPAM_INIT:-true}
OCAML_BETA=${OCAML_BETA:-disable}
OPAM_LATEST_RELEASE=2.0.7
case ${TRAVIS_CPU_ARCH:-amd64} in
amd64|notset) OPAM_ARCH=x86_64;;
arm64) OPAM_ARCH=arm64;;
*) echo "'$TRAVIS_CPU_ARCH' architecture not currently supported"; exit 1;;
esac
case $OPAM_VERSION in
2|2.0) OPAM_VERSION=$OPAM_LATEST_RELEASE;;
1.*) echo "Opam version '$OPAM_VERSION' is not supported"; exit 1;;
esac
if [ "$TRAVIS_OS_NAME" = "osx" ] ; then
brew update &> /dev/null
BREW_OPAM_VERSION=$(brew info opam --json=v1 | sed -e 's/.*"versions":{[^}]*"stable":"//' -e 's/".*//')
if [ "$OPAM_VERSION" != "$BREW_OPAM_VERSION" ] ; then
set +x
echo -e "[\e[0;31mWARNING\e[0m] Ignored OPAM_VERSION=$OPAM_VERSION; interpreted as \"$BREW_OPAM_VERSION\"" >&2
echo -e "[\e[0;31mWARNING\e[0m] opam 2 is installed via Homebrew" >&2
set -x
fi
OPAM_VERSION="$BREW_OPAM_VERSION"
fi
if [ "$OPAM_VERSION" != "$OPAM_LATEST_RELEASE" ] ; then
set +x
echo -e "[\e[0;31mWARNING\e[0m] Out-of-date opam $OPAM_VERSION requested" >&2
echo -e "[\e[0;31mWARNING\e[0m] Latest release is $OPAM_LATEST_RELEASE" >&2
set -x
fi
if [ "${INSTALL_LOCAL+x}" = x ] ; then
if [ "$TRAVIS_OS_NAME" = osx -o "$TRAVIS_OS_NAME" = freebsd ] ; then
echo INSTALL_LOCAL not permitted for macOS and FreeBSD targets
exit 1
fi
if [ "${OPAM_SWITCH:=ocaml-system}" != ocaml-system ] ; then
echo "INSTALL_LOCAL requires OPAM_SWITCH=ocaml-system (or unset/null)"
exit 1
fi
fi
# the base opam repository to use for bootstrapping and catch-all namespace
BASE_REMOTE=${BASE_REMOTE:-git://github.com/ocaml/opam-repository}
# whether we need a new gcc and binutils
UPDATE_GCC_BINUTILS=${UPDATE_GCC_BINUTILS:-"0"}
# Install Xenial remotes
UBUNTU_XENIAL=${UBUNTU_XENIAL:-"0"}
# Install XQuartz on OSX
INSTALL_XQUARTZ=${INSTALL_XQUARTZ:-"false"}
APT_UPDATED=0
add_ppa () {
if [ "$TRAVIS_OS_NAME" = "linux" ] ; then
APT_UPDATED=0
sudo add-apt-repository --yes ppa:$1
fi
}
apt_install () {
if [ "$TRAVIS_OS_NAME" = "linux" ] ; then
if [ "$APT_UPDATED" -eq 0 ] ; then
APT_UPDATED=1
sudo apt-get update -qq
fi
sudo apt-get install --no-install-recommends -y "$@"
fi
}
install_ocaml () {
apt_install \
ocaml ocaml-base ocaml-native-compilers ocaml-compiler-libs \
ocaml-interp ocaml-base-nox ocaml-nox
}
install_opam2 () {
case $TRAVIS_OS_NAME in
freebsd)
# Opam does not have any ready to use binaries for FreeBSD
sudo pkg install -qy ocaml-opam ;;
linux)
case $TRAVIS_DIST in
precise|trusty|xenial)
# Required for bubblewrap (supports arm64 & amd64)
add_ppa avsm/ppa ;;
esac
if [ "${INSTALL_LOCAL:=0}" = 0 ] ; then
install_ocaml
fi
apt_install bubblewrap
sudo wget https://github.com/ocaml/opam/releases/download/$OPAM_VERSION/opam-$OPAM_VERSION-$OPAM_ARCH-linux -O /usr/local/bin/opam
sudo chmod +x /usr/local/bin/opam ;;
osx)
if [ "${INSTALL_LOCAL:=0}" = 0 ] ; then
brew install ocaml
fi
sudo curl -fsSL https://github.com/ocaml/opam/releases/download/$OPAM_VERSION/opam-$OPAM_VERSION-$OPAM_ARCH-macos -o /usr/local/bin/opam
sudo chmod +x /usr/local/bin/opam ;;
esac
}
install_ppa () {
add_ppa $1
if [ "${INSTALL_LOCAL:=0}" = 0 ] ; then
sudo apt-get -qq update
APT_UPDATED=1
apt_install \
"$(full_apt_version ocaml $SYS_OCAML_VERSION)" \
"$(full_apt_version ocaml-base $SYS_OCAML_VERSION)" \
"$(full_apt_version ocaml-native-compilers $SYS_OCAML_VERSION)" \
"$(full_apt_version ocaml-compiler-libs $SYS_OCAML_VERSION)" \
"$(full_apt_version ocaml-interp $SYS_OCAML_VERSION)" \
"$(full_apt_version ocaml-base-nox $SYS_OCAML_VERSION)" \
"$(full_apt_version ocaml-nox $SYS_OCAML_VERSION)"
fi
apt_install opam
}
install_on_freebsd () {
case "$OCAML_VERSION" in
3.12) OCAML_FULL_VERSION=3.12.1; install_opam2 ;;
4.00) OCAML_FULL_VERSION=4.00.1; install_opam2 ;;
4.01) OCAML_FULL_VERSION=4.01.0; install_opam2 ;;
4.02) OCAML_FULL_VERSION=4.02.3; install_opam2 ;;
4.03) OCAML_FULL_VERSION=4.03.0; install_opam2 ;;
4.04) OCAML_FULL_VERSION=4.04.2; install_opam2 ;;
4.05) OCAML_FULL_VERSION=4.05.0; install_opam2 ;;
4.06) OCAML_FULL_VERSION=4.06.1; install_opam2 ;;
4.07) OCAML_FULL_VERSION=4.07.1; install_opam2 ;;
4.08) OCAML_FULL_VERSION=4.08.1; install_opam2 ;;
4.09) OCAML_FULL_VERSION=4.09.1; install_opam2 ;;
4.10) OCAML_FULL_VERSION=4.10.1; install_opam2 ;;
4.11) OCAML_FULL_VERSION=4.11.0; install_opam2 ;;
4.12) OCAML_FULL_VERSION=4.12.0+trunk; OCAML_BETA=enable; install_opam2 ;;
*)
if [ "$OCAML_BETA" != "enable" ]; then
echo "Unknown OCAML_VERSION=$OCAML_VERSION"
echo "(An unset OCAML_VERSION used to default to \"latest\", but you must now specify it."
echo "Try something like \"OCAML_VERSION=3.12\", \"OCAML_VERSION=4.10\", or see README-travis.md at https://github.com/ocaml/ocaml-ci-scripts )"
exit 1
fi
OCAML_FULL_VERSION="${OCAML_VERSION}"
install_opam2 ;;
esac
}
install_on_linux () {
case "$OCAML_VERSION" in
3.12) OCAML_FULL_VERSION=3.12.1; install_opam2 ;;
4.00) OCAML_FULL_VERSION=4.00.1; install_opam2 ;;
4.01) OCAML_FULL_VERSION=4.01.0; install_opam2 ;;
4.02) OCAML_FULL_VERSION=4.02.3; install_opam2 ;;
4.03) OCAML_FULL_VERSION=4.03.0; install_opam2 ;;
4.04) OCAML_FULL_VERSION=4.04.2; install_opam2 ;;
4.05) OCAML_FULL_VERSION=4.05.0; install_opam2 ;;
4.06) OCAML_FULL_VERSION=4.06.1; install_opam2 ;;
4.07) OCAML_FULL_VERSION=4.07.1; install_opam2 ;;
4.08) OCAML_FULL_VERSION=4.08.1; install_opam2 ;;
4.09) OCAML_FULL_VERSION=4.09.1; install_opam2 ;;
4.10) OCAML_FULL_VERSION=4.10.1; install_opam2 ;;
4.11) OCAML_FULL_VERSION=4.11.0; install_opam2 ;;
4.12) OCAML_FULL_VERSION=4.12.0+trunk; OCAML_BETA=enable; install_opam2 ;;
*)
if [ "$OCAML_BETA" != "enable" ]; then
echo "Unknown OCAML_VERSION=$OCAML_VERSION"
echo "(An unset OCAML_VERSION used to default to \"latest\", but you must now specify it."
echo "Try something like \"OCAML_VERSION=3.12\", \"OCAML_VERSION=4.10\", or see README-travis.md at https://github.com/ocaml/ocaml-ci-scripts )"
exit 1
fi
OCAML_FULL_VERSION="${OCAML_VERSION}"
install_opam2 ;;
esac
XENIAL="deb mirror://mirrors.ubuntu.com/mirrors.txt xenial main restricted universe"
if [ "$UPDATE_GCC_BINUTILS" != "0" ] ; then
echo "installing a recent gcc and binutils (mainly to get mirage-entropy-xen working!)"
sudo add-apt-repository "${XENIAL}"
sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test
sudo apt-get -qq update
sudo apt-get install -y gcc-5
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 90
sudo add-apt-repository -r "${XENIAL}"
fi
if [ "$UBUNTU_XENIAL" != "0" ] ; then
echo "Adding Ubuntu Xenial mirrors"
sudo add-apt-repository "${XENIAL}"
sudo apt-get -qq update
APT_UPDATED=1
fi
if [ "${INSTALL_LOCAL:=0}" != 0 ] ; then
( set +x; echo -en "travis_fold:start:build.ocaml\r" ) 2>/dev/null
echo "Building a local OCaml; this may take a few minutes..."
wget "http://caml.inria.fr/pub/distrib/ocaml-${OCAML_FULL_VERSION%.*}/ocaml-$OCAML_FULL_VERSION.tar.gz"
tar -xzf "ocaml-$OCAML_FULL_VERSION.tar.gz"
cd "ocaml-$OCAML_FULL_VERSION"
./configure -prefix /usr/local ${OCAML_CONFIGURE_ARGS:=--with-debug-runtime}
make world.opt
sudo make install
cd ..
rm -rf "ocaml-$OCAML_FULL_VERSION"
( set +x; echo -en "travis_fold:end:build.ocaml\r" ) 2>/dev/null
fi
}
install_on_osx () {
case $INSTALL_XQUARTZ in
true)
curl -OL "http://xquartz.macosforge.org/downloads/SL/XQuartz-2.7.6.dmg"
sudo hdiutil attach XQuartz-2.7.6.dmg
sudo installer -verbose -pkg /Volumes/XQuartz-2.7.6/XQuartz.pkg -target /
;;
esac
case "$OCAML_VERSION" in
3.12) OCAML_FULL_VERSION=3.12.1; install_opam2 ;;
4.00) OCAML_FULL_VERSION=4.00.1; install_opam2 ;;
4.01) OCAML_FULL_VERSION=4.01.0; install_opam2 ;;
4.02) OCAML_FULL_VERSION=4.02.3; install_opam2 ;;
4.03) OCAML_FULL_VERSION=4.03.0; install_opam2 ;;
4.04) OCAML_FULL_VERSION=4.04.2; install_opam2 ;;
4.05) OCAML_FULL_VERSION=4.05.0; install_opam2 ;;
4.06) OCAML_FULL_VERSION=4.06.1; install_opam2 ;;
4.07) OCAML_FULL_VERSION=4.07.1; install_opam2 ;;
4.08) OCAML_FULL_VERSION=4.08.1; install_opam2 ;;
4.09) OCAML_FULL_VERSION=4.09.0;
OPAM_SWITCH=${OPAM_SWITCH:-ocaml-system};
brew install ocaml;
install_opam2 ;;
4.10) OCAML_FULL_VERSION=4.10.1; install_opam2 ;;
4.11) OCAML_FULL_VERSION=4.11.0; install_opam2 ;;
4.12) OCAML_FULL_VERSION=4.12.0+trunk; OCAML_BETA=enable; install_opam2 ;;
*)
if [ "$OCAML_BETA" != "enable" ]; then
echo "Unknown OCAML_VERSION=$OCAML_VERSION"
exit 1
fi
OCAML_FULL_VERSION="${OCAML_VERSION}"
install_opam2 ;;
esac
}
case $TRAVIS_OS_NAME in
freebsd) install_on_freebsd ;;
osx) install_on_osx ;;
linux) install_on_linux ;;
esac
ocaml_package=ocaml-base-compiler
if [ "$OCAML_BETA" = "enable" ]; then
ocaml_package=ocaml-variants
fi
OPAM_SWITCH=${OPAM_SWITCH:-$ocaml_package.$OCAML_FULL_VERSION}
PACKAGES="$OPAM_SWITCH"
case "$OCAML_VERSION" in
3.12|4.00|4.01|4.02|4.03|4.04|4.05|4.06)
PACKAGES="$PACKAGES,ocaml-secondary-compiler";;
esac
export OPAMYES=1
case $OPAM_INIT in
true)
opam init -a --bare "$BASE_REMOTE"
opam_repo_selection=
if [ "$OCAML_BETA" = "enable" ]; then
opam repo add --dont-select beta git://github.com/ocaml/ocaml-beta-repository.git
opam_repo_selection="--repo=default,beta"
fi
opam switch "$OPAM_SWITCH" || opam switch create $opam_repo_selection "$OPAM_SWITCH" --packages="$PACKAGES"
eval $(opam config env)
;;
esac
echo OCAML_VERSION=$OCAML_VERSION > .travis-ocaml.env
echo OPAM_SWITCH=$OPAM_SWITCH >> .travis-ocaml.env
# Temporary fix an issue with opam-depext < 1.1.3 on FreeBSD.
# See https://github.com/ocaml/opam-depext/pull/123
echo export ASSUME_ALWAYS_YES=YES >> .travis-ocaml.env
if [ -x "$(command -v ocaml)" ]; then
# "|| true" is a temp fix for OCaml 4.12: https://github.com/ocaml/ocaml/pull/9798
ocaml -version || true
else
echo "OCaml is not yet installed"
fi
opam --version
opam --git-version