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 36NAT64_SERVICE="${NAT64_SERVICE:-openthread}" 37 38FIREWALL="${FIREWALL:-1}" 39 40install_packages_apt() 41{ 42 sudo apt-get update 43 sudo apt-get install --no-install-recommends -y \ 44 wget \ 45 iproute2 \ 46 iputils-ping \ 47 libreadline-dev \ 48 libncurses-dev 49 50 sudo apt-get install --no-install-recommends -y build-essential ninja-build cmake 51 52 with RELEASE || sudo apt-get install --no-install-recommends -y libcpputest-dev 53 54 sudo apt-get install --no-install-recommends -y rsyslog 55 56 # For DBus server 57 sudo apt-get install --no-install-recommends -y libdbus-1-dev 58 59 # mDNS 60 sudo apt-get install --no-install-recommends -y libavahi-client3 libavahi-common-dev libavahi-client-dev avahi-daemon 61 (MDNS_RESPONDER_SOURCE_NAME=mDNSResponder-1790.80.10 \ 62 && MDNS_RESPONDER_PATCH_PATH=$(realpath "$(dirname "$0")"/../third_party/mDNSResponder) \ 63 && cd /tmp \ 64 && wget --no-check-certificate https://github.com/apple-oss-distributions/mDNSResponder/archive/refs/tags/$MDNS_RESPONDER_SOURCE_NAME.tar.gz \ 65 && mkdir -p $MDNS_RESPONDER_SOURCE_NAME \ 66 && tar xvf $MDNS_RESPONDER_SOURCE_NAME.tar.gz -C $MDNS_RESPONDER_SOURCE_NAME --strip-components=1 \ 67 && cd /tmp/"$MDNS_RESPONDER_SOURCE_NAME" \ 68 && ( 69 for patch in "$MDNS_RESPONDER_PATCH_PATH"/*.patch; do 70 patch -p1 <"$patch" 71 done 72 ) \ 73 && cd mDNSPosix \ 74 && make os=linux tls=no && sudo make install os=linux tls=no) 75 76 # Boost 77 sudo apt-get install --no-install-recommends -y libboost-dev libboost-filesystem-dev libboost-system-dev 78 79 # nat64 80 without NAT64 || { 81 [ "$NAT64_SERVICE" != "tayga" ] || sudo apt-get install --no-install-recommends -y tayga 82 sudo apt-get install --no-install-recommends -y iptables 83 } 84 85 # dns64 86 without DNS64 || { 87 if [ "$PLATFORM" = "beagleboneblack" ]; then 88 # dnsmasq needs to be stopped before bind9 is installed 89 sudo systemctl disable dnsmasq 90 sudo systemctl stop dnsmasq 91 fi 92 sudo apt-get install --no-install-recommends -y bind9 93 # Resolvconf cannot be installed inside docker environment 94 if without DOCKER; then 95 sudo apt-get install --no-install-recommends -y resolvconf 96 fi 97 } 98 99 # network-manager 100 without NETWORK_MANAGER || sudo apt-get install --no-install-recommends -y dnsmasq network-manager 101 102 # dhcpcd5 103 without DHCPV6_PD || sudo apt-get install --no-install-recommends -y dhcpcd5 104 105 # libjsoncpp 106 sudo apt-get install --no-install-recommends -y libjsoncpp-dev 107 108 # reference device 109 without REFERENCE_DEVICE || sudo apt-get install --no-install-recommends -y radvd dnsutils avahi-utils 110 111 # backbone-router 112 without BACKBONE_ROUTER || sudo apt-get install --no-install-recommends -y libnetfilter-queue1 libnetfilter-queue-dev 113 114 # web dependencies 115 without WEB_GUI || command -v npm || sudo apt-get install --no-install-recommends -y nodejs npm 116 117 # firewall 118 sudo apt-get install -y iptables ipset 119 120 # protobuf compiler 121 sudo apt-get install -y libprotobuf-dev protobuf-compiler 122} 123 124install_packages_opkg() 125{ 126 die 'opkg not supported currently' 127} 128 129install_packages_rpm() 130{ 131 if have dnf; then 132 PM=dnf 133 else 134 PM=yum 135 fi 136 sudo $PM install -y gcc gcc-c++ 137 with RELEASE || sudo $PM install -y cmake ninja-build 138 sudo $PM install -y dbus-devel 139 sudo $PM install -y avahi avahi-devel 140 sudo $PM install -y boost-devel boost-filesystem boost-system 141 [ "$NAT64_SERVICE" != "tayga" ] || sudo $PM install -y tayga 142 sudo $PM install -y iptables 143 sudo $PM install -y jsoncpp-devel 144 sudo $PM install -y wget 145 sudo $PM install -y protobuf protobuf-devel 146} 147 148install_packages_brew() 149{ 150 brew install boost cmake cpputest dbus jsoncpp ninja 151} 152 153install_packages_source() 154{ 155 die 'source not supported currently' 156} 157 158install_packages() 159{ 160 if have apt-get; then 161 install_packages_apt 162 elif have rpm; then 163 install_packages_rpm 164 elif have opkg; then 165 install_packages_opkg 166 elif have brew; then 167 install_packages_brew 168 else 169 install_packages_source 170 fi 171} 172 173main() 174{ 175 . "$BEFORE_HOOK" 176 # TODO remove `|| true` after docker hub builder gets its git upgraded 177 git submodule update --init --recursive --depth 1 || true 178 install_packages 179 . "$AFTER_HOOK" 180} 181 182main 183