Skip to content

Commit 81162a9

Browse files
authored
Add setup script for cent7 (#408)
Signed-off-by: Yuan Zhou <[email protected]>
1 parent 5a56be9 commit 81162a9

File tree

1 file changed

+272
-0
lines changed

1 file changed

+272
-0
lines changed

scripts/setup-centos7.sh

Lines changed: 272 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,272 @@
1+
#!/bin/bash
2+
# Copyright (c) Facebook, Inc. and its affiliates.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -efx -o pipefail
17+
# Some of the packages must be build with the same compiler flags
18+
# so that some low level types are the same size. Also, disable warnings.
19+
SCRIPTDIR=$(dirname "${BASH_SOURCE[0]}")
20+
source $SCRIPTDIR/setup-helper-functions.sh
21+
DEPENDENCY_DIR=${DEPENDENCY_DIR:-/tmp/velox-deps}
22+
CPU_TARGET="${CPU_TARGET:-avx}"
23+
NPROC=$(getconf _NPROCESSORS_ONLN)
24+
export CFLAGS=$(get_cxx_flags $CPU_TARGET) # Used by LZO.
25+
export CXXFLAGS=$CFLAGS # Used by boost.
26+
export CPPFLAGS=$CFLAGS # Used by LZO.
27+
export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib64/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH
28+
FB_OS_VERSION=v2022.11.14.00
29+
30+
# shellcheck disable=SC2037
31+
SUDO="sudo -E"
32+
33+
function run_and_time {
34+
time "$@"
35+
{ echo "+ Finished running $*"; } 2> /dev/null
36+
}
37+
38+
function dnf_install {
39+
$SUDO dnf install -y -q --setopt=install_weak_deps=False "$@"
40+
}
41+
42+
function yum_install {
43+
$SUDO yum install -y "$@"
44+
}
45+
46+
function cmake_install_deps {
47+
cmake -B"$1-build" -GNinja -DCMAKE_CXX_STANDARD=17 \
48+
-DCMAKE_CXX_FLAGS="${CFLAGS}" -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=Release -Wno-dev "$@"
49+
ninja -C "$1-build"
50+
$SUDO ninja -C "$1-build" install
51+
}
52+
53+
function wget_and_untar {
54+
local URL=$1
55+
local DIR=$2
56+
mkdir -p "${DIR}"
57+
wget -q --max-redirect 3 -O - "${URL}" | tar -xz -C "${DIR}" --strip-components=1
58+
}
59+
60+
function install_cmake {
61+
cd "${DEPENDENCY_DIR}"
62+
wget_and_untar https://cmake.org/files/v3.25/cmake-3.25.1.tar.gz cmake-3
63+
cd cmake-3
64+
./bootstrap --prefix=/usr/local
65+
make -j$(nproc)
66+
$SUDO make install
67+
cmake --version
68+
}
69+
70+
function install_ninja {
71+
cd "${DEPENDENCY_DIR}"
72+
github_checkout ninja-build/ninja v1.11.1
73+
./configure.py --bootstrap
74+
cmake -Bbuild-cmake
75+
cmake --build build-cmake
76+
$SUDO cp ninja /usr/local/bin/
77+
}
78+
79+
function install_fmt {
80+
cd "${DEPENDENCY_DIR}"
81+
github_checkout fmtlib/fmt 8.0.0
82+
cmake_install -DFMT_TEST=OFF
83+
}
84+
85+
function install_folly {
86+
cd "${DEPENDENCY_DIR}"
87+
github_checkout facebook/folly "${FB_OS_VERSION}"
88+
cmake_install -DBUILD_TESTS=OFF -DFOLLY_HAVE_INT128_T=ON
89+
}
90+
91+
function install_conda {
92+
cd "${DEPENDENCY_DIR}"
93+
mkdir -p conda && cd conda
94+
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
95+
MINICONDA_PATH=/opt/miniconda-for-velox
96+
bash Miniconda3-latest-Linux-x86_64.sh -b -u $MINICONDA_PATH
97+
}
98+
99+
function install_openssl {
100+
cd "${DEPENDENCY_DIR}"
101+
wget_and_untar https://github.com/openssl/openssl/archive/refs/tags/OpenSSL_1_1_1s.tar.gz openssl
102+
cd openssl
103+
./config no-shared
104+
make depend
105+
make
106+
$SUDO make install
107+
}
108+
109+
function install_gflags {
110+
cd "${DEPENDENCY_DIR}"
111+
wget_and_untar https://github.com/gflags/gflags/archive/v2.2.2.tar.gz gflags
112+
cd gflags
113+
cmake_install -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DBUILD_gflags_LIB=ON -DLIB_SUFFIX=64 -DCMAKE_INSTALL_PREFIX:PATH=/usr/local
114+
}
115+
116+
function install_glog {
117+
cd "${DEPENDENCY_DIR}"
118+
wget_and_untar https://github.com/google/glog/archive/v0.5.0.tar.gz glog
119+
cd glog
120+
cmake_install -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DCMAKE_INSTALL_PREFIX:PATH=/usr/local
121+
}
122+
123+
function install_snappy {
124+
cd "${DEPENDENCY_DIR}"
125+
wget_and_untar https://github.com/google/snappy/archive/1.1.8.tar.gz snappy
126+
cd snappy
127+
cmake_install -DSNAPPY_BUILD_TESTS=OFF
128+
}
129+
130+
function install_dwarf {
131+
cd "${DEPENDENCY_DIR}"
132+
wget_and_untar https://github.com/davea42/libdwarf-code/archive/refs/tags/20210528.tar.gz dwarf
133+
cd dwarf
134+
#local URL=https://github.com/davea42/libdwarf-code/releases/download/v0.5.0/libdwarf-0.5.0.tar.xz
135+
#local DIR=dwarf
136+
#mkdir -p "${DIR}"
137+
#wget -q --max-redirect 3 "${URL}"
138+
#tar -xf libdwarf-0.5.0.tar.xz -C "${DIR}"
139+
#cd dwarf/libdwarf-0.5.0
140+
./configure --enable-shared=no
141+
make
142+
make check
143+
$SUDO make install
144+
}
145+
146+
function install_re2 {
147+
cd "${DEPENDENCY_DIR}"
148+
wget_and_untar https://github.com/google/re2/archive/refs/tags/2023-03-01.tar.gz re2
149+
cd re2
150+
$SUDO make install
151+
}
152+
153+
function install_flex {
154+
cd "${DEPENDENCY_DIR}"
155+
wget_and_untar https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz flex
156+
cd flex
157+
./autogen.sh
158+
./configure
159+
$SUDO make install
160+
}
161+
162+
function install_lzo {
163+
cd "${DEPENDENCY_DIR}"
164+
wget_and_untar http://www.oberhumer.com/opensource/lzo/download/lzo-2.10.tar.gz lzo
165+
cd lzo
166+
./configure --prefix=/usr/local --enable-shared --disable-static --docdir=/usr/local/share/doc/lzo-2.10
167+
make "-j$(nproc)"
168+
$SUDO make install
169+
}
170+
171+
function install_boost {
172+
cd "${DEPENDENCY_DIR}"
173+
wget_and_untar https://boostorg.jfrog.io/artifactory/main/release/1.72.0/source/boost_1_72_0.tar.gz boost
174+
cd boost
175+
./bootstrap.sh --prefix=/usr/local --with-python=/usr/bin/python3 --with-python-root=/usr/lib/python3.6 --without-libraries=python
176+
$SUDO ./b2 "-j$(nproc)" -d0 install threading=multi
177+
}
178+
179+
function install_libhdfs3 {
180+
cd "${DEPENDENCY_DIR}"
181+
github_checkout apache/hawq master
182+
cd depends/libhdfs3
183+
sed -i "/FIND_PACKAGE(GoogleTest REQUIRED)/d" ./CMakeLists.txt
184+
sed -i "s/dumpversion/dumpfullversion/" ./CMake/Platform.cmake
185+
sed -i "s/dfs.domain.socket.path\", \"\"/dfs.domain.socket.path\", \"\/var\/lib\/hadoop-hdfs\/dn_socket\"/g" src/common/SessionConfig.cpp
186+
sed -i "s/pos < endOfCurBlock/pos \< endOfCurBlock \&\& pos \- cursor \<\= 128 \* 1024/g" src/client/InputStreamImpl.cpp
187+
cmake_install
188+
}
189+
190+
function install_protobuf {
191+
cd "${DEPENDENCY_DIR}"
192+
wget https://github.com/protocolbuffers/protobuf/releases/download/v21.4/protobuf-all-21.4.tar.gz
193+
tar -xzf protobuf-all-21.4.tar.gz
194+
cd protobuf-21.4
195+
./configure CXXFLAGS="-fPIC" --prefix=/usr/local
196+
make "-j$(nproc)"
197+
$SUDO make install
198+
}
199+
200+
function install_awssdk {
201+
cd "${DEPENDENCY_DIR}"
202+
github_checkout aws/aws-sdk-cpp 1.9.379 --depth 1 --recurse-submodules
203+
cmake_install -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS:BOOL=OFF -DMINIMIZE_SIZE:BOOL=ON -DENABLE_TESTING:BOOL=OFF -DBUILD_ONLY:STRING="s3;identity-management"
204+
}
205+
206+
function install_gtest {
207+
cd "${DEPENDENCY_DIR}"
208+
wget https://github.com/google/googletest/archive/refs/tags/release-1.12.1.tar.gz
209+
tar -xzf release-1.12.1.tar.gz
210+
cd googletest-release-1.12.1
211+
mkdir -p build && cd build && cmake -DBUILD_GTEST=ON -DBUILD_GMOCK=ON -DINSTALL_GTEST=ON -DINSTALL_GMOCK=ON -DBUILD_SHARED_LIBS=ON ..
212+
make "-j$(nproc)"
213+
$SUDO make install
214+
}
215+
216+
function install_prerequisites {
217+
run_and_time install_lzo
218+
run_and_time install_boost
219+
run_and_time install_re2
220+
run_and_time install_flex
221+
run_and_time install_openssl
222+
run_and_time install_gflags
223+
run_and_time install_glog
224+
run_and_time install_snappy
225+
run_and_time install_dwarf
226+
}
227+
228+
function install_velox_deps {
229+
run_and_time install_fmt
230+
run_and_time install_folly
231+
run_and_time install_conda
232+
}
233+
234+
$SUDO dnf makecache
235+
236+
# dnf install dependency libraries
237+
dnf_install epel-release dnf-plugins-core # For ccache, ninja
238+
# PowerTools only works on CentOS8
239+
# dnf config-manager --set-enabled powertools
240+
dnf_install ccache git wget which libevent-devel \
241+
openssl-devel libzstd-devel lz4-devel double-conversion-devel \
242+
curl-devel cmake libxml2-devel libgsasl-devel libuuid-devel patch
243+
244+
$SUDO dnf remove -y gflags
245+
246+
# Required for Thrift
247+
dnf_install autoconf automake libtool bison python3 python3-devel
248+
249+
# Required for build flex
250+
dnf_install gettext-devel texinfo help2man
251+
252+
# dnf_install conda
253+
254+
# Activate gcc9; enable errors on unset variables afterwards.
255+
# GCC9 install via yum and devtoolset
256+
# dnf install gcc-toolset-9 only works on CentOS8
257+
258+
$SUDO yum makecache
259+
yum_install centos-release-scl
260+
yum_install devtoolset-9
261+
source /opt/rh/devtoolset-9/enable || exit 1
262+
gcc --version
263+
set -u
264+
265+
# Build from source
266+
[ -d "$DEPENDENCY_DIR" ] || mkdir -p "$DEPENDENCY_DIR"
267+
268+
run_and_time install_cmake
269+
run_and_time install_ninja
270+
271+
install_prerequisites
272+
install_velox_deps

0 commit comments

Comments
 (0)