-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.sh
executable file
·213 lines (205 loc) · 7.34 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
#!/bin/bash
set -euo pipefail
mpiname=${MPINAME:-mpich}
case "$mpiname" in
mpich) version=4.3.0 ;;
openmpi) version=5.0.7 ;;
esac
version=${VERSION:-$version}
release=${RELEASE:-}
ucxversion=1.18.0
ofiversion=1.22.0
ucxversion=${UCXVERSION:-$ucxversion}
ofiversion=${OFIVERSION:-$ofiversion}
PROJECT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
PACKAGE=$PROJECT/package
SOURCE=$PACKAGE/source
echo MPINAME="$mpiname"
echo VERSION="$version"
if test "$mpiname" = "mpich"; then
urlbase="https://www.mpich.org/static/downloads/$version"
tarball="$mpiname-$version.tar.gz"
fi
if test "$mpiname" = "openmpi"; then
urlbase=https://download.open-mpi.org/release/open-mpi/v${version%.*}
tarball="$mpiname-$version.tar.gz"
fi
if test ! -d "$SOURCE"; then
if test ! -f "$tarball"; then
echo downloading "$urlbase"/"$tarball"...
curl -fsSLO "$urlbase"/"$tarball"
else
echo reusing "$tarball"...
fi
echo extracting "$tarball"...
tar xf "$tarball"
mv "$mpiname-$version" "$SOURCE"
patch="$PROJECT/patches/$mpiname-$version"
if test -f "$patch"; then
patch -p1 -i "$patch" -d "$SOURCE"
fi
if test "$mpiname" = "mpich"; then
if test "${version}" \< "4.2.0"; then
disable_doc='s/^\(install-data-local:\s\+\)\$/\1#\$/'
sed -i.orig "$disable_doc" "$SOURCE"/Makefile.in
fi
if test "${version}" \< "4.3.0"; then
if test -d "$SOURCE"/modules/yaksa; then
cd "$SOURCE"/modules/yaksa
echo regenerating yaksa with nesting level 2
PYTHONDONTWRITEBYTECODE=1 PYTHONHASHSEED=0 \
src/backend/seq/genpup.py --pup-max-nesting 2
cd src/backend/seq/pup
find . -type f -exec touch -r . {} \;
cd "$PROJECT"
fi
fi
fi
if test "$mpiname" = "openmpi"; then
for deptarball in "$SOURCE"/3rd-party/*.tar.*; do
test -f "$deptarball" || continue
echo extracting "$(basename "$deptarball")"
tar xf "$deptarball" -C "$(dirname "$deptarball")"
done
makefiles=(
"$SOURCE"/3rd-party/openpmix/src/util/keyval/Makefile.in
"$SOURCE"/3rd-party/prrte/src/mca/rmaps/rank_file/Makefile.in
"$SOURCE"/3rd-party/prrte/src/util/hostfile/Makefile.in
)
for makefile in "${makefiles[@]}"; do
test -f "$makefile" || continue
echo "PMIX_CFLAGS_BEFORE_PICKY = @CFLAGS@" >> "$makefile"
echo "PRTE_CFLAGS_BEFORE_PICKY = @CFLAGS@" >> "$makefile"
done
fi
if test "$mpiname" = "openmpi" && test "${version}" \< "5.0.5"; then
if test "$(uname)" = "Darwin" && test -d "$SOURCE"/3rd-party; then
cd "$SOURCE"/3rd-party/libevent-*
echo running autogen.sh on "$(basename "$(pwd)")"
./autogen.sh
cd "$PROJECT"
fi
fi
echo writing package metadata ...
echo "Name: $mpiname" > "$PACKAGE/METADATA"
echo "Version: $version" >> "$PACKAGE/METADATA"
echo "Release: $release" >> "$PACKAGE/METADATA"
else
echo reusing directory "$SOURCE"...
check() { test "$(awk "/$1/"'{print $2}' "$PACKAGE/METADATA")" = "$2"; }
check Name "$mpiname" || (echo "error: MPINAME!=$mpiname" && exit 1)
check Version "$version" || (echo "error: VERSION!=$version" && exit 1)
check Release "$release" || (echo "error: RELEASE!=$release" && exit 1)
fi
if test "$(uname)" = "Linux"; then
case "$mpiname" in
mpich) MODSOURCE="$SOURCE"/modules ;;
openmpi) MODSOURCE="$SOURCE"/3rd-party ;;
esac
ofigithub="https://github.com/ofiwg/libfabric"
ofiurlbase="$ofigithub/releases/download/v$ofiversion"
ofitarball="libfabric-$ofiversion.tar.bz2"
ofidestdir="$MODSOURCE"/"${ofitarball%%.tar.*}"
if test ! -d "$ofidestdir"; then
if test ! -f "$ofitarball"; then
echo downloading "$ofiurlbase"/"$ofitarball"...
curl -fsSLO "$ofiurlbase"/"$ofitarball"
else
echo reusing "$ofitarball"...
fi
echo extracting "$ofitarball"...
tar xf "$ofitarball"
mkdir -p "$(dirname "$ofidestdir")"
mv "$(basename "$ofidestdir")" "$ofidestdir"
else
echo reusing directory "$ofidestdir"...
fi
ucxgithub="https://github.com/openucx/ucx"
ucxurlbase="$ucxgithub/releases/download/v$ucxversion"
ucxtarball="ucx-$ucxversion.tar.gz"
ucxdestdir="$MODSOURCE"/"${ucxtarball%%.tar.*}"
if test ! -d "$ucxdestdir"; then
if test ! -f "$ucxtarball"; then
echo downloading "$ucxurlbase"/"$ucxtarball"...
curl -fsSLO "$ucxurlbase"/"$ucxtarball"
else
echo reusing "$ucxtarball"...
fi
echo extracting "$ucxtarball"...
tar xf "$ucxtarball"
mkdir -p "$(dirname "$ucxdestdir")"
mv "$(basename "$ucxdestdir")" "$ucxdestdir"
if test "${ucxversion}" \< "1.17.1"; then
cmd='s/\(#include <limits.h>\)/\1\n#include <math.h>/'
sed -i.orig "$cmd" "$ucxdestdir/src/ucs/time/time.h"
fi
else
echo reusing directory "$ucxdestdir"...
fi
fi
if test "$mpiname" = "mpich"; then
mpidate=$(sed -nE "s/MPICH_RELEASE_DATE=\"(.*)\"/\1/p" "$SOURCE/configure")
fi
if test "$mpiname" = "openmpi"; then
mpidate=$(sed -nE "s/date=\"(.*)\"/\1/p" "$SOURCE/VERSION")
fi
if test -n "${mpidate+x}"; then
case "$(uname)" in
Linux)
timestamp=$(date -d "$mpidate" "+%s")
;;
Darwin)
datefmt="%b %d, %Y %T%z"
if test "$mpiname" = "mpich"; then
mpidate=$(awk '{$3=$3",";print $2,$3,$NF}' <<< "$mpidate")
fi
timestamp=$(date -j -f "$datefmt" "$mpidate 12:00:00+0000" "+%s")
;;
esac
echo writing source-date-epoch ...
echo "$timestamp" > "$SOURCE/source-date-epoch"
fi
if test "$mpiname" = "mpich"; then
mpilicense="$SOURCE"/COPYRIGHT
otherlicenses=(
"$SOURCE"/modules/hwloc/COPYING
"$SOURCE"/modules/json-c/COPYING
"$SOURCE"/modules/yaksa/COPYRIGHT
)
fi
if test "$mpiname" = "openmpi"; then
mpilicense="$SOURCE"/LICENSE
otherlicenses=(
"$SOURCE"/3rd-party/hwloc-*/COPYING
"$SOURCE"/3rd-party/libevent-*/LICENSE
"$SOURCE"/3rd-party/openpmix/LICENSE
"$SOURCE"/3rd-party/prrte/LICENSE
"$SOURCE"/3rd-party/treematch/COPYING
"$SOURCE"/opal/mca/event/libevent2022/libevent/LICENSE
"$SOURCE"/opal/mca/pmix/pmix3x/pmix/LICENSE
"$SOURCE"/ompi/mca/topo/treematch/treematch/COPYING
)
fi
echo copying MPI license file...
cp "$mpilicense" "$PACKAGE/LICENSE"
if test -n "${ofidestdir+x}"; then
echo copying OFI license file...
cp "$ofidestdir/COPYING" "$PACKAGE/LICENSE.ofi"
fi
if test -n "${ucxdestdir+x}"; then
echo copying UCX license file...
cp "$ucxdestdir/LICENSE" "$PACKAGE/LICENSE.ucx"
fi
for license in "${otherlicenses[@]}"; do
test -f "$license" || continue
module=$(basename "$(dirname "$license")")
module="${module%%-[0-9]*}"
echo copying "$module" license file...
cp "$license" "$PACKAGE/LICENSE.$module"
done
if test -n "${GITHUB_OUTPUT+x}"; then
# shellcheck disable=SC2129
echo "mpiname=${mpiname}" >> "$GITHUB_OUTPUT"
echo "version=${version}" >> "$GITHUB_OUTPUT"
echo "release=${release}" >> "$GITHUB_OUTPUT"
fi