Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / ot-br-posix / repo / script / bootstrap
1 #!/bin/bash
2 #
3 #  Copyright (c) 2017, The OpenThread Authors.
4 #  All rights reserved.
5 #
6 #  Redistribution and use in source and binary forms, with or without
7 #  modification, are permitted provided that the following conditions are met:
8 #  1. Redistributions of source code must retain the above copyright
9 #     notice, this list of conditions and the following disclaimer.
10 #  2. Redistributions in binary form must reproduce the above copyright
11 #     notice, this list of conditions and the following disclaimer in the
12 #     documentation and/or other materials provided with the distribution.
13 #  3. Neither the name of the copyright holder nor the
14 #     names of its contributors may be used to endorse or promote products
15 #     derived from this software without specific prior written permission.
16 #
17 #  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 #  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 #  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 #  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 #  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 #  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 #  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 #  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 #  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 #  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 #  POSSIBILITY OF SUCH DAMAGE.
28 #
29 #   Description:
30 #       This script resolves all dependencies.
31 #
32
33 # shellcheck source=script/_initrc
34 . "$(dirname "$0")"/_initrc
35
36 install_packages_apt()
37 {
38     sudo apt-get update
39     sudo apt-get install --no-install-recommends -y \
40         wget \
41         iproute2 \
42         iputils-ping \
43         libreadline-dev \
44         libncurses-dev
45
46     sudo apt-get install --no-install-recommends -y build-essential ninja-build cmake
47
48     with RELEASE || sudo apt-get install --no-install-recommends -y libcpputest-dev
49
50     sudo apt-get install --no-install-recommends -y rsyslog
51
52     # For DBus server
53     sudo apt-get install --no-install-recommends -y libdbus-1-dev
54
55     # mDNS
56     sudo apt-get install --no-install-recommends -y libavahi-client3 libavahi-common-dev libavahi-client-dev avahi-daemon
57
58     # Boost
59     sudo apt-get install --no-install-recommends -y libboost-dev libboost-filesystem-dev libboost-system-dev
60
61     # nat64
62     without NAT64 || sudo apt-get install --no-install-recommends -y tayga iptables
63
64     # dns64
65     without DNS64 || {
66         sudo apt-get install --no-install-recommends -y bind9
67         # Resolvconf cannot be installed inside docker environment
68         if without DOCKER; then
69             sudo apt-get install --no-install-recommends -y resolvconf
70         fi
71     }
72
73     # network-manager
74     without NETWORK_MANAGER || sudo apt-get install --no-install-recommends -y dnsmasq network-manager
75
76     # dhcpcd5
77     without DHCPV6_PD || {
78         # More details can be found in issue: #122
79         if [ "$PLATFORM" = 'raspbian' ]; then
80             # TODO should figure out a better way to deal with this
81             sudo dpkg -i third_party/dhcpcd/dhcpcd5_6.11.5-1+rpt2_armhf.deb
82         else
83             sudo apt-get install --no-install-recommends -y dhcpcd5
84         fi
85     }
86
87     # libjsoncpp
88     sudo apt-get install --no-install-recommends -y libjsoncpp1 libjsoncpp-dev
89
90     # reference device
91     without REFERENCE_DEVICE || sudo apt-get install --no-install-recommends -y radvd dnsutils
92
93     # backbone-router
94     without BACKBONE_ROUTER || sudo apt-get install --no-install-recommends -y iptables libnetfilter-queue1 libnetfilter-queue-dev
95 }
96
97 install_packages_opkg()
98 {
99     die 'opkg not supported currently'
100 }
101
102 install_packages_rpm()
103 {
104     if have dnf; then
105         PM=dnf
106     else
107         PM=yum
108     fi
109     sudo $PM install -y gcc gcc-c++
110     with RELEASE || sudo $PM install -y cmake ninja-build
111     sudo $PM install -y dbus-devel
112     sudo $PM install -y avahi avahi-devel
113     sudo $PM install -y doxygen
114     sudo $PM install -y boost-devel boost-filesystem boost-system
115     sudo $PM install -y tayga iptables
116     sudo $PM install -y jsoncpp-devel
117     sudo $PM install -y wget
118 }
119
120 install_packages_brew()
121 {
122     brew install boost cmake cpputest dbus jsoncpp ninja
123 }
124
125 install_packages_source()
126 {
127     die 'source not supported currently'
128 }
129
130 install_packages()
131 {
132     if have apt-get; then
133         install_packages_apt
134     elif have rpm; then
135         install_packages_rpm
136     elif have opkg; then
137         install_packages_opkg
138     elif have brew; then
139         install_packages_brew
140     else
141         install_packages_source
142     fi
143 }
144
145 main()
146 {
147     . "$BEFORE_HOOK"
148     # TODO remove `|| true` after docker hub builder gets its git upgraded
149     git submodule update --init --recursive --depth 1 || true
150     install_packages
151     . "$AFTER_HOOK"
152 }
153
154 main