Repository navigation
Expand file tree
/
Copy pathsetupDevEnvironment.sh
More file actions
executable file
·244 lines (217 loc) · 5.86 KB
/
Copy pathsetupDevEnvironment.sh
File metadata and controls
executable file
·244 lines (217 loc) · 5.86 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#!/bin/sh
#
# Copyright 2022 Vinícius Ferrão <vinicius@ferrao.net.br>
# SPDX-License-Identifier: Apache-2.0
#
# This file is part of OpenCATTUS
# https://github.com/versatushpc/opencattus
#
# Script to ease development environment setup on EL and Ubuntu systems
# Stop execution in case of any error (add x for debugging)
set -e
# Check if it's not running as root
if [ "$(id -u)" -ne 0 ]; then
if command -v sudo >/dev/null; then
SUDO=sudo
else
echo \
"sudo is required but not installed. Please install sudo or run as root."
exit 1
fi
fi
# Detect OS family
if [ -f /etc/os-release ]; then
. /etc/os-release
fi
case "${ID:-}" in
ubuntu|debian)
os_family=debian
;;
rhel|rocky|almalinux|ol)
os_family=el
os_version=$(rpm -E %rhel)
;;
*)
echo "Unsupported distribution: ${ID:-unknown}. Supported: RHEL, Rocky, AlmaLinux, Oracle Linux, Ubuntu."
exit 2
;;
esac
dnf() {
$SUDO /usr/bin/dnf "$@"
}
apt() {
DEBIAN_FRONTEND=noninteractive $SUDO /usr/bin/apt "$@"
}
# Helper functions
add_epel() {
dnf -y install \
"https://dl.fedoraproject.org/pub/epel/epel-release-latest-${os_version}.noarch.rpm"
}
python_bootstrap_bin() {
case "$os_family" in
debian)
command -v python3
;;
el)
case "$os_version" in
8) printf '%s\n' "/usr/bin/python3.12" ;;
*) command -v python3 2>/dev/null || command -v python ;;
esac
;;
esac
}
install_conan() {
python_bin=$(python_bootstrap_bin)
if [ ! -x "$python_bin" ]; then
echo "Unable to locate a supported Python interpreter at $python_bin"
exit 3
fi
case "$os_family" in
debian)
"$python_bin" -m pip install --break-system-packages --user --upgrade pip
"$python_bin" -m pip install --break-system-packages --user conan
;;
el)
case "$os_version" in
8)
"$python_bin" -m ensurepip --upgrade
mkdir -p "$HOME/.local/bin"
ln -sf "$python_bin" "$HOME/.local/bin/python3"
;;
esac
"$python_bin" -m pip install --user --upgrade pip
"$python_bin" -m pip install --user conan
;;
esac
}
# OS relevant settings
redhat() {
if [ "$(id -u)" -eq 0 ]; then
if ! subscription-manager refresh; then
echo "subscription-manager refresh failed; continuing with existing repository configuration"
fi
else
if ! sudo subscription-manager refresh; then
echo "subscription-manager refresh failed; continuing with existing repository configuration"
fi
fi
if [ "$os_version" -eq 10 ]; then
dnf config-manager --set-enabled \
"codeready-builder-beta-for-rhel-${os_version}-x86_64-rpms" ||
dnf config-manager --set-enabled \
"codeready-builder-for-rhel-${os_version}-x86_64-rpms" ||
echo "CodeReady Builder repo is not available; relying on the currently configured repositories"
else
dnf config-manager --set-enabled \
"codeready-builder-for-rhel-${os_version}-x86_64-rpms" ||
echo "CodeReady Builder repo is not available; relying on the currently configured repositories"
fi
add_epel;
}
rocky() {
case "$os_version" in
8)
repo_name="powertools"
;;
9|10)
repo_name="crb"
;;
esac
dnf config-manager --set-enabled "$repo_name"
dnf -y install epel-release
}
almalinux() {
case "$os_version" in
8)
repo_name="powertools"
;;
9|10)
repo_name="crb"
;;
esac
dnf config-manager --set-enabled "$repo_name"
dnf -y install epel-release
}
oracle() {
dnf config-manager --set-enabled "ol${os_version}_codeready_builder"
add_epel;
}
ubuntu() {
export DEBIAN_FRONTEND=noninteractive
$SUDO apt update
}
#
# Entrypoint
#
echo Setting up development environment for OpenCATTUS
echo
case "$os_family" in
debian)
ubuntu
;;
el)
case $(cut -f 3 -d : /etc/system-release-cpe) in
redhat) redhat ;;
rocky) rocky ;;
almalinux) almalinux ;;
oracle) oracle ;;
*)
echo Unable to properly identify the running OS. Aborting.
exit 2
;;
esac
;;
esac
# Build toolset, packages and utils
case "$os_family" in
debian)
apt install -y build-essential cmake ninja-build pkg-config ccache \
git gdb rsync autoconf automake libtool meson perl \
python3 python3-pip python3-venv \
libglibmm-2.4-dev libnewt-dev libsystemd-dev
;;
el)
dnf -y install rsync git gcc-c++ gdb cmake ninja-build ccache llvm-toolset \
lldb compiler-rt
case "$os_version" in
8)
dnf -y install python3.12 python3.12-pip-wheel gcc-toolset-14 \
gcc-toolset-14-libubsan-devel gcc-toolset-14-libasan-devel cppcheck \
glibmm24 glibmm24-devel \
perl-Thread-Queue perl-open
;;
9)
dnf -y install python pip libasan libubsan gcc-toolset-14 \
gcc-toolset-14-libubsan-devel gcc-toolset-14-libasan-devel cppcheck \
glibmm24 glibmm24-devel \
perl-File-Copy perl-File-Compare perl-Thread-Queue perl-FindBin
;;
10)
dnf -y install python pip libubsan libasan liblsan libtsan libhwasan \
glibmm2.68 glibmm2.68-devel \
perl-File-Copy perl-File-Compare perl-Thread-Queue perl-FindBin
;;
esac
dnf -y install newt-devel
;;
esac
# Conan is not packaged; install via pip
install_conan
echo
echo Development tools, packages and libraries were installed on your system.
echo
case "$os_family" in
el)
echo If compiling or running on EL8 or EL9, please remember to source or
echo activate the environment file with the correct toolset compiler:
echo " source rhel-gcc-toolset-14.sh"
echo
;;
debian)
echo Ensure ~/.local/bin is in your PATH so cmake can find conan:
echo " export PATH=\"\$HOME/.local/bin:\$PATH\""
echo
;;
esac
echo To proceed with the compilation please refer to the README.md file.
echo