Skip to content

Commit 2e032c4

Browse files
committed
refactor scripts
1 parent ec91864 commit 2e032c4

File tree

7 files changed

+99
-73
lines changed

7 files changed

+99
-73
lines changed

apps/microtvm/reference-vm/arduino/base-box/base_box_setup.sh

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,42 +26,19 @@ if [ -e "$HOME/skip_zeroing_disk" ]; then
2626
skip_zeroing_disk=1
2727
fi
2828

29-
sudo apt update
30-
sudo apt install -y build-essential
31-
sudo apt-get --purge remove modemmanager # required to access serial ports.
29+
# Install common configs
30+
~/base_box_setup_common.sh
31+
rm -rf ~/base_box_setup_common.sh
3232

33-
sudo apt install -y --no-install-recommends git \
34-
cmake cmake-data \
35-
ninja-build gperf ccache dfu-util device-tree-compiler wget \
36-
python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \
37-
make gcc gcc-multilib g++-multilib libsdl2-dev
38-
39-
OLD_HOSTNAME=$(hostname)
40-
sudo hostnamectl set-hostname microtvm
41-
sudo sed -i.bak "s/${OLD_HOSTNAME}/microtvm.localdomain/g" /etc/hosts
42-
43-
# Poetry deps
44-
sudo apt install -y python3-venv
45-
46-
# TVM deps
47-
sudo apt install -y llvm
48-
49-
# ONNX deps
50-
sudo apt install -y protobuf-compiler libprotoc-dev
33+
# Poetry
34+
sed -i "/^# If not running interactively,/ i source \$HOME/.poetry/env" ~/.bashrc
35+
sed -i "/^# If not running interactively,/ i\\ " ~/.bashrc
5136

5237
# TODO do we need this?
5338
echo 'export PATH=$HOME/vagrant/bin:"$PATH"' >> ~/.profile
5439
source ~/.profile
5540
echo PATH=$PATH
5641

57-
# Poetry
58-
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3
59-
sed -i "/^# If not running interactively,/ i source \$HOME/.poetry/env" ~/.bashrc
60-
sed -i "/^# If not running interactively,/ i\\ " ~/.bashrc
61-
62-
# Python 3.7
63-
sudo apt install -y python3.7
64-
6542
# Clean box for packaging as a base box
6643
sudo apt-get clean
6744
if [ $skip_zeroing_disk -eq 0 ]; then

apps/microtvm/reference-vm/base-box-tool.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,15 @@
5353
# Extra scripts required to execute on provisioning
5454
# in [platform]/base-box/base_box_provision.sh
5555
EXTRA_SCRIPTS = {
56-
"arduino": (),
56+
"arduino": (
57+
"apps/microtvm/reference-vm/base_box_setup_common.sh",
58+
"docker/install/ubuntu_install_core.sh",
59+
"docker/install/ubuntu_install_python.sh",
60+
),
5761
"zephyr": (
62+
"apps/microtvm/reference-vm/base_box_setup_common.sh",
63+
"docker/install/ubuntu_install_core.sh",
64+
"docker/install/ubuntu_install_python.sh",
5865
"docker/install/ubuntu_init_zephyr_project.sh",
5966
"docker/install/ubuntu_install_zephyr_sdk.sh",
6067
"docker/install/ubuntu_install_cmsis.sh",
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash -e
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
19+
set -e
20+
set -x
21+
22+
# Fix network DNS issue
23+
sudo sed -i 's/DNSSEC=yes/DNSSEC=no/' /etc/systemd/resolved.conf
24+
sudo systemctl restart systemd-resolved
25+
sudo cat /etc/systemd/resolved.conf
26+
27+
sudo apt update
28+
sudo apt install -y build-essential
29+
sudo apt-get --purge remove modemmanager # required to access serial ports.
30+
31+
# Core
32+
sudo ~/ubuntu_install_core.sh
33+
rm -rf ~/ubuntu_install_core.sh
34+
35+
sudo apt install -y --no-install-recommends git \
36+
gperf ccache dfu-util device-tree-compiler xz-utils file \
37+
gcc gcc-multilib g++-multilib libsdl2-dev
38+
39+
# Cmake
40+
# NOTE: latest cmake cannot be installed due to
41+
# https://github.com/zephyrproject-rtos/zephyr/issues/30232
42+
wget --no-verbose https://apt.kitware.com/keys/kitware-archive-latest.asc
43+
sudo apt-key add kitware-archive-latest.asc
44+
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main'
45+
sudo apt update
46+
sudo apt install -y --no-install-recommends \
47+
cmake=3.22.2-0kitware1ubuntu18.04.1 cmake-data=3.22.2-0kitware1ubuntu18.04.1 \
48+
49+
# Python
50+
sudo ~/ubuntu_install_python.sh
51+
rm -rf ~/ubuntu_install_python.sh
52+
53+
# Poetry deps
54+
sudo apt install -y python3-venv
55+
56+
# TVM deps
57+
# TODO(mehrdadh): replace with ubuntu_install_llvm.sh
58+
sudo apt install -y llvm
59+
60+
# ONNX deps
61+
sudo apt install -y protobuf-compiler libprotoc-dev
62+
63+
# Poetry
64+
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3
65+
66+
# Host name
67+
OLD_HOSTNAME=$(hostname)
68+
sudo hostnamectl set-hostname microtvm
69+
sudo sed -i.bak "s/${OLD_HOSTNAME}/microtvm.localdomain/g" /etc/hosts

apps/microtvm/reference-vm/zephyr/base-box/base_box_setup.sh

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -26,38 +26,14 @@ if [ -e "$HOME/skip_zeroing_disk" ]; then
2626
skip_zeroing_disk=1
2727
fi
2828

29-
sudo apt update
30-
sudo apt install -y build-essential
31-
sudo apt-get --purge remove modemmanager # required to access serial ports.
29+
# Install common configs
30+
~/base_box_setup_common.sh
31+
rm -rf ~/base_box_setup_common.sh
3232

33-
# Zephyr
34-
wget --no-verbose https://apt.kitware.com/keys/kitware-archive-latest.asc
35-
sudo apt-key add kitware-archive-latest.asc
36-
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main'
37-
sudo apt update
38-
# NOTE: latest cmake cannot be installed due to
39-
# https://github.com/zephyrproject-rtos/zephyr/issues/30232
40-
sudo apt install -y --no-install-recommends git \
41-
cmake=3.22.2-0kitware1ubuntu18.04.1 cmake-data=3.22.2-0kitware1ubuntu18.04.1 \
42-
ninja-build gperf ccache dfu-util device-tree-compiler wget \
43-
python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \
44-
make gcc gcc-multilib g++-multilib libsdl2-dev
45-
46-
# Avahi, so that ssh microtvm works.
47-
# apt install -y avahi-daemon
48-
49-
OLD_HOSTNAME=$(hostname)
50-
sudo hostnamectl set-hostname microtvm
51-
sudo sed -i.bak "s/${OLD_HOSTNAME}/microtvm.localdomain/g" /etc/hosts
52-
53-
# Poetry deps
54-
sudo apt install -y python3-venv
55-
56-
# TVM deps
57-
sudo apt install -y llvm
58-
59-
# ONNX deps
60-
sudo apt install -y protobuf-compiler libprotoc-dev
33+
# Poetry
34+
sed -i "/^# If not running interactively,/ i source \$HOME/.poetry/env" ~/.bashrc
35+
sed -i "/^# If not running interactively,/ i export ZEPHYR_BASE=$HOME/zephyr/zephyr" ~/.bashrc
36+
sed -i "/^# If not running interactively,/ i\\ " ~/.bashrc
6137

6238
# nrfjprog
6339
NRF_COMMANDLINE_TOOLS_FILE=nRFCommandLineToolsLinuxamd64.tar.gz
@@ -95,15 +71,6 @@ sudo apt install -y python3.8-dev
9571
sudo find ~/zephyr-sdk -name '*.rules' -exec cp {} /etc/udev/rules.d \;
9672
sudo udevadm control --reload
9773

98-
# Poetry
99-
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3
100-
sed -i "/^# If not running interactively,/ i source \$HOME/.poetry/env" ~/.bashrc
101-
sed -i "/^# If not running interactively,/ i export ZEPHYR_BASE=$HOME/zephyr/zephyr" ~/.bashrc
102-
sed -i "/^# If not running interactively,/ i\\ " ~/.bashrc
103-
104-
# Python 3.7
105-
sudo apt install -y python3.7
106-
10774
# Clean box for packaging as a base box
10875
sudo apt-get clean
10976
if [ $skip_zeroing_disk -eq 0 ]; then

apps/microtvm/reference-vm/zephyr/base-box/base_box_test.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,4 @@ fi
3030

3131
board=$1
3232

33-
pytest tests/micro/zephyr/test_zephyr.py --zephyr-board=${board}
34-
pytest tests/micro/zephyr/test_zephyr_aot.py --zephyr-board=${board}
33+
pytest tests/micro/zephyr --zephyr-board=${board}

docker/install/ubuntu_install_core.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
set -e
2020
set -u
21+
# Used for debugging RVM build
22+
set -x
2123
set -o pipefail
2224

2325
# install libraries for building c++ core on ubuntu

docker/install/ubuntu_install_python.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
set -e
2020
set -u
21+
# Used for debugging RVM build
22+
set -x
2123
set -o pipefail
2224

2325
# install python and pip, don't modify this, modify install_python_package.sh
@@ -33,8 +35,11 @@ apt-get install -y python-pip python-dev python3.6 python3.6-dev
3335

3436
rm -f /usr/bin/python3 && ln -s /usr/bin/python3.6 /usr/bin/python3
3537

38+
# python 3.7
39+
apt-get install -y python3.7
40+
3641
# Install pip
37-
cd /tmp && wget -q https://bootstrap.pypa.io/get-pip.py && python3.6 get-pip.py
42+
wget -q https://bootstrap.pypa.io/get-pip.py && python3.7 get-pip.py
3843

3944
# Pin pip and setuptools versions
4045
pip3 install pip==19.3.1 setuptools==58.4.0

0 commit comments

Comments
 (0)