forked from play-co/devkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·174 lines (137 loc) · 3.89 KB
/
install.sh
File metadata and controls
executable file
·174 lines (137 loc) · 3.89 KB
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/usr/bin/env bash
install_type=""
is_silent=0
while [ $# -gt 0 ]; do
case $1 in
--basic) install_type="basic"; shift 1 ;;
--silent) is_silent=1; shift 1 ;;
*) shift 1 ;;
esac
done
# Make sure we are not running as root
if [[ $EUID -eq 0 ]]; then
echo "This script should not be run as root" 1>&2
exit 1
fi
BASIL_ROOT=$(cd -P $(dirname "$0") && pwd)
if [[ -z "$BASH_VERSION" ]]; then
echo "Error: GC DevKit install script should be run in bash."
exit 1
fi
echo $'\033[1;32m-{{{>\033[0m Game Closure DevKit'
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 DevKit requires git to install. (http://git-scm.com)"
exit 1
fi
if ! which node > /dev/null; then
error "GC DevKit requires node 0.8+ to install. (http://nodejs.org)"
exit 1
fi
if ! which npm > /dev/null; then
error "GC DevKit 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 DevKit install requires write permission to $HOME/.npm"
echo "Try: sudo chown -R $USER $HOME/.npm"
exit 1
fi
# Prompt for global install early to avoid error: 0 problem
SYSTEM_WIDE_INSTALL=false
if [[ $is_silent != 1 ]]; then
if [[ `uname` != MINGW32* ]]; then
read -p "Would you like to install the Game Closure DevKit system-wide in /usr/local/bin [Y/n] ?" -r
while [[ ($REPLY != 'y') && ($REPLY != 'Y') && ($REPLY != 'n') && ($REPLY != 'N') ]]; do
read -p "Invalid option \"$REPLY\". Please type either Y or n:" -r
done
echo
if [[ ($REPLY != 'n') && ($REPLY != 'N') ]]; then
SYSTEM_WIDE_INSTALL=true
fi
fi
fi
#
# Install
#
echo -e "\nInitializing GC DevKit 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 init
if [[ $install_type == "basic" ]]; then
git submodule deinit projects/whack-that-mole
git submodule deinit projects/platformer
git submodule deinit lib/menus
git submodule deinit lib/shooter
git submodule deinit projects/demoMenus
git submodule deinit projects/demoShooter
git submodule deinit lib/isometric
git submodule deinit projects/demoIsometricGame
fi
git submodule update --recursive
if $PRIV_SUBMODS; then
git checkout .gitmodules
fi
if ! npm install; then
error "Running npm install"
echo "Try running: sudo chown -R \$USER /usr/local"
exit 1
fi
echo
node bin/checkSymlinks
node src/dependencyCheck.js $install_type
if [[ $is_silent != 1 ]]; then
node src/analytics.js
CURRENT_BASIL_PATH=$(which basil)
TARGET_BASIL_PATH="$BASIL_ROOT/bin/basil"
if [[ `uname` == MINGW32* ]]; then
npm link --local
SYSTEM_WIDE_INSTALL=true
else
if [[ $SYSTEM_WIDE_INSTALL == true ]]; then
echo
echo 'Trying to link from /usr/local with sudo. You may be prompted for your root password.'
SYSTEM_WIDE_INSTALL=true
if [[ -e /usr/local/bin/basil ]]; then
sudo sh -c "unlink /usr/local/bin/basil; ln -s '$TARGET_BASIL_PATH' /usr/local/bin/basil"
else
sudo ln -s "$TARGET_BASIL_PATH" /usr/local/bin/basil
fi
if [[ $? != 0 ]]; then
error "Could not link basil to /usr/local"
SYSTEM_WIDE_INSTALL=false
fi
fi
fi
if [[ $SYSTEM_WIDE_INSTALL == false ]]; then
echo $'\033[1;32mSuccessfully installed. -{{{>\033[0m' "Type \"$BASIL_ROOT/bin/basil\" to begin."
echo "+ Suggestion: You may wish to add $BASIL_ROOT/bin to your \$PATH"
else
echo $'\033[1;32mSuccessfully installed. -{{{>\033[0m Type "basil" to begin.'
fi
fi