forked from viniciusferrao/cloysterhpc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetupDevEnvironment.sh
More file actions
executable file
·222 lines (192 loc) · 5.11 KB
/
setupDevEnvironment.sh
File metadata and controls
executable file
·222 lines (192 loc) · 5.11 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
#!/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 Enterprise Linux (EL) 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
# Check if sudo is available
if command -v sudo >/dev/null; then
# Override dnf to use sudo
dnf() {
sudo /usr/bin/dnf "$@"
}
else
echo \
"sudo is required but not installed. Please install sudo or run as root."
exit 1
fi
fi
# Grab EL version from RPM
os_version=$(rpm -E %rhel)
# 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_version" in
8)
printf '%s\n' "/usr/bin/python3.12"
;;
9|10)
if command -v python3 >/dev/null 2>&1; then
command -v python3
else
command -v python
fi
;;
*)
command -v python3
;;
esac
}
install_conan_user() {
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_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
}
install_ninja_user() {
if command -v ninja >/dev/null 2>&1; then
return 0
fi
if dnf -y install ninja-build; then
return 0
fi
python_bin=$(python_bootstrap_bin)
if [ ! -x "$python_bin" ]; then
echo "Unable to locate a supported Python interpreter at $python_bin"
exit 3
fi
echo "ninja-build is not available from the configured repositories; installing ninja via pip"
"$python_bin" -m pip install --user --upgrade pip
"$python_bin" -m pip install --user ninja
}
# 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;
}
#
# Entrypoint
#
echo Setting up development environment for OpenCATTUS
echo
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
# Build toolset, packages and utils
dnf -y install rsync git gcc-c++ gdb cmake 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
# Install Conan as user
install_conan_user
install_ninja_user
# Required libraries
dnf -y install newt-devel
echo
echo Development tools, packages and libraries were installed on your system.
echo
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
echo To proceed with the compilation please refer to the README.md file.
echo