Whamcloud - gitweb
LU-2784 build: Provide RPMs build for Xeon Phi(TM) card
[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/osd_ldiskfs.ko
367 %endif
368 %if %{build_lustre_osd_zfs}
369 %exclude %{?rootdir}/lib/modules/%{kversion}/updates/kernel/fs/lustre/osd_zfs.ko
370 %endif
371 %if %{defined rpm_post_base}
372 %attr(0555, root, root) %{rpm_post_base}-modules.sh
373 %endif
374 %attr(-, root, root) %doc COPYING
375 %attr(-, root, root) %doc ChangeLog-lustre
376 %attr(-, root, root) %doc ChangeLog-lnet
377
378 %if %{build_lustre_osd_ldiskfs}
379 %files osd-ldiskfs
380 %attr(-, root, root) %{?rootdir}/lib/modules/%{kversion}/updates/kernel/fs/lustre/osd_ldiskfs.ko
381 %if %{defined rpm_post_base}
382 %attr(0555, root, root) %{rpm_post_base}-osd-ldiskfs.sh
383 %endif
384 %endif
385
386 %if %{build_lustre_osd_zfs}
387 %files osd-zfs
388 %attr(-, root, root) %{?rootdir}/lib/modules/%{kversion}/updates/kernel/fs/lustre/osd_zfs.ko
389 %if %{defined rpm_post_base}
390 %attr(0555, root, root) %{rpm_post_base}-osd-zfs.sh
391 %endif
392 %endif
393
394 %files source
395 %attr(-, root, root) %{_prefix}/src/lustre-%{version}
396
397 # uncomment these lines to enable deps packages
398 # %files deps-sles
399 # %files deps-rhel
400
401 %if %{build_lustre_tests}
402 %files tests -f lustre-tests.files
403 %endif
404
405 %if %{defined rpm_post_base}
406 %post
407 if [ -x %{rpm_post_base}.sh ]; then
408         %{rpm_post_base}.sh %{cross_path} create
409 fi
410
411 %preun
412 if [ -x %{rpm_post_base}.sh ]; then
413         %{rpm_post_base}.sh %{cross_path} remove
414 fi
415 %endif
416
417 %post modules
418 %if %{defined rpm_post_base}
419 if [ -x %{rpm_post_base}-modules.sh ]; then
420         %{rpm_post_base}-modules.sh %{cross_path} create
421 fi
422 %else
423 if [ -f /boot/System.map-%{kversion} ]; then
424         depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
425 else
426         depmod -ae %{kversion} || exit 0
427 fi
428
429 MODULES_RPM_NAME=$(rpm -q %{name}-modules | grep "%{version}-%{release}")
430 # "weak modules" support
431 # Suse
432 if [ -x /usr/lib/module-init-tools/weak-modules ]; then
433     rpm -ql $MODULES_RPM_NAME | grep '\.ko$' |
434         /usr/lib/module-init-tools/weak-modules --add-modules
435 fi
436 # RedHat
437 if [ -x /sbin/weak-modules ]; then
438     rpm -ql $MODULES_RPM_NAME | grep '\.ko$' |
439         /sbin/weak-modules --add-modules
440 fi
441
442 # If the kernel was built to reject unsupported modules (e.g. not a Lustre
443 # kernel), and this hasn't been overridden in /etc/modprobe.d yet, then
444 # print a warning so that users are aware of this issue.
445 if sysctl kernel.unsupported >/dev/null 2>&1 &&
446    [ "$(sysctl -n kernel.unsupported 2>/dev/null)" = "0" ] &&
447     ! modprobe -c | grep -q "^allow_unsupported_modules[ \t]1" ; then
448      echo "
449      warning: the Lustre modules are not supported by Novell. To use Lustre
450               on this system, you should put
451
452      allow_unsupported_modules 1
453
454      into /etc/modprobe.d/unsupported_modules"
455 fi
456 %endif
457
458 %if %{build_lustre_osd_ldiskfs}
459 %post osd-ldiskfs
460 %if %{defined rpm_post_base}
461 if [ -x %{rpm_post_base}-osd-ldiskfs.sh ]; then
462         %{rpm_post_base}-osd-ldiskfs.sh %{cross_path} create
463 fi
464 %else
465 if [ -f /boot/System.map-%{kversion} ]; then
466        depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
467 else
468        depmod -ae %{kversion} || exit 0
469 fi
470
471 OSD_LDISKFS_RPM_NAME=$(rpm -q %{name}-osd-ldiskfs | grep "%{version}-%{release}")
472 # "weak modules" support
473 # Suse
474 if [ -x /usr/lib/module-init-tools/weak-modules ]; then
475     rpm -ql $OSD_LDISKFS_RPM_NAME | grep '\.ko$' |
476         /usr/lib/module-init-tools/weak-modules --add-modules
477 fi
478 # RedHat
479 if [ -x /sbin/weak-modules ]; then
480     rpm -ql $OSD_LDISKFS_RPM_NAME | grep '\.ko$' |
481         /sbin/weak-modules --add-modules
482 fi
483
484 # If the kernel was built to reject unsupported modules (e.g. not a Lustre
485 # kernel), and this hasn't been overridden in /etc/modprobe.d yet, then
486 # print a warning so that users are aware of this issue.
487 if sysctl kernel.unsupported >/dev/null 2>&1 &&
488    [ "$(sysctl -n kernel.unsupported 2>/dev/null)" = "0" ] &&
489     ! modprobe -c | grep -q "^allow_unsupported_modules[ \t]1" ; then
490      echo "
491      warning: the Lustre modules are not supported by Novell. To use Lustre
492               on this system, you should put
493
494      allow_unsupported_modules 1
495
496      into /etc/modprobe.d/unsupported_modules"
497 fi
498 %endif
499 %endif
500
501 %if %{build_lustre_osd_zfs}
502 %post osd-zfs
503 %if %{defined rpm_post_base}
504 if [ -x %{rpm_post_base}-osd-zfs.sh ]; then
505         %{rpm_post_base}-osd-zfs.sh %{cross_path} create
506 fi
507 %else
508 if [ -f /boot/System.map-%{kversion} ]; then
509        depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
510 else
511        depmod -ae %{kversion} || exit 0
512 fi
513
514 OSD_ZFS_RPM_NAME=$(rpm -q %{name}-osd-zfs | grep "%{version}-%{release}")
515 # "weak modules" support
516 # Suse
517 if [ -x /usr/lib/module-init-tools/weak-modules ]; then
518     rpm -ql $OSD_ZFS_RPM_NAME | grep '\.ko$' |
519         /usr/lib/module-init-tools/weak-modules --add-modules
520 fi
521 # RedHat
522 if [ -x /sbin/weak-modules ]; then
523     rpm -ql $OSD_ZFS_RPM_NAME | grep '\.ko$' |
524         /sbin/weak-modules --add-modules
525 fi
526
527 # If the kernel was built to reject unsupported modules (e.g. not a Lustre
528 # kernel), and this hasn't been overridden in /etc/modprobe.d yet, then
529 # print a warning so that users are aware of this issue.
530 if sysctl kernel.unsupported >/dev/null 2>&1 &&
531    [ "$(sysctl -n kernel.unsupported 2>/dev/null)" = "0" ] &&
532     ! modprobe -c | grep -q "^allow_unsupported_modules[ \t]1" ; then
533      echo "
534      warning: the Lustre modules are not supported by Novell. To use Lustre
535               on this system, you should put
536
537      allow_unsupported_modules 1
538
539      into /etc/modprobe.d/unsupported_modules"
540 fi
541 %endif
542 %endif
543
544 %preun modules
545 %if %{defined rpm_post_base}
546 if [ -x %{rpm_post_base}-modules.sh ]; then
547         %{rpm_post_base}-modules.sh %{cross_path} remove
548 fi
549 %else
550 MODULES_RPM_NAME=$(rpm -q %{name}-modules | grep "%{version}-%{release}")
551 rpm -ql $MODULES_RPM_NAME | grep '\.ko$' > /var/run/%{name}-modules || true
552 %endif
553
554 %if %{build_lustre_osd_ldiskfs}
555 %preun osd-ldiskfs
556 %if %{defined rpm_post_base}
557 if [ -x %{rpm_post_base}-osd-ldiskfs.sh ]; then
558         %{rpm_post_base}-osd-ldiskfs.sh %{cross_path} remove
559 fi
560 %else
561 OSD_LDISKFS_RPM_NAME=$(rpm -q %{name}-osd-ldiskfs | grep "%{version}-%{release}")
562 rpm -ql $OSD_LDISKFS_RPM_NAME | grep '\.ko$' > /var/run/%{name}-osd-ldiskfs || true
563 %endif
564 %endif
565
566 %if %{build_lustre_osd_zfs}
567 %preun osd-zfs
568 %if %{defined rpm_post_base}
569 if [ -x %{rpm_post_base}-osd-zfs.sh ]; then
570         %{rpm_post_base}-osd-zfs.sh %{cross_path} remove
571 fi
572 %else
573 OSD_ZFS_RPM_NAME=$(rpm -q %{name}-osd-zfs | grep "%{version}-%{release}")
574 rpm -ql $OSD_ZFS_RPM_NAME | grep '\.ko$' > /var/run/%{name}-osd-zfs || true
575 %endif
576 %endif
577
578 %if %{undefined cross_path}
579 %postun modules
580 if [ -f /boot/System.map-%{kversion} ]; then
581         depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
582 else
583         depmod -ae %{kversion} || exit 0
584 fi
585
586 # "weak modules" support
587 # Suse
588 if [ -x /usr/lib/module-init-tools/weak-modules ]; then
589     cat /var/run/%{name}-modules |
590         /usr/lib/module-init-tools/weak-modules --remove-modules
591 fi
592 # RedHat
593 if [ -x /sbin/weak-modules ]; then
594     cat /var/run/%{name}-modules |
595         /sbin/weak-modules --remove-modules
596 fi
597 rm /var/run/%{name}-modules
598
599 %if %{build_lustre_osd_ldiskfs}
600 %postun osd-ldiskfs
601 if [ -f /boot/System.map-%{kversion} ]; then
602        depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
603 else
604        depmod -ae %{kversion} || exit 0
605 fi
606
607 # "weak modules" support
608 # Suse
609 if [ -x /usr/lib/module-init-tools/weak-modules ]; then
610     cat /var/run/%{name}-osd-ldiskfs |
611         /usr/lib/module-init-tools/weak-modules --remove-modules
612 fi
613 # RedHat
614 if [ -x /sbin/weak-modules ]; then
615     cat /var/run/%{name}-osd-ldiskfs |
616         /sbin/weak-modules --remove-modules
617 fi
618 rm /var/run/%{name}-osd-ldiskfs
619 %endif
620
621 %if %{build_lustre_osd_zfs}
622 %postun osd-zfs
623 if [ -f /boot/System.map-%{kversion} ]; then
624        depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
625 else
626        depmod -ae %{kversion} || exit 0
627 fi
628
629 # "weak modules" support
630 # Suse
631 if [ -x /usr/lib/module-init-tools/weak-modules ]; then
632     cat /var/run/%{name}-osd-zfs |
633         /usr/lib/module-init-tools/weak-modules --remove-modules
634 fi
635 # RedHat
636 if [ -x /sbin/weak-modules ]; then
637     cat /var/run/%{name}-osd-zfs |
638         /sbin/weak-modules --remove-modules
639 fi
640 rm /var/run/%{name}-osd-zfs
641 %endif
642 %endif
643
644 %if %{build_lustre_tests}
645 %post tests
646 %if %{defined rpm_post_base}
647 if [ -x %{rpm_post_base}-tests.sh ]; then
648         %{rpm_post_base}-tests.sh %{cross_path} create
649 fi
650
651 %preun tests
652 if [ -x %{rpm_post_base}-tests.sh ]; then
653         %{rpm_post_base}-tests.sh %{cross_path} remove
654 fi
655 %else
656 if [ -f /boot/System.map-%{kversion} ]; then
657         depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
658 else
659         depmod -ae %{kversion} || exit 0
660 fi
661
662 %postun tests
663 if [ -f /boot/System.map-%{kversion} ]; then
664         depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
665 else
666         depmod -ae %{kversion} || exit 0
667 fi
668 %endif
669 %endif
670
671 %clean
672 rm -rf $RPM_BUILD_ROOT