Skip to content

Commit f211c92

Browse files
committed
Regenerate modulefiles on update (fixes #1601)
Signed-off-by: Orion Poplawski <orion@nwra.com>
1 parent bb6ea36 commit f211c92

File tree

4 files changed

+181
-146
lines changed

4 files changed

+181
-146
lines changed

components/OHPC_macros

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
%global OHPC_ADMIN %{OHPC_HOME}/admin
2121
%global OHPC_PUB %{OHPC_HOME}/pub
2222
%global OHPC_APPS %{OHPC_PUB}/apps
23+
%global OHPC_BIN %{OHPC_PUB}/bin
2324
%global OHPC_COMPILERS %{OHPC_PUB}/compiler
2425
%global OHPC_LIBS %{OHPC_PUB}/libs
2526
%global OHPC_MODULES %{OHPC_PUB}/modulefiles

components/admin/ohpc-filesystem/SPECS/ohpc-filesystem.spec

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
Name: ohpc-filesystem
1818
Version: %{version}
19-
Release: %{?dist}.1
19+
Release: %{?dist}.2
2020
Summary: Common top-level OpenHPC directories
2121

2222
Group: ohpc/admin
@@ -48,7 +48,7 @@ builds.
4848

4949
%install
5050
# The ohpc-filesystems owns all the common directories
51-
mkdir -p $RPM_BUILD_ROOT/opt/ohpc/pub/{apps,doc,compiler,libs,moduledeps,modulefiles,mpi}
51+
mkdir -p $RPM_BUILD_ROOT/opt/ohpc/pub/{apps,bin,doc,compiler,libs,moduledeps,modulefiles,mpi}
5252
mkdir -p $RPM_BUILD_ROOT/opt/ohpc/admin/ohpc
5353
mkdir -p $RPM_BUILD_ROOT/usr/lib/rpm/fileattrs
5454

@@ -83,6 +83,7 @@ EOF
8383
%dir /opt/ohpc/admin/
8484
%dir /opt/ohpc/pub/
8585
%dir /opt/ohpc/pub/apps/
86+
%dir /opt/ohpc/pub/bin/
8687
%dir /opt/ohpc/pub/doc/
8788
%dir /opt/ohpc/pub/compiler/
8889
%dir /opt/ohpc/pub/libs/
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
#!/bin/bash
2+
# Do not overwrite existing files
3+
# Write the new file as rpmnew
4+
testfile () {
5+
if [ -e $1 ]; then
6+
echo "$1.rpmnew"
7+
else
8+
echo "$1"
9+
fi
10+
}
11+
12+
# Remove .rpmnew files if they are identical
13+
# otherwise record in manifest
14+
modprocess () {
15+
if [ "${1/.rpmnew/}" != "$1" ]; then
16+
if cmp "${1/.rpmnew/}" "$1"; then
17+
rm "$1"
18+
return
19+
fi
20+
fi
21+
md5sum ${modname} >> @@oneapi_manifest@@
22+
}
23+
24+
rm -f @@oneapi_manifest@@
25+
26+
# Regenerate the oneAPI modules directory
27+
echo "Generating new oneAPI modulefiles"
28+
/opt/intel/oneapi/modulefiles-setup.sh --ignore-latest --force --output-dir=@@OHPC_MODULEDEPS@@/oneapi/ > /dev/null
29+
if [ ! -d @@OHPC_MODULEDEPS@@/oneapi/compiler ]; then
30+
echo "ERROR: Failed to create oneAPI module directory"
31+
exit 1
32+
fi
33+
34+
# Set system defaults for default OBS oneAPI modules
35+
for tool in @@exact_deps@@; do
36+
filename=@@OHPC_MODULEDEPS@@/oneapi/${tool%%/*}/.version
37+
echo "#%Module1.0" > ${filename}
38+
echo "set ModulesVersion \"${tool##*/}\"" >> ${filename}
39+
done
40+
41+
# Create an OpenHPC module file for each version found in compilers
42+
echo "Creating OpenHPC-style modulefiles for local oneAPI compiler installation(s)."
43+
for compilers in @@OHPC_MODULEDEPS@@/oneapi/compiler/2*; do
44+
ver=$(basename "$compilers")
45+
# Skip 2023.2.0 due to errors that can hang installer
46+
if [ "$ver" = "2023.2.0" ]; then
47+
echo "--> Skipping version=2023.2.0 : environment module format error"
48+
continue
49+
fi
50+
# For the default, also specify the MKL version
51+
if [ "$ver" = "@@exact_intel_ver@@" ]; then
52+
mklver="mkl/@@exact_mkl_ver@@"
53+
else
54+
mklver="mkl"
55+
fi
56+
echo "--> Installing modulefile for version=${ver}"
57+
# Do not overwrite existing files
58+
# Write the new file as rpmnew
59+
modname=$(testfile @@OHPC_MODULES@@/intel/$ver)
60+
61+
cat << EOF > ${modname}
62+
#%Module1.0#####################################################################
63+
64+
set version "$ver"
65+
66+
proc ModulesHelp { } {
67+
global version
68+
puts stderr "\nThis module loads the oneAPI compiler environment.\n"
69+
puts stderr "\nSee the man pages for icc, icpc, and ifort for detailed information"
70+
puts stderr "on available compiler options and command-line syntax."
71+
puts stderr "\nVersion \$version\n"
72+
}
73+
74+
module-whatis "Name: Intel(R) Compiler"
75+
module-whatis "Version: \$version"
76+
module-whatis "Category: compiler, runtime support"
77+
module-whatis "Description: Intel(R) Compiler Family (C/C++/Fortran for x86_64)"
78+
module-whatis "URL: http://software.intel.com/en-us/articles/intel-compilers/"
79+
80+
# update module path hierarchy
81+
prepend-path MODULEPATH @@OHPC_MODULEDEPS@@/intel
82+
prepend-path MODULEPATH @@OHPC_MODULEDEPS@@/oneapi
83+
84+
# Assume no PAC device; allow override on each node
85+
if { ![info exists ::env(ACL_SKIP_BSP_CONF)] } {
86+
setenv ACL_SKIP_BSP_CONF 1
87+
}
88+
89+
module load "oclfpga"
90+
module load "tbb"
91+
module load "compiler-rt"
92+
module load "compiler/\$version"
93+
module load "$mklver"
94+
95+
family "compiler"
96+
EOF
97+
98+
modprocess ${modname}
99+
100+
# Provide standalone module for use with GNU toolchain
101+
modname=$(testfile @@OHPC_MODULEDEPS@@/gnu/mkl/$ver)
102+
103+
cat << EOF > ${modname}
104+
#%Module1.0#####################################################################
105+
106+
set version "$ver"
107+
108+
proc ModulesHelp { } {
109+
global version
110+
puts stderr "\nConfigures oneAPI MKL environment\n"
111+
puts stderr "\$version\n"
112+
}
113+
114+
module-whatis "Name: Intel(R) Math Kernel Library"
115+
module-whatis "Version: \$version"
116+
module-whatis "Category: library, runtime support"
117+
module-whatis "Description: Intel(R) Math Kernel Library for C/C++ and Fortran"
118+
module-whatis "URL: https://software.intel.com/en-us/en-us/intel-mkl"
119+
120+
prepend-path MODULEPATH @@OHPC_MODULEDEPS@@/oneapi
121+
module load "$mklver"
122+
EOF
123+
124+
modprocess ${modname}
125+
done
126+
127+
# Set default version to match that used to build OpenHPC packages
128+
modname=$(testfile @@OHPC_MODULES@@/intel/.version)
129+
130+
cat << EOF > ${modname}
131+
#%Module1.0#####################################################################
132+
set ModulesVersion "@@exact_intel_ver_module@@"
133+
EOF
134+
135+
modprocess ${modname}

components/compiler-families/intel-compilers-devel/SPECS/intel-compilers-devel.spec

Lines changed: 42 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@
2828
Summary: OpenHPC compatibility package for Intel(R) oneAPI HPC Toolkit
2929
Name: %{pname}%{PROJ_DELIM}
3030
Version: 2024.0
31-
Release: %{?dist}.1
31+
Release: %{?dist}.2
3232
License: Apache-2.0
3333
URL: https://github.com/openhpc/ohpc
3434
Group: %{PROJ_NAME}/compiler-families
3535
BuildArch: x86_64
3636
AutoReq: no
3737
Source1: mod_generator.sh
3838
Source2: oneAPI.repo
39+
Source3: ohpc-update-modules-intel
3940

4041

4142
#!BuildIgnore: post-build-checks
@@ -70,13 +71,28 @@ install -D -m644 %{SOURCE2} -t %{buildroot}%{repodir}/
7071
# Mod generator for PSXE support
7172
install -D -m755 %{SOURCE1} %{buildroot}/%{OHPC_ADMIN}/compat/modulegen/mod_generator.sh
7273

74+
# Mod generator for oneAPI support
75+
sed -e 's/@@oneapi_manifest@@/%{oneapi_manifes}/' \
76+
-e 's/@@OHPC_MODULEDEPS@@/%{OHPC_MODULEDEPS}/' \
77+
-e 's/@@OHPC_MODULES@@/%{OHPC_MODULES}/' \
78+
-e 's/@@exact_deps@@/%{exact_deps}/' \
79+
-e 's/@@exact_intel_ver@@/%{exact_intel_ver}/' \
80+
-e 's/@@exact_intel_ver_module@@/%{exact_intel_ver_module}/' \
81+
-e 's/@@exact_mkl_ver@@/%{exact_mkl_ver}/' %{SOURCE3} > ohpc-update-modules-intel
82+
install -D -m755 ohpc-update-modules-intel %{buildroot}/%{OHPC_BIN}/ohpc-update-modules-intel
83+
7384
# Module directories
7485
mkdir -p %{buildroot}/%{OHPC_MODULEDEPS}/oneapi
7586
mkdir -p %{buildroot}/%{OHPC_MODULES}/intel
7687
mkdir -p %{buildroot}/%{OHPC_MODULEDEPS}/gnu/mkl
7788
mkdir -p %{buildroot}/%{OHPC_MODULEDEPS}/intel
7889

7990

91+
# Regenerate module files when components are added or removed
92+
%transfiletriggerin -- /opt/intel/oneapi
93+
%{OHPC_BIN}/ohpc-update-modules-intel
94+
95+
8096
%pre -p /bin/bash
8197
if ! [ -f /opt/intel/oneapi/modulefiles-setup.sh ]; then
8298
echo " "
@@ -87,157 +103,39 @@ fi
87103

88104

89105
%post -p /bin/bash
90-
# Do not overwrite existing files
91-
# Write the new file as rpmnew
92-
testfile () {
93-
if [ -e $1 ]; then
94-
echo "$1.rpmnew"
95-
else
96-
echo "$1"
97-
fi
98-
}
99-
100-
rm -f %{oneapi_manifest}
106+
%{OHPC_BIN}/ohpc-update-modules-intel
101107

102-
# Regenerate the oneAPI modules directory
103-
echo "Generating new oneAPI modulefiles"
104-
/opt/intel/oneapi/modulefiles-setup.sh --ignore-latest --force --output-dir=%{OHPC_MODULEDEPS}/oneapi/ > /dev/null
105-
if [ ! -d %{OHPC_MODULEDEPS}/oneapi/compiler ]; then
106-
echo "ERROR: Failed to create oneAPI module directory"
107-
exit 1
108-
fi
109108

110-
# Set system defaults for default OBS oneAPI modules
111-
for tool in %{exact_deps}; do
112-
filename=%{OHPC_MODULEDEPS}/oneapi/${tool%%/*}/.version
113-
echo "#%Module1.0" > ${filename}
114-
echo "set ModulesVersion \"${tool##*/}\"" >> ${filename}
115-
done
116-
117-
# Create an OpenHPC module file for each version found in compilers
118-
echo "Creating OpenHPC-style modulefiles for local oneAPI compiler installation(s)."
119-
for compilers in %{OHPC_MODULEDEPS}/oneapi/compiler/2*; do
120-
ver=$(basename "$compilers")
121-
# Skip 2023.2.0 due to errors that can hang installer
122-
if [ "$ver" = "2023.2.0" ]; then
123-
echo "--> Skipping version=2023.2.0 : environment module format error"
124-
continue
125-
fi
126-
# For the default, also specify the MKL version
127-
if [ "$ver" = "%{exact_intel_ver}" ]; then
128-
mklver="mkl/%{exact_mkl_ver}"
109+
%preun -p /bin/bash
110+
if [ $1 -eq 0 ]; then
111+
# Check current files against the manifest
112+
# Remove files that match and backup files that don't
113+
if [ -s %{oneapi_manifest} ]; then
114+
echo "Removing module files"
115+
while IFS= read -r line; do
116+
f=${line%:*}
117+
s=${line#*:}
118+
if [ "${s: -2}" = "OK" ]; then
119+
rm -f $f
120+
elif [ -f $f ]; then
121+
mv -T -f $f $f.rpmsave
122+
fi
123+
done <<< $(md5sum --check %{oneapi_manifest})
129124
else
130-
mklver="mkl"
125+
# Don't touch any generated files if there's no manifest
126+
# On upgrade, expect lots of modulefiles created as .rpmnew
127+
echo "WARNING: Manifest not found. Previously generated"
128+
echo " modulefiles will not be removed or moved."
131129
fi
132-
echo "--> Installing modulefile for version=${ver}"
133-
# Do not overwrite existing files
134-
# Write the new file as rpmnew
135-
modname=$(testfile %{OHPC_MODULES}/intel/$ver)
136-
137-
cat << EOF > ${modname}
138-
#%Module1.0#####################################################################
139-
140-
set version "$ver"
141-
142-
proc ModulesHelp { } {
143-
global version
144-
puts stderr "\nThis module loads the oneAPI compiler environment.\n"
145-
puts stderr "\nSee the man pages for icc, icpc, and ifort for detailed information"
146-
puts stderr "on available compiler options and command-line syntax."
147-
puts stderr "\nVersion \$version\n"
148-
}
149-
150-
module-whatis "Name: Intel(R) Compiler"
151-
module-whatis "Version: \$version"
152-
module-whatis "Category: compiler, runtime support"
153-
module-whatis "Description: Intel(R) Compiler Family (C/C++/Fortran for x86_64)"
154-
module-whatis "URL: http://software.intel.com/en-us/articles/intel-compilers/"
155-
156-
# update module path hierarchy
157-
prepend-path MODULEPATH %{OHPC_MODULEDEPS}/intel
158-
prepend-path MODULEPATH %{OHPC_MODULEDEPS}/oneapi
159-
160-
# Assume no PAC device; allow override on each node
161-
if { ![info exists ::env(ACL_SKIP_BSP_CONF)] } {
162-
setenv ACL_SKIP_BSP_CONF 1
163-
}
164-
165-
module load "oclfpga"
166-
module load "tbb"
167-
module load "compiler-rt"
168-
module load "compiler/\$version"
169-
module load "$mklver"
170-
171-
family "compiler"
172-
EOF
173-
174-
md5sum ${modname} >> %{oneapi_manifest}
175-
176-
# Provide standalone module for use with GNU toolchain
177-
modname=$(testfile %{OHPC_MODULEDEPS}/gnu/mkl/$ver)
178-
179-
cat << EOF > ${modname}
180-
#%Module1.0#####################################################################
181-
182-
set version "$ver"
183-
184-
proc ModulesHelp { } {
185-
global version
186-
puts stderr "\nConfigures oneAPI MKL environment\n"
187-
puts stderr "\$version\n"
188-
}
189-
190-
module-whatis "Name: Intel(R) Math Kernel Library"
191-
module-whatis "Version: \$version"
192-
module-whatis "Category: library, runtime support"
193-
module-whatis "Description: Intel(R) Math Kernel Library for C/C++ and Fortran"
194-
module-whatis "URL: https://software.intel.com/en-us/en-us/intel-mkl"
195-
196-
prepend-path MODULEPATH %{OHPC_MODULEDEPS}/oneapi
197-
module load "$mklver"
198-
EOF
199-
200-
md5sum ${modname} >> %{oneapi_manifest}
201-
done
202-
203-
# Set default version to match that used to build OpenHPC packages
204-
modname=$(testfile %{OHPC_MODULES}/intel/.version)
205-
206-
cat << EOF > ${modname}
207-
#%Module1.0#####################################################################
208-
set ModulesVersion "%{exact_intel_ver_module}"
209-
EOF
210-
211-
md5sum ${modname} >> %{oneapi_manifest}
212-
213-
214-
%preun -p /bin/bash
215-
# Check current files against the manifest
216-
# Remove files that match and backup files that don't
217-
if [ -s %{oneapi_manifest} ]; then
218-
echo "Removing module files"
219-
while IFS= read -r line; do
220-
f=${line%:*}
221-
s=${line#*:}
222-
if [ "${s: -2}" = "OK" ]; then
223-
rm -f $f
224-
elif [ -f $f ]; then
225-
mv -T -f $f $f.rpmsave
226-
fi
227-
done <<< $(md5sum --check %{oneapi_manifest})
228-
else
229-
# Don't touch any generated files if there's no manifest
230-
# On upgrade, expect lots of modulefiles created as .rpmnew
231-
echo "WARNING: Manifest not found. Previously generated"
232-
echo " modulefiles will not be removed or moved."
130+
# Remove the generated oneAPI module links, remove directories if empty
131+
echo "Removing oneAPI module directory"
132+
find %{OHPC_MODULEDEPS}/oneapi -type l -delete || true
133+
find %{OHPC_MODULEDEPS}/oneapi/* -empty -type d -delete || true
233134
fi
234-
# Remove the generated oneAPI module links, remove directories if empty
235-
echo "Removing oneAPI module directory"
236-
find %{OHPC_MODULEDEPS}/oneapi -type l -delete || true
237-
find %{OHPC_MODULEDEPS}/oneapi/* -empty -type d -delete || true
238135

239136

240137
%files
138+
%{OHPC_BIN}/ohpc-update-modules-intel
241139
%dir %{OHPC_MODULES}/intel
242140
%dir %{OHPC_MODULEDEPS}/oneapi
243141
%dir %{OHPC_MODULEDEPS}/intel

0 commit comments

Comments
 (0)