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