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