forked from google/codeworld
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·259 lines (204 loc) · 7.52 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
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
#!/bin/bash
# Copyright 2019 The CodeWorld Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -euo pipefail
source base.sh
rm -rf $BUILD ~/.ghc ~/.ghcjs ~/.cabal ~/.npm
mkdir $BUILD
mkdir $BUILD/downloads
mkdir $BUILD/bin
# Determine which package management tool is installed, and install
# necessary system packages.
if type yum > /dev/null 2> /dev/null
then
echo Detected 'yum': Installing packages from there.
echo
# Update and install basic dependencies
run . sudo yum update -y
run . sudo yum install -y git
run . sudo yum install -y curl
run . sudo yum install -y wget
run . sudo yum install -y bzip2
run . sudo yum install -y zlib-devel
run . sudo yum install -y ncurses-devel
# Needed for GHC 7.8
run . sudo yum install -y gcc
run . sudo yum install -y gcc-c++
run . sudo yum install -y gmp-devel
# Needed for GHCJS
run --quiet . curl --silent --location https://rpm.nodesource.com/setup_8.x | run . sudo bash -
run . sudo yum install -y nodejs
# Needed for ghcjs-boot --dev
run . sudo yum install -y patch
run . sudo yum install -y autoconf
run . sudo yum install -y automake
# Needed for codeworld-auth
run . sudo yum install -y openssl-devel
elif type apt-get > /dev/null 2> /dev/null
then
echo Detected 'apt-get': Installing packages from there.
echo
# Update and install basic dependencies
run . sudo apt-get update -y
run . sudo apt-get install -y git
run . sudo apt-get install -y curl
run . sudo apt-get install -y wget
run . sudo apt-get install -y bzip2
run . sudo apt-get install -y xz-utils
run . sudo apt-get install -y psmisc
run . sudo apt-get install -y zlib1g-dev
run . sudo apt-get install -y libncurses5-dev
# Needed for GHC 7.8
run . sudo apt-get install -y make
run . sudo apt-get install -y gcc
run . sudo apt-get install -y g++
run . sudo apt-get install -y libgmp-dev
# Needed for GHCJS
run . sudo apt-get install -y gnupg
run --quiet . curl -sL https://deb.nodesource.com/setup_8.x | run . sudo -E bash -
run . sudo apt-get install -y nodejs
# Needed for ghcjs-boot --dev
run . sudo apt-get install -y patch
run . sudo apt-get install -y autoconf
run . sudo apt-get install -y automake
run . sudo apt-get install -y libtinfo-dev
# Needed for codeworld-auth
run . sudo apt-get install -y libssl-dev
elif type zypper > /dev/null 2> /dev/null
then
echo Detected 'zypper': Installing packages from there.
echo
# Update and install basic dependencies
run . sudo zypper -n refresh
run . sudo zypper -n install git
run . sudo zypper -n install curl
run . sudo zypper -n install wget
run . sudo zypper -n install bzip2
run . sudo zypper -n install psmisc
run . sudo zypper -n install zlib-devel
run . sudo zypper -n install ncurses-devel
# Needed for GHC 7.8
run . sudo zypper -n install make
run . sudo zypper -n install gcc
run . sudo zypper -n install gmp-devel
# Needed for GHCJS
run . sudo zypper -n install nodejs6
# Needed for ghcjs-boot --dev
run . sudo zypper -n install patch
run . sudo zypper -n install autoconf
run . sudo zypper -n install automake
# Needed for codeworld-auth
run . sudo zypper -n install libopenssl-devel
elif type brew > /dev/null 2> /dev/null
then
echo Detected 'brew': Installing packages from there.
echo
# install missing packages -- don't try to upgrade already installed packages
function brew_install {
if ! brew ls $1 > /dev/null 2> /dev/null
then
run . brew install $1
fi
}
# Update and install basic dependencies
xcode-select --install
brew_install git
brew_install curl
brew_install wget
brew_install bzip2
# No psmisc in homebrew
#brew_install psmisc
# brew_install ncurses-devel
# Needed for GHC 7.8
brew_install make
brew_install gcc
#brew_install gmp-devel
# Needed for GHCJS
brew_install node@6
# Needed for ghcjs-boot --dev
# already present on OS X
#brew_install patch
brew_install autoconf
brew_install automake
# Needed for codeworld-auth
brew_install openssl
else
echo "WARNING: Could not find package manager."
echo "Make sure necessary packages are installed."
fi
# Choose the right GHC download
MACHINE="$(uname -m)"
case "${MACHINE}" in
i386) GHC_CPU=i386;;
i686) GHC_CPU=i386;;
x86_64) GHC_CPU=x86_64;;
amd7) GHC_CPU=amd7;;
*) >&2 echo "Unrecognized machine: ${MACHINE}"; exit 1;;
esac
set +e
result=$(/sbin/ldconfig -p 2> /dev/null)
set -e
if [[ $result = *libgmp.so.10* ]]; then
GHC_ARCH="${GHC_CPU}-deb8-linux"
elif [[ $result = *libgmp.so.3* ]]; then
GHC_ARCH="${GHC_CPU}-centos67-linux"
else
set +e
result=$(uname 2> /dev/null)
set -e
if [[ $result = *Darwin* ]]; then
GHC_ARCH="${GHC_CPU}-apple-darwin"
else
echo Sorry, but no supported libgmp is installed.
exit 1
fi
fi
# Install a precompiled GHC to bootstrap itself.
GHC_DIR=8.0.2
GHC_VERSION=8.0.2
run $DOWNLOADS wget http://downloads.haskell.org/~ghc/$GHC_DIR/ghc-$GHC_VERSION-$GHC_ARCH.tar.xz
run $BUILD tar xf $DOWNLOADS/ghc-$GHC_VERSION-$GHC_ARCH.tar.xz
run $BUILD/ghc-$GHC_VERSION ./configure --prefix=$BUILD
run $BUILD/ghc-$GHC_VERSION make install
run $BUILD rm -rf ghc-$GHC_VERSION
# Now install the patched GHC, built from source.
run $DOWNLOADS wget https://downloads.haskell.org/~ghc/$GHC_DIR/ghc-$GHC_VERSION-src.tar.xz
run $BUILD tar xf $DOWNLOADS/ghc-$GHC_VERSION-src.tar.xz
run . patch -p0 -u -d $BUILD < ghc-artifacts/ghc-$GHC_VERSION-default-main.patch
run . cp ghc-artifacts/build.mk $BUILD/ghc-$GHC_VERSION/mk/build.mk
run $BUILD/ghc-$GHC_VERSION ./configure --prefix=$BUILD
run $BUILD/ghc-$GHC_VERSION make
run $BUILD/ghc-$GHC_VERSION make install
run $BUILD rm -rf ghc-$GHC_VERSION
# Install all the dependencies for cabal
run $DOWNLOADS wget https://www.haskell.org/cabal/release/cabal-install-2.0.0.0/cabal-install-2.0.0.0.tar.gz
run $BUILD tar xf $DOWNLOADS/cabal-install-2.0.0.0.tar.gz
EXTRA_CONFIGURE_OPTS="" run $BUILD/cabal-install-2.0.0.0 ./bootstrap.sh
run . cabal update
run $BUILD rm -rf cabal-install-2.0.0.0
# Fetch the prerequisites for GHCJS.
run . cabal_install happy alex
# Install GHCJS itself (https://github.com/ghcjs/ghcjs) and cabal install.
run $BUILD git clone --branch ghc-8.0 --single-branch https://github.com/ghcjs/ghcjs
run $BUILD cabal_install ./ghcjs
run $BUILD rm -rf ghcjs
run . ghcjs-boot --dev --ghcjs-boot-dev-branch ghc-8.0 --shims-dev-branch ghc-8.0 --no-prof --no-haddock
run $BUILD rm -rf downloads
# Install tools to build CodeMirror editor.
run $BUILD git clone https://github.com/codemirror/CodeMirror.git
run $BUILD/CodeMirror git checkout tags/5.43.0
run $BUILD/CodeMirror npm install
run $BUILD/CodeMirror npm install -s uglify-js git+ssh://git@github.com:angelozerr/CodeMirror-Extension.git
# Go ahead and run a first build, which installs more local packages.
./build.sh