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