forked from matterhorn-chat/matterhorn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·79 lines (62 loc) · 1.66 KB
/
install.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
#!/usr/bin/env bash
# This script builds and installs this package and its dependencies in a
# sandbox. This script is also suitable for rebuilds during development.
#
# Note that this uses standard cabal commands rather than 'new-build'.
set -e
HERE=$(cd `dirname $0`; pwd)
# Where dependency repos get cloned
DEPS=$HERE/deps
# Where we'll put the package sandbox
SANDBOX=$HERE/.cabal-sandbox
# The source for the mattermost API package
MATTERMOST_API_REPO=https://github.com/matterhorn-chat/mattermost-api.git
# Where to clone the mattermost API package
MATTERMOST_DIR=$DEPS/mattermost-api
# Whether this is a first-time install (see below)
FIRST_TIME=0
function init {
if [ ! -d "$HERE/.cabal-sandbox" ]
then
FIRST_TIME=1
cabal sandbox --sandbox=$SANDBOX init
fi
}
# clone_or_update_repo $REPO_URL $DEST_DIR
#
# Clones if absent; pulls otherwise.
function clone_or_update_repo {
mkdir -p $DEPS
local repo=$1
local destdir=$2
if [ ! -d "$destdir" ]
then
git clone $repo $destdir
else
cd $destdir && git pull
fi
if [ "$FIRST_TIME" == "1" ]
then
cd $HERE && \
cabal sandbox --sandbox=$SANDBOX add-source $destdir
fi
}
function install_deps {
clone_or_update_repo $MATTERMOST_API_REPO $MATTERMOST_DIR
}
function build {
cd $HERE
if [ $FIRST_TIME -eq 1 ]
then
# For first-time builds, get dependencies installed as fast as
# possible.
cabal install -j
else
# But for subsequent builds, build with -j1 to avoid suppression
# of useful (e.g. warning) output.
cabal install -j1
fi
}
init
install_deps
build