-
Notifications
You must be signed in to change notification settings - Fork 235
/
bootstrap
executable file
·206 lines (176 loc) · 6.98 KB
/
bootstrap
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
#!/bin/bash
#
# Copyright (c) 2017, The OpenThread Authors.
# All rights reserved.
#
# 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.
#
# Description:
# This script resolves all dependencies.
#
# shellcheck source=script/_initrc
. "$(dirname "$0")"/_initrc
NAT64_SERVICE="${NAT64_SERVICE:-openthread}"
FIREWALL="${FIREWALL:-1}"
OTBR_MDNS="${OTBR_MDNS:-mDNSResponder}"
OT_BACKBONE_CI="${OT_BACKBONE_CI:-0}"
REFERENCE_DEVICE="${REFERENCE_DEVICE:-0}"
install_packages_apt()
{
sudo apt-get update
sudo apt-get install --no-install-recommends -y \
wget \
iproute2 \
iputils-ping \
libreadline-dev \
libncurses-dev
sudo apt-get install --no-install-recommends -y build-essential ninja-build cmake
sudo apt-get install --no-install-recommends -y rsyslog
# For DBus server
sudo apt-get install --no-install-recommends -y dbus libdbus-1-dev
# mDNS
sudo apt-get install --no-install-recommends -y libavahi-client3 libavahi-common-dev libavahi-client-dev
# Thread Certification tests require Avahi to publish records for tests. Since the
# same image is used for all tests this needs to be installed here. Additionally
# Avahi should be included for reference device builds.
if [[ ${OTBR_MDNS} == "avahi" || ${OT_BACKBONE_CI} == 1 || ${REFERENCE_DEVICE} == 1 ]]; then
sudo apt-get install --no-install-recommends -y avahi-daemon
fi
(MDNS_RESPONDER_SOURCE_NAME=mDNSResponder-1790.80.10 \
&& MDNS_RESPONDER_PATCH_PATH=$(realpath "$(dirname "$0")"/../third_party/mDNSResponder) \
&& cd /tmp \
&& wget --no-check-certificate https://github.com/apple-oss-distributions/mDNSResponder/archive/refs/tags/$MDNS_RESPONDER_SOURCE_NAME.tar.gz \
&& mkdir -p $MDNS_RESPONDER_SOURCE_NAME \
&& tar xvf $MDNS_RESPONDER_SOURCE_NAME.tar.gz -C $MDNS_RESPONDER_SOURCE_NAME --strip-components=1 \
&& cd /tmp/"$MDNS_RESPONDER_SOURCE_NAME" \
&& (
for patch in "$MDNS_RESPONDER_PATCH_PATH"/*.patch; do
patch -p1 <"$patch"
done
) \
&& cd mDNSPosix \
&& make os=linux tls=no && sudo make install os=linux tls=no)
# Boost
sudo apt-get install --no-install-recommends -y libboost-dev libboost-filesystem-dev libboost-system-dev
# nat64
without NAT64 || {
[ "$NAT64_SERVICE" != "tayga" ] || sudo apt-get install --no-install-recommends -y tayga
sudo apt-get install --no-install-recommends -y iptables
}
# dns64
without DNS64 || {
if [ "$PLATFORM" = "beagleboneblack" ]; then
# dnsmasq needs to be stopped before bind9 is installed
sudo systemctl disable dnsmasq
sudo systemctl stop dnsmasq
fi
sudo apt-get install --no-install-recommends -y bind9
# Resolvconf cannot be installed inside docker environment
if without DOCKER; then
sudo apt-get install --no-install-recommends -y resolvconf
fi
}
# dhcpv6-pd
without DHCPV6_PD_REF || {
sudo apt-get install --no-install-recommends -y dhcpcd
sudo mkdir -p /etc/systemd/system/dhcpcd.service.d
# allow edit system config file eg. /etc/radvd.conf
sudo tee /etc/systemd/system/dhcpcd.service.d/custom.conf >/dev/null <<EOF
[Service]
ProtectSystem=false
EOF
# reload dhcpcd daemon to activate the custom.conf
sudo systemctl daemon-reload
sudo apt-get install --no-install-recommends -y radvd
}
# network-manager
without NETWORK_MANAGER || sudo apt-get install --no-install-recommends -y dnsmasq network-manager
# dhcpcd5
without DHCPV6_PD || sudo apt-get install --no-install-recommends -y dhcpcd5
# libjsoncpp
sudo apt-get install --no-install-recommends -y libjsoncpp-dev
# reference device
without REFERENCE_DEVICE || sudo apt-get install --no-install-recommends -y radvd dnsutils avahi-utils iperf3
# backbone-router
without BACKBONE_ROUTER || sudo apt-get install --no-install-recommends -y libnetfilter-queue1 libnetfilter-queue-dev
# web dependencies
without WEB_GUI || command -v npm || sudo apt-get install --no-install-recommends -y nodejs npm
# firewall
sudo apt-get install -y iptables ipset
# protobuf compiler
sudo apt-get install -y libprotobuf-dev protobuf-compiler
}
install_packages_opkg()
{
die 'opkg not supported currently'
}
install_packages_rpm()
{
if have dnf; then
PM=dnf
else
PM=yum
fi
sudo $PM install -y gcc gcc-c++
with RELEASE || sudo $PM install -y cmake ninja-build
sudo $PM install -y dbus-devel
sudo $PM install -y avahi avahi-devel
sudo $PM install -y boost-devel boost-filesystem boost-system
[ "$NAT64_SERVICE" != "tayga" ] || sudo $PM install -y tayga
sudo $PM install -y iptables
sudo $PM install -y jsoncpp-devel
sudo $PM install -y wget
sudo $PM install -y protobuf protobuf-devel
}
install_packages_brew()
{
brew install boost cmake dbus jsoncpp ninja
}
install_packages_source()
{
die 'source not supported currently'
}
install_packages()
{
if have apt-get; then
install_packages_apt
elif have rpm; then
install_packages_rpm
elif have opkg; then
install_packages_opkg
elif have brew; then
install_packages_brew
else
install_packages_source
fi
}
main()
{
. "$BEFORE_HOOK"
# TODO remove `|| true` after docker hub builder gets its git upgraded
git submodule update --init --recursive --depth 1 || true
install_packages
. "$AFTER_HOOK"
}
main