-
Notifications
You must be signed in to change notification settings - Fork 124
Expand file tree
/
Copy pathutil.sh
More file actions
executable file
·149 lines (132 loc) · 6.42 KB
/
util.sh
File metadata and controls
executable file
·149 lines (132 loc) · 6.42 KB
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
install_autoref() {
if is_darwin $1; then
autoref_version=1.5.5
curl -L https://github.com/TIGERs-Mannheim/AutoReferee/releases/download/${autoref_version}/autoReferee.zip -o /tmp/tbots_download_cache/autoReferee.zip
unzip -q -o -d /tmp/tbots_download_cache/ /tmp/tbots_download_cache/autoReferee.zip
sudo mv /tmp/tbots_download_cache/autoReferee /opt/tbotspython/
rm -rf /tmp/tbots_download_cache/autoReferee.zip
else
autoref_commit=b30660b78728c3ce159de8ae096181a1ec52e9ba
wget -N https://github.com/TIGERs-Mannheim/AutoReferee/archive/${autoref_commit}.zip -O /tmp/tbots_download_cache/autoReferee.zip
unzip -q -o -d /tmp/tbots_download_cache/ /tmp/tbots_download_cache/autoReferee.zip
/tmp/tbots_download_cache/AutoReferee-${autoref_commit}/./gradlew installDist -p /tmp/tbots_download_cache/AutoReferee-${autoref_commit} -Dorg.gradle.java.home=/opt/tbotspython/bin/jdk
mv /tmp/tbots_download_cache/AutoReferee-${autoref_commit}/build/install/autoReferee /opt/tbotspython/
rm -rf /tmp/tbots_download_cache/autoReferee.zip /tmp/tbots_download_cache/AutoReferee-${autoref_commit}
fi
}
install_bazel() {
download=https://github.com/bazelbuild/bazelisk/releases/download/v1.26.0/bazelisk-linux-arm64
if is_x86 $1; then
download=https://github.com/bazelbuild/bazelisk/releases/download/v1.26.0/bazelisk-linux-amd64
fi
wget -nc $download -O /tmp/tbots_download_cache/bazel
sudo mv /tmp/tbots_download_cache/bazel /usr/bin/bazel
sudo chmod +x /usr/bin/bazel
}
install_clang_format() {
ln -s /usr/bin/clang-format-14 /opt/tbotspython/bin/clang-format
}
install_cross_compiler() {
file_name=aarch64-tbots-linux-gnu-for-aarch64
if is_darwin $1; then
full_file_name=$file_name.tar.xz
curl -L "https://raw.githubusercontent.com/UBC-Thunderbots/Software-External-Dependencies/refs/heads/main/toolchain/$full_file_name" \
-o /tmp/tbots_download_cache/$full_file_name
tar -xf /tmp/tbots_download_cache/$full_file_name -C /tmp/tbots_download_cache/
sudo mv /tmp/tbots_download_cache/aarch64-tbots-linux-gnu /opt/tbotspython
rm /tmp/tbots_download_cache/$full_file_name
else
if is_x86 $1; then
file_name=aarch64-tbots-linux-gnu-for-x86
fi
full_file_name=$file_name.tar.xz
wget https://raw.githubusercontent.com/UBC-Thunderbots/Software-External-Dependencies/refs/heads/main/toolchain/$full_file_name -O /tmp/tbots_download_cache/$full_file_name
tar -xf /tmp/tbots_download_cache/$full_file_name -C /tmp/tbots_download_cache/
sudo mv /tmp/tbots_download_cache/aarch64-tbots-linux-gnu /opt/tbotspython
rm /tmp/tbots_download_cache/$full_file_name
fi
}
install_gamecontroller () {
if is_darwin $1; then
curl -L https://github.com/RoboCup-SSL/ssl-game-controller/archive/refs/tags/v3.17.0.zip -o /tmp/tbots_download_cache/ssl-game-controller.zip
unzip -q -o -d /tmp/tbots_download_cache/ /tmp/tbots_download_cache/ssl-game-controller.zip
cd /tmp/tbots_download_cache/ssl-game-controller-3.17.0
make install
go build cmd/ssl-game-controller/main.go
sudo mv main /opt/tbotspython/gamecontroller
sudo chmod +x /opt/tbotspython/gamecontroller
cd -
sudo rm -rf /tmp/tbots_download_cache/ssl-game-controller-3.17.0 /tmp/tbots_download_cache/go /tmp/tbots_download_cache/go.tar.gz /tmp/tbots_download_cache/ssl-game-controller.zip
else
arch=arm64
if is_x86 $1; then
arch=amd64
fi
wget https://github.com/RoboCup-SSL/ssl-game-controller/releases/download/v3.16.1/ssl-game-controller_v3.16.1_linux_${arch} -O /tmp/tbots_download_cache/gamecontroller
sudo mv /tmp/tbots_download_cache/gamecontroller /opt/tbotspython/gamecontroller
sudo chmod +x /opt/tbotspython/gamecontroller
fi
}
install_java () {
java_home=""
java_download=https://download.oracle.com/java/21/latest/jdk-21_linux-aarch64_bin.tar.gz
if is_x86 $1; then
java_download=https://download.oracle.com/java/21/latest/jdk-21_linux-x64_bin.tar.gz
fi
wget -N $java_download -O /tmp/tbots_download_cache/jdk-21.tar.gz
tar -xzf /tmp/tbots_download_cache/jdk-21.tar.gz -C /opt/tbotspython/
mv /opt/tbotspython/jdk-21* /opt/tbotspython/bin/jdk
rm /tmp/tbots_download_cache/jdk-21.tar.gz
}
install_python_dev_cross_compile_headers() {
mkdir -p /opt/tbotspython/cross_compile_headers
wget -N https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tar.xz -O /tmp/tbots_download_cache/python-3.12.0.tar.xz
tar -xf /tmp/tbots_download_cache/python-3.12.0.tar.xz -C /tmp/tbots_download_cache/
cd /tmp/tbots_download_cache/Python-3.12.0
# The configuration is taken from the examples provided in https://docs.python.org/3.12/using/configure.html
echo ac_cv_buggy_getaddrinfo=no > config.site-aarch64
echo ac_cv_file__dev_ptmx=yes >> config.site-aarch64
echo ac_cv_file__dev_ptc=no >> config.site-aarch64
if is_x86 $1; then
CONFIG_SITE=config.site-aarch64 ./configure \
--build=x86_64-pc-linux-gnu \
--host=aarch64-unknown-linux-gnu \
-with-build-python=/usr/bin/python3.12 \
--enable-optimizations \
--prefix=/opt/tbotspython/cross_compile_headers > /dev/null
else
CONFIG_SITE=config.site-aarch64 ./configure \
--build=aarch64-pc-linux-gnu \
--host=aarch64-unknown-linux-gnu \
-with-build-python=/usr/bin/python3.12 \
--enable-optimizations \
--prefix=/opt/tbotspython/cross_compile_headers > /dev/null
fi
make inclinstall -j$(nproc) > /dev/null
cd -
rm -rf /tmp/tbots_download_cache/Python-3.12.0
rm -rf /tmp/tbots_download_cache/python-3.12.0.tar.xz
}
install_python_toolchain_headers() {
sudo mkdir -p /opt/tbotspython/py_headers/include/
sudo ln -sfn "$(python3.12-config --includes | awk '{for(i=1;i<=NF;++i) if ($i ~ /^-I/) print substr($i, 3)}' | head -n1)" /opt/tbotspython/py_headers/include/
}
is_x86() {
if [[ $1 == "x86_64" ]]; then
return 0
else
return 1
fi
}
is_darwin() {
if [[ $1 == "Darwin" ]]; then
return 0
else
return 1
fi
}
print_status_msg () {
echo "================================================================"
echo $1
echo "================================================================"
}