-
Notifications
You must be signed in to change notification settings - Fork 4
/
build-lens
executable file
·52 lines (45 loc) · 1.14 KB
/
build-lens
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
#!/bin/bash
set -e
# set -x
help_text() {
echo "Usage:
${0##*/} [-h] cabal [-- cabal opts]
Options:
-h, --help
display this help and exit"
}
CABAL=
while [ "$#" -gt 0 ]; do
case "$1" in
-h|--help) help_text; exit;;
--) shift 1; break;;
-*) echo "unknown option: $1" >&2; exit 1;;
*) if [ -z $CABAL ]
then CABAL="$1"
else args+="$1"
fi
shift 1;;
esac
done
if [ -z $CABAL ]; then
echo "No cabal selected" >&2
exit 1
fi
custom_pkgs="distributive comonad semigroupoids lens-head"
for pkg in $custom_pkgs; do
echo "Building $pkg"
CABAL_FLAGS=
case $pkg in
*-head) CABAL_FLAGS+=" --source-repository=head"; pkg="${pkg%-*}";;
*) pkg=$pkg
esac
# use system cabal to get the package, until we are certain that $CABAL
# supports get properly.
cabal get $pkg $CABAL_FLAGS || true
cd $pkg*
# replace the custom build type with the simple build type.
# this is UNSAFE! an not necessarily guaranteed to work!
sed -i.bak -E 's/(build-type:[ ]+)Custom/\1Simple/g' *.cabal
$CABAL install "$@"
cd ..
done