aboutsummaryrefslogtreecommitdiff
path: root/scripts/ci/steps/25-deps.sh
blob: 3a0cb210aba92d7bbb74c3363ac67d6e71204fa8 (plain) (blame)
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
verlte() {
    [  "$1" = "$(printf '%s\n%s\n' "$1" "$2" | sort -V | head -n1)" ]
}

mkdir -p "$build_dir/bin"


if command -v stack; then
	stack_ver=$(stack --numeric-version)
else
	stack_ver=0
fi

ghc_ver=$(ghc --numeric-version)

# we need at least 1.9.4 for `stack ide packages --cabal-files --stdout`
if verlte "$stack_ver" 1.9.3 &&
   verlte 8.2.2 "$ghc_ver"
then
	PATH="$build_dir/bin:$PATH"
	export PATH

	cabal v2-install \
	      --symlink-bindir="$build_dir/bin" \
	      --constraint "network < 3" \
	      --package-env=/dev/null \
	      hpack || exit 1

	stack_dir="$(mktemp --tmpdir -d "cabal-helper.stacksrcXXXXXXXXX")"

	git clone \
	    --depth=1 \
	    --branch=stable \
	    https://github.com/commercialhaskell/stack "$stack_dir"  || exit 1

	(
		cd "$stack_dir"
		hpack
		cabal v2-install \
		      --symlink-bindir="$build_dir/bin" \
		      --constraint "Cabal == 2.4.0.1" \
		      --constraint "network < 3" . \
		      --package-env=/dev/null || exit 1
        ) || exit 1
fi