summaryrefslogtreecommitdiff
path: root/standalone/linux/install-haskell-packages
blob: 4361a2f931ddabf8b2ffac75fd55b75d138617fb (plain)
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
#!/bin/bash
# Bootstraps from an empty cabal (plus apt-get build-dep git-annex)
# to all the necessary haskell packages being installed.
# Some packages are patched for wider portability.
#
# The cabal.config is used to pin the haskell packages to the last
# versions that have been gotten working. To update, delete the
# cabal.config, run this script with an empty cabal and fix up the broken
# patches, and then use cabal freeze to generate a new cabal.config.

set -e

if [ ! -d haskell-patches ]; then
	cd standalone/linux
fi

cabalopts="$@"

cabalinstall () {
	echo cabal install -j1 "$@" "$cabalopts"
	eval cabal install -j1 "$@" "$cabalopts"
}

patched () {
	pkg=$1
	ver=$2
        if [ -z "$ver" ]; then
                ver="$(grep " $pkg " ../cabal.config | cut -d= -f 3 | sed 's/,$//')"
        fi
        if [ -z "$ver" ]; then
                cabal unpack --pristine $pkg
        else
                cabal unpack --pristine $pkg-$ver
        fi
	cd $pkg*
	git init
	git config user.name dummy
	git config user.email dummy@example.com
	git add .
	git commit -m "pre-patched state of $pkg"
	ln -sf ../../cabal.config
	for patch in ../../haskell-patches/${pkg}_* ../../../no-th/haskell-patches/${pkg}_*; do
		if [ -e "$patch" ]; then
			echo trying $patch
			if ! patch -p1 < $patch; then
				echo "failed to apply $patch"
				echo "please resolve this, replace the patch with a new version, and exit the subshell to continue"
				$SHELL
			fi
		fi
	done
	cabalinstall
	rm -f cabal.config
	cd ..
	rm -rf $pkg*
}

installgitannexdeps () {
	pushd ../..
	ln -sf standalone/linux/cabal.config
	echo cabal install --only-dependencies "$@"
	cabal install -j1 --only-dependencies "$@"
	rm -f cabal.config
	popd
}

install_pkgs () {
	rm -rf tmp
	mkdir tmp
	cd tmp

	patched network

	cd ..

	installgitannexdeps
}

cabal update

# Some packages fail to install in a non unicode locale.
LANG=C.UTF-8
export LANG

install_pkgs