forked from opencog/ocpkg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-fedora-dependencies.sh
executable file
·261 lines (238 loc) · 7.51 KB
/
install-fedora-dependencies.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
260
261
#!/bin/bash
#
# This script is used for installing the dependencies required for
# building opencog on fedora.The script has been tested using docker
# image fedora:21.
# It is provided for those on 32-bit system or don't want to use
# If you encounter an issue don't hesitate to supply a patch on github.
# trap errors
set -e
# Environment Variables
SELF_NAME=$(basename $0)
# Fedora version
FEDORA_VERSION=$(cat /etc/issue | head -n 1 | cut -d " " -f 3)
# Some tools
PACKAGES_TOOLS="
git \
python-pip \
wget \
tar \
sudo \
curl \
"
# Packages for building opencog
PACKAGES_BUILD="
make \
gcc \
gcc-c++ \
cmake \
cxxtest \
rlwrap \
guile-devel \
libicu-devel \
bzip2-devel \
Cython \
python-devel \
python-zmq \
boost-devel \
zeromq-devel \
cppzmq-devel \
tbb-devel \
binutils-devel \
unixODBC-devel \
uuid-devel \
protobuf-c \
protobuf-compiler \
SDL_gfx-devel \
openssl-devel \
tcl-devel \
tcsh \
freetype-devel \
atlas-devel \
gcc-gfortran \
"
# Packages required for integrating opencog with other services
PACKAGES_RUNTIME="
unixODBC \
postgresql-odbc \
postgresql-devel \
"
# Template for messages printed.
message() {
echo -e "\e[1;34m[$SELF_NAME] $MESSAGE\e[0m"
}
# Install json-spirit (4.05)
install_json_spirit(){
MESSAGE="Installing json-spirit library...." ; message
cd /tmp
# cleaning up remnants from previous install failures, if any.
rm -rf json-spirit_4.05.orig.tar.gz json_spirit_v4_05
export BOOST_ROOT=/usr/include/boost/
wget http://http.debian.net/debian/pool/main/j/json-spirit/json-spirit_4.05.orig.tar.gz
tar -xvf json-spirit_4.05.orig.tar.gz
cd json_spirit_v4_05
mkdir build
cd build/
cmake ..
make -j"$(nproc)"
sudo make install
cd ../..
rm -rf json-spirit_4.05.orig.tar.gz json_spirit_v4_05
}
# Install Python Packages
install_opencog_python_packages(){
MESSAGE="Installing python packages...." ; message
cd /tmp
# cleaning up remnants from previous install failures, if any.
rm requirements.txt
wget https://raw.githubusercontent.com/opencog/opencog/master/opencog/python/requirements.txt
sudo pip install -U -r /tmp/requirements.txt
rm requirements.txt
}
# Install cogutil
install_cogutil(){
MESSAGE="Installing cogutil...." ; message
cd /tmp/
# cleaning up remnants from previous install failures, if any.
rm -rf master.tar.gz cogutil-master/
wget https://github.com/opencog/cogutil/archive/master.tar.gz
tar -xvf master.tar.gz
cd cogutil-master/
mkdir build
cd build/
cmake ..
make -j"$(nproc)"
sudo make install
cd ../..
rm -rf master.tar.gz cogutil-master/
}
# Install Link-Grammar
install_link_grammar(){
MESSAGE="Installing Link-Grammar...." ; message
cd /tmp/
# cleaning up remnants from previous install failures, if any.
rm -rf link-grammar-5.*/
wget -r --no-parent -nH --cut-dirs=2 http://www.abisource.com/downloads/link-grammar/current/
tar -zxf current/link-grammar-5*.tar.gz
rm -r current
cd link-grammar-5.*/
mkdir build
cd build
../configure
make -j"$(nproc)"
sudo make install
sudo ldconfig
cd /tmp/
rm -rf link-grammar-5.*/
cd $CURRENT_DIR
}
# Install AtomSpace
install_atomspace(){
MESSAGE="Installing atomspace...." ; message
cd /tmp/
# cleaning up remnants from previous install failures, if any.
rm -rf master.tar.gz atomspace-master/
wget https://github.com/opencog/atomspace/archive/master.tar.gz
tar -xvf master.tar.gz
cd atomspace-master/
mkdir build
cd build/
cmake ..
make -j"$(nproc)"
sudo make install
cd ../..
rm -rf master.tar.gz atomspace-master/
}
# Function for installing all required dependenceis for building OpenCog,
# as well as dependencies required for running opencog with other services.
install_dependencies() {
MESSAGE="Updating Package db...." ; message
$PM updateinfo
MESSAGE="Installing OpenCog build dependencies...." ; message
if ! (sudo $PM -y install $PACKAGES_BUILD $PACKAGES_RUNTIME $PACKAGES_TOOLS)
then
MESSAGE="Error installing some of dependencies... :( :(" ; message
exit 1
fi
install_json_spirit
}
# Install Haskell Dependencies
install_haskell_dependencies(){
MESSAGE="Installing haskell dependencies in user space...." ; message
# Install stack.
if [ "$FEDORA_VERSION" == "22" ]; then
curl -sSL https://s3.amazonaws.com/download.fpcomplete.com/fedora/22/fpco.repo | sudo tee /etc/yum.repos.d/fpco.repo
elif [ "$FEDORA_VERSION" == "21" ]; then
curl -sSL https://s3.amazonaws.com/download.fpcomplete.com/fedora/21/fpco.repo | sudo tee /etc/yum.repos.d/fpco.repo
fi
sudo $PM -y install stack
# Notes
# 1. Stack setup must me run in user space:
# "stack setup" looks for proper ghc version in the system according to the
# information provided by stack.yaml. If it is not installed, it attempts to
# install proper ghc version on user space (~/.stack/...). Because of that,
# it must not be run as root.
# 2. Difference b/n .cabal and stack.yaml:
# The .cabal file contains package metadata, in this case
# "opencog-atomspace.cabal" contains information of the opencog-atomspace
# package (autor, license, dependencies, etc.). The stack.yaml file contains
# configuration options for the stack building tool, we use it to set the
# proper "long term support" snapshot that we are using, which determines the
# proper ghc version to use, etc. In this case, it doesn't make sense to
# require the .cabal file, because we are not using that information to build
# the hscolour package, but it looks like stack always looks for a .cabal
# file when building, even though, in this case, it doesn't use it.
if [ "$EUID" -ne 0 ] ; then
cd /tmp
wget https://raw.githubusercontent.com/opencog/atomspace/master/opencog/haskell/stack.yaml
wget https://raw.githubusercontent.com/opencog/atomspace/master/opencog/haskell/opencog-atomspace.cabal
stack setup
# hscolour is necessary for haddock documentation.
stack build hscolour --copy-bins
rm stack.yaml opencog-atomspace.cabal
cd $CURRENT_DIR
else
echo "Please run without sudo. Stack need to be run in non-root user space."
fi
}
usage() {
echo "Usage: $SELF_NAME OPTION"
echo " -d Install base/system build dependencies"
echo " -p Install opencog python build dependencies"
echo " -s Install haskell build dependencies in user space. Don't use sudo"
echo " -c Install Cogutil"
echo " -a Install Atomspace"
echo " -l Install Link Grammar"
echo " -h This help message"
}
# Main Program
# Choose package manager
if [ "$FEDORA_VERSION" == "22" ]; then
PM=dnf
elif [ "$FEDORA_VERSION" == "21" ]; then
PM=yum
fi
if [ $# -eq 0 ] ; then NO_ARGS=true ; fi
while getopts "dpcalsh" flag ; do
case $flag in
d) INSTALL_DEPENDENCIES=true ;; #base development packages
p) INSTALL_OPENCOG_PYTHON_PACKAGES=true ;;
c) INSTALL_COGUTIL=true ;;
a) INSTALL_ATOMSPACE=true ;;
l) INSTALL_LINK_GRAMMAR=true ;;
s) HASKELL_STACK_SETUP=true;;
h) usage ;;
\?) usage ;;
*) UNKNOWN_FLAGS=true ;;
esac
done
if [ $INSTALL_DEPENDENCIES ] ; then install_dependencies ; fi
if [ $HASKELL_STACK_SETUP ] ; then install_haskell_dependencies ; fi
if [ $INSTALL_OPENCOG_PYTHON_PACKAGES ] ; then
install_opencog_python_packages
fi
if [ $INSTALL_COGUTIL ] ; then install_cogutil ; fi
if [ $INSTALL_ATOMSPACE ] ; then install_atomspace ; fi
if [ $INSTALL_LINK_GRAMMAR ] ; then install_link_grammar ; fi
if [ $UNKNOWN_FLAGS ] ; then usage ; fi
if [ $NO_ARGS ] ; then usage ; fi