forked from autowarefoundation/autoware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-dev-env.sh
executable file
·132 lines (111 loc) · 3.38 KB
/
setup-dev-env.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/env bash
# Set up development environment for Autoware Core/Universe.
# Usage: setup-dev-env.sh <installation_type('core' or 'universe')> [-y] [-v] [--no-nvidia]
# Note: -y option is only for CI.
set -e
SCRIPT_DIR=$(readlink -f "$(dirname "$0")")
# Parse arguments
args=()
while [ "$1" != "" ]; do
case "$1" in
-y)
# Use non-interactive mode.
option_yes=true
;;
-v)
# Enable debug outputs.
option_verbose=true
;;
--no-nvidia)
# Disable installation of the NVIDIA-related roles ('cuda' and 'tensorrt').
option_no_nvidia=true
;;
--no-cuda-drivers)
# Disable installation of 'cuda-drivers' in the role 'cuda'.
option_no_cuda_drivers=true
;;
*)
args+=("$1")
;;
esac
shift
done
# Select installation type
target_playbook="autoware.dev_env.universe" # default
if [ ${#args[@]} -ge 1 ]; then
target_playbook="autoware.dev_env.${args[0]}"
fi
# Initialize ansible args
ansible_args=()
# Confirm to start installation
if [ "$option_yes" = "true" ]; then
echo -e "\e[36mRun the setup in non-interactive mode.\e[m"
else
echo -e "\e[33mSetting up the build environment can take up to 1 hour.\e[m"
read -rp "> Are you sure you want to run setup? [y/N] " answer
# Check whether to cancel
if ! [[ ${answer:0:1} =~ y|Y ]]; then
echo -e "\e[33mCancelled.\e[0m"
exit 1
fi
ansible_args+=("--ask-become-pass")
fi
# Check verbose option
if [ "$option_verbose" = "true" ]; then
ansible_args+=("-vvv")
fi
# Check installation of NVIDIA libraries
if [ "$option_no_nvidia" = "true" ]; then
ansible_args+=("--extra-vars" "prompt_install_nvidia=n")
elif [ "$option_yes" = "true" ]; then
ansible_args+=("--extra-vars" "prompt_install_nvidia=y")
fi
# Check installation of CUDA Drivers
if [ "$option_no_cuda_drivers" = "true" ]; then
ansible_args+=("--extra-vars" "install_cuda_drivers=false")
fi
# Load env
source "$SCRIPT_DIR/amd64.env"
if [ "$(uname -m)" = "aarch64" ]; then
source "$SCRIPT_DIR/arm64.env"
fi
# Add env args
# shellcheck disable=SC2013
for env_name in $(sed -e "s/^\s*//" -e "/^#/d" -e "s/=.*//" <amd64.env); do
ansible_args+=("--extra-vars" "${env_name}=${!env_name}")
done
# Install sudo
if ! (command -v sudo >/dev/null 2>&1); then
apt-get -y update
apt-get -y install sudo
fi
# Install git
if ! (command -v git >/dev/null 2>&1); then
sudo apt-get -y update
sudo apt-get -y install git
fi
# Install pip for ansible
if ! (command -v pip3 >/dev/null 2>&1); then
sudo apt-get -y update
sudo apt-get -y install python3-pip
fi
# Install ansible
ansible_version=$(pip3 list | grep -oP "^ansible\s+\K([0-9]+)" || true)
if [ "$ansible_version" != "5" ]; then
sudo apt-get -y purge ansible
pip3 install -U "ansible==5.*"
fi
# For Python packages installed with user privileges
export PATH="$HOME/.local/bin:$PATH"
# Install ansible collections
echo -e "\e[36m"ansible-galaxy collection install -f -r "$SCRIPT_DIR/ansible-galaxy-requirements.yaml" "\e[m"
ansible-galaxy collection install -f -r "$SCRIPT_DIR/ansible-galaxy-requirements.yaml"
# Run ansible
echo -e "\e[36m"ansible-playbook "$target_playbook" "${ansible_args[@]}" "\e[m"
if ansible-playbook "$target_playbook" "${ansible_args[@]}"; then
echo -e "\e[32mCompleted.\e[0m"
exit 0
else
echo -e "\e[31mFailed.\e[0m"
exit 1
fi