forked from stepanblyschak/fboss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getdeps.sh
executable file
·130 lines (117 loc) · 3.88 KB
/
getdeps.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
#!/usr/bin/env bash
function die() {
echo "$1 : fatal error; dying..." >&2
exit 1
}
function update() {
repo=`basename $1 .git`
echo "updating $repo..."
if [ -d $repo ]; then
(cd $repo && git pull)
else
git clone "$1" || die "Failed to clone $1"
[ -z "$2" ] || (cd $repo && git checkout $2)
fi
}
function update_branch() {
branch="$1"
if [ "$(git symbolic-ref -q --short HEAD)" != "OpenNSL_6.3" ]; then
git checkout -tb "$branch" "origin/$branch"
fi
}
function build_autoconf() {
(
echo "building $1..."
cd "$1" || die "Missing dir $1"
if [ ! -e ./configure ]; then
autoreconf --install
fi
./configure || die "Configure failed for $1"
make -j "$NPROC" || die "Make failed for $1"
)
}
function build_make() {
(
echo "Building $1..."
cd "$1" || die "Missing dir $1"
if [ ! -e Makefile ] ; then
die "Missing Makefile for $1"
fi
make -j "$NPROC"|| die "Make failed for $1"
make install prefix="$INSTALL_DIR" || \
die "Failed to install $1 to $INSTALL_DIR"
)
}
function build_cmake() {
(
echo "building $1..."
cd "$1" || die "Missing dir $1"
if [ -e ./CMakeLists.txt ]; then
mkdir -p _build || true
cd _build || die "Failed to cd into _build directory"
cmake configure .. \
-DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \
-DCMAKE_PREFIX_PATH="$INSTALL_DIR" \
-DBUILD_TESTS=OFF \
|| die "Cmake failed for $1"
make -j "$NPROC" || die "Failed to build $1"
make install || die "Failed to install $1 to $INSTALL_DIR"
else
die "No CmakeLists.txt found for $1"
fi
)
}
function get_packages() {
echo "updating package indices"
sudo apt-get update
echo "installing packages"
sudo apt-get install -yq autoconf automake libdouble-conversion-dev \
libssl-dev make zip git autoconf libtool g++ libboost-all-dev \
libevent-dev flex bison libgoogle-glog-dev scons libkrb5-dev \
libsnappy-dev libsasl2-dev libnuma-dev libi2c-dev libcurl4-nss-dev \
libusb-1.0-0-dev libpcap-dev libdb5.3-dev cmake libnl-3-dev \
libnl-route-3-dev iptables-dev
sudo apt-get install -yq shtool pkg-config
}
if [ "$1" != 'nopkg' ]; then
get_packages
else
shift
fi
if [ "$1" == 'pkgsonly' ]; then
echo Requested to install packages only >&2
exit 0
fi
GET_OPENNSL=1
if [ "$1" == "nobcm" ]; then
GET_OPENNSL=0 # used by people concerned with OpenNSL agreement
# WARNING: setting this will currently break compile!
fi
echo "creating external..."
mkdir -p external
NPROC=$(grep -c processor /proc/cpuinfo)
(
cd external
EXT=$(pwd)
# build and install everything to this dir
INSTALL_DIR="$EXT.install"
if [ $GET_OPENNSL == 1 ] ; then
# We hard code OpenNSL to OpenNSL-6.4.6.6 release, later releases seem to
# SIGSEV in opennsl_pkt_alloc()
update https://github.com/Broadcom-Switch/OpenNSL.git 8e0b499f02dcef751a3703c9a18600901374b28a
fi
# iproute2 v4.4.0
update https://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git 7ca63aef7d1b0c808da0040c6b366ef7a61f38c1
update https://github.com/facebook/folly.git
update https://github.com/facebook/wangle.git
update https://github.com/facebook/fbthrift.git
update https://github.com/no1msd/mstch.git
update https://github.com/facebook/zstd.git
update https://github.com/google/googletest.git release-1.8.0
build_cmake mstch || die "Failed to build mstch"
build_make zstd || die "Failed to build zstd"
build_autoconf iproute2 || die "Failed to build iproute2"
build_cmake folly || die "Failed to build folly"
build_cmake wangle/wangle || die "Failed to build wangle"
build_cmake fbthrift/ || die "Failed to build thrift"
)