Whamcloud - gitweb
LU-5396 lov: add sparse annotation __user wherever needed
[fs/lustre-release.git] / lustre.spec.in
1 # lustre.spec
2
3 # Declare rpmbuild --with/--without parameters
4 %bcond_without servers
5 %bcond_without ldiskfs
6 %bcond_with zfs
7 %bcond_without lustre_tests
8 %bcond_without lustre_iokit
9 %bcond_without lustre_modules
10
11 %if %{without servers}
12     # --without servers overrides --with {ldiskfs|zfs}
13     # so undefine the internal variables set by bcond_*
14     %undefine with_ldiskfs
15     %undefine with_zfs
16 %endif
17
18 %{!?version: %global version @VERSION@}
19 %{!?kver: %global kver ""}
20 %{!?kdir: %global kdir %(dir=$(echo "%configure_args" | sed -ne 's/.*--with-linux=\\([^ ][^ ]*\\).*$/\\1/p'); if [ -n "$dir" ]; then echo "$dir"; else if [ -n "%kver" ]; then kversion="%kver"; else kversion="$(uname -r)"; fi; echo "/lib/modules/$kversion/source"; fi)}
21
22 %{!?kobjdir: %global kobjdir %(dir=$(echo "%configure_args" | sed -ne 's/.*--with-linux-obj=\\([^ ][^ ]*\\).*$/\\1/p'); if [ -n "$dir" ]; then echo "$dir"; else if [ -n "%kver" ]; then kversion="%kver"; else kversion="$(uname -r)"; fi; if [ "%kdir" = "/lib/modules/$kversion/source" ]; then echo "/lib/modules/$kversion/build"; else echo "%kdir"; fi; fi)}
23
24 # as an alternative to this implementation we could simply "make -C $kdir kernelversion"
25 %{!?kversion: %global kversion %(if test -s %kobjdir/include/generated/utsrelease.h ; then LINUXRELEASEHEADER=%kobjdir/include/generated/utsrelease.h ; elif test -s %kobjdir/include/linux/utsrelease.h ; then LINUXRELEASEHEADER=%kobjdir/include/linux/utsrelease.h ; else LINUXRELEASEHEADER=%kobjdir/include/linux/version.h; fi; sed -ne '/^#define UTS_RELEASE/s/.*"\\(.*\\)"$/\\1/p' $LINUXRELEASEHEADER)}
26
27 %{!?downstream_release: %global downstream_release "@DOWNSTREAM_RELEASE@"}
28
29 %define buildid %(if [ -n "@BUILDID@" ]; then echo "_@BUILDID@"; fi)
30
31 %{!?myrelease: %global myrelease %(if [ -n "%downstream_release" ]; then echo -n "%{downstream_release}_"; fi; echo %kversion | tr '-' '_')}
32
33 # always append the buildid, even when the caller defines %release
34 %define fullrelease %{myrelease}%{buildid}
35
36 # in order to get kernel symset and/or kernel module dependencies into
37 # the RPM, in order to support weak-modules, the internal dependency gen-
38 # erator needs to be disabled
39 # this is done with (reduce the double % down to a single %):
40 #
41 # %%global _use_internal_dependency_generator 0
42 #
43 # on SLES10, /usr/lib/rpm/macros already sets this, so no harm in also
44 # defining it here (until Suse changes their mind)
45 #
46 # on RHEL5, however, we do need to explicitly disable the internal dep-
47 # endency generator and allow the external one be used
48 # but since RedHat's kABI is only a subset of the total kernel ABI, it
49 # doesn't include all of the symbols we (or OFED for that matter) need
50 # until RedHat includes all of the symbols we need in their symsets we
51 # cannot support weak-modules
52 # we did e-mail the maintainer of all of this stuff @redhat but got no
53 # response from them
54 #%%global _use_internal_dependency_generator 0
55
56 # for those uses that don't want the -smp/-bigsmp (or the .arch) on the end
57 # of %kversion
58 %define krequires %(bash -c "echo %{kversion} | sed -e 's/\.x86_64$//' -e 's/\.i[3456]86$//' -e 's/-smp$//' -e 's/-bigsmp$//' -e 's/-ppc64$//' -e 's/-default$//'")
59
60 # Set the package name prefix
61 %if %{undefined lustre_name}
62     %if %{with servers}
63         %global lustre_name lustre
64     %else
65         %global lustre_name lustre-client
66     %endif
67 %endif
68
69 %if %{undefined kmoddir}
70     %if %{defined kernel_module_package_moddir}
71         %global kmoddir %{kernel_module_package_moddir}
72     %else
73         %if %{defined suse_kernel_module_package}
74             %global kmoddir updates
75         %else
76             %global kmoddir extra
77         %endif
78     %endif
79 %endif
80
81 %if %{defined cross_path} && %{defined post_script}
82 %define rpm_post_base %(echo $(dirname %{cross_path})/%{lustre_name})
83 %endif
84
85 # SUSE don't support .debug_info section from cross compiler:
86 # /usr/lib/rpm/debugedit: Unhandled relocation 10 in .debug_info section
87 %if %{defined cross_path} && 0%{?suse_version}
88 %global __debug_install_post %{nil}
89 %global __debug_package %{nil}
90 %global debug_package %{nil}
91 %endif
92
93 Summary: Lustre File System
94 Name: %{lustre_name}
95 Version: %{version}
96 Release: %{fullrelease}
97 License: GPL
98 Group: Utilities/System
99 Source: lustre-%{version}.tar.gz
100 URL: https://wiki.hpdd.intel.com/
101 BuildRoot: %{_tmppath}/lustre-%{version}-root
102 Obsoletes: lustre-lite, lustre-lite-utils, lustre-ldap nfs-utils-lustre
103 Provides: lustre-lite = %{version}, lustre-lite-utils = %{version}
104 Requires: %{name}-modules = %{version}
105 BuildRequires: libtool
106 %if %{with servers}
107 Requires: lustre-osd
108 %endif
109 %if %{defined cross_requires}
110 Requires: %{cross_requires}
111 AutoReqProv: no
112 %else
113 # GSS requires this: BuildRequires: pkgconfig, libgssapi-devel >= 0.10
114 %if %{_vendor}=="redhat" || %{_vendor}=="fedora"
115 #suse don't support selinux
116 BuildRequires: libselinux-devel
117 Requires: libselinux
118 %endif
119 %endif
120
121 %description
122 Userspace tools and files for the Lustre file system.
123
124 %if %{with lustre_modules}
125 %package modules
126 Summary: Kernel Lustre modules for Linux %{kversion}
127 %if %{defined cross_requires}
128 Requires: %{cross_requires}
129 AutoReqProv: no
130 %else
131 # for SLES11, we need nothing here
132 %if %{_vendor}=="redhat" || %{_vendor}=="fedora"
133 # for RHEL we need to require the specific kernel still since weak-modules
134 # support on RH is, well, weak, to be punny about it
135 Requires: kernel = %{krequires}
136 %endif
137 %endif
138 Group: Development/Kernel
139
140 %description modules
141 Lustre file system, server and network drivers for Linux %{kversion}.
142
143 %if %{with ldiskfs}
144 %package osd-ldiskfs
145 Summary: osd-ldiskfs contains both ldiskfs and its osd interface in Lustre.
146 Requires: lustre-modules = %{version}
147 Requires: module-init-tools >= 3.9
148 Requires: ldiskfsprogs >= 1.42.7.wc1
149 Provides: lustre-osd
150 Obsoletes: lustre-ldiskfs
151 Group: Development/Kernel
152
153 %description osd-ldiskfs
154 The Lustre Object Storage Device (OSD) API is the interface to access and
155 modify data that is supposed to be stored persistently. This API is the interface
156 to code that bridges individual file systems. This specific package provides an
157 implementation of the OSD API for using the Ldiskfs filesystem as the underlying
158 backing store of a Lustre server.
159 %endif
160
161 %if %{with zfs}
162 %package osd-zfs
163 Summary: osd-zfs is the mandatory glue for ZFS support in Lustre.
164 Requires: lustre-modules = %{version}, zfs-kmod
165 Provides: lustre-osd
166 Group: Development/Kernel
167
168 %description osd-zfs
169 The Lustre Object Storage Device (OSD) API is the interface to access and
170 modify data that is supposed to be stored persistently. This API is the interface
171 to code that bridges individual file systems. This specific package provides an
172 implementation of the OSD API for using the ZFS filesystem as the underlying
173 backing store of a Lustre server.
174 %endif
175 %endif # with lustre_modules
176
177 %package source
178 Summary: Object-Based Disk storage driver source
179 Group: Development/Kernel
180
181 %description source
182 Lustre sources for further development
183
184 # Since the RPMs we ship are to be used on both SLES and RHEL, we
185 # can't include any dependency information (since the package names
186 # are different on the two platforms).
187 #
188 # Instead, we can build these empty meta-packages that only include
189 # dependency information.  These let people get the correct
190 # dependencies for their platform and lets them use tools like yum and
191 # red carpet to install the correct files.
192 #
193 # Unfortunately I have not seen this come up on the lists much, so I
194 # have disabled them (by commenting out their empty files section
195 # below) until it's clear that they resolve more confusion than they
196 # add.
197
198 %package deps-sles
199 Summary: Lustre dependencies meta-package for SLES
200 Group: Utilities/System
201 Provides: lustre-deps = %{version}
202 Requires: %{name} = %{version}, sles-release
203 Conflicts: %{name}-deps-rhel
204
205 %description deps-sles
206 This package has RPM dependencies appropriate for SLES systems.
207
208 %package deps-rhel
209 Summary: Lustre dependencies meta-package for RHEL
210 Group: Utilities/System
211 Provides: lustre-deps = %{version}
212 Requires: %{name} = %{version}, redhat-release
213 Conflicts: %{name}-deps-sles
214
215 %description deps-rhel
216 This package has RPM dependencies appropriate for RHEL, RHL, and FC
217 systems.
218
219 %package tests
220 Summary: Lustre testing framework
221 Group: Development/Kernel
222 Provides: %{name}-tests = %{version}
223 Requires: %{name} = %{version}, %{name}-modules = %{version}, lustre-iokit
224 Requires: attr, rsync, perl, lsof, /usr/bin/getconf
225
226 %description tests
227 This package contains a set of test binaries and scripts that are intended
228 to be used by the Lustre testing framework.
229
230 %if %{with lustre_iokit}
231 %package -n lustre-iokit
232 Summary: The Lustre IO-Kit is a collection of benchmark tools for a cluster with the Lustre file system.
233 Group: Applications/System
234 Requires: python > 2.2, sg3_utils
235
236 %description -n lustre-iokit
237 This package includes five tools:
238 sgpdd-survey:
239 A test of the 'bare metal' performance, bypassing as much of the kernel as we can. Uses the sgp_dd utility.
240
241 obdfilter-survey
242 This survey can be run in 3 modes to test disk I/O including the filesystem,
243 network I/O, and disk I/O via the network.  The script does sequential I/O
244 with varying numbers of threads and objects (files) by using lctl::test_brw
245 to drive the echo_client connected to local or remote obdfilter instances,
246 or remote obdecho instances.
247
248 ost-survey
249 This survey tests the client-to-disk performance of individual OSTs, and
250 ranks then for comparison.
251
252 stats-collect
253 This script will collect IO stats on a defined set of nodes.
254
255 ior-survey:
256 A script to run the IOR benchmark. The latest version can be downloaded from
257 http://www.llnl.gov/asci/purple/benchmarks/limited/ior/
258
259 mds-survey:
260 This survey tests the local metadata performance using the echo_client to drive
261 the MDD layer to perform operations. It is run with multiple threads (to
262 simulate MDT service threads) locally on the MDS node, and does not need Lustre
263 clients in order to run
264 %endif
265
266 %if 0%{?suse_version}
267 %debug_package
268 %endif
269 %prep
270 %setup -qn lustre-%{version}
271 ln lustre/ChangeLog ChangeLog-lustre
272 ln lnet/ChangeLog ChangeLog-lnet
273
274 %build
275
276 # Set an explicit path to our Linux tree, if we can.
277 cd $RPM_BUILD_DIR/lustre-%{version}
278 # override %optflags so that the vendor's overzealous flags don't create
279 # build failures
280 %define optflags -g -O2 -Werror
281 CONFIGURE_ARGS="%{?configure_args} --with-release=%release"
282 %if %{with lustre_tests}
283 CONFIGURE_ARGS="$CONFIGURE_ARGS --enable-tests"
284 %else
285 CONFIGURE_ARGS="$CONFIGURE_ARGS --disable-tests"
286 %endif
287 %if %{without lustre_iokit}
288 CONFIGURE_ARGS="$CONFIGURE_ARGS --disable-iokit"
289 %endif
290
291 %if %{with lustre_modules}
292 CONFIGURE_ARGS="$CONFIGURE_ARGS --enable-modules"
293 %else
294 CONFIGURE_ARGS="$CONFIGURE_ARGS --disable-modules"
295 %endif
296
297 %if %{without zfs}
298 CONFIGURE_ARGS="$CONFIGURE_ARGS --without-zfs"
299 %endif
300
301 # if %%kdir was given, make sure it's not in the configure arguments
302 if [ -n "%kdir" ]; then
303         CONFIGURE_ARGS=$(echo $CONFIGURE_ARGS | sed -e 's/"\?--with-linux=[^ ][^ ]* \?//')
304 fi
305 # ditto for %%kobjdir
306 if [ -n "%kobjdir" ]; then
307         CONFIGURE_ARGS=$(echo $CONFIGURE_ARGS | sed -e 's/"\?--with-linux-obj=[^ ][^ ]* \?//')
308 fi
309 # remove --with-kmp-moddir from configure arguments,
310 # it will be set --with-kmp-moddir=%%kmoddir
311 CONFIGURE_ARGS=$(echo $CONFIGURE_ARGS | sed -e 's/"\?--with-kmp-moddir=[^ ][^ ]* \?//')
312
313 # we need to eval "configure" because $CONFIGURE_ARGS could have a quoted
314 # string in it which we don't want word splitted by the shell
315 # also remove (build|host|target) options because they will be specified
316 # inside $CONFIGURE_ARGS
317 %define eval_configure %(echo '%configure' | sed -e 's#\./configure#eval ./configure#' -e 's/--\\(build\\|host\\|target\\)=[^ ][^ ]* //g')
318
319 %eval_configure \
320         %{?kdir: --with-linux=%kdir} %{?kobjdir: --with-linux-obj=%kobjdir} \
321         $CONFIGURE_ARGS --with-kmp-moddir=%{kmoddir}
322 make %{?_smp_mflags} -s %{?make_args}
323
324 %install
325 make install DESTDIR=$RPM_BUILD_ROOT
326
327 :> lustre.files
328
329 %if %{with servers}
330 # The .ha_v2 extension identifies the heartbeat resource agent as using
331 # legacy syntax. Install a compatibility symlink to avoid conflicts when
332 # newer-style agents are added.
333 ln -s Lustre.ha_v2 $RPM_BUILD_ROOT%{_sysconfdir}/ha.d/resource.d/Lustre
334 echo '%{_sysconfdir}/ha.d/resource.d/Lustre.ha_v2' >>lustre.files
335 echo '%{_sysconfdir}/ha.d/resource.d/Lustre' >>lustre.files
336
337 if [ -f $RPM_BUILD_ROOT%{_sysconfdir}/init.d/lustre ]; then
338         echo '%{_sysconfdir}/sysconfig/lustre' >>lustre.files
339         echo '%{_sysconfdir}/init.d/lustre' >>lustre.files
340 fi
341 %endif
342
343 if [ -f $RPM_BUILD_ROOT%{_sysconfdir}/init.d/lnet ]; then
344         echo '%{_sysconfdir}/init.d/lnet' >>lustre.files
345 fi
346
347 # Create the pristine source directory.
348 cd $RPM_BUILD_DIR/lustre-%{version}
349 mkdir -p $RPM_BUILD_ROOT%{_prefix}/src
350 rm -f lustre-source
351 ln -s $RPM_BUILD_ROOT%{_prefix}/src lustre-source
352 make distdir distdir=lustre-source/lustre-%{version}
353 chmod -R go-w lustre-source/lustre-%{version}
354 # fc18 needs 'x' permission for library files
355 find $RPM_BUILD_ROOT -name '*.so' | xargs chmod +x
356
357 if [ -f $RPM_BUILD_ROOT%{_libdir}/libiam.a ] ; then
358   echo '%{_libdir}/libiam.a' >>lustre.files
359 fi
360
361 if [ -d $RPM_BUILD_ROOT%{_libdir}/lustre/snmp ] ; then
362   echo '%{_libdir}/lustre/snmp' >>lustre.files
363   echo '%{_datadir}/lustre/snmp/mibs' >>lustre.files
364 fi
365
366 find $RPM_BUILD_ROOT%{_libdir}/@PACKAGE@/ -name \*.la -delete
367
368 %if %{with lustre_tests}
369 echo '%{_libdir}/lustre/tests/*' >>lustre-tests.files
370 echo '%{_bindir}/mcreate' >>lustre-tests.files
371 echo '%{_bindir}/munlink' >>lustre-tests.files
372 %if %{with lustre_modules}
373 echo '%{?rootdir}/lib/modules/%{kversion}/%{kmoddir}/kernel/fs/@PACKAGE@/llog_test.ko' >>lustre-tests.files
374 %endif
375 %endif
376
377 %if %{defined cross_path}
378 %if %{defined rpm_post_base}
379 POST_SCRIPT=$RPM_BUILD_DIR/lustre-%{version}/%{post_script}
380 if [ -f $POST_SCRIPT ]; then
381         cp -f $POST_SCRIPT $RPM_BUILD_ROOT/%{rpm_post_base}.sh
382         echo '%attr(0555, root, root) %{rpm_post_base}.sh' >>lustre.files
383         cp -f $POST_SCRIPT $RPM_BUILD_ROOT/%{rpm_post_base}-modules.sh
384 %if %{with ldiskfs}
385         cp -f $POST_SCRIPT $RPM_BUILD_ROOT/%{rpm_post_base}-osd-ldiskfs.sh
386 %endif
387 %if %{with zfs}
388         cp -f $POST_SCRIPT $RPM_BUILD_ROOT/%{rpm_post_base}-osd-zfs.sh
389 %endif
390 %if %{with lustre_tests}
391         cp -f $POST_SCRIPT $RPM_BUILD_ROOT/%{rpm_post_base}-tests.sh
392         echo '%attr(0555, root, root) %{rpm_post_base}-tests.sh' >>lustre-tests.files
393 %endif
394 fi
395 %endif
396 %else
397 # mark modules executable for find-debuginfo.sh
398 find $RPM_BUILD_ROOT%{?rootdir}/lib/modules/%{kversion}/%{kmoddir} -name "*.ko" -type f | \
399         xargs --no-run-if-empty chmod u+x
400 %endif
401
402 %files -f lustre.files
403 %defattr(-,root,root)
404 %{?rootdir}/sbin/mount.lustre
405 %{_sbindir}/*
406 %{_bindir}/lfs
407 %{_bindir}/lfs_migrate
408 %{_bindir}/llbackup
409 %{_bindir}/llobdstat
410 %{_bindir}/llstat
411 %{_bindir}/lustre_req_history
412 %{_bindir}/plot-llstat
413 %{_bindir}/req_layout
414 %{_libdir}/libptlctl.a
415 %{_libdir}/libcfsutil.a
416 %{_libdir}/liblustreapi.a
417 %{_libdir}/liblustreapi.so
418 %{_mandir}/man?/*
419 %{_datadir}/lustre
420 %{_includedir}/lustre
421 %{_includedir}/libcfs
422 %{_includedir}/linux/lustre_user.h
423 %{_libexecdir}/lustre/lc_common
424 %{_libexecdir}/lustre/haconfig
425 %{_sysconfdir}/udev/rules.d/99-lustre.rules
426 %config(noreplace) %{_sysconfdir}/ldev.conf
427
428 %if %{with lustre_modules}
429 %files modules
430 %defattr(-,root,root)
431 %{?rootdir}/lib/modules/%{kversion}/%{kmoddir}/*
432 %if %{with lustre_tests}
433 %exclude %{?rootdir}/lib/modules/%{kversion}/%{kmoddir}/kernel/fs/@PACKAGE@/llog_test.ko
434 %endif
435 %if %{with ldiskfs}
436 %exclude %{?rootdir}/lib/modules/%{kversion}/%{kmoddir}/kernel/fs/@PACKAGE@/ldiskfs.ko
437 %exclude %{?rootdir}/lib/modules/%{kversion}/%{kmoddir}/kernel/fs/@PACKAGE@/osd_ldiskfs.ko
438 %endif
439 %if %{with zfs}
440 %exclude %{?rootdir}/lib/modules/%{kversion}/%{kmoddir}/kernel/fs/@PACKAGE@/osd_zfs.ko
441 %endif
442 %if %{defined rpm_post_base}
443 %attr(0555, root, root) %{rpm_post_base}-modules.sh
444 %endif
445 %doc COPYING
446 %doc ChangeLog-lustre
447 %doc ChangeLog-lnet
448
449 %if %{with ldiskfs}
450 %files osd-ldiskfs
451 %defattr(-,root,root)
452 %{?rootdir}/lib/modules/%{kversion}/%{kmoddir}/kernel/fs/@PACKAGE@/ldiskfs.ko
453 %{?rootdir}/lib/modules/%{kversion}/%{kmoddir}/kernel/fs/@PACKAGE@/osd_ldiskfs.ko
454 %{_libdir}/@PACKAGE@/mount_osd_ldiskfs.so
455 %if %{defined rpm_post_base}
456 %attr(0555, root, root) %{rpm_post_base}-osd-ldiskfs.sh
457 %endif
458 %endif
459
460 %if %{with zfs}
461 %files osd-zfs
462 %defattr(-,root,root)
463 %{?rootdir}/lib/modules/%{kversion}/%{kmoddir}/kernel/fs/@PACKAGE@/osd_zfs.ko
464 %{_libdir}/@PACKAGE@/mount_osd_zfs.so
465 %if %{defined rpm_post_base}
466 %attr(0555, root, root) %{rpm_post_base}-osd-zfs.sh
467 %endif
468 %endif
469 %endif # with lustre_modules
470
471 %files source
472 %defattr(-,root,root)
473 %{_prefix}/src/lustre-%{version}
474
475 # uncomment these lines to enable deps packages
476 # %files deps-sles
477 # %files deps-rhel
478
479 %if %{with lustre_tests}
480 %files tests -f lustre-tests.files
481 %defattr(-,root,root)
482 %endif
483
484 %if %{with lustre_iokit}
485 %files -n lustre-iokit
486 %defattr(-, root, root)
487 %{_bindir}/iokit-config
488 %{_bindir}/iokit-gather-stats
489 %{_bindir}/iokit-libecho
490 %{_bindir}/iokit-lstats
491 %{_bindir}/iokit-parse-ior
492 %{_bindir}/iokit-plot-obdfilter
493 %{_bindir}/iokit-plot-ost
494 %{_bindir}/iokit-plot-sgpdd
495 %{_bindir}/ior-survey
496 %{_bindir}/mds-survey
497 %{_bindir}/obdfilter-survey
498 %{_bindir}/ost-survey
499 %{_bindir}/sgpdd-survey
500 %doc lustre-iokit/ior-survey/README.ior-survey
501 %doc lustre-iokit/mds-survey/README.mds-survey
502 %doc lustre-iokit/obdfilter-survey/README.obdfilter-survey
503 %doc lustre-iokit/ost-survey/README.ost-survey
504 %doc lustre-iokit/sgpdd-survey/README.sgpdd-survey
505 %doc lustre-iokit/stats-collect/README.iokit-lstats
506 %endif
507
508 %if %{defined rpm_post_base}
509 %post
510 if [ -x %{rpm_post_base}.sh ]; then
511         %{rpm_post_base}.sh %{cross_path} create
512 fi
513
514 %preun
515 if [ -x %{rpm_post_base}.sh ]; then
516         %{rpm_post_base}.sh %{cross_path} remove
517 fi
518 %endif
519
520 %if %{with lustre_modules}
521 %post modules
522 %if %{defined rpm_post_base}
523 if [ -x %{rpm_post_base}-modules.sh ]; then
524         %{rpm_post_base}-modules.sh %{cross_path} create
525 fi
526 %else
527 if [ -f /boot/System.map-%{kversion} ]; then
528         depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
529 else
530         depmod -ae %{kversion} || exit 0
531 fi
532
533 MODULES_RPM_NAME=$(rpm -q %{name}-modules | grep "%{version}-%{release}")
534 # "weak modules" support
535 # Suse
536 if [ -x /usr/lib/module-init-tools/weak-modules ]; then
537     rpm -ql $MODULES_RPM_NAME | grep '\.ko$' |
538         /usr/lib/module-init-tools/weak-modules --add-modules
539 fi
540 # RedHat
541 if [ -x /sbin/weak-modules ]; then
542     rpm -ql $MODULES_RPM_NAME | grep '\.ko$' |
543         /sbin/weak-modules --add-modules
544 fi
545
546 # If the kernel was built to reject unsupported modules (e.g. not a Lustre
547 # kernel), and this hasn't been overridden in /etc/modprobe.d yet, then
548 # print a warning so that users are aware of this issue.
549 if sysctl kernel.unsupported >/dev/null 2>&1 &&
550    [ "$(sysctl -n kernel.unsupported 2>/dev/null)" = "0" ] &&
551     ! modprobe -c | grep -q "^allow_unsupported_modules[ \t]1" ; then
552      echo "
553      warning: the Lustre modules are not supported by Novell. To use Lustre
554               on this system, you should put
555
556      allow_unsupported_modules 1
557
558      into /etc/modprobe.d/unsupported_modules"
559 fi
560 %endif
561
562 %if %{with ldiskfs}
563 %post osd-ldiskfs
564 %if %{defined rpm_post_base}
565 if [ -x %{rpm_post_base}-osd-ldiskfs.sh ]; then
566         %{rpm_post_base}-osd-ldiskfs.sh %{cross_path} create
567 fi
568 %else
569 if [ -f /boot/System.map-%{kversion} ]; then
570        depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
571 else
572        depmod -ae %{kversion} || exit 0
573 fi
574
575 OSD_LDISKFS_RPM_NAME=$(rpm -q %{name}-osd-ldiskfs | grep "%{version}-%{release}")
576 # "weak modules" support
577 # Suse
578 if [ -x /usr/lib/module-init-tools/weak-modules ]; then
579     rpm -ql $OSD_LDISKFS_RPM_NAME | grep '\.ko$' |
580         /usr/lib/module-init-tools/weak-modules --add-modules
581 fi
582 # RedHat
583 if [ -x /sbin/weak-modules ]; then
584     rpm -ql $OSD_LDISKFS_RPM_NAME | grep '\.ko$' |
585         /sbin/weak-modules --add-modules
586 fi
587
588 # If the kernel was built to reject unsupported modules (e.g. not a Lustre
589 # kernel), and this hasn't been overridden in /etc/modprobe.d yet, then
590 # print a warning so that users are aware of this issue.
591 if sysctl kernel.unsupported >/dev/null 2>&1 &&
592    [ "$(sysctl -n kernel.unsupported 2>/dev/null)" = "0" ] &&
593     ! modprobe -c | grep -q "^allow_unsupported_modules[ \t]1" ; then
594      echo "
595      warning: the Lustre modules are not supported by Novell. To use Lustre
596               on this system, you should put
597
598      allow_unsupported_modules 1
599
600      into /etc/modprobe.d/unsupported_modules"
601 fi
602 %endif
603 %endif
604
605 %if %{with zfs}
606 %post osd-zfs
607 %if %{defined rpm_post_base}
608 if [ -x %{rpm_post_base}-osd-zfs.sh ]; then
609         %{rpm_post_base}-osd-zfs.sh %{cross_path} create
610 fi
611 %else
612 if [ -f /boot/System.map-%{kversion} ]; then
613        depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
614 else
615        depmod -ae %{kversion} || exit 0
616 fi
617
618 OSD_ZFS_RPM_NAME=$(rpm -q %{name}-osd-zfs | grep "%{version}-%{release}")
619 # "weak modules" support
620 # Suse
621 if [ -x /usr/lib/module-init-tools/weak-modules ]; then
622     rpm -ql $OSD_ZFS_RPM_NAME | grep '\.ko$' |
623         /usr/lib/module-init-tools/weak-modules --add-modules
624 fi
625 # RedHat
626 if [ -x /sbin/weak-modules ]; then
627     rpm -ql $OSD_ZFS_RPM_NAME | grep '\.ko$' |
628         /sbin/weak-modules --add-modules
629 fi
630
631 # If the kernel was built to reject unsupported modules (e.g. not a Lustre
632 # kernel), and this hasn't been overridden in /etc/modprobe.d yet, then
633 # print a warning so that users are aware of this issue.
634 if sysctl kernel.unsupported >/dev/null 2>&1 &&
635    [ "$(sysctl -n kernel.unsupported 2>/dev/null)" = "0" ] &&
636     ! modprobe -c | grep -q "^allow_unsupported_modules[ \t]1" ; then
637      echo "
638      warning: the Lustre modules are not supported by Novell. To use Lustre
639               on this system, you should put
640
641      allow_unsupported_modules 1
642
643      into /etc/modprobe.d/unsupported_modules"
644 fi
645 %endif
646 %endif
647
648 %preun modules
649 %if %{defined rpm_post_base}
650 if [ -x %{rpm_post_base}-modules.sh ]; then
651         %{rpm_post_base}-modules.sh %{cross_path} remove
652 fi
653 %else
654 MODULES_RPM_NAME=$(rpm -q %{name}-modules | grep "%{version}-%{release}")
655 rpm -ql $MODULES_RPM_NAME | grep '\.ko$' > /var/run/%{name}-modules || true
656 %endif
657
658 %if %{with ldiskfs}
659 %preun osd-ldiskfs
660 %if %{defined rpm_post_base}
661 if [ -x %{rpm_post_base}-osd-ldiskfs.sh ]; then
662         %{rpm_post_base}-osd-ldiskfs.sh %{cross_path} remove
663 fi
664 %else
665 OSD_LDISKFS_RPM_NAME=$(rpm -q %{name}-osd-ldiskfs | grep "%{version}-%{release}")
666 rpm -ql $OSD_LDISKFS_RPM_NAME | grep '\.ko$' > /var/run/%{name}-osd-ldiskfs || true
667 %endif
668 %endif
669
670 %if %{with zfs}
671 %preun osd-zfs
672 %if %{defined rpm_post_base}
673 if [ -x %{rpm_post_base}-osd-zfs.sh ]; then
674         %{rpm_post_base}-osd-zfs.sh %{cross_path} remove
675 fi
676 %else
677 OSD_ZFS_RPM_NAME=$(rpm -q %{name}-osd-zfs | grep "%{version}-%{release}")
678 rpm -ql $OSD_ZFS_RPM_NAME | grep '\.ko$' > /var/run/%{name}-osd-zfs || true
679 %endif
680 %endif
681
682 %if %{undefined cross_path}
683 %postun modules
684 if [ -f /boot/System.map-%{kversion} ]; then
685         depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
686 else
687         depmod -ae %{kversion} || exit 0
688 fi
689
690 # "weak modules" support
691 # Suse
692 if [ -x /usr/lib/module-init-tools/weak-modules ]; then
693     cat /var/run/%{name}-modules |
694         /usr/lib/module-init-tools/weak-modules --remove-modules
695 fi
696 # RedHat
697 if [ -x /sbin/weak-modules ]; then
698     cat /var/run/%{name}-modules |
699         /sbin/weak-modules --remove-modules
700 fi
701 rm /var/run/%{name}-modules
702
703 %if %{with ldiskfs}
704 %postun osd-ldiskfs
705 if [ -f /boot/System.map-%{kversion} ]; then
706        depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
707 else
708        depmod -ae %{kversion} || exit 0
709 fi
710
711 # "weak modules" support
712 # Suse
713 if [ -x /usr/lib/module-init-tools/weak-modules ]; then
714     cat /var/run/%{name}-osd-ldiskfs |
715         /usr/lib/module-init-tools/weak-modules --remove-modules
716 fi
717 # RedHat
718 if [ -x /sbin/weak-modules ]; then
719     cat /var/run/%{name}-osd-ldiskfs |
720         /sbin/weak-modules --remove-modules
721 fi
722 rm /var/run/%{name}-osd-ldiskfs
723 %endif
724
725 %if %{with zfs}
726 %postun osd-zfs
727 if [ -f /boot/System.map-%{kversion} ]; then
728        depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
729 else
730        depmod -ae %{kversion} || exit 0
731 fi
732
733 # "weak modules" support
734 # Suse
735 if [ -x /usr/lib/module-init-tools/weak-modules ]; then
736     cat /var/run/%{name}-osd-zfs |
737         /usr/lib/module-init-tools/weak-modules --remove-modules
738 fi
739 # RedHat
740 if [ -x /sbin/weak-modules ]; then
741     cat /var/run/%{name}-osd-zfs |
742         /sbin/weak-modules --remove-modules
743 fi
744 rm /var/run/%{name}-osd-zfs
745 %endif
746 %endif
747 %endif # with lustre_modules
748
749 %if %{with lustre_tests}
750 %if %{defined rpm_post_base}
751 %post tests
752 if [ -x %{rpm_post_base}-tests.sh ]; then
753         %{rpm_post_base}-tests.sh %{cross_path} create
754 fi
755
756 %preun tests
757 if [ -x %{rpm_post_base}-tests.sh ]; then
758         %{rpm_post_base}-tests.sh %{cross_path} remove
759 fi
760 %else
761 %if %{with lustre_modules}
762 %post tests
763 if [ -f /boot/System.map-%{kversion} ]; then
764         depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
765 else
766         depmod -ae %{kversion} || exit 0
767 fi
768
769 %postun tests
770 if [ -f /boot/System.map-%{kversion} ]; then
771         depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
772 else
773         depmod -ae %{kversion} || exit 0
774 fi
775 %endif
776 %endif
777 %endif
778
779 %clean
780 rm -rf $RPM_BUILD_ROOT