-
Notifications
You must be signed in to change notification settings - Fork 731
/
build-prereq.sh
executable file
·141 lines (114 loc) · 5.28 KB
/
build-prereq.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
#!/bin/bash
set -euo pipefail
# Copyright 2017 Google LLC.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from this
# software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
echo ========== Load config settings.
source settings.sh
################################################################################
# Misc. setup
################################################################################
note_build_stage "Install the runtime packages"
./run-prereq.sh
note_build_stage "Update package list"
sudo -H apt-get -qq -y update
note_build_stage "Install development packages"
sudo -H apt-get -qq -y install pkg-config zip g++ zlib1g-dev unzip curl git lsb-release wget > /dev/null
################################################################################
# bazel
################################################################################
note_build_stage "Install bazel"
function ensure_wanted_bazel_version {
local wanted_bazel_version=$1
rm -rf ~/bazel
mkdir ~/bazel
if
v=$(bazel --bazelrc=/dev/null --nomaster_bazelrc version) &&
echo "$v" | awk -v b="$wanted_bazel_version" '/Build label/ { exit ($3 != b)}'
then
echo "Bazel ${wanted_bazel_version} already installed on the machine, not reinstalling"
else
pushd ~/bazel
curl -L -O https://github.com/bazelbuild/bazel/releases/download/"${wanted_bazel_version}"/bazel-"${wanted_bazel_version}"-installer-linux-x86_64.sh
chmod +x bazel-*.sh
./bazel-"${wanted_bazel_version}"-installer-linux-x86_64.sh --user > /dev/null
rm bazel-"${wanted_bazel_version}"-installer-linux-x86_64.sh
popd
fi
}
ensure_wanted_bazel_version "${DV_BAZEL_VERSION}"
################################################################################
# CLIF
################################################################################
note_build_stage "Install CLIF binary"
if [[ -e /usr/local/clif/bin/pyclif ]];
then
echo "CLIF already installed."
else
# Figure out which linux installation we are on to fetch an appropriate
# version of the pre-built CLIF binary. Note that we only support now Ubuntu
# 14, 16, and 18.
case "$(lsb_release -d)" in
*Ubuntu*18.*.*) export DV_PLATFORM="ubuntu-18" ;;
*Ubuntu*16.*.*) export DV_PLATFORM="ubuntu-16" ;;
*Ubuntu*14.*.*) export DV_PLATFORM="ubuntu-14" ;;
*Debian*9.*) export DV_PLATFORM="debian" ;;
*Debian*rodete) export DV_PLATFORM="debian" ;;
*) echo "CLIF is not installed on this machine and a prebuilt binary is not
available for this platform. Please install CLIF at
https://github.com/google/clif before continuing."
exit 1
esac
OSS_CLIF_CURL_ROOT="${DV_PACKAGE_CURL_PATH}/oss_clif_py3"
OSS_CLIF_PKG="oss_clif.${DV_PLATFORM}.latest.tgz"
if [[ ! -f "/tmp/${OSS_CLIF_PKG}" ]]; then
wget "${OSS_CLIF_CURL_ROOT}/${OSS_CLIF_PKG}" -O /tmp/${OSS_CLIF_PKG}
fi
(cd / && sudo tar xzf "/tmp/${OSS_CLIF_PKG}")
sudo ldconfig # Reload shared libraries.
fi
################################################################################
# TensorFlow
################################################################################
note_build_stage "Download and configure TensorFlow sources"
if [[ ! -d ../tensorflow ]]; then
note_build_stage "Cloning TensorFlow from github as ../tensorflow doesn't exist"
(cd .. && git clone https://github.com/tensorflow/tensorflow)
fi
export PYTHON_BIN_PATH=$(which python3.6)
export PYTHON_LIB_PATH='/usr/local/lib/python3.6/dist-packages'
(cd ../tensorflow &&
git checkout "${DV_CPP_TENSORFLOW_TAG}" &&
echo | ./configure)
# We use TensorFlow's .bazelrc as part of DeepVariant's. In it they use a java
# toolchain flag based on a definition in a BUILD file in the TF repo. This
# causes that flag's usage to raise build errors when building DeepVariant
# unless we also include that BUILD file.
mkdir -p third_party/toolchains/java
cp ../tensorflow/third_party/toolchains/java/BUILD third_party/toolchains/java/
note_build_stage "build-prereq.sh complete"