Skip to content

Commit a2fd86d

Browse files
rootyma11
authored andcommitted
Add setup script for cent7 (oap 408)
1 parent f951fd5 commit a2fd86d

File tree

1 file changed

+279
-0
lines changed

1 file changed

+279
-0
lines changed

scripts/setup-centos7.sh

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

0 commit comments

Comments
 (0)