forked from play-co/devkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·135 lines (107 loc) · 2.71 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
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
#!/usr/bin/env bash
BASIL_ROOT=$(cd -P $(dirname "$0") && pwd)
if [[ -z "$BASH_VERSION" ]]; then
echo "Error: GC SDK install script should be run in bash."
exit 1
fi
echo $'\033[1;32m-{{{>\033[0m Game Closure SDK'
echo 'Installing...'
function abs_path() {
echo "$1" | sed "s@^./@$PWD@"
}
function error () {
echo -e "\033[1;31mError:\033[0m $@"
}
function warn () {
echo -e "\033[1;33mWarning:\033[0m $@"
}
if ! which git > /dev/null; then
error "GC SDK requires git to install. (http://git-scm.com)"
exit 1
fi
if ! which node > /dev/null; then
error "GC SDK requires node 0.8+ to install. (http://nodejs.org)"
exit 1
fi
if ! which npm > /dev/null; then
error "GC SDK requires npm to install. (http://npmjs.org)"
exit 1
fi
#
# Permission checks
#
#
if [[ ! -d "$HOME/.npm" ]]; then
mkdir "$HOME/.npm"
fi
if [[ ! -w "$HOME/.npm" ]]; then
error "GC SDK install requires write permission to $HOME/.npm"
echo "Try: sudo chown -R $USER $HOME/.npm"
exit 1
fi
#
# Install
#
BASIL_PATH=$(which basil)
if [[ -L "$BASIL_PATH" ]] ; then
echo "Removing old basil symlink."
rm "$BASIL_PATH"
fi
echo -e "\nInitializing GC SDK libraries ..."
# setup for gc internal repositories
remoteurl=`git config --get remote.origin.url`
PRIV_SUBMODS=false && [[ "$remoteurl" == *devkit-priv* ]] && PRIV_SUBMODS=true
if $PRIV_SUBMODS; then
echo "Using private submodules..."
cp .gitmodules-priv .gitmodules
fi
if ! git submodule sync; then
error "Unable to sync git submodules"
exit 1
fi
git submodule update --init --recursive
if $PRIV_SUBMODS; then
git checkout .gitmodules
fi
if [ ! -w "/usr/local" ]; then
error "You need write permissions to /usr/local"
echo "Try running: sudo chown -R \$USER /usr/local"
exit 1
fi
if ! npm link --local; then
error "Linking npm to local"
echo "Try running: sudo chown -R \$USER /usr/local"
exit 1
fi
#
# Check if basil on path
#
which basil
if [[ $? != 0 ]]; then
if [[ ! -w /usr/local/bin ]]; then
error "GC SDK install requires write permission to /usr/local/bin"
echo "Try: sudo chown -R $(whoami) /usr/local/bin"
exit 1
fi
if [[ -e /usr/local/share/npm/bin/basil ]]; then
warn "You should add /usr/local/share/npm/bin/ to your PATH"
ln -sf $(readlink /usr/local/share/npm/bin/basil) /usr/local/bin/basil
else
warn "We could not find basil in your path. Attempting a manual link..."
BASIL_PATH=$(abs_path $(dirname $0){/bin/basil})
echo $BASIL_PATH
if [[ ! -e $BASIL_PATH ]]; then
error 'Could not find basil runtime.'
exit 1
fi
ln -sf $BASIL_PATH /usr/local/bin/basil
fi
fi
echo
node src/dependencyCheck.js
echo
if [[ $? != 0 ]]; then
error 'Could not complete installation'
else
echo 'Successfully installed. Type "basil" to begin.'
fi