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