Whamcloud - gitweb
LU-17226 build: create config option for l_getsepol
[fs/lustre-release.git] / lustre.spec.in
1 # SPDX-License-Identifier: GPL-2.0
2
3 #
4 # This file is part of Lustre, http://www.lustre.org/
5 #
6 # lustre.spec.in
7 #
8 # spec file template for RHEL package builds
9 #
10
11 # Declare rpmbuild --with/--without parameters
12 %bcond_without servers
13 %bcond_without ldiskfs
14 %bcond_with zfs
15 %bcond_without lustre_tests
16 %bcond_without lustre_utils
17 %bcond_without lustre_iokit
18 %bcond_without lustre_modules
19 %bcond_with gss
20 %bcond_with gss_keyring
21 %bcond_without manpages
22 %bcond_without shared
23 %bcond_without static
24 %bcond_with systemd
25 %bcond_without mpi
26 %bcond_with kabi
27 %bcond_with multiple_lnds
28 %bcond_with mofed
29 %bcond_without o2ib
30 %bcond_with kfi
31 %bcond_with gni
32 %bcond_without l_getsepol
33
34 %if %{with multiple_lnds}
35 %global enable_multi_lnds 1
36 %endif
37
38 # LUTF Turn off brp-python-precompile script as we don't want the python files
39 # to be compiled on installation
40 %global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g')
41
42 # By default both gss and gss keyring are disabled.
43 # gss keyring requires the gss core. If the builder
44 # request gss_keyring we must enable gss core even if
45 # the builder attempts to disable gss.
46 %if %{with gss_keyring}
47     %define with_gss 1
48 %endif
49
50 %if %{without servers}
51     # --without servers overrides --with {ldiskfs|zfs}
52     # so undefine the internal variables set by bcond_*
53     %undefine with_ldiskfs
54     %undefine with_zfs
55 %endif
56
57 %if %{without shared} && %{without static}
58 # need exit to stop build because error only displays a message
59 %{error: you can't disable both library types}
60 %{exit 1}
61 %endif
62
63 # lustre_tests depends on lustre_utils
64 %if %{without lustre_utils}
65 %undefine with_lustre_tests
66 %endif
67
68 %{!?version: %global version @VERSION@}
69 # if you want a custom kernel version set it variable with $ver.$arch
70 %{!?kver:    %global kver    %(uname -r)}
71 # cut epoch for kmodtool
72 %define _kver %(echo %{kver} | sed -e 's/^[0-9]*://')
73 # trust version from kdir - but it can lost 'epoch'
74 %if %{defined kdir}
75         %define _take_kver 1
76 %endif
77 %if %{defined kobjdir}
78         %define _take_kobj 1
79 %endif
80 %{!?kdir:    %global kdir    /lib/modules/%{_kver}/source}
81 %{!?kobjdir: %global kobjdir %(if [ "%{kdir}" = "/lib/modules/%{_kver}/source" ]; then echo "/lib/modules/%{_kver}/build"; else echo "%{kdir}"; fi)}
82
83 %if 0%{?suse_version} >= 1310 && %{defined _take_kobj}
84         %global _flavor %(echo %{_kver} | sed -e 's/^.*-//')
85 %else
86         %global _flavor default
87 %endif
88
89 %if %{defined _take_kver}
90 # as an alternative to this implementation we could simply "make -C $kdir kernelversion"
91 %global kver %(files="include/generated/utsrelease.h include/linux/utsrelease.h include/linux/version.h"; for f in $files; do if test -r %{kobjdir}/$f && grep UTS_RELEASE %{kobjdir}/$f >/dev/null; then sed -ne '/^#define UTS_RELEASE/s/.*"\\(.*\\)"$/\\1/p' %{kobjdir}/$f; break; fi; done)
92 %define _kver %kver
93 %endif
94
95 # We set this because kernel_module_package has its own method of identifying
96 # which kernel to build against, and it is unlikely that its decision will
97 # match with Lustre's method of selecting which kernel to build against.
98 # By setting this variable, we override kernel_module_package's kernel
99 # selection with our selection.
100 # kmodtool failed to take a version if epoch set
101 %global kernel_version %_kver
102
103 # in order to get kernel symset and/or kernel module dependencies into
104 # the RPM, in order to support weak-modules, the internal dependency gen-
105 # erator needs to be disabled
106 # this is done with (reduce the double % down to a single %):
107 #
108 # %%global _use_internal_dependency_generator 0
109 #
110 # on SLES10, /usr/lib/rpm/macros already sets this, so no harm in also
111 # defining it here (until Suse changes their mind)
112 #
113 # on RHEL5, however, we do need to explicitly disable the internal dep-
114 # endency generator and allow the external one be used
115 # but since RedHat's kABI is only a subset of the total kernel ABI, it
116 # doesn't include all of the symbols we (or OFED for that matter) need
117 # until RedHat includes all of the symbols we need in their symsets we
118 # cannot support weak-modules
119 # we did e-mail the maintainer of all of this stuff @redhat but got no
120 # response from them
121 #%%global _use_internal_dependency_generator 0
122
123 %if 0%{?rhel} > 7 || 0%{?fedora} > 33
124 ## SUSE uses another tool for provides:
125 ## https://github.com/openSUSE/kernel-source/blob/master/patches.rpmify/Add-ksym-provides-tool.patch
126 %global __find_provides   %{_sourcedir}/find-provides
127 %endif
128
129 # Set the package name prefix
130 %if %{undefined lustre_name}
131     %if %{with servers}
132         %global lustre_name lustre
133     %else
134         %global lustre_name lustre-client
135     %endif
136 %endif
137
138 %if %{with lustre_modules}
139 %if %{undefined kmoddir}
140     %if %{defined kernel_module_package_moddir}
141         %global kmoddir %{kernel_module_package_moddir}
142     %else
143         %if %{defined suse_kernel_module_package}
144             %global kmoddir updates
145         %else
146             %global kmoddir extra
147         %endif
148     %endif
149 %endif
150
151 %global modules_fs_path /lib/modules/%{_kver}/%{kmoddir}
152 # requires want to set a version including epoch
153 %global krequires %(echo %{kver} | sed -e 's/\.x86_64$//' -e 's/\.i[3456]86$//' -e 's/-smp$//' -e 's/-bigsmp$//' -e 's/[-.]ppc64$//' -e 's/\.aarch64$//' -e 's/-default$//' -e 's/-%{_flavor}//')
154
155 %if "%{_vendor}" == "redhat" || "%{_vendor}" == "fedora" || 0%{?openEuler}
156         %global requires_kmod_name kmod-%{lustre_name}
157         %global requires_kmod_osd_zfs_name kmod-%{lustre_name}-osd-zfs
158         %if %{with lustre_tests}
159                 %global requires_kmod_tests_name kmod-%{lustre_name}-tests
160         %endif
161         %global requires_kmod_version %{version}
162 #for Suse
163 %else
164         %global requires_kmod_name %{lustre_name}-kmp
165         %global requires_kmod_osd_zfs_name %{lustre_name}-osd-zfs-kmp
166         %if %{with lustre_tests}
167                 %global requires_kmod_tests_name %{lustre_name}-tests-kmp
168         %endif
169         %if 0%{?suse_version} >= 1200
170                 %global requires_kmod_version %{version}_k%(echo %{krequires} | sed -r 'y/-/_/; s/^(2\.6\.[0-9]+)_/\\1.0_/;')
171         %else
172                 %global requires_kmod_version %{version}_%(echo %{krequires} | sed -r 'y/-/_/; s/^(2\.6\.[0-9]+)_/\\1.0_/;')
173         %endif
174 %endif
175 %endif
176
177 # RHEL >= 7 comes with systemd
178 %if 0%{?rhel} >= 7
179 %define with_systemd 1
180 %endif
181
182 # Fedora >= 15 comes with systemd, but only >= 18 has
183 # the proper macros
184 %if 0%{?fedora} >= 18
185 %define with_systemd 1
186 %endif
187
188 # opensuse >= 12.1 comes with systemd, but only >= 13.1
189 # has the proper macros
190 %if 0%{?suse_version} >= 1310
191 %define with_systemd 1
192 %endif
193
194 # openEuler comes with systemd
195 %if 0%{?openEuler}
196 %define with_systemd 1
197 %endif
198
199 # Detect when mlnx-ofa_kernel-devel contents exist and mofed_source to 0
200 %define mofed_src_path  $(echo %{?configure_args} | tr ' ' '\\n' | grep -- '--with-o2ib=' | cut -c 13-)
201 %define mofed_source    %(test -f %mofed_src_path/Module.symvers; echo $?)
202 # Update the search path for mofed_scripts
203 %if 0%{?mofed_source} > 0
204 %define mofed_default_path      /usr/src/ofa_kernel/
205 %else
206 %define mofed_default_path      %{mofed_src_path}
207 %endif
208
209 %{!?mpi_name: %global mpi_name openmpi}
210
211 Summary: Lustre File System
212 Name: %{lustre_name}
213 Version: %{version}
214 Release: 1%{?dist}
215 License: GPL-2.0-only AND LGPL-2.1-or-later
216 %if 0%{?suse_version} >= 1310
217 # SUSE needs Group for the kernel_module_package macro
218 Group: System/Kernel
219 %endif
220 Source: lustre-%{version}.tar.gz
221 Source1: kmp-lustre.preamble
222 Source2: kmp-lustre.files
223 Source3: kmp-lustre-osd-ldiskfs.preamble
224 Source4: kmp-lustre-osd-ldiskfs.files
225 Source5: kmp-lustre-osd-zfs.preamble
226 Source6: kmp-lustre-osd-zfs.files
227 Source7: kmp-lustre-tests.preamble
228 Source8: kmp-lustre-tests.files
229 Source9: find-provides
230 Source10: find-provides.ksyms
231 Source11: kmp-lnet-socklnd.preamble
232 Source12: kmp-lnet-socklnd.files
233 Source13: kmp-lnet-o2iblnd.preamble
234 Source14: kmp-lnet-o2iblnd.files
235 Source15: kmp-lnet-gnilnd.preamble
236 Source16: kmp-lnet-gnilnd.files
237 Source17: kmp-lnet-kfilnd.preamble
238 Source18: kmp-lnet-kfilnd.files
239 Source19: kmp-lnet-in-kernel-o2iblnd.preamble
240 Source20: kmp-lnet-in-kernel-o2iblnd.files
241 URL: https://wiki.whamcloud.com/
242 BuildRoot: %{_tmppath}/lustre-%{version}-root
243 %if %{with lustre_modules}
244 Requires: %{requires_kmod_name} = %{requires_kmod_version}
245 %endif
246 %if %{with lustre_tests_lutf}
247 Requires: python3 >= 3.6.0
248 BuildRequires: python3-devel >= 3.6.0, swig
249 %endif
250 BuildRequires: libtool pkgconfig(yaml-0.1) pkgconfig(zlib) pkgconfig(libnl-3.0) flex bison
251 %if "%{_vendor}" == "redhat"
252 BuildRequires: redhat-rpm-config
253 BuildRequires: pkgconfig
254 %if 0%{?rhel} > 7 || 0%{?fedora} > 33 || 0%{?rhel} < 1
255 Suggests: bash-completion
256 %endif
257 %else
258 %if 0%{?openEuler}
259 BuildRequires: openEuler-rpm-config
260 %if %{with ldiskfs}
261 BuildRequires: kernel-debugsource
262 %endif
263 %endif
264 BuildRequires: pkg-config
265 %endif
266 %if %{with gss}
267 BuildRequires: krb5-devel openssl-devel
268 %endif
269 %if %{with lustre_modules}
270 # abuild (auto-build) used by SUSE Open Build Service needs kernel-source as
271 # a build requirement, but the code which extracts these requirements does not
272 # understand the percent-open-close-paren construct aka %%()
273 #  [NOTE: a percent abovie is doubled to avoid yet another rpmbuild warning]
274 # such occurances as failures.  So the following dance allows the requirements
275 # to be seen by abuild, but ignored by lbuild.
276 %if "%(echo $USER)" != "abuild"
277 %else
278 BuildRequires: kernel-source
279 %endif
280 %endif
281 %if %{with servers}
282 Requires: %{name}-osd
283 Requires: %{name}-osd-mount
284 Obsoletes: lustre-server < %{version}
285 Provides: lustre-server = %{version}-%{release}
286 %endif
287 Obsoletes: lustre-client < %{version}
288 Provides: lustre-client = %{version}-%{release}
289 %if "%{_vendor}" == "redhat" || "%{_vendor}" == "fedora" || 0%{?openEuler}
290 #suse don't support selinux
291 BuildRequires: pkgconfig(libselinux)
292 %endif
293 %if %{with l_getsepol}
294 BuildRequires: pkgconfig(libselinux) openssl-devel
295 %endif
296 %if %{with lustre_modules}
297 %if %{with mofed}
298 %if 0%{?mofed_source} > 0
299 BuildRequires: mlnx-ofa_kernel-devel
300 %endif
301 %if %{with multiple_lnds}
302 %if "%{_vendor}" == "redhat" || 0%{?openEuler}
303 Requires: kmod-mlnx-ofa_kernel
304 %else
305 Requires: mlnx-ofa_kernel-kmp
306 %endif
307 %endif
308 %endif
309 %if 0%{?rhel} >= 8 || 0%{?openEuler}
310 BuildRequires: kernel-rpm-macros
311 %endif
312 %if 0%{?suse_version} >= 1530
313 BuildRequires: rpm-build >= 4.14.3
314 %endif
315 BuildRequires: %kernel_module_package_buildreqs
316 # need to provide a /usr/lib/${uname -r)/build dir
317 BuildRequires: kernel >= 3.10
318 %if "%{_vendor}" == "redhat"
319 %if %{with kabi}
320 BuildRequires: kernel-abi-whitelists
321 %endif
322 %endif
323 %endif
324
325 %if %{with systemd}
326 Requires(post): systemd
327 Requires(preun): systemd
328 Requires(postun): systemd
329 BuildRequires: pkgconfig(systemd)
330 %endif
331
332 %description
333 Userspace tools and files for the Lustre file system.
334
335 %if %{with lustre_modules}
336 %if 0%{?rhel} == 7
337 # until we have achieved full kABI compatibility we need to
338 # restrict the kernel range that can be used to the kernel
339 # version from the RHEL minor release
340 # this is supposed to be done for kmods automatically but
341 # RHBZ#1467319 seems to be getting in the way
342 # this is true for el7.0 through el7.4
343 %define preamble %{expand:%(
344 TMPFILE=`mktemp`
345 cat %{SOURCE1} > $TMPFILE
346 kver=%{kernel_version}
347 linuxversion=${kver%%%%-*}
348 linuxrelease=${kver##*-}
349 kabiminor=${linuxrelease%%%%.*}
350 echo "Requires:       kernel < $linuxversion-$((kabiminor+1)), kernel >= $linuxversion-$((kabiminor))" >> $TMPFILE
351 echo $TMPFILE
352 )}
353 %else
354 %define preamble %{SOURCE1}
355 %endif
356 %kernel_module_package -n %{name} -p %preamble -f %SOURCE2 %{_flavor}
357
358 %if %{with ldiskfs}
359 %kernel_module_package -n %{name}-osd-ldiskfs -p %SOURCE3 -f %SOURCE4 %{_flavor}
360 %if %{with lustre_utils}
361 %package osd-ldiskfs-mount
362 Summary: Lustre mount's ldiskfs-specific helper library
363 BuildRequires: e2fsprogs-devel >= 1.44.3 pkgconfig(mount)
364 Requires: ldiskfsprogs > 1.45.6
365 Provides: lustre-osd-mount = %{version}
366 Provides: %{name}-osd-mount = %{version}
367 Obsoletes: %{name}-osd-mount < %{version}
368 Obsoletes: lustre-osd-mount < %{version}
369
370 %description osd-ldiskfs-mount
371 Provide a shared library (dso) that can be loaded into various
372 lustre tools (mount/mkfs) to provide support for ldisfs
373
374 # with lustre_utils
375 %endif
376 # with ldiskfs
377 %endif
378
379 %if %{with zfs}
380 %global confzfsdobjpath %(echo '%configure_args' | grep -q -- --with-zfs-obj= ; echo $?)
381 %kernel_module_package -n %{name}-osd-zfs -p %SOURCE5 -f %SOURCE6 %{_flavor}
382 %if %{with lustre_utils}
383 %package osd-zfs-mount
384 Summary: Lustre mount's zfs-specific helper library
385 BuildRequires: pkgconfig(mount)
386 Provides: %{name}-osd-mount = %{version}
387 Obsoletes: lustre-osd-mount < %{version}
388 %if 0%{confzfsdobjpath} != 0
389 BuildRequires: (libzfs-devel or libzfs4-devel or libzfs5-devel)
390 %endif
391 # end confzfsdobjpath
392 # Tests also require zpool from zfs package:
393 Requires: zfs
394 Requires: %{requires_kmod_osd_zfs_name}
395 Provides: %{name}-osd-mount = %{version}
396 Provides: %{name}-osd-zfs-mount = %{version}
397 Requires: %{name}-osd-zfs = %{version}
398
399 %description osd-zfs-mount
400 Provide a shared library (dso) that can be loaded into various
401 lustre tools (mount/mkfs) to provide support for ZFS.
402
403 # with lustre_utils
404 %endif
405 # with zfs
406 %endif
407 # with lustre_modules
408 %endif
409
410 %if %{with servers}
411 %package resource-agents
412 Summary: HA Resuable Cluster Resource Scripts for Lustre
413 Requires: %{name}
414 Requires: resource-agents
415
416 %description resource-agents
417 A set of scripts to operate Lustre resources in a High Availablity
418 environment for both Pacemaker and rgmanager.
419 %endif
420
421 %package devel
422 Summary: Lustre include headers
423 Provides: lustre-devel = %{version}
424 Requires: %{lustre_name} = %{version}
425 %if %{with lustre_modules}
426 Requires: %{requires_kmod_name} = %{requires_kmod_version}
427 %endif
428
429 %description devel
430 This package contains the header files needed for building additional
431 applications against the Lustre / LNet utilities libraries.
432
433 :> lustre-devel.files
434
435 %if %{with lustre_tests}
436 %package tests
437 Summary: Lustre testing framework
438 Provides: %{name}-tests = %{version}
439 %if %{with lustre_iokit}
440 Requires: %{name} = %{version}, lustre-iokit
441 %else
442 Requires: %{name} = %{version}
443 %endif
444 Requires: lustre-devel = %{version}
445 %if 0%{?rhel} >= 8 || 0%{?suse_version} >= 1500 || 0%{?openEuler}
446 Requires: python3 >= 3.6.0, python3-PyYAML
447 %endif
448 %if %{with lustre_modules}
449 Requires: %{requires_kmod_name} = %{requires_kmod_version}
450 Requires: %{requires_kmod_tests_name} = %{requires_kmod_version}
451 %endif
452 %if %{with lustre_tests_lutf}
453 Requires: python3 >= 3.6.0
454 %endif
455 Requires: attr, rsync, lsof, /usr/bin/getconf
456 Requires: /usr/sbin/getenforce, acl, /usr/bin/killall, /usr/bin/ping, bc
457 # Of the supported targets, only rhel7 doesn't support Recommends.
458 %if 0%{?rhel} > 7 || 0%{?fedora} > 33 || 0%{?rhel} < 1
459 Recommends: perl, dbench, iozone
460 # Either of these is sufficient
461 Suggests: pdsh, clush
462 %endif
463 %if %{with mpi}
464 %if "%{mpi_name}" == "mpich"
465 BuildRequires: mpich-devel
466 %endif
467 %if "%{mpi_name}" == "openmpi"
468 %if "%{_vendor}" == "redhat" || 0%{?openEuler} || 0%{?suse_version} < 1500
469 BuildRequires: openmpi-devel
470 %else
471 BuildRequires: openmpi2-devel
472 %endif
473 # openmpi
474 %endif
475 # mpi
476 %endif
477
478 %description tests
479 This package contains a set of test binaries and scripts that are intended
480 to be used by the Lustre testing framework.
481
482 %if %{with lustre_modules}
483 %kernel_module_package -n %{name}-tests -p %SOURCE7 -f %SOURCE8 %{_flavor}
484 %endif
485 %endif
486
487 %if %{with multiple_lnds}
488 # begin multiple_lnds
489 %kernel_module_package -n %{name}-lnet-socklnd -p %SOURCE11 -f %SOURCE12 %{_flavor}
490 %if %{with o2ib}
491 ## re-write post/preun generated by kmodtool [ls -s and rm -f]
492 %define inkernmod %{modules_fs_path}/%{lustre_name}/net/in-kernel-ko2iblnd.ko
493 %define inkernsym %{modules_fs_path}/%{lustre_name}/net/ko2iblnd.ko
494 %define ofed_module_package %{expand:%(
495 TMPFILE=`mktemp`
496 cat <<EOF > $TMPFILE
497 %kernel_module_package -n %{name}-lnet-in-kernel-o2iblnd -p %SOURCE19 -f %SOURCE20 %{_flavor}
498 EOF
499 sed -i -e '/^%%post.*/a ln -sf %{inkernmod} %{inkernsym}' -e '/^%%preun.*/a rm -f %{inkernsym}' $TMPFILE
500 echo $TMPFILE
501 )}
502 %{expand:%(cat '%{ofed_module_package}')}
503 %endif
504 %if %{with mofed}
505 %kernel_module_package -n %{name}-lnet-o2iblnd -p %SOURCE13 -f %SOURCE14 %{_flavor}
506 %endif
507 %if %{with gni}
508 %kernel_module_package -n %{name}-lnet-gnilnd -p %SOURCE15 -f %SOURCE16 %{_flavor}
509 %endif
510 %if %{with kfi}
511 %kernel_module_package -n %{name}-lnet-kfilnd -p %SOURCE17 -f %SOURCE18 %{_flavor}
512 %endif
513 # end multiple_lnds
514 %endif
515
516 %if %{with lustre_iokit}
517 %package -n lustre-iokit
518 Summary: Collection of benchmark tools for a cluster with the Lustre file system
519 Requires: sg3_utils
520 %if 0%{?rhel} > 7 || 0%{?fedora} > 33 || 0%{?rhel} < 1
521 Recommends: perl
522 %endif
523
524 %description -n lustre-iokit
525 This package includes five tools:
526 sgpdd-survey:
527 A test of the 'bare metal' performance, bypassing as much of the kernel as we can. Uses the sgp_dd utility.
528
529 obdfilter-survey
530 This survey can be run in 3 modes to test disk I/O including the filesystem,
531 network I/O, and disk I/O via the network.  The script does sequential I/O
532 with varying numbers of threads and objects (files) by using lctl::test_brw
533 to drive the echo_client connected to local or remote obdfilter instances,
534 or remote obdecho instances.
535
536 ost-survey
537 This survey tests the client-to-disk performance of individual OSTs, and
538 ranks then for comparison.
539
540 stats-collect
541 This script will collect IO stats on a defined set of nodes.
542
543 ior-survey:
544 A script to run the IOR benchmark. The latest version can be downloaded from
545 https://github.com/hpc/ior/
546
547 mds-survey:
548 This survey tests the local metadata performance using the echo_client to drive
549 the MDD layer to perform operations. It is run with multiple threads (to
550 simulate MDT service threads) locally on the MDS node, and does not need Lustre
551 clients in order to run
552
553 lst-survey:
554 This survey tests LNet performance between a group of clients and servers.
555 %endif
556
557 %if 0%{?suse_version}
558 %debug_package
559 %endif
560 %prep
561 %setup -qn lustre-%{version}
562 ln lustre/ChangeLog ChangeLog-lustre
563 ln lnet/ChangeLog ChangeLog-lnet
564
565 %build
566 # Set an explicit path to our Linux tree, if we can.
567 cd $RPM_BUILD_DIR/lustre-%{version}
568
569 # Store the CFLAGS and LDFLAGS that would normally be used in the UTILS_CFLAGS
570 # and UTILS_LDFLAGS environment variables so that we use can them when compiling
571 # the user-space code in lustre/utils and lnet/utils. As of RHEL 8.0, the
572 # __global_* variants are deprecated in favour of build_cflags, etc. If neither
573 # style is available (e.g. on SLES), then these just end up as empty strings.
574 export UTILS_CFLAGS="%{?build_cflags:%{build_cflags}}%{!?build_cflags:%{?__global_cflags:%{__global_cflags}}}"
575 export UTILS_LDFLAGS="%{?build_ldflags:%{build_ldflags}}%{!?build_ldflags:%{?__global_ldflags:%{__global_ldflags}}}"
576
577 # RHEL7 on PPC64 needs __SANE_USERSPACE_TYPES__ defined so that __s64 and __u64
578 # are presented to user-land as long long instead of long long. Without this it
579 # will fail the format check whenever such a variable is printed.
580 %if 0%{?rhel}
581 %ifarch ppc64
582 export UTILS_CFLAGS="${UTILS_CFLAGS} -D__SANE_USERSPACE_TYPES__=1"
583 %endif
584 %endif
585
586 # Disable any hardening or annotation since this doesn't make sense for
587 # kernel code, and reset "optflags" so that the vendor's overzealous flags don't
588 # create build failures.
589 %define optflags -g -O2 -Werror
590 %undefine _annotated_build
591 %undefine _hardened_build
592
593 CONFIGURE_ARGS="%{?configure_args}"
594 if [ -n "$CONFIGURE_ARGS" ]; then
595         # make sure %%kdir and %%kobjdir are not in the configure arguments
596         CONFIGURE_ARGS=$(echo $CONFIGURE_ARGS | sed -e 's/"\?--with-linux=[^ ][^ ]* \?//')
597         CONFIGURE_ARGS=$(echo $CONFIGURE_ARGS | sed -e 's/"\?--with-linux-obj=[^ ][^ ]* \?//')
598         # remove --with-kmp-moddir from configure arguments,
599         # it will be set --with-kmp-moddir=%%kmoddir
600         CONFIGURE_ARGS=$(echo $CONFIGURE_ARGS | sed -e 's/"\?--with-kmp-moddir=[^ ][^ ]* \?//')
601         # remove env variables from config cache built by initial configure,
602         # and create dedicated cache in temporary build directory
603         if [ -f "$CONFIG_CACHE_FILE" ]; then
604                 TMP_CONFIG_CACHE="$(mktemp --tmpdir newconfig-XXXXXXXX.cache)"
605                 sed -e "/ac_cv_env/d" \
606                     -e "/am_cv_CC_dependencies_compiler_type/d" \
607                     -e "/lb_cv_mpi_tests/d" \
608                        "$CONFIG_CACHE_FILE" > $TMP_CONFIG_CACHE
609                 CONFIGURE_ARGS="$CONFIGURE_ARGS --cache-file=$TMP_CONFIG_CACHE"
610         fi
611 fi
612
613 # we need to eval "configure" because $CONFIGURE_ARGS could have a quoted
614 # string in it which we don't want word splitted by the shell
615 # also remove (build|host|target) options because they will be specified
616 # inside $CONFIGURE_ARGS
617 # kmod tools/scripts require "name" directory with kernel modules
618
619 %if 0%{?rhel} >= 9
620 %define _configure eval ./configure
621 %define eval_configure %configure
622 %else
623 %define eval_configure %(echo -n '%configure' | sed -e 's#\./configure#eval ./configure#' -e 's/--\\(build\\|host\\|target\\)=[^ ][^ ]* //g')
624 %endif
625
626 %if %{with mpi}
627 %if "%{mpi_name}" == "mpich"
628 %{?_mpich_load}
629 %endif
630 %if "%{mpi_name}" == "openmpi"
631 %{?_openmpi_load}
632 %endif
633 # mpi
634 %endif
635
636 WITH_O2IB=""
637 %if %{with mofed}
638         o2ib_path=$(find %{mofed_default_path} -type d -name ofed_scripts | xargs dirname)
639         if [ -z "$o2ib_path" ]; then
640                 echo "ERROR: could not find OFED devel headers"
641                 exit 1
642         fi
643         if [ $(echo $o2ib_path | wc -w) -ge 2 ]; then
644                 echo "ERROR: multiple OFED versions installed"
645                 exit 1
646         fi
647         WITH_O2IB="--with-o2ib=${o2ib_path}"
648 %else
649 %if %{without o2ib}
650         WITH_O2IB="--with-o2ib=no"
651 %endif
652 %endif
653
654 %eval_configure $CONFIGURE_ARGS \
655         %{?with_lustre_tests:--enable-tests}%{!?with_lustre_tests:--disable-tests} \
656         %{?with_lustre_utils:--enable-utils}%{!?with_lustre_utils:--disable-utils} \
657         %{?with_lustre_modules:--enable-modules}%{!?with_lustre_modules:--disable-modules} \
658         %{!?with_shared:--disable-shared} \
659         %{!?with_static:--disable-static} \
660         %{!?with_lustre_iokit:--disable-iokit} \
661         %{!?with_ldiskfs:--disable-ldiskfs} \
662         %{!?with_servers:--disable-server} \
663         %{!?with_zfs:--without-zfs} \
664         %{!?with_gss:--disable-gss} \
665         %{!?with_gss_keyring:--disable-gss-keyring} \
666         %{!?with_manpages:--disable-manpages} \
667         %{!?with_systemd:--with-systemdsystemunitdir=no} \
668         %{?with_systemd:--with-systemdsystemunitdir=%{_unitdir}} \
669         %{?with_multiple_lnds:--enable-multiple-lnds} \
670         %{?with_kfi:--with-kfi=/usr/src/cray-kfabric/default} \
671         %{?with_gni:--enable-gni} \
672         ${WITH_O2IB} \
673         %{!?with_l_getsepol:--disable-l_getsepol} \
674         --with-linux=%{kdir} \
675         --with-linux-obj=%{kobjdir} \
676         --with-kmp-moddir=%{kmoddir}/%{name}
677
678 %if %{with servers}
679 if ! grep -q define[[:space:]]*HAVE_SERVER_SUPPORT config.h 2> /dev/null; then
680         echo "Error: Server Support configured but not found"
681         false
682 fi
683 %endif
684
685 make %{?_smp_mflags} -s %{?make_args}
686
687 %if %{with mpi}
688 %if "%{mpi_name}" == "mpich"
689 %{?_mpich_unload}
690 %endif
691 %if "%{mpi_name}" == "openmpi"
692 %{?_openmpi_unload}
693 %endif
694 # mpi
695 %endif
696
697 %install
698
699 %if %{with mpi}
700 %if "%{mpi_name}" == "mpich"
701 %{?_mpich_load}
702 %endif
703 %if "%{mpi_name}" == "openmpi"
704 %{?_openmpi_load}
705 %endif
706 # mpi
707 %endif
708
709 make install DESTDIR=$RPM_BUILD_ROOT
710
711 %if %{with lustre_modules}
712 # RHEL's kernel_module_path macro expects that all the modules
713 # in a kmod package will be in modules_fs_path/<sub packagename>
714 # but Lustre installs all of the modules in a single pass into
715 # a shared location.  Since this is a restriction imposed by
716 # RHEL, we handle this here in the spec file rather than in
717 # Lustre's build system.  This is not expected to bother SLES's
718 # kernel_module_path macro.
719 basemodpath=$RPM_BUILD_ROOT%{modules_fs_path}/%{name}
720 %{__install} -D -m 0644 ${PWD}/Module.symvers %{buildroot}/Module.symvers
721 %if %{with ldiskfs}
722 mkdir -p $basemodpath-osd-ldiskfs/fs
723 mv $basemodpath/fs/osd_ldiskfs.ko $basemodpath-osd-ldiskfs/fs/osd_ldiskfs.ko
724 mv $basemodpath/fs/ldiskfs.ko $basemodpath-osd-ldiskfs/fs/ldiskfs.ko
725 %endif
726 %if %{with zfs}
727 mkdir -p $basemodpath-osd-zfs/fs
728 mv $basemodpath/fs/osd_zfs.ko $basemodpath-osd-zfs/fs/osd_zfs.ko
729 %endif
730 %if %{with lustre_tests}
731 mkdir -p $basemodpath-tests/fs
732 mv $basemodpath/fs/llog_test.ko $basemodpath-tests/fs/llog_test.ko
733 mv $basemodpath/fs/obd_test.ko $basemodpath-tests/fs/obd_test.ko
734 mkdir -p $RPM_BUILD_ROOT%{_libdir}/lustre/tests/kernel/
735 mv $basemodpath/fs/kinode.ko $RPM_BUILD_ROOT%{_libdir}/lustre/tests/kernel/
736 %endif
737 %endif
738
739 %if %{without mpi}
740 if [ -d $RPM_BUILD_ROOT%{_libdir}/openmpi ] ; then
741         rm -fr $RPM_BUILD_ROOT%{_libdir}/openmpi
742 fi
743 if [ -d $RPM_BUILD_ROOT%{_libdir}/mpich ] ; then
744         rm -fr $RPM_BUILD_ROOT%{_libdir}/mpich
745 fi
746 %endif
747
748 :> lustre.files
749
750 %if %{with servers} && %{with lustre_utils}
751 # The .ha_v2 extension identifies the heartbeat resource agent as using
752 # legacy syntax. Install a compatibility symlink to avoid conflicts when
753 # newer-style agents are added.
754 ln -s Lustre.ha_v2 $RPM_BUILD_ROOT%{_sysconfdir}/ha.d/resource.d/Lustre
755 echo '%dir %{_sysconfdir}/ha.d' >>lustre.files
756 echo '%dir %{_sysconfdir}/ha.d/resource.d' >>lustre.files
757 echo '%{_sysconfdir}/ha.d/resource.d/Lustre.ha_v2' >>lustre.files
758 echo '%{_sysconfdir}/ha.d/resource.d/Lustre' >>lustre.files
759 %endif
760
761 # systemd is on redhat, fedora, and suse
762 %if %{with systemd}
763 echo '%{_unitdir}/lnet.service' >>lustre.files
764 %endif
765
766 %if "%{_vendor}" == "redhat" || 0%{?openEuler}
767 # The following scripts are Red Hat specific
768 %if %{with servers}
769 echo '%{_sysconfdir}/init.d/lustre' >>lustre.files
770 echo '%{_sysconfdir}/sysconfig/lustre' >>lustre.files
771 %if %{with gss_keyring}
772 echo '%{_sysconfdir}/init.d/lsvcgss' >>lustre.files
773 echo '%config(noreplace) %{_sysconfdir}/sysconfig/lsvcgss' >>lustre.files
774 %endif
775 %endif
776
777 %if %{without systemd}
778 echo '%{_sysconfdir}/init.d/lnet' >>lustre.files
779 %endif
780 %endif
781 %if %{with gss_keyring}
782 echo '%config(noreplace) %{_sysconfdir}/request-key.d/lgssc.conf' >>lustre.files
783 %endif
784
785 # fc18 needs 'x' permission for library files
786 find $RPM_BUILD_ROOT -name \*.so -type f -exec chmod +x {} \;
787
788 rm -f $RPM_BUILD_ROOT%{_libdir}/liblnetconfig.la
789 %if %{with static}
790 echo '%attr(-, root, root) %{_libdir}/liblnetconfig.a' >>lustre.files
791 %endif
792 %if %{with shared}
793 echo '%attr(-, root, root) %{_libdir}/liblnetconfig.so' >>lustre-devel.files
794 echo '%attr(-, root, root) %{_libdir}/liblnetconfig.so.*' >>lustre.files
795 %endif
796
797 %if %{with ldiskfs}
798 echo '%{_libdir}/libiam.a' >>lustre.files
799 %endif
800
801 %if %{with lustre_utils}
802 mkdir -p $RPM_BUILD_ROOT/%{_datadir}/lustre
803 if [ -d $RPM_BUILD_ROOT%{_libdir}/lustre ] ; then
804         find $RPM_BUILD_ROOT%{_libdir}/@PACKAGE@ -name \*.la -type f -exec rm -f {} \;
805 fi
806 %endif
807
808 echo '%{_prefix}/lib/firewalld/services/*.xml' >>lustre.files
809 %if %{with lustre_modules}
810 # mark modules executable for find-debuginfo.sh
811 find $RPM_BUILD_ROOT/lib/modules -name \*.ko -type f -exec chmod u+x {} \;
812 %endif
813
814 rm -f $RPM_BUILD_ROOT%{_libdir}/liblustreapi.la
815
816 %if %{with lustre_tests}
817 :> lustre-tests.files
818 %if %{with mpi}
819 %if "%{mpi_name}" == "mpich"
820 %{?_mpich_load}
821 %endif
822 %if "%{mpi_name}" == "openmpi"
823 %{?_openmpi_load}
824 %endif
825 # mpi
826 %endif
827 echo '%dir %{_libdir}/lustre' >>lustre-tests.files
828 echo '%dir %{_libdir}/lustre/tests' >>lustre-tests.files
829 echo '%{_libdir}/lustre/tests/*' >>lustre-tests.files
830 echo '%{_bindir}/mcreate' >>lustre-tests.files
831 echo '%{_bindir}/statx' >>lustre-tests.files
832 echo '%{_sbindir}/wirecheck' >>lustre-tests.files
833 echo '%{_sbindir}/wiretest' >>lustre-tests.files
834 if [ -n "$MPI_BIN" ]; then
835         echo "$MPI_BIN/*" >>lustre-tests.files
836 fi
837 %if %{with lustre_tests_lutf}
838 echo '%{_libdir}/lustre/tests/lutf/*' >>lustre-tests.files
839 %endif
840 %endif
841
842 %if %{with lustre_tests_lutf}
843 echo '%{_libdir}/lustre/tests/lutf/*' >>lustre-tests.files
844 %endif
845
846 %files devel -f lustre-devel.files
847 %defattr(-,root,root)
848 %{_libdir}/pkgconfig/lustre.pc
849 %if %{with static}
850 %{_libdir}/liblustreapi.a
851 %endif
852 %if %{with shared}
853 %{_libdir}/liblustreapi.so
854 %endif
855 %{_includedir}/lustre
856 %if %{with lustre_modules}
857 %{_includedir}/linux/lnet
858 %{_includedir}/linux/lustre
859 %else
860 %exclude %{_includedir}/linux/lnet
861 %exclude %{_includedir}/linux/lustre
862 %endif
863
864 %files -f lustre.files
865 %defattr(-,root,root)
866 %{_sbindir}/*
867 %if %{with lustre_tests}
868 %exclude %{_sbindir}/wirecheck
869 %exclude %{_sbindir}/wiretest
870 %endif
871 %if %{with zfs}
872 %exclude %{_sbindir}/zfsobj2fid
873 %endif
874 %if %{with lustre_utils}
875 %if %{with servers}
876 %dir %{_libexecdir}/lustre
877 %{_libexecdir}/lustre/lc_common
878 %{_libexecdir}/lustre/haconfig
879 %{_bindir}/lustre_req_history
880 %{_bindir}/remove_changelog
881 %{_bindir}/remove_updatelog
882 %endif
883
884 %{_bindir}/llobdstat
885 %{_bindir}/lljobstat
886 %{_bindir}/llstat
887 %{_bindir}/plot-llstat
888 %{_datadir}/lustre
889
890 %{_bindir}/lfs
891 %{_bindir}/lfs_migrate
892 /sbin/mount.lustre
893 %if %{with servers}
894 /sbin/mount.lustre_tgt
895 %endif
896 @BASH_COMPLETION_DIR@
897 %endif
898
899 %if %{with manpages}
900 %{_mandir}/man?/*
901 %endif
902
903 %if %{with shared}
904 %{_libdir}/liblustreapi.so.*
905 %endif
906 %{_udevrulesdir}/99-lustre.rules
907 %if %{with servers}
908 %{_udevrulesdir}/99-lustre-server.rules
909 %endif
910 %if %{with zfs}
911 %config(noreplace) %{_sysconfdir}/ldev.conf
912 %endif
913 %config(noreplace) %{_sysconfdir}/lnet.conf
914 %config(noreplace) %{_sysconfdir}/modprobe.d/ko2iblnd.conf
915 %if %{with lustre_utils}
916 %config(noreplace) %{_sysconfdir}/lnet_routes.conf
917 %endif
918 %if %{with lustre_modules}
919 %exclude /Module.symvers
920 %if %{with shared}
921 %if %{with ldiskfs}
922 %if %{with lustre_utils}
923 %files osd-ldiskfs-mount
924 %defattr(-,root,root)
925 %dir %{_libdir}/@PACKAGE@
926 %{_libdir}/@PACKAGE@/mount_osd_ldiskfs.so
927 %endif
928 %endif
929 %endif
930
931 %if %{with shared}
932 %if %{with zfs}
933 %if %{with lustre_utils}
934 %files osd-zfs-mount
935 %defattr(-,root,root)
936 %dir %{_libdir}/@PACKAGE@
937 %{_libdir}/@PACKAGE@/mount_osd_zfs.so
938 %{_sysconfdir}/zfs/zed.d/*
939 %endif
940 %endif
941 %endif
942
943 # with lustre_modules
944 %endif
945
946 %if %{with servers}
947 %files resource-agents
948 %defattr(0755,root,root)
949 %dir %{_prefix}/lib/ocf
950 %dir %{_prefix}/lib/ocf/resource.d
951 %{_prefix}/lib/ocf/resource.d/lustre/
952 %endif
953
954 %if %{with lustre_tests}
955 %files tests -f lustre-tests.files
956 %defattr(-,root,root)
957 %endif
958
959 %if %{with lustre_iokit}
960 %files -n lustre-iokit
961 %defattr(-, root, root)
962 %{_bindir}/iokit-config
963 %{_bindir}/iokit-gather-stats
964
965 %{_bindir}/iokit-libecho
966 %{_bindir}/iokit-lstats
967 %{_bindir}/iokit-parse-ior
968 %{_bindir}/iokit-plot-obdfilter
969 %{_bindir}/iokit-plot-ost
970 %{_bindir}/iokit-plot-sgpdd
971 %{_bindir}/ior-survey
972 %{_bindir}/mds-survey
973 %{_bindir}/obdfilter-survey
974 %{_bindir}/ost-survey
975 %{_bindir}/sgpdd-survey
976 %{_bindir}/lst-survey
977 %{_bindir}/lst.sh
978 %doc lustre-iokit/ior-survey/README.ior-survey
979 %doc lustre-iokit/mds-survey/README.mds-survey
980 %doc lustre-iokit/obdfilter-survey/README.obdfilter-survey
981 %doc lustre-iokit/ost-survey/README.ost-survey
982 %doc lustre-iokit/sgpdd-survey/README.sgpdd-survey
983 %doc lustre-iokit/stats-collect/README.iokit-lstats
984 %doc lustre-iokit/lst-survey/README.lst-survey
985 %endif
986
987 %post
988 %if %{with systemd}
989 %systemd_post lnet.service
990 %endif
991
992 %preun
993 %if %{with systemd}
994 %systemd_preun lnet.service
995 %endif
996
997 %postun
998 %if %{with systemd}
999 %systemd_postun_with_restart lnet.service
1000 %endif
1001
1002 %clean
1003 rm -rf $RPM_BUILD_ROOT
1004 rm -rf %{_tmppath}/kmp