summaryrefslogtreecommitdiff
path: root/standalone/android/install-haskell-packages
blob: 376ad165fb14b80d8fdcba7d65d6f2437b5345a9 (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
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
#!/bin/bash
# Bootstraps from an empty cabal to all the necessary haskell packages
# being installed, with the necessary patches to work on Android.
#
# You should install ghc-android first.
#
# 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/android
fi

cabalopts="$@"

setupcabal () {
	cabal update

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

	# The android build chroot has recent versions of alex and happy
	# installed here.
	PATH=$HOME/bin:$PATH
	export PATH
}

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 $pkg
	else
		cabal unpack $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"
	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

	ln -sf ../../cabal.config
	cabal install "$@" "$cabalopts"
	rm -f cabal.config

	rm -rf $pkg*
	cd ..
}

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

install_pkgs () {
	rm -rf tmp
	mkdir tmp
	cd tmp
	patched network
	patched unix-time
	patched lifted-base
	patched zlib
	patched MissingH
	patched distributive
	patched comonad
	patched iproute
	patched primitive
	patched socks
	patched entropy
	patched vector
	patched stm-chans
	patched persistent
	patched profunctors
	patched skein
	patched lens
	patched certificate
	patched x509-system
	patched persistent-template
	patched system-filepath
	patched optparse-applicative
	patched wai-app-static
	patched shakespeare
	patched shakespeare-css
	patched shakespeare-js
	patched yesod-routes
	patched yesod-core
	patched yesod-persistent
	patched yesod-form
	patched crypto-numbers
	patched yesod-auth
	patched yesod
	patched shakespeare-text
	patched process-conduit
	patched DAV
	patched yesod-static
	patched uuid
	patched dns
	patched gnutls
	patched unbounded-delays

	cd ..

	installgitannexdeps -fAndroid -f-Pairing
}

echo
echo
echo native build
echo
setupcabal
installgitannexdeps

echo 
echo
echo cross build
echo
PATH=$HOME/.ghc/$(cat abiversion)/bin:$HOME/.ghc/$(cat abiversion)/arm-linux-androideabi/bin:$PATH
setupcabal
install_pkgs