| #!/bin/sh |
| # |
| # 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. |
| # |
| |
| . "$(dirname "$0")"/_initrc |
| |
| install_packages_apt() |
| { |
| sudo apt-get update |
| sudo apt-get install -y \ |
| wget \ |
| iproute2 \ |
| iputils-ping \ |
| apt-utils |
| sudo apt-get install -y build-essential libtool git automake autoconf |
| |
| with RELEASE || sudo apt-get install -y cmake |
| |
| # For wpantund |
| sudo apt-get install -y libdbus-1-dev |
| |
| # This is for configuring wpantund |
| sudo apt-get install -y autoconf-archive |
| |
| # mDNS |
| sudo apt-get install -y libavahi-common-dev libavahi-client-dev avahi-daemon |
| |
| # Doxygen |
| # TODO remove this in release mode |
| sudo apt-get install -y doxygen |
| |
| # For libcoap to generate .sym and .map |
| # TODO remove this in release mode |
| sudo apt-get install -y ctags |
| |
| # Boost |
| sudo apt-get install -y libboost-dev libboost-filesystem-dev libboost-system-dev |
| |
| # nat64 |
| without NAT64 || sudo apt-get install -y tayga iptables |
| |
| # dns64 |
| without DNS64 || { |
| sudo apt-get install -y bind9 |
| # Resolvconf cannot be installed inside docker environment |
| [ -f /.dockerenv ] || sudo apt-get install -y resolvconf |
| } |
| |
| # network-manager |
| without NETWORK_MANAGER || sudo apt-get install -y network-manager |
| |
| # dhcpcd5 |
| if [ $DHCPV6_PD -eq 1 ]; then |
| # More details can be found in issue: #122 |
| if [ $PLATFORM = "raspbian" ]; then |
| sudo dpkg -i third_party/dhcpcd/dhcpcd5_6.11.5-1+rpt2_armhf.deb |
| else |
| sudo apt-get install -y dhcpcd5 |
| fi |
| fi |
| |
| # libjsoncpp |
| sudo apt-get install -y libjsoncpp-dev |
| } |
| |
| 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++ libtool automake autoconf autoconf-archive git |
| with RELEASE || sudo $PM install -y cmake |
| sudo $PM install -y dbus-devel |
| sudo $PM install -y avahi avahi-devel |
| sudo $PM install -y doxygen |
| sudo $PM install -y ctags |
| sudo $PM install -y boost-devel boost-filesystem boost-system |
| sudo $PM install -y tayga iptables |
| sudo $PM install -y jsoncpp-devel |
| sudo $PM install -y wget |
| } |
| |
| install_packages_brew() |
| { |
| die 'macOS not supported currently' |
| } |
| |
| 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 |
| } |
| |
| install_cpputest() |
| { |
| if test -f $STAGE_DIR/usr/lib/libCppUTest.a; then |
| echo 'CppUTest already installed' |
| return |
| fi |
| |
| BUILD_DIR=/tmp/build-$(date +%s) |
| test ! -e $BUILD_DIR || die "$BUILD_DIR already exists!" |
| mkdir -p $BUILD_DIR |
| (cd $BUILD_DIR && |
| wget https://github.com/cpputest/cpputest/archive/v3.8.tar.gz && |
| tar xzf v3.8.tar.gz && |
| cd cpputest-3.8 && |
| ./autogen.sh && |
| ./configure --prefix=/usr && |
| make install DESTDIR=$STAGE_DIR) || die 'Failed to build CppUTest!' |
| } |
| |
| main() |
| { |
| . $BEFORE_HOOK |
| install_packages |
| with RELEASE || install_cpputest |
| ./bootstrap |
| . $AFTER_HOOK |
| } |
| |
| main |