-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patheosio_build_fedora.sh
executable file
·236 lines (208 loc) · 8.3 KB
/
eosio_build_fedora.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
if [ $1 == 1 ]; then ANSWER=1; else ANSWER=0; fi
CPU_SPEED=$( lscpu | grep "MHz" | tr -s ' ' | cut -d\ -f3 | cut -d'.' -f1 )
CPU_CORE=$( nproc )
OS_VER=$( grep VERSION_ID /etc/os-release | cut -d'=' -f2 | sed 's/[^0-9\.]//gI' )
if [ "${OS_VER}" -lt 25 ]; then
printf "You must be running Fedora 25 or higher to install EOSIO.\\n"
printf "Exiting now.\\n"
exit 1;
fi
# procps-ng includes free command
if [[ -z "$( rpm -qi "procps-ng" 2>/dev/null | grep Name )" ]]; then yum install -y procps-ng; fi
MEM_MEG=$( free -m | sed -n 2p | tr -s ' ' | cut -d\ -f2 )
if [ "${MEM_MEG}" -lt 7000 ]; then
printf "Your system must have 7 or more Gigabytes of physical memory installed.\\n"
printf "Exiting now.\\n"
exit 1;
fi
MEM_GIG=$(( ((MEM_MEG / 1000) / 2) ))
export JOBS=$(( MEM_GIG > CPU_CORE ? CPU_CORE : MEM_GIG ))
DISK_INSTALL=$( df -h . | tail -1 | tr -s ' ' | cut -d\\ -f1 )
DISK_TOTAL_KB=$( df . | tail -1 | awk '{print $2}' )
DISK_AVAIL_KB=$( df . | tail -1 | awk '{print $4}' )
DISK_TOTAL=$(( DISK_TOTAL_KB / 1048576 ))
DISK_AVAIL=$(( DISK_AVAIL_KB / 1048576 ))
if [ "${DISK_AVAIL%.*}" -lt "${DISK_MIN}" ]; then
printf "You must have at least %sGB of available storage to install EOSIO.\\n" "${DISK_MIN}"
printf "Exiting now.\\n"
exit 1;
fi
printf "\\nOS name: ${OS_NAME}\\n"
printf "OS Version: ${OS_VER}\\n"
printf "CPU speed: ${CPU_SPEED}Mhz\\n"
printf "CPU cores: ${CPU_CORE}\\n"
printf "Physical Memory: ${MEM_MEG} Mgb\\n"
printf "Disk space total: ${DISK_TOTAL%.*}G\\n"
printf "Disk space available: ${DISK_AVAIL%.*}G\\n"
# llvm is symlinked from /usr/lib64/llvm4.0 into user's home
DEP_ARRAY=(
git sudo procps-ng which gcc gcc-c++ autoconf automake libtool make \
bzip2-devel wget bzip2 compat-openssl10 graphviz doxygen \
openssl-devel gmp-devel libstdc++-devel python2 python2-devel python3 python3-devel \
libedit ncurses-devel swig llvm4.0 llvm4.0-devel llvm4.0-libs llvm4.0-static libcurl-devel libusb-devel
)
COUNT=1
DISPLAY=""
DEP=""
printf "\\nChecking Yum installation...\\n"
if ! YUM=$( command -v yum 2>/dev/null ); then
printf "!! Yum must be installed to compile EOS.IO !!\\n"
printf "Exiting now.\\n"
exit 1;
fi
printf " - Yum installation found at %s.\\n" "${YUM}"
if [ $ANSWER != 1 ]; then read -p "Do you wish to update YUM repositories? (y/n) " ANSWER; fi
case $ANSWER in
1 | [Yy]* )
if ! sudo $YUM -y update; then
printf " - YUM update failed.\\n"
exit 1;
else
printf " - YUM update complete.\\n"
fi
;;
[Nn]* ) echo " - Proceeding without update!";;
* ) echo "Please type 'y' for yes or 'n' for no."; exit;;
esac
printf "Checking RPM for installed dependencies...\\n"
for (( i=0; i<${#DEP_ARRAY[@]}; i++ )); do
pkg=$( rpm -qi "${DEP_ARRAY[$i]}" 2>/dev/null | grep Name )
if [[ -z $pkg ]]; then
DEP=$DEP" ${DEP_ARRAY[$i]} "
DISPLAY="${DISPLAY}${COUNT}. ${DEP_ARRAY[$i]}\\n"
printf " - Package %s ${bldred} NOT ${txtrst} found!\\n" "${DEP_ARRAY[$i]}"
(( COUNT++ ))
else
printf " - Package %s found.\\n" "${DEP_ARRAY[$i]}"
continue
fi
done
if [ "${COUNT}" -gt 1 ]; then
printf "\\nThe following dependencies are required to install EOSIO:\\n"
printf "${DISPLAY}\\n\\n"
if [ $ANSWER != 1 ]; then read -p "Do you wish to install these dependencies? (y/n) " ANSWER; fi
case $ANSWER in
1 | [Yy]* )
if ! sudo $YUM -y install ${DEP}; then
printf " - YUM dependency installation failed!\\n"
exit 1;
else
printf " - YUM dependencies installed successfully.\\n"
fi
;;
[Nn]* ) echo "User aborting installation of required dependencies, Exiting now."; exit;;
* ) echo "Please type 'y' for yes or 'n' for no."; exit;;
esac
else
printf " - No required YUM dependencies to install.\\n"
fi
printf "\\n"
printf "Checking CMAKE installation...\\n"
if [ ! -e $CMAKE ]; then
printf "Installing CMAKE...\\n"
curl -LO https://cmake.org/files/v$CMAKE_VERSION_MAJOR.$CMAKE_VERSION_MINOR/cmake-$CMAKE_VERSION.tar.gz \
&& tar -xzf cmake-$CMAKE_VERSION.tar.gz \
&& cd cmake-$CMAKE_VERSION \
&& ./bootstrap --prefix=$HOME \
&& make -j"${JOBS}" \
&& make install \
&& cd .. \
&& rm -f cmake-$CMAKE_VERSION.tar.gz \
|| exit 1
printf " - CMAKE successfully installed @ ${CMAKE} \\n"
else
printf " - CMAKE found @ ${CMAKE}.\\n"
fi
if [ $? -ne 0 ]; then exit -1; fi
printf "\\n"
printf "Checking Boost library (${BOOST_VERSION}) installation...\\n"
BOOSTVERSION=$( grep "#define BOOST_VERSION" "$HOME/opt/boost/include/boost/version.hpp" 2>/dev/null | tail -1 | tr -s ' ' | cut -d\ -f3 )
if [ "${BOOSTVERSION}" != "${BOOST_VERSION_MAJOR}0${BOOST_VERSION_MINOR}0${BOOST_VERSION_PATCH}" ]; then
printf "Installing Boost library...\\n"
curl -LO https://dl.bintray.com/boostorg/release/${BOOST_VERSION_MAJOR}.${BOOST_VERSION_MINOR}.${BOOST_VERSION_PATCH}/source/boost_$BOOST_VERSION.tar.bz2 \
&& tar -xjf boost_$BOOST_VERSION.tar.bz2 \
&& cd $BOOST_ROOT \
&& ./bootstrap.sh --prefix=$BOOST_ROOT \
&& ./b2 -q -j"${JOBS}" install \
&& cd .. \
&& rm -f boost_$BOOST_VERSION.tar.bz2 \
&& rm -rf $BOOST_LINK_LOCATION \
&& ln -s $BOOST_ROOT $BOOST_LINK_LOCATION \
|| exit 1
printf " - Boost library successfully installed @ ${BOOST_ROOT} (Symlinked to ${BOOST_LINK_LOCATION}).\\n"
else
printf " - Boost library found with correct version @ ${BOOST_ROOT} (Symlinked to ${BOOST_LINK_LOCATION}).\\n"
fi
if [ $? -ne 0 ]; then exit -1; fi
printf "\\n"
printf "Checking MongoDB installation...\\n"
if [ ! -d $MONGODB_ROOT ]; then
printf "Installing MongoDB into ${MONGODB_ROOT}...\\n"
curl -OL https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \
&& tar -xzf mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \
&& mv $SRC_LOCATION/mongodb-linux-x86_64-amazon-$MONGODB_VERSION $MONGODB_ROOT \
&& touch $MONGODB_LOG_LOCATION/mongod.log \
&& rm -f mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \
&& cp -f $REPO_ROOT/scripts/mongod.conf $MONGODB_CONF \
&& mkdir -p $MONGODB_DATA_LOCATION \
&& rm -rf $MONGODB_LINK_LOCATION \
&& rm -rf $BIN_LOCATION/mongod \
&& ln -s $MONGODB_ROOT $MONGODB_LINK_LOCATION \
&& ln -s $MONGODB_LINK_LOCATION/bin/mongod $BIN_LOCATION/mongod \
|| exit 1
printf " - MongoDB successfully installed @ ${MONGODB_ROOT}\\n"
else
printf " - MongoDB found with correct version @ ${MONGODB_ROOT}.\\n"
fi
if [ $? -ne 0 ]; then exit -1; fi
printf "Checking MongoDB C driver installation...\\n"
if [ ! -d $MONGO_C_DRIVER_ROOT ]; then
printf "Installing MongoDB C driver...\\n"
curl -LO https://github.com/mongodb/mongo-c-driver/releases/download/$MONGO_C_DRIVER_VERSION/mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \
&& tar -xzf mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \
&& cd mongo-c-driver-$MONGO_C_DRIVER_VERSION \
&& mkdir -p cmake-build \
&& cd cmake-build \
&& $CMAKE -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME -DENABLE_BSON=ON -DENABLE_SSL=OPENSSL -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DENABLE_STATIC=ON .. \
&& make -j"${JOBS}" \
&& make install \
&& cd ../.. \
&& rm mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \
|| exit 1
printf " - MongoDB C driver successfully installed @ ${MONGO_C_DRIVER_ROOT}.\\n"
else
printf " - MongoDB C driver found with correct version @ ${MONGO_C_DRIVER_ROOT}.\\n"
fi
if [ $? -ne 0 ]; then exit -1; fi
printf "Checking MongoDB C++ driver installation...\\n"
if [ ! -d $MONGO_CXX_DRIVER_ROOT ]; then
printf "Installing MongoDB C++ driver...\\n"
curl -L https://github.com/mongodb/mongo-cxx-driver/archive/r$MONGO_CXX_DRIVER_VERSION.tar.gz -o mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \
&& tar -xzf mongo-cxx-driver-r${MONGO_CXX_DRIVER_VERSION}.tar.gz \
&& cd mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION/build \
&& $CMAKE -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME .. \
&& make -j"${JOBS}" VERBOSE=1 \
&& make install \
&& cd ../.. \
&& rm -f mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \
|| exit 1
printf " - MongoDB C++ driver successfully installed @ ${MONGO_CXX_DRIVER_ROOT}.\\n"
else
printf " - MongoDB C++ driver found with correct version @ ${MONGO_CXX_DRIVER_ROOT}.\\n"
fi
if [ $? -ne 0 ]; then exit -1; fi
printf "\\n"
printf "Checking LLVM 4 support...\\n"
if [ ! -d $LLVM_ROOT ]; then
ln -s /usr/lib64/llvm4.0 $LLVM_ROOT \
|| exit 1
printf " - LLVM successfully linked from /usr/lib64/llvm4.0 to ${LLVM_ROOT}\\n"
else
printf " - LLVM found @ ${LLVM_ROOT}.\\n"
fi
if [ $? -ne 0 ]; then exit -1; fi
cd ..
printf "\\n"
function print_instructions() {
return 0
}