3 # Copyright (c) 2017, The OpenThread Authors.
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.
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.
32 TOOLS_HOME="$HOME"/.cache/tools
33 [[ -d $TOOLS_HOME ]] || mkdir -p "$TOOLS_HOME"
35 disable_install_recommends()
37 OTBR_APT_CONF_FILE=/etc/apt/apt.conf
39 if [[ -f ${OTBR_APT_CONF_FILE} ]] && grep Install-Recommends "${OTBR_APT_CONF_FILE}"; then
43 sudo tee -a /etc/apt/apt.conf <<EOF
44 APT::Get::Install-Recommends "false";
45 APT::Get::Install-Suggests "false";
49 install_common_dependencies()
52 sudo apt-get install --no-install-recommends -y \
59 libboost-filesystem-dev \
68 install_openthread_binraries()
71 cd third_party/openthread/repo
72 mkdir -p build && cd build
74 cmake .. -GNinja -DOT_PLATFORM=simulation -DOT_FULL_LOGS=1 -DOT_COMMISSIONER=ON -DOT_JOINER=ON
78 sudo apt-get install --no-install-recommends -y socat
83 echo 0 | sudo tee /proc/sys/net/ipv6/conf/all/disable_ipv6
84 echo 1 | sudo tee /proc/sys/net/ipv6/conf/all/forwarding
85 echo 1 | sudo tee /proc/sys/net/ipv4/conf/all/forwarding
90 disable_install_recommends
92 install_common_dependencies
94 if [ "$BUILD_TARGET" == script-check ] || [ "$BUILD_TARGET" == docker-check ]; then
95 install_openthread_binraries
100 if [ "$BUILD_TARGET" == otbr-dbus-check ]; then
101 install_openthread_binraries
103 install_common_dependencies
107 if [ "$BUILD_TARGET" == check ] || [ "$BUILD_TARGET" == meshcop ]; then
108 install_openthread_binraries
109 sudo apt-get install --no-install-recommends -y avahi-daemon avahi-utils cpputest
113 if [ "$BUILD_TARGET" == android-check ]; then
114 sudo apt-get install --no-install-recommends -y wget unzip libexpat1-dev gcc-multilib g++-multilib
117 wget -nv https://dl.google.com/android/repository/android-ndk-r17c-linux-x86_64.zip
118 unzip android-ndk-r17c-linux-x86_64.zip >/dev/null
119 mv android-ndk-r17c ndk-bundle
124 if [ "$BUILD_TARGET" == scan-build ]; then
125 pip3 install -U cmake
126 sudo apt-get install --no-install-recommends -y clang clang-tools
129 if [ "$BUILD_TARGET" == pretty-check ]; then
130 sudo apt-get install -y clang-format-9 shellcheck
131 sudo snap install shfmt
134 if [ "${OTBR_MDNS-}" == 'mDNSResponder' ]; then
135 SOURCE_NAME=mDNSResponder-878.30.4
136 wget https://opensource.apple.com/tarballs/mDNSResponder/$SOURCE_NAME.tar.gz \
137 && tar xvf $SOURCE_NAME.tar.gz \
138 && cd $SOURCE_NAME/mDNSPosix \
139 && make os=linux && sudo make install os=linux
143 if [ "$BUILD_TARGET" == check ]; then
144 echo 0 | sudo tee /proc/sys/net/ipv6/conf/all/disable_ipv6
147 # Allow access syslog file for unit test
148 if [ "$BUILD_TARGET" == check ]; then
149 sudo chmod a+r /var/log/syslog
152 # Prepare Raspbian image
153 if [ "$BUILD_TARGET" == raspbian-gcc ]; then
154 sudo apt-get install --no-install-recommends --allow-unauthenticated -y qemu qemu-user-static binfmt-support parted
156 (mkdir -p docker-rpi-emu \
157 && cd docker-rpi-emu \
158 && (git --git-dir=.git rev-parse --is-inside-work-tree || git --git-dir=.git init .) \
159 && git fetch --depth 1 https://github.com/ryankurte/docker-rpi-emu.git master \
160 && git checkout FETCH_HEAD)
162 pip3 install git-archive-all
164 IMAGE_NAME=$(basename "${IMAGE_URL}" .zip)
165 IMAGE_FILE="$IMAGE_NAME".img
166 [ -f "$TOOLS_HOME"/images/"$IMAGE_FILE" ] || {
170 [ -d "$TOOLS_HOME"/images ] || mkdir -p "$TOOLS_HOME"/images
172 [[ -f "$IMAGE_NAME".zip ]] || curl -LO "$IMAGE_URL"
174 unzip "$IMAGE_NAME".zip -d /tmp
177 && dd if=/dev/zero bs=1048576 count="$EXPAND_SIZE" >>"$IMAGE_FILE" \
178 && mv "$IMAGE_FILE" "$TOOLS_HOME"/images/"$IMAGE_FILE")
180 (cd docker-rpi-emu/scripts \
181 && sudo ./expand.sh "$TOOLS_HOME"/images/"$IMAGE_FILE" "$EXPAND_SIZE")
187 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
191 echo "Unknown os type"