forked from SchedMD/slurm
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.sh
executable file
·150 lines (121 loc) · 5.16 KB
/
build.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
#!/bin/bash
set -e # exit whenever command in pipeline fails
set -x # print commands as they are executed
VERSION=`grep "Version:.*[0-9]" slurm.spec | tr -s " " | awk '{print $2;}'`
RELEASE=`grep "%define rel.*[-1-9]" slurm.spec | tr -s " " | awk '{print $3}'`
if [ "${RELEASE}" != "1" ]; then
SUFFIX=${VERSION}-${RELEASE}
else
SUFFIX=${VERSION}
fi
GITTAG=$(git log --format=%ct.%h -1)
SCRIPT=$(readlink -f "${BASH_SOURCE[0]}")
ORIGIN=$(dirname "$SCRIPT")
# which version to download from github
SLURM_VERSION=${VERSION:-24.05.3}
UPSTREAM_REL=${UPSTREAM_REL:-1}
# which release should be used for our RPMs
OUR_RELEASE=${RELEASE:-1}
# NVML
# allow _empty_ version, which is used in pipeline
if grep "release 8.8" /etc/redhat-release; then
NVIDIA_DRIVER=${NVIDIA_DRIVER-555.42.06}
NVDRV_NVML_PKG="nvidia-driver-NVML${NVIDIA_DRIVER:+-$NVIDIA_DRIVER}"
CUDA_VERSION=${CUDA_VERSION:-12.6}
CUDA_NVML_PKG="cuda-nvml-devel-${CUDA_VERSION//./-}"
elif grep "release 9.4" /etc/redhat-release; then
NVIDIA_DRIVER=${NVIDIA_DRIVER-555.42.06}
NVDRV_NVML_PKG="nvidia-driver-NVML${NVIDIA_DRIVER:+-$NVIDIA_DRIVER}"
CUDA_VERSION=${CUDA_VERSION:-12.6}
CUDA_NVML_PKG="cuda-nvml-devel-${CUDA_VERSION//./-}"
fi
# Prepare directory structure
rm -Rf $ORIGIN/rpmbuild/ $ORIGIN/dist/
mkdir -p $ORIGIN/rpmbuild/{BUILD,RPMS,SRPMS,SOURCES} $ORIGIN/dist
echo "Building source tarball"
# archive git repo
echo "archive suffix: ${SUFFIX}"
git archive --format=tar.gz -o "rpmbuild/SOURCES/slurm-${SUFFIX}.tar.gz" --prefix="slurm-${SUFFIX}/" HEAD
cp slurm.spec "SPECS"
# Patch sources
#for src_patch in $ORIGIN/src-patches/*.patch; do
#echo "Patching $src_patch"
#git am $src_patch
#done
# Patch spec file
#for spec_patch in $ORIGIN/spec-patches/*.patch; do
#echo "Patching $spec_patch"
#patch -p1 -b -i $spec_patch
#done
# Install dependencies
# see https://slurm.schedmd.com/quickstart_admin.html#build_install
echo "Installing specfile requires"
# this goes first because it might install undesired stuff related to `--with` options
sudo dnf -y builddep slurm.spec
# dependecy versions
if grep "release 8.8" /etc/redhat-release; then
UCX_VERSION="1.13.1-2.el8.x86_64"
PMIX_VERSION=">= 4.2.6"
HWLOC_VERSION=">= 2.2.0-3"
elif grep "release 9.2" /etc/redhat-release; then
UCX_VERSION="1.13.1-2.el9.x86_64"
PMIX_VERSION=">= 4.2.7"
HWLOC_VERSION=">= 2.4.1-5"
elif grep "release 9.4" /etc/redhat-release; then
UCX_VERSION="1.15.0-2.el9.x86_64"
PMIX_VERSION=">= 4.2.7"
HWLOC_VERSION=">= 2.4.1-5"
else
echo "unsupported OS release"
exit 1
fi
echo "Installing dependencies"
# - features: basic
sudo dnf -y install lua-devel mariadb-devel lz4-devel
# - features: authentication (MUNGE: yes, JWT: yes, PAM: yes)
sudo dnf -y install munge-devel libjwt-devel pam-devel
# - features: slurmrestd
sudo dnf -y install http-parser-devel json-c-devel libyaml-devel
# - features: Nvidia NVML
sudo dnf -y autoremove cuda-nvml-* nvidia-driver-NVML-* nvidia-driver* libnvidia-ml*
sudo dnf -y install "$CUDA_NVML_PKG" "$NVDRV_NVML_PKG" "nvidia-driver-devel"
# - plugins: MPI
sudo dnf -y install pmix "pmix-devel ${PMIX_VERSION}" "ucx-devel-${UCX_VERSION}"
# - plugins: cgroup/v2
# see https://slurm.schedmd.com/cgroup_v2.html
sudo dnf -y install kernel-headers dbus-devel
# - plugins: task/cgroup, task/affinity
sudo dnf -y install "hwloc-devel ${HWLOC_VERSION}" numactl-devel
# - plugins: acct_gather_profile/hdf5
sudo dnf -y install hdf5-devel
# Build defines
RPM_DEFINES=( --define "gittag ${GITTAG}" --define "_topdir $ORIGIN/rpmbuild" )
# Build options
SLURM_BUILDOPTS=( --with slurmrestd --without debug )
# basic features
SLURM_BUILDOPTS+=( --with lua --with mysql --with x11 )
# plugins
SLURM_BUILDOPTS+=( --with numa --with hwloc --with pmix --with ucx )
# authentication
SLURM_BUILDOPTS+=( --with pam --with jwt )
echo "Running rpmbuild (without nvml)"
rpmbuild -ba "${RPM_DEFINES[@]}" "${SLURM_BUILDOPTS[@]}" --without nvml \
slurm.spec 2>&1 | tee rpmbuild-without-nvml.out
echo "Doing rpm rebuild (without nvml)"
for rpm in $ORIGIN/rpmbuild/RPMS/x86_64/slurm-*$SUFFIX*.rpm ; do
rpmrebuild --release=${OUR_RELEASE}.${GITTAG}$(rpm -E '%dist').nogpu.ug -d $ORIGIN/dist -p $rpm
done
echo "Running rpmbuild (with nvml)"
RPM_DEFINES+=( --define "_cuda_version $CUDA_VERSION" )
rpmbuild -ba "${RPM_DEFINES[@]}" "${SLURM_BUILDOPTS[@]}" --with nvml \
slurm.spec 2>&1 | tee rpmbuild-with-nvml.out
echo "Doing rpm rebuild (with nvml)"
for rpm in $ORIGIN/rpmbuild/RPMS/x86_64/slurm-*$SUFFIX*.rpm ; do
rpmrebuild --release=${OUR_RELEASE}.${GITTAG}$(rpm -E '%dist').ug -d $ORIGIN/dist -p $rpm
done
# strip out torque binaries/wrapper from slurm-torque
rpmrebuild -d $ORIGIN/dist --change-spec-files="sed '/\(pbsnodes\|mpiexec\|bin\/q.\+\)/d'" -p $ORIGIN/dist/x86_64/slurm-torque-*-${OUR_RELEASE}.${GITTAG}$(rpm -E '%dist').nogpu.ug*.rpm
rpmrebuild -d $ORIGIN/dist --change-spec-files="sed '/\(pbsnodes\|mpiexec\|bin\/q.\+\)/d'" -p $ORIGIN/dist/x86_64/slurm-torque-*-${OUR_RELEASE}.${GITTAG}$(rpm -E '%dist').ug.*.rpm
# get the RPMs out of the subdirectories
find rpmbuild -type f -name "*.rpm" -exec rm {} ";"
find $ORIGIN/dist/ -type f -name '*.rpm' -print0 | xargs -0 -I{} mv {} rpmbuild/RPMS/x86_64/