-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.sh
executable file
·328 lines (266 loc) · 6.96 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
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
#!/bin/sh
set -e
SELF_PATH="$(readlink --canonicalize-existing -- "$0")"
SELF_DIR="${SELF_PATH%/*}"
SELF_BASE="${SELF_PATH##*/}"
usage ()
{
printf 'Usage: %s config [prepare|build]\n' "${SELF_BASE}"
exit 1
}
BOOTSTRAP_CONFIG=''
BOOTSTRAP_CONFIG_COMPILER=''
BOOTSTRAP_CONFIG_OS=''
BOOTSTRAP_MIRROR="$(realpath "$(pwd)/../spack-mirror")"
#BOOTSTRAP_MIRROR=''
BOOTSTRAP_PHASE=''
bootstrap_in_phase ()
{
local phase
phase="$1"
test -n "${phase}" || return 1
test "${phase}" = 'prepare' -o "${phase}" = 'build' || return 1
if test -z "${BOOTSTRAP_PHASE}" -o "${BOOTSTRAP_PHASE}" = "${phase}"
then
return 0
else
return 1
fi
}
bootstrap_apply_pr ()
{
local pr
pr="$1"
test -n "${pr}" || return 1
rm --force "${pr}.diff"
curl --fail --location --remote-name "https://github.com/spack/spack/pull/${pr}.diff"
git apply --verbose "${pr}.diff"
}
bootstrap_get_os ()
{
./bin/spack arch --operating-system
}
bootstrap_install ()
{
local compiler
local package
package="$1"
compiler="$2"
test -n "${package}" || return 1
test -n "${compiler}" || compiler='gcc@14'
if bootstrap_in_phase prepare
then
if test -n "${BOOTSTRAP_MIRROR}"
then
echo "Mirroring ${package}"
# FIXME Mirroring for missing compilers currently does not work (https://github.com/spack/spack/issues/43092)
./bin/spack mirror create --directory "${BOOTSTRAP_MIRROR}" --dependencies "${package}"
fi
fi
if bootstrap_in_phase build
then
echo "Installing ${package}"
./bin/spack install "${package}" "%${compiler}"
fi
}
bootstrap_install_compiler ()
{
local compiler
local location
local package
package="$1"
compiler="$2"
test -n "${package}" || return 1
test -n "${compiler}" || return 1
bootstrap_install "${package}" "${compiler}"
if bootstrap_in_phase build
then
location="$(./bin/spack location --install-dir "${package}" "%${compiler}")"
./bin/spack compiler find "${location}"
fi
}
bootstrap_create_env ()
{
sed \
--expression="s#@BOOTSTRAP_CONFIG@#${BOOTSTRAP_CONFIG}#g" \
--expression="s#@SPACK_ROOT@#$(pwd)#g" \
../env.sh.in > ../env.sh
}
BOOTSTRAP_CONFIG="$1"
BOOTSTRAP_PHASE="$2"
test -n "${BOOTSTRAP_CONFIG}" || usage
test -z "${BOOTSTRAP_PHASE}" -o "${BOOTSTRAP_PHASE}" = 'prepare' -o "${BOOTSTRAP_PHASE}" = 'build' || usage
case "${BOOTSTRAP_CONFIG}" in
ants)
BOOTSTRAP_CONFIG_OS='rocky9'
BOOTSTRAP_CONFIG_COMPILER='gcc@11'
BOOTSTRAP_CONFIG_CUDA='12.3'
BOOTSTRAP_CONFIG_CUDA_COMPILER='gcc@12'
;;
sofja)
BOOTSTRAP_CONFIG_OS='rocky8'
BOOTSTRAP_CONFIG_COMPILER='gcc@8'
BOOTSTRAP_CONFIG_CUDA='12.4'
BOOTSTRAP_CONFIG_CUDA_COMPILER='gcc@13'
;;
*)
printf 'Config %s is not supported.\n' "${BOOTSTRAP_CONFIG}"
exit 1
;;
esac
if test -f /etc/profile.d/modules.sh
then
. /etc/profile.d/modules.sh
fi
if command -v module >/dev/null 2>&1
then
module purge
fi
cd spack
export SPACK_DISABLE_LOCAL_CONFIG=1
if bootstrap_in_phase prepare
then
git checkout --force
# FIXME Find a better way to do this
git apply --verbose ../patches/env.patch
#bootstrap_apply_pr xyz
bootstrap_apply_pr 43158
bootstrap_apply_pr 43519
bootstrap_apply_pr 45226
rm --force --recursive "${HOME}/.spack"
rm --force etc/spack/mirrors.yaml
cp ../config/concretizer.yaml etc/spack
cp ../config/config.yaml etc/spack
cp ../config/modules.yaml etc/spack
sed \
--expression="s#@BOOTSTRAP_CONFIG_CUDA@#${BOOTSTRAP_CONFIG_CUDA}#g" \
../config/packages.yaml.in > etc/spack/packages.yaml
if test -n "${BOOTSTRAP_MIRROR}"
then
mkdir --parents "${BOOTSTRAP_MIRROR}"
./bin/spack mirror add local "file://${BOOTSTRAP_MIRROR}"
fi
fi
test "${BOOTSTRAP_CONFIG_OS}" = "$(bootstrap_get_os)" || exit 1
# Force recreating the compiler configuration since it might be different from the prepare phase
./bin/spack compiler remove "${BOOTSTRAP_CONFIG_COMPILER}" || true
./bin/spack compiler find
# Keep in sync with packages.yaml and modules.yaml
bootstrap_install_compiler gcc@14 "${BOOTSTRAP_CONFIG_COMPILER}"
# CUDA requires an older GCC
bootstrap_install_compiler "${BOOTSTRAP_CONFIG_CUDA_COMPILER}" "${BOOTSTRAP_CONFIG_COMPILER}"
# Modules might not be installed system-wide
bootstrap_install environment-modules
if test "${BOOTSTRAP_CONFIG_OS}" = 'centos8' -o "${BOOTSTRAP_CONFIG_OS}" = 'rocky8'
then
# man in CentOS/Rocky Linux 8 cannot handle a long MANPATH
bootstrap_install man-db
fi
# MPI
bootstrap_install mpich
# I/O
bootstrap_install adios2
bootstrap_install fio
bootstrap_install hdf5
bootstrap_install libfuse
bootstrap_install netcdf-c
# Tracing
bootstrap_install cube
bootstrap_install likwid
bootstrap_install otf
bootstrap_install otf2
bootstrap_install scalasca
bootstrap_install scorep
# Compression
bootstrap_install c-blosc
bootstrap_install lz4
bootstrap_install lzma
bootstrap_install lzo
bootstrap_install snappy
bootstrap_install zfp
bootstrap_install zstd
# Math
bootstrap_install gsl
bootstrap_install netlib-scalapack
bootstrap_install octave
bootstrap_install openblas
# Development
bootstrap_install autoconf
bootstrap_install automake
bootstrap_install bison
bootstrap_install boost
bootstrap_install cmake
bootstrap_install doxygen
bootstrap_install flex
bootstrap_install glib
bootstrap_install hwloc
bootstrap_install intel-tbb
bootstrap_install json-c
bootstrap_install libtool
bootstrap_install m4
bootstrap_install meson
bootstrap_install ninja
bootstrap_install pkgconf
bootstrap_install qt-base
# Tools
bootstrap_install emacs
bootstrap_install gdb
bootstrap_install git
bootstrap_install git-lfs
bootstrap_install hyperfine
bootstrap_install nano
bootstrap_install numactl
bootstrap_install strace
bootstrap_install sysstat
bootstrap_install tmux
bootstrap_install valgrind
bootstrap_install vim
# Languages
bootstrap_install go
bootstrap_install julia
bootstrap_install llvm
bootstrap_install perl
bootstrap_install rust
# Visualization
bootstrap_install gnuplot
bootstrap_install graphviz
# Multimedia
bootstrap_install ffmpeg
# Python
bootstrap_install python
bootstrap_install py-flake8
#bootstrap_install py-keras
bootstrap_install py-h5py
bootstrap_install py-matplotlib
bootstrap_install py-netcdf4
bootstrap_install py-numpy
bootstrap_install py-pandas
bootstrap_install py-pip
bootstrap_install py-poetry
bootstrap_install py-requests
bootstrap_install py-scikit-learn
bootstrap_install py-scipy
bootstrap_install py-seaborn
bootstrap_install py-sphinx
#bootstrap_install py-tensorflow
bootstrap_install py-virtualenv
# R
bootstrap_install r
# CUDA
bootstrap_install py-torch "${BOOTSTRAP_CONFIG_CUDA_COMPILER}"
if bootstrap_in_phase build
then
# Remove all unneeded packages
./bin/spack gc --yes-to-all
# Precreate the variables for our hack in setup-env.sh
# FIXME Does not work with more than one OS
./bin/spack --print-shell-vars sh,modules > share/spack/setup-env.vars
# This is required for chaining to work
./bin/spack module tcl refresh --delete-tree --yes-to-all "os=${BOOTSTRAP_CONFIG_OS}"
bootstrap_create_env
if test -n "${BOOTSTRAP_MIRROR}"
then
# Remove cached downloads, which are also available in the mirror
./bin/spack clean --downloads
fi
fi