-
Notifications
You must be signed in to change notification settings - Fork 65
/
fun.sh
executable file
·208 lines (185 loc) · 4.96 KB
/
fun.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
#!/bin/bash -e
set -o pipefail
# shellcheck source=docker/linux/common_fun.sh
. ./common_fun.sh
if ! command -v lsb_release &> /dev/null; then
apt-get -qq update -y
apt-get -qq install -y --no-install-recommends locales
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
apt-get -qq update -y
apt-get -qq install -y --no-install-recommends lsb-release
fi
LSB_RELEASE="$(lsb_release -cs)"
APT_KEYS_ENV=(
"${APT_KEY_TOOLCHAIN}")
APT_REPOS_LLVM=(
"https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main")
APT_KEYS_MOBILE=(
"$APT_KEY_AZUL")
APT_REPOS_ENV=(
"http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu ${LSB_RELEASE} main")
APT_REPOS=(
"[arch=${DEB_ARCH}] https://download.docker.com/linux/ubuntu ${LSB_RELEASE} stable"
"http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_20.04/ /")
COMMON_PACKAGES=(
apt-transport-https
ca-certificates
gnupg2
gpg-agent
unzip
wget
xz-utils)
DEV_PACKAGES=(
g++-11
git)
CI_PACKAGES=(
aspell
aspell-en
jq
libcap2-bin
make
patch
tcpdump
time
sudo)
LLVM_PACKAGES=(
cmake
cmake-data
ninja-build
python3)
UBUNTU_PACKAGES=(
automake
bc
byobu
bzip2
curl
devscripts
docker-buildx-plugin
docker-ce-cli
doxygen
expect
gdb
graphviz
libffi-dev
libncurses-dev
libssl-dev
libtool
make
rpm
rsync
skopeo
ssh-client
strace
tshark
zip)
if [[ "$ARCH" == "aarch64" ]]; then
COMMON_PACKAGES+=(libtinfo5)
fi
# This is not currently used
add_ubuntu_keys () {
apt-get update -y
for key in "${@}"; do
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys "$key"
done
}
add_apt_key () {
apt-get update -y
wget -q -O - "$1" | apt-key add -
}
add_apt_k8s_key () {
apt-get update -y
wget -q -O - "$1" | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/devel_kubic_libcontainers_stable.gpg > /dev/null
}
add_apt_repos () {
local repo
apt-get update -y
apt-get -qq install -y ca-certificates
for repo in "${@}"; do
echo "deb ${repo}" >> "/etc/apt/sources.list"
done
apt-get update -y
}
apt_install () {
apt-get -qq update -y
apt-get -qq install -y --no-install-recommends --no-install-suggests "${@}"
}
ensure_stdlibcc () {
apt list libstdc++6 | grep installed | grep "$LIBSTDCXX_EXPECTED_VERSION"
}
install_base () {
apt_install "${COMMON_PACKAGES[@]}"
add_ubuntu_keys "${APT_KEYS_ENV[@]}"
add_apt_repos "${APT_REPOS_ENV[@]}"
apt-get -qq update
apt_install "${DEV_PACKAGES[@]}"
apt-get -qq dist-upgrade -y
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 1
ensure_stdlibcc
}
install_gn (){
# Install gn tools which will be used for building wee8
wget -q -O gntool.zip "https://chrome-infra-packages.appspot.com/dl/gn/gn/linux-${DEB_ARCH}/+/latest"
unzip -q gntool.zip -d gntool
cp gntool/gn /usr/local/bin/gn
chmod +x /usr/local/bin/gn
rm -rf gntool*
}
mobile_install_android () {
mkdir -p "$ANDROID_HOME"
cd "$ANDROID_SDK_INSTALL_TARGET"
wget -q -O android-tools.zip "${ANDROID_CLI_TOOLS}"
unzip -q android-tools.zip
rm android-tools.zip
mkdir -p sdk/cmdline-tools/latest
mv cmdline-tools/* sdk/cmdline-tools/latest
sdkmanager="${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager"
echo "y" | $sdkmanager --install "ndk;${ANDROID_NDK_VERSION}" | grep -v = || true
$sdkmanager --install "platforms;android-30" | grep -v = || true
$sdkmanager --install "build-tools;30.0.2" | grep -v = || true
}
mobile_install_jdk () {
# Download and install the package that adds
# the Azul APT repository to the list of sources
wget -q -O zulu.deb "${ZULU_INSTALL_DEB}"
# Install the Java 11 JDK
apt-get install -y ./zulu.deb
apt-get update -y
apt-get install -y zulu11-jdk
rm ./zulu.deb
}
mobile_install () {
add_ubuntu_keys "${APT_KEYS_MOBILE[@]}"
mobile_install_jdk
mobile_install_android
}
install () {
if [[ "$ARCH" == "ppc64le" ]]; then
install_ppc64le_bazel
fi
add_apt_key "${APT_KEY_DOCKER}"
add_apt_k8s_key "${APT_KEY_K8S}"
add_apt_repos "${APT_REPOS[@]}"
apt-get -qq update
apt-get -qq install -y --no-install-recommends "${UBUNTU_PACKAGES[@]}"
apt-get -qq update
apt-get -qq upgrade -y
ensure_stdlibcc
LLVM_HOST_TARGET="$(/opt/llvm/bin/llvm-config --host-target)"
echo "/opt/llvm/lib/${LLVM_HOST_TARGET}" > /etc/ld.so.conf.d/llvm.conf
ldconfig
}
install_ci () {
ensure_stdlibcc
apt-get -qq update -y
apt-get -qq install -y --no-install-recommends "${CI_PACKAGES[@]}"
install_build
}
install_llvm () {
add_apt_key "${APT_KEY_KITWARE}"
add_apt_repos "${APT_REPOS_LLVM[@]}"
apt-get -qq update -y
apt-get -qq install -y --no-install-recommends "${LLVM_PACKAGES[@]}"
install_llvm_bins
install_san
install_gn
}