-
Notifications
You must be signed in to change notification settings - Fork 10
/
bootstrap.sh
executable file
·88 lines (75 loc) · 1.84 KB
/
bootstrap.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
#!/usr/bin/env bash
#
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Description:
# This file installs all needed dependencies and toolchains needed for
# example compilation and programming.
#
python='python3'
# Establish some key directories
srcdir=`dirname ${0}`
abs_srcdir=`pwd`
abs_top_srcdir="${abs_srcdir}"
use_venv='false'
python_cmd="sudo ${python}"
while getopts ':v' 'OPTKEY'; do
case ${OPTKEY} in
'v')
use_venv='true'
python_cmd="./env/bin/${python}"
;;
*) ;;
esac
done
link_sh_to_bash()
{
sudo mv /bin/sh /bin/sh.orig
sudo ln -s /bin/bash /bin/sh
}
install_packages_apt()
{
# apt update and install dependencies
sudo apt-get update
sudo apt-get install $python-pip $python-venv expect figlet graphviz $python-tk -y
}
install_packages_pip()
{
$python_cmd -m pip install --upgrade pip setuptools wheel
$python_cmd -m pip install -r requirements.txt
}
install_packages()
{
install_packages_apt
install_packages_pip
link_sh_to_bash
}
compile_proto()
{
$python_cmd -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. ./silk/tools/pb/visualize_grpc.proto
}
setup_venv()
{
$python -m venv env
}
main()
{
if ${use_venv}; then
setup_venv
fi
install_packages
compile_proto
}
main