Whamcloud - gitweb
b=22514 kernel update for rhel5.5 & oel5.5.
[fs/lustre-release.git] / lustre.spec.in
1 # lustre.spec
2 %{!?version: %define version @VERSION@}
3 %{!?kversion: %define kversion @LINUXRELEASE@}
4 %{!?release: %define release @RELEASE@}
5 %{!?lustre_name: %define lustre_name lustre}
6 %{!?build_lustre_tests: %define build_lustre_tests 1}
7
8 # in order to get kernel symset and/or kernel module dependencies into
9 # the RPM, in order to support weak-modules, the internal dependency gen-
10 # erator needs to be disabled
11 # this is done with (reduce the double % down to a single %):
12 #
13 # %%global _use_internal_dependency_generator 0
14 #
15 # on SLES10, /usr/lib/rpm/macros already sets this, so no harm in also
16 # defining it here (until Suse changes their mind)
17 #
18 # on RHEL5, however, we do need to explicitly disable the internal dep-
19 # endency generator and allow the external one be used
20 # but since RedHat's kABI is only a subset of the total kernel ABI, it
21 # doesn't include all of the symbols we (or OFED for that matter) need
22 # until RedHat includes all of the symbols we need in their symsets we
23 # cannot support weak-modules
24 # we did e-mail the maintainer of all of this stuff @redhat but got no
25 # response from them
26 #%%global _use_internal_dependency_generator 0
27
28 %define is_client %(bash -c "if [[ %{lustre_name} = *-client ]]; then echo -n '1'; else echo -n '0'; fi")
29 # for those uses that don't want the -smp/-bigsmp on the end of %kversion
30 %define krequires %(bash -c "echo %{kversion} | sed -e 's/.x86_64$//' -e 's/.i586$//' -e 's/-smp$//' -e 's/-bigsmp$//' -e 's/-ppc64$//' -e 's/-default$//'")
31
32 %define sles10 %(bash -c "if [ "%sles_version" = "10" ]; then echo -n '1'; else echo -n '0'; fi")
33
34 %if %sles10
35 %define flavor %(bash -c "echo %{kversion} | sed -e 's/^.*-//'")
36 %endif
37
38 Summary: Lustre File System
39 Name: %{lustre_name}
40 Version: %{version}
41 Release: %{release}
42 License: GPL
43 Group: Utilities/System
44 Source: lustre-%{version}.tar.gz
45 URL: http://www.sun.com/software/products/lustre/index.xml
46 BuildRoot: %{_tmppath}/lustre-%{version}-root
47 Obsoletes: lustre-lite, lustre-lite-utils, lustre-ldap nfs-utils-lustre
48 Provides: lustre-lite = %{version}, lustre-lite-utils = %{version}
49 Requires: %{name}-modules = %{version}
50 # GSS requires this: BuildRequires: pkgconfig, libgssapi-devel >= 0.10
51
52 %description
53 Userspace tools and files for the Lustre file system.
54
55 %package modules
56 Summary: Kernel Lustre modules for Linux %{kversion}
57 # for RHEL5 and SLES11, we need nothing here
58 # for SLES10, we need (where %{flavor} is, i.e. smp):
59 %if %sles10
60 Requires: kernel-%{flavor}
61 %endif
62 Group: Development/Kernel
63
64 %description modules
65 Lustre file system, server and network drivers for Linux %{kversion}.
66
67 %package source
68 Summary: Object-Based Disk storage driver source
69 Group: Development/Kernel
70
71 %description source
72 Lustre sources for further development
73
74 # Since the RPMs we ship are to be used on both SLES and RHEL, we
75 # can't include any dependency information (since the package names
76 # are different on the two platforms).
77 #
78 # Instead, we can build these empty meta-packages that only include
79 # dependency information.  These let people get the correct
80 # dependencies for their platform and lets them use tools like yum and
81 # red carpet to install the correct files.
82 #
83 # Unfortunately I have not seen this come up on the lists much, so I
84 # have disabled them (by commenting out their empty files section
85 # below) until it's clear that they resolve more confusion than they
86 # add.
87
88 %package deps-sles
89 Summary: Lustre dependencies meta-package for SLES
90 Group: Utilities/System
91 Provides: lustre-deps = %{version}
92 Requires: %{name} = %{version}, sles-release
93 Conflicts: %{name}-deps-rhel
94
95 %description deps-sles
96 This package has RPM dependencies appropriate for SLES systems.
97
98 %package deps-rhel
99 Summary: Lustre dependencies meta-package for RHEL
100 Group: Utilities/System
101 Provides: lustre-deps = %{version}
102 Requires: %{name} = %{version}, redhat-release
103 Conflicts: %{name}-deps-sles
104
105 %description deps-rhel
106 This package has RPM dependencies appropriate for RHEL, RHL, and FC
107 systems.
108
109 %package tests
110 Summary: Lustre testing framework
111 Group: Development/Kernel
112 Provides: %{name}-tests = %{version}
113 Requires: %{name} = %{version}, %{name}-modules = %{version}
114
115 %description tests
116 This package contains a set of test binaries and scripts that are intended
117 to be used by the Lustre testing framework.
118
119 %if 0%{?suse_version}
120 %debug_package
121 %endif
122 %prep
123 %setup -qn lustre-%{version}
124 ln lustre/ChangeLog ChangeLog-lustre
125 ln lnet/ChangeLog ChangeLog-lnet
126
127 %build
128 # if RPM_BUILD_NCPUS unset, set it
129 if [ -z "$RPM_BUILD_NCPUS" ] ; then
130     RPM_BUILD_NCPUS=$(egrep -c "^cpu[0-9]+" /proc/stat 2>/dev/null || echo 0 :)
131     if [ $RPM_BUILD_NCPUS -eq 0 ] ; then
132         RPM_BUILD_NCPUS=1
133     fi
134     if [ $RPM_BUILD_NCPUS -gt 8 ] ; then
135         RPM_BUILD_NCPUS=8
136     fi
137 fi
138
139 rm -rf $RPM_BUILD_ROOT
140
141 # Set an explicit path to our Linux tree, if we can.
142 cd $RPM_BUILD_DIR/lustre-%{version}
143 # override %optflags so that the vendor's overzealous flags don't create
144 # build failures
145 %define optflags -g -O2 -Werror
146 CONFIGURE_ARGS=""
147 %if %{build_lustre_tests}
148 CONFIGURE_ARGS="$CONFIGURE_ARGS --enable-tests --enable-liblustre-tests"
149 %else
150 CONFIGURE_ARGS="$CONFIGURE_ARGS --disable-tests --disable-liblustre-tests"
151 %endif
152 %configure %{?configure_args:%configure_args} $CONFIGURE_ARGS
153 make -j $RPM_BUILD_NCPUS -s
154
155 %install
156 make install DESTDIR=$RPM_BUILD_ROOT
157 # hack to avoid changing the libsysio code for "make install"
158 rm -f $RPM_BUILD_ROOT%{_libdir}/libsysio.a
159 # Remove ldiskfs module(s) - they are packaged by the ldiskfs .spec.
160 rm -rf $RPM_BUILD_ROOT/lib/modules/%{kversion}/updates/kernel/fs/lustre-ldiskfs
161
162 # hack to include the llog_test module in lustre-tests
163 llog_base=$RPM_BUILD_DIR/lustre-%{version}/lustre/obdclass/llog_test
164 if [ -e ${llog_base}.ko ]; then
165   cp ${llog_base}.ko $RPM_BUILD_ROOT/lib/modules/%{kversion}/updates/kernel/fs/lustre
166 elif [ -e ${llog_base}.o ]; then
167   cp ${llog_base}.o $RPM_BUILD_ROOT/lib/modules/%{kversion}/updates/kernel/fs/lustre
168 fi
169
170 # Create the pristine source directory.
171 cd $RPM_BUILD_DIR/lustre-%{version}
172 mkdir -p $RPM_BUILD_ROOT/usr/src
173 rm -f lustre-source
174 ln -s $RPM_BUILD_ROOT/usr/src lustre-source
175 make distdir distdir=lustre-source/lustre-%{version}
176 chmod -R go-w lustre-source/lustre-%{version}
177
178 cat >lustre.files <<EOF
179 %attr(-, root, root) /sbin/mount.lustre
180 %attr(-, root, root) /usr/sbin/*
181 %attr(-, root, root) /usr/bin/*
182
183 %attr(-, root, root) /usr/share/lustre
184
185 %attr(-, root, root) %{_libdir}/libptlctl.a
186 %attr(-, root, root) %{_libdir}/liblustreapi.a
187 %attr(-, root, root) /usr/include/lustre
188
189 %attr(-, root, root) %{_mandir}/man?/*
190
191 %attr(-, root, root) %{_libexecdir}/lustre/lc_common
192
193 %attr(-, root, root) %{_sysconfdir}/udev/rules.d/99-lustre.rules
194 EOF
195
196 if [ -f $RPM_BUILD_ROOT%{_libdir}/libcfsutil.a ] ; then
197   echo '%attr(-, root, root) %{_libdir}/libcfsutil.a' >>lustre.files
198 fi
199
200 if [ -f $RPM_BUILD_ROOT%{_libdir}/liblustre.so ] ; then
201   echo '%attr(-, root, root) %{_libdir}/liblustre.a' >>lustre.files
202   echo '%attr(-, root, root) %{_libdir}/liblustre.so' >>lustre.files
203 fi
204
205 if [ -f $RPM_BUILD_DIR/lustre-%{version}/lustre/utils/libiam.c ] ; then
206   echo '%attr(-, root, root) %{_libdir}/libiam.a' >>lustre.files
207 fi
208
209 if [ -d $RPM_BUILD_ROOT%{_libdir}/lustre/snmp ] ; then
210   echo '%attr(-, root, root) %{_libdir}/lustre/snmp' >>lustre.files
211   echo '%attr(-, root, root) %{_datadir}/lustre/snmp/mibs' >>lustre.files
212 fi
213
214 # Have universal lustre headers 
215 if [ -f $RPM_BUILD_DIR/lustre-%{version}/lustre/include/lustre/lustre_idl.h ] ; then
216   echo '%attr(-, root, root) /usr/include/linux/lustre_user.h' >>lustre.files
217 else
218   echo '%attr(-, root, root) /usr/include/linux/lustre_idl.h' >>lustre.files
219 fi
220
221 if [ -f $RPM_BUILD_DIR/lustre-%{version}/lustre/include/linux/lustre_types.h ] ; then
222   echo '%attr(-, root, root) /usr/include/linux/lustre_types.h' >>lustre.files
223 fi
224
225 %if %{build_lustre_tests}
226 echo '%attr(-, root, root) %{_libdir}/lustre/tests/*' >lustre-tests.files
227 echo '%attr(-, root, root) /lib/modules/%{kversion}/updates/kernel/fs/lustre/llog_test.*' >>lustre-tests.files
228 modules_excludes="|llog_test"
229 if [ -d $RPM_BUILD_ROOT%{_libdir}/lustre/liblustre/tests ] ; then
230   echo '%attr(-, root, root) %{_libdir}/lustre/liblustre/tests/*' >>lustre-tests.files
231 fi
232 %endif
233
234 pushd $RPM_BUILD_ROOT >/dev/null
235 find lib/modules/%{kversion}/updates -type f | awk "!/(ZZZZZZZZZZ$modules_excludes)/ {print \"%attr(-, root, root) /\"\$0}" >>$RPM_BUILD_DIR/lustre-%{version}/lustre-modules.files
236 popd >/dev/null
237
238 %files -f lustre.files
239
240 %files modules -f lustre-modules.files
241 %attr(-, root, root) %doc COPYING
242 %attr(-, root, root) %doc ChangeLog-lustre
243 %attr(-, root, root) %doc ChangeLog-lnet
244
245 %files source
246 %attr(-, root, root) /usr/src/lustre-%{version}
247
248 # uncomment these lines to enable deps packages
249 # %files deps-sles
250 # %files deps-rhel
251
252 %if %{build_lustre_tests}
253 %files tests -f lustre-tests.files
254 %endif
255
256 %post modules
257 if [ -f /boot/System.map-%{kversion} ]; then
258         depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
259 else
260         depmod -ae %{kversion} || exit 0
261 fi
262
263 # "weak modules" support
264 # Suse
265 if [ -x /usr/lib/module-init-tools/weak-modules ]; then
266     rpm -ql %{name}-modules-%{version}-%{release} | grep '\.ko$' |
267         /usr/lib/module-init-tools/weak-modules --add-modules
268 fi
269 # RedHat
270 if [ -x /sbin/weak-modules ]; then
271     rpm -ql %{name}-modules-%{version}-%{release} | grep '\.ko$' |
272         /sbin/weak-modules --add-modules
273 fi
274
275 cat <<EOF
276 Congratulations on finishing your Lustre installation!  To register
277 your copy of Lustre and find out more about Lustre Support, Service,
278 and Training offerings please visit
279
280 http://www.sun.com/software/products/lustre/lustre_reg.jsp
281 EOF
282
283 # for update from < v1.4.6
284
285 for f in /etc/modules.conf /etc/modprobe.conf /etc/modprobe.conf.local ; 
286 do
287         if [ -f $f ]; then
288                 if grep 'lustre llite' $f >/dev/null 2>/dev/null ; then
289                         [ ! -f $f.rpmsave ] && cp $f $f.rpmsave
290                         TMPFILE=`mktemp $f.XXXXXX` && \
291                         rm -f $TMPFILE && touch $TMPFILE && \
292                         grep -v 'lustre llite' $f >> $TMPFILE && \
293                         mv $TMPFILE $f
294                 fi
295                 if egrep "^[^#]*(add below|install) ptlrpc" $f ; then
296                         [ ! -f $f.rpmsave ] && cp $f $f.rpmsave
297                         TMPFILE=`mktemp $f.XXXXXX` && \
298                         rm -f $TMPFILE && touch $TMPFILE && \
299                         sed -e "s/^[^#]*\(add below\|install\) ptlrpc.*/#&/" $f >> $TMPFILE && \
300                         mv $TMPFILE $f
301                 fi
302         fi
303 done
304
305 # If the kernel was built to reject unsupported modules (e.g. not a Lustre
306 # kernel), and this hasn't been overridden in /etc/modprobe.d yet, then
307 # print a warning so that users are aware of this issue.
308 if sysctl kernel.unsupported >/dev/null 2>&1 &&
309    [ "$(sysctl -n kernel.unsupported 2>/dev/null)" = "0" ] &&
310     ! modprobe -c | grep -q "^allow_unsupported_modules[ \t]1" ; then
311      echo "
312      warning: the Lustre modules are not supported by Novell. To use Lustre
313               on this system, you should put
314
315      allow_unsupported_modules 1
316
317      into /etc/modprobe.d/unsupported_modules"
318 fi
319
320 %preun modules
321 rpm -ql %{name}-modules-%{version}-%{release} | grep '\.ko$' > /var/run/%{name}-modules
322
323 %postun modules
324 if [ -f /boot/System.map-%{kversion} ]; then
325         depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
326 else
327         depmod -ae %{kversion} || exit 0
328 fi
329
330 # "weak modules" support
331 # Suse
332 if [ -x /usr/lib/module-init-tools/weak-modules ]; then
333     cat /var/run/%{name}-modules | grep '\.ko$' |
334         /usr/lib/module-init-tools/weak-modules --remove-modules
335 fi
336 # RedHat
337 if [ -x /sbin/weak-modules ]; then
338     cat /var/run/%{name}-modules | grep '\.ko$' |
339         /sbin/weak-modules --remove-modules
340 fi
341 rm /var/run/%{name}-modules
342
343 %if %{build_lustre_tests}
344 %post tests
345 if [ -f /boot/System.map-%{kversion} ]; then
346         depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
347 else
348         depmod -ae %{kversion} || exit 0
349 fi
350
351 %postun tests
352 if [ -f /boot/System.map-%{kversion} ]; then
353         depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
354 else
355         depmod -ae %{kversion} || exit 0
356 fi
357 %endif
358
359 %clean
360 rm -rf $RPM_BUILD_ROOT