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