forked from google/orbit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap-orbit.sh
executable file
·154 lines (132 loc) · 5.21 KB
/
bootstrap-orbit.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
#
# Copyright (c) 2020 The Orbit Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
OPTIONS=$(getopt -o "" -l "force-public-remotes,assume-linux,assume-windows,ignore-system-requirements,dont-compile" -- "$@")
eval set -- "$OPTIONS"
CONFIG_INSTALL_OPTIONS=""
IGNORE_SYS_REQUIREMENTS=""
DONT_COMPILE=""
while true; do
case "$1" in
--force-public-remotes|--assume-linux|--assume-windows)
CONFIG_INSTALL_OPTIONS="${CONFIG_INSTALL_OPTIONS} $1"; shift;;
--ignore-system-requirements) IGNORE_SYS_REQUIREMENTS="yes"; shift;;
--dont-compile) DONT_COMPILE="yes"; shift;;
--) shift; break;;
esac
done
readonly REQUIRED_PACKAGES=( build-essential libglu1-mesa-dev mesa-common-dev \
libxmu-dev libxi-dev libopengl0 qtbase5-dev \
qtwebengine5-dev libqt5webchannel5-dev \
libqt5websockets5-dev libxxf86vm-dev python3-pip )
function add_ubuntu_universe_repo {
sudo add-apt-repository universe
if [ $? -ne 0 ]; then
sudo apt-get install -y software-properties-common
sudo add-apt-repository universe
fi
}
function install_required_packages {
sudo apt-get update || exit $?
sudo apt-get install -y ${REQUIRED_PACKAGES[@]} || exit $?
}
if [[ $IGNORE_SYS_REQUIREMENTS != "yes" ]]; then
if which dpkg-query >/dev/null 2>&1; then
readonly installed="$(dpkg-query --show -f'${Package}\n')"
PACKAGES_MISSING="no"
for package in ${REQUIRED_PACKAGES[@]}; do
if ! egrep "^${package}$" <<<"$installed" > /dev/null; then
PACKAGES_MISSING="yes"
break
fi
done
if [[ $PACKAGES_MISSING == "yes" ]]; then
echo "Installing required system dependencies..."
# That only works on Ubuntu!
if [[ "$(lsb_release -si)" == "Ubuntu" ]]; then
add_ubuntu_universe_repo
fi
install_required_packages
fi
else
cat <<EOF
We detected you're not on a debian-based system. Orbit requires some system
packages to be installed. Please make sure that you have those installed.
Here are Debian package names: ${REQUIRED_PACKAGES[@]}.
On other Linux distributions the package names might be similar but not exactly
the same!
EOF
fi # which dpkg-query
fi # IGNORE_SYS_REQ
echo "Checking if conan is available..."
which conan >/dev/null
if [ $? -ne 0 ]; then
echo "Couldn't find conan. Trying to install via pip..."
pip3 install --user conan==1.40.3 || exit $?
which conan >/dev/null
if [ $? -ne 0 ]; then
echo "Could not find conan in the path, although the installation reported success."
echo "Probably conan was installed into a directory which is not in the PATH."
echo "Please ensure conan is reachable via the PATH and call this script again."
echo "Hint: Probably you have to add $HOME/.local/bin to your path variable."
echo " If you use bash, you can call 'export PATH=\$HOME/.local/bin:\$PATH'"
echo " to do that. Add this line to your .bashrc file, to make this change"
echo " persistent."
exit 1
fi
else
echo "Found conan. Checking version..."
CONAN_VERSION="$(conan --version | cut -d' ' -f3)"
CONAN_VERSION_MAJOR="$(echo "$CONAN_VERSION" | cut -d'.' -f1)"
CONAN_VERSION_MINOR="$(echo "$CONAN_VERSION" | cut -d'.' -f2)"
CONAN_VERSION_MAJOR_REQUIRED=1
CONAN_VERSION_MINOR_MIN=36
if [ "$CONAN_VERSION_MAJOR" -eq $CONAN_VERSION_MAJOR_REQUIRED -a "$CONAN_VERSION_MINOR" -lt $CONAN_VERSION_MINOR_MIN ]; then
echo "Your conan version $CONAN_VERSION is too old. I will try to update..."
pip3 install --upgrade --user conan==1.40.3
if [ $? -ne 0 ]; then
echo "The upgrade of your conan installation failed. Probably because conan was not installed by this script."
echo "Please manually update conan to at least version $CONAN_VERSION_MAJOR_REQUIRED.$CONAN_VERSION_MINOR_MIN."
exit 2
fi
echo "Conan updated finished."
else
echo "Conan's version fulfills the requirements. Continuing..."
fi
fi
echo "Installing conan configuration (profiles, settings, etc.)..."
$DIR/third_party/conan/configs/install.sh $CONFIG_INSTALL_OPTIONS || exit $?
if [[ $DONT_COMPILE != "yes" ]]; then
if [ -n "$1" ] ; then
exec $DIR/build.sh "$@"
else
conan remote list | grep -v 'Disabled:' | grep -e '^artifactory:' > /dev/null 2>&1
if [ $? -eq 0 ]; then
exec $DIR/build.sh default_relwithdebinfo ggp_relwithdebinfo
else
exec $DIR/build.sh
fi
fi
fi
PRE_COMMIT_HOOK_FILE=.git/hooks/pre-commit
function install_clang_format_pre_commit_hook {
if [ ! -f $PRE_COMMIT_HOOK_FILE ] ; then
touch $PRE_COMMIT_HOOK_FILE
chmod +x $PRE_COMMIT_HOOK_FILE
fi
echo "source \"contrib/hooks/clang-format-pre-commit.sh\"" >> $PRE_COMMIT_HOOK_FILE
}
if [ -d .git ] ; then
if [ ! -f $PRE_COMMIT_HOOK_FILE ] || ! grep -q "contrib/hooks/clang-format-pre-commit.sh" .git/hooks/pre-commit ; then
while true; do
read -p "Do you want to install the clang-format pre-commit hook [y/n]? `echo $'\n> '`" yn
case $yn in
[Yy]* ) install_clang_format_pre_commit_hook; break;;
[Nn]* ) break;;
esac
done
fi
fi